Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the /apis endpoint call with expand false flag #2985

Open
wants to merge 4 commits into
base: choreo
Choose a base branch
from

Conversation

VirajSalaka
Copy link
Contributor

@VirajSalaka VirajSalaka commented Jul 4, 2022

Purpose
Since the /apis endpoint call was a costly operation (due to API Manager DB operations), this was removed from the choreo branch. As a result of that, switching an API to Blocked Lifecycle state did not function.
With this PR, the /apis endpoint call will be added again. Hence the fore-mentioned limitation will be removed.

In this case, the /apis endpoint will be called with the query parameter expand=false so that it would return default APIs and blocked APIs only. This call is made during the startup. Then onwards, the blocked APIs and default APIs are identified using message events.

Issues

Fixes #2857

Automation tests

  • Unit tests added: No
  • Integration tests added: Yes (Covered by existing tests)

Tested environments

Not Tested


Maintainers: Check before merge

  • Assigned 'Type' label
  • Assigned the project
  • Validated respective github issues
  • Assigned milestone to the github issue(s)

@VirajSalaka VirajSalaka changed the title Improved handling blocked APIs by not invoking /apis endpoint unless … Add the /apis endpoint call with expand false flag Jul 4, 2022
@VirajSalaka VirajSalaka force-pushed the apis-ep-fix-r-2 branch 2 times, most recently from 53002a1 to aa16e1f Compare July 4, 2022 16:51
…it is the startup. The JMS/ASB event's details are used to populate the necessary maps(api-metadata)

APIList object is not passed to the enforcer now, instead of that EnforcerAPI's lifecycle state is used.
Any API within the api metadata map should be kept only if the API is a default API or API is in blocked state. If the API becomes unblocked, it is removed from the map.
During the startup also only blocked and default versioned APIs are pulled.
@VirajSalaka VirajSalaka marked this pull request as ready for review July 5, 2022 05:17
mgwSwagger.LifeCycleState = blockedStatus
return
}
mgwSwagger.LifeCycleState = nonBlockedStatus
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leave the lifecycleState as it is.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed the lifecycle status to be published.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted to previous state as we cannot decide whether the API is in created or published state when deployed for the first time. (Cannot depend on the API.yaml to populate this field)

@@ -20,117 +20,20 @@

import org.wso2.choreo.connect.enforcer.common.CacheableEntity;

import java.util.ArrayList;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the API.java as it remains unused.

apiInfo.setTier(api.getApiTier());
apiInfo.setVersion(api.getApiVersion());
apiInfo.setProvider(api.getApiProvider());
apiInfo.setApiUUID(api.getAPIConfig().getUuid());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extends on BasicAPIInfo

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We had to remove tier as the BasicAPIInfo class already contains the policy. Since this is just used for troubleshooting I guess it is fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants