com.amazonaws.services.apigateway.AmazonApiGateway Java Examples
The following examples show how to use
com.amazonaws.services.apigateway.AmazonApiGateway.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InventoryUtilTest.java From pacbot with Apache License 2.0 | 6 votes |
/** * Fetch api gateways test. * * @throws Exception the exception */ @SuppressWarnings("static-access") @Test public void fetchApiGatewaysTest() throws Exception { mockStatic(AmazonApiGatewayClientBuilder.class); AmazonApiGateway apiGatWayClient = PowerMockito.mock(AmazonApiGateway.class); AmazonApiGatewayClientBuilder amazonApiGatewayClientBuilder = PowerMockito.mock(AmazonApiGatewayClientBuilder.class); AWSStaticCredentialsProvider awsStaticCredentialsProvider = PowerMockito.mock(AWSStaticCredentialsProvider.class); PowerMockito.whenNew(AWSStaticCredentialsProvider.class).withAnyArguments().thenReturn(awsStaticCredentialsProvider); when(amazonApiGatewayClientBuilder.standard()).thenReturn(amazonApiGatewayClientBuilder); when(amazonApiGatewayClientBuilder.withCredentials(anyObject())).thenReturn(amazonApiGatewayClientBuilder); when(amazonApiGatewayClientBuilder.withRegion(anyString())).thenReturn(amazonApiGatewayClientBuilder); when(amazonApiGatewayClientBuilder.build()).thenReturn(apiGatWayClient); GetRestApisResult getRestApisResult = new GetRestApisResult(); List<RestApi> apiGateWaysList = new ArrayList<>(); apiGateWaysList.add(new RestApi()); getRestApisResult.setItems(apiGateWaysList); when(apiGatWayClient.getRestApis(anyObject())).thenReturn(getRestApisResult); assertThat(inventoryUtil.fetchApiGateways(new BasicSessionCredentials("awsAccessKey", "awsSecretKey", "sessionToken"), "skipRegions", "account","accountName").size(), is(1)); }
Example #2
Source File: DeployAPIStep.java From pipeline-aws-plugin with Apache License 2.0 | 6 votes |
@Override protected Void run() throws Exception { TaskListener listener = this.getContext().get(TaskListener.class); AmazonApiGateway client = AWSClientFactory.create(AmazonApiGatewayClient.builder(), this.getContext()); String stage = this.step.getStage(); String api = this.step.getApi(); listener.getLogger().format("Deploying API %s to stage %s %n", api, stage); CreateDeploymentRequest request = new CreateDeploymentRequest(); request.withRestApiId(api); request.withStageName(stage); if (this.step.getDescription() != null) { request.withDescription(this.step.getDescription()); } if (this.step.getVariables() != null && this.step.getVariables().length > 0) { request.withVariables(this.parseVariables(this.step.getVariables())); } client.createDeployment(request); listener.getLogger().println("Deployment complete"); return null; }
Example #3
Source File: AmazonDockerClientsHolder.java From spring-localstack with Apache License 2.0 | 5 votes |
@Override public AmazonApiGateway amazonApiGateway() { return decorateWithConfigsAndBuild( AmazonApiGatewayClientBuilder.standard(), LocalstackDocker::getEndpointAPIGateway ); }
Example #4
Source File: InventoryUtil.java From pacbot with Apache License 2.0 | 5 votes |
/** * Fetch api gateways. * * @param temporaryCredentials the temporary credentials * @param skipRegions the skip regions * @param accountId the accountId * @param accountName the account name * @return the map */ public static Map<String,List<RestApi>> fetchApiGateways(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName) { Map<String,List<RestApi>> apiGateWays = new LinkedHashMap<>(); AmazonApiGateway apiGatWayClient ; String expPrefix = InventoryConstants.ERROR_PREFIX_CODE+accountId + "\",\"Message\": \"Exception in fetching info for resource in specific region\" ,\"type\": \"API\" , \"region\":\"" ; for(Region region : RegionUtils.getRegions()){ try{ if(!skipRegions.contains(region.getName())){ apiGatWayClient = AmazonApiGatewayClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(temporaryCredentials)).withRegion(region.getName()).build(); List<RestApi> apiGateWaysList = new ArrayList<>(); String position = null; GetRestApisResult rslt ; do{ rslt = apiGatWayClient.getRestApis(new GetRestApisRequest().withPosition(position)); apiGateWaysList.addAll(rslt.getItems()); position = rslt.getPosition(); }while(position!=null); if( !apiGateWaysList.isEmpty() ) { log.debug(InventoryConstants.ACCOUNT + accountId +" Type : ApiGateway "+region.getName() + " >> "+apiGateWaysList.size()); apiGateWays.put(accountId+delimiter+accountName+delimiter+region.getName(),apiGateWaysList); } } }catch(Exception e){ log.warn(expPrefix+ region.getName()+InventoryConstants.ERROR_CAUSE +e.getMessage()+"\"}"); ErrorManageUtil.uploadError(accountId,region.getName(),"api",e.getMessage()); } } return apiGateWays; }
Example #5
Source File: ApiGateway.java From lambadaframework with MIT License | 5 votes |
protected AmazonApiGateway getApiGatewayClient() { if (apiGatewayClient != null) { return apiGatewayClient; } RetryPolicy.RetryCondition retryCondition = new RetryPolicy.RetryCondition() { @Override public boolean shouldRetry(AmazonWebServiceRequest amazonWebServiceRequest, AmazonClientException amazonClientException, int i) { if (amazonClientException instanceof TooManyRequestsException) { return true; } return PredefinedRetryPolicies.DEFAULT_RETRY_CONDITION.shouldRetry(amazonWebServiceRequest, amazonClientException, i); } }; RetryPolicy retryPolicy = new RetryPolicy(retryCondition, PredefinedRetryPolicies.DEFAULT_BACKOFF_STRATEGY, 10, true); ClientConfiguration clientConfig = new ClientConfiguration() .withRetryPolicy(retryPolicy); apiGatewayClient = new AmazonApiGatewayClient(getAWSCredentialsProvideChain(), clientConfig).withRegion(Region.getRegion(Regions.fromName(deployment.getRegion()))); return apiGatewayClient; }
Example #6
Source File: ApiImporterDefaultModule.java From aws-apigateway-importer with Apache License 2.0 | 5 votes |
@Provides protected ApiGateway provideAmazonApiGateway(AWSCredentialsProvider credsProvider, RetryPolicy.BackoffStrategy backoffStrategy, @Named("region") String region) { final RetryPolicy retrypolicy = new RetryPolicy(PredefinedRetryPolicies.DEFAULT_RETRY_CONDITION, backoffStrategy, 5, true); final ClientConfiguration clientConfig = new ClientConfiguration().withUserAgent(USER_AGENT).withRetryPolicy(retrypolicy); return new AmazonApiGateway(getEndpoint(region)).with(credsProvider).with(clientConfig).getApiGateway(); }
Example #7
Source File: EveryAwsClientAutoConfiguration.java From spring-localstack with Apache License 2.0 | 4 votes |
@Bean public AmazonApiGateway amazonApiGateway() { return amazonClientsHolder.amazonApiGateway(); }
Example #8
Source File: AmazonClientsHolder.java From spring-localstack with Apache License 2.0 | votes |
AmazonApiGateway amazonApiGateway();