Class AWSAPIUtil

java.lang.Object
org.wso2.aws.client.util.AWSAPIUtil

public class AWSAPIUtil extends Object
This class contains utility methods to interact with AWS API Gateway
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    createReferenceArtifact(software.amazon.awssdk.services.apigateway.model.RestApi restApi, String swaggerDefinitionJson)
    Creates a reference artifact by combining a given RestApi object and its Swagger definition in JSON format.
    static void
    deleteAPI(String externalReference, software.amazon.awssdk.services.apigateway.ApiGatewayClient apiGatewayClient)
    Deletes a Rest API from AWS API Gateway using its external reference (API ID).
    static void
    deleteDeployment(String referenceArtifact, software.amazon.awssdk.services.apigateway.ApiGatewayClient apiGatewayClient, String stage)
     
    static String
    getRestApiDefinition(software.amazon.awssdk.services.apigateway.ApiGatewayClient client, String apiId, String stage)
    This method is used to get the API definition from AWS API Gateway.
    static List<software.amazon.awssdk.services.apigateway.model.RestApi>
    getRestApis(software.amazon.awssdk.services.apigateway.ApiGatewayClient client)
    This method is used to get Rest APIs from AWS API Gateway.
    static String
    getStageNames(software.amazon.awssdk.services.apigateway.ApiGatewayClient client, String apiId)
    This method retrieves the stage names for a given API ID.
    static String
    importRestAPI(org.wso2.carbon.apimgt.api.model.API api, software.amazon.awssdk.services.apigateway.ApiGatewayClient apiGatewayClient, String region, String stage)
     
    static String
    reimportRestAPI(String referenceArtifact, org.wso2.carbon.apimgt.api.model.API api, software.amazon.awssdk.services.apigateway.ApiGatewayClient apiGatewayClient, String region, String stage)
     
    static org.wso2.carbon.apimgt.api.model.API
    restAPItoAPI(software.amazon.awssdk.services.apigateway.model.RestApi restApi, String apiDefinition, String organization, org.wso2.carbon.apimgt.api.model.Environment environment)
    Converts a RestApi object to an API object.
    static void
    setEndpointConfig(org.wso2.carbon.apimgt.api.model.API api, software.amazon.awssdk.services.apigateway.model.RestApi restApi, software.amazon.awssdk.services.apigateway.ApiGatewayClient client)
    Sets the endpoint configuration for the API based on the provided RestApi.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • AWSAPIUtil

      public AWSAPIUtil()
  • Method Details

    • importRestAPI

      public static String importRestAPI(org.wso2.carbon.apimgt.api.model.API api, software.amazon.awssdk.services.apigateway.ApiGatewayClient apiGatewayClient, String region, String stage) throws org.wso2.carbon.apimgt.api.APIManagementException
      Throws:
      org.wso2.carbon.apimgt.api.APIManagementException
    • reimportRestAPI

      public static String reimportRestAPI(String referenceArtifact, org.wso2.carbon.apimgt.api.model.API api, software.amazon.awssdk.services.apigateway.ApiGatewayClient apiGatewayClient, String region, String stage) throws org.wso2.carbon.apimgt.api.APIManagementException
      Throws:
      org.wso2.carbon.apimgt.api.APIManagementException
    • deleteDeployment

      public static void deleteDeployment(String referenceArtifact, software.amazon.awssdk.services.apigateway.ApiGatewayClient apiGatewayClient, String stage) throws org.wso2.carbon.apimgt.api.APIManagementException
      Throws:
      org.wso2.carbon.apimgt.api.APIManagementException
    • getRestApis

      public static List<software.amazon.awssdk.services.apigateway.model.RestApi> getRestApis(software.amazon.awssdk.services.apigateway.ApiGatewayClient client)
      This method is used to get Rest APIs from AWS API Gateway.
      Parameters:
      client - APIGatewayClient object
      Returns:
      List of RestApi objects
    • getRestApiDefinition

      public static String getRestApiDefinition(software.amazon.awssdk.services.apigateway.ApiGatewayClient client, String apiId, String stage)
      This method is used to get the API definition from AWS API Gateway.
      Parameters:
      client - APIGatewayClient object
      apiId - ID of the Rest API
      Returns:
      API definition in OpenAPI format
    • getStageNames

      public static String getStageNames(software.amazon.awssdk.services.apigateway.ApiGatewayClient client, String apiId)
      This method retrieves the stage names for a given API ID.
      Parameters:
      client - APIGatewayClient object
      apiId - ID of the Rest API
      Returns:
      Stage name or null if no stages are found
    • restAPItoAPI

      public static org.wso2.carbon.apimgt.api.model.API restAPItoAPI(software.amazon.awssdk.services.apigateway.model.RestApi restApi, String apiDefinition, String organization, org.wso2.carbon.apimgt.api.model.Environment environment)
      Converts a RestApi object to an API object.
      Parameters:
      restApi - The RestApi object to convert.
      apiDefinition - The OpenAPI definition of the API.
      organization - The organization name.
      environment - The environment in which the API is deployed.
      Returns:
      An API object representing the RestApi.
    • setEndpointConfig

      public static void setEndpointConfig(org.wso2.carbon.apimgt.api.model.API api, software.amazon.awssdk.services.apigateway.model.RestApi restApi, software.amazon.awssdk.services.apigateway.ApiGatewayClient client)
      Sets the endpoint configuration for the API based on the provided RestApi.
      Parameters:
      api - The API object to set the endpoint configuration for.
      restApi - The RestApi object containing endpoint information.
      client - The ApiGatewayClient to interact with AWS API Gateway.
    • createReferenceArtifact

      public static String createReferenceArtifact(software.amazon.awssdk.services.apigateway.model.RestApi restApi, String swaggerDefinitionJson)
      Creates a reference artifact by combining a given RestApi object and its Swagger definition in JSON format.
      Parameters:
      restApi - The RestApi object containing API details.
      swaggerDefinitionJson - The Swagger/OpenAPI definition of the API in JSON format.
      Returns:
      A JSON string that represents the combined reference artifact.
    • deleteAPI

      public static void deleteAPI(String externalReference, software.amazon.awssdk.services.apigateway.ApiGatewayClient apiGatewayClient) throws org.wso2.carbon.apimgt.api.APIManagementException
      Deletes a Rest API from AWS API Gateway using its external reference (API ID).
      Parameters:
      externalReference - The external reference (API ID) of the Rest API to be deleted.
      apiGatewayClient - The ApiGatewayClient instance used to interact with AWS API Gateway.
      Throws:
      org.wso2.carbon.apimgt.api.APIManagementException