software.amazon.awssdk.services.resourcegroups.DefaultResourceGroupsAsyncClient Maven / Gradle / Ivy
Show all versions of resourcegroups Show documentation
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
* the License. A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/
package software.amazon.awssdk.services.resourcegroups;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.function.Consumer;
import java.util.function.Function;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.awscore.client.handler.AwsAsyncClientHandler;
import software.amazon.awssdk.awscore.exception.AwsServiceException;
import software.amazon.awssdk.awscore.internal.AwsProtocolMetadata;
import software.amazon.awssdk.awscore.internal.AwsServiceProtocol;
import software.amazon.awssdk.awscore.retry.AwsRetryStrategy;
import software.amazon.awssdk.core.RequestOverrideConfiguration;
import software.amazon.awssdk.core.SdkPlugin;
import software.amazon.awssdk.core.SdkRequest;
import software.amazon.awssdk.core.client.config.ClientOverrideConfiguration;
import software.amazon.awssdk.core.client.config.SdkClientConfiguration;
import software.amazon.awssdk.core.client.config.SdkClientOption;
import software.amazon.awssdk.core.client.handler.AsyncClientHandler;
import software.amazon.awssdk.core.client.handler.ClientExecutionParams;
import software.amazon.awssdk.core.http.HttpResponseHandler;
import software.amazon.awssdk.core.metrics.CoreMetric;
import software.amazon.awssdk.core.retry.RetryMode;
import software.amazon.awssdk.metrics.MetricCollector;
import software.amazon.awssdk.metrics.MetricPublisher;
import software.amazon.awssdk.metrics.NoOpMetricCollector;
import software.amazon.awssdk.protocols.core.ExceptionMetadata;
import software.amazon.awssdk.protocols.json.AwsJsonProtocol;
import software.amazon.awssdk.protocols.json.AwsJsonProtocolFactory;
import software.amazon.awssdk.protocols.json.BaseAwsJsonProtocolFactory;
import software.amazon.awssdk.protocols.json.JsonOperationMetadata;
import software.amazon.awssdk.retries.api.RetryStrategy;
import software.amazon.awssdk.services.resourcegroups.internal.ResourceGroupsServiceClientConfigurationBuilder;
import software.amazon.awssdk.services.resourcegroups.model.BadRequestException;
import software.amazon.awssdk.services.resourcegroups.model.CancelTagSyncTaskRequest;
import software.amazon.awssdk.services.resourcegroups.model.CancelTagSyncTaskResponse;
import software.amazon.awssdk.services.resourcegroups.model.CreateGroupRequest;
import software.amazon.awssdk.services.resourcegroups.model.CreateGroupResponse;
import software.amazon.awssdk.services.resourcegroups.model.DeleteGroupRequest;
import software.amazon.awssdk.services.resourcegroups.model.DeleteGroupResponse;
import software.amazon.awssdk.services.resourcegroups.model.ForbiddenException;
import software.amazon.awssdk.services.resourcegroups.model.GetAccountSettingsRequest;
import software.amazon.awssdk.services.resourcegroups.model.GetAccountSettingsResponse;
import software.amazon.awssdk.services.resourcegroups.model.GetGroupConfigurationRequest;
import software.amazon.awssdk.services.resourcegroups.model.GetGroupConfigurationResponse;
import software.amazon.awssdk.services.resourcegroups.model.GetGroupQueryRequest;
import software.amazon.awssdk.services.resourcegroups.model.GetGroupQueryResponse;
import software.amazon.awssdk.services.resourcegroups.model.GetGroupRequest;
import software.amazon.awssdk.services.resourcegroups.model.GetGroupResponse;
import software.amazon.awssdk.services.resourcegroups.model.GetTagSyncTaskRequest;
import software.amazon.awssdk.services.resourcegroups.model.GetTagSyncTaskResponse;
import software.amazon.awssdk.services.resourcegroups.model.GetTagsRequest;
import software.amazon.awssdk.services.resourcegroups.model.GetTagsResponse;
import software.amazon.awssdk.services.resourcegroups.model.GroupResourcesRequest;
import software.amazon.awssdk.services.resourcegroups.model.GroupResourcesResponse;
import software.amazon.awssdk.services.resourcegroups.model.InternalServerErrorException;
import software.amazon.awssdk.services.resourcegroups.model.ListGroupResourcesRequest;
import software.amazon.awssdk.services.resourcegroups.model.ListGroupResourcesResponse;
import software.amazon.awssdk.services.resourcegroups.model.ListGroupingStatusesRequest;
import software.amazon.awssdk.services.resourcegroups.model.ListGroupingStatusesResponse;
import software.amazon.awssdk.services.resourcegroups.model.ListGroupsRequest;
import software.amazon.awssdk.services.resourcegroups.model.ListGroupsResponse;
import software.amazon.awssdk.services.resourcegroups.model.ListTagSyncTasksRequest;
import software.amazon.awssdk.services.resourcegroups.model.ListTagSyncTasksResponse;
import software.amazon.awssdk.services.resourcegroups.model.MethodNotAllowedException;
import software.amazon.awssdk.services.resourcegroups.model.NotFoundException;
import software.amazon.awssdk.services.resourcegroups.model.PutGroupConfigurationRequest;
import software.amazon.awssdk.services.resourcegroups.model.PutGroupConfigurationResponse;
import software.amazon.awssdk.services.resourcegroups.model.ResourceGroupsException;
import software.amazon.awssdk.services.resourcegroups.model.SearchResourcesRequest;
import software.amazon.awssdk.services.resourcegroups.model.SearchResourcesResponse;
import software.amazon.awssdk.services.resourcegroups.model.StartTagSyncTaskRequest;
import software.amazon.awssdk.services.resourcegroups.model.StartTagSyncTaskResponse;
import software.amazon.awssdk.services.resourcegroups.model.TagRequest;
import software.amazon.awssdk.services.resourcegroups.model.TagResponse;
import software.amazon.awssdk.services.resourcegroups.model.TooManyRequestsException;
import software.amazon.awssdk.services.resourcegroups.model.UnauthorizedException;
import software.amazon.awssdk.services.resourcegroups.model.UngroupResourcesRequest;
import software.amazon.awssdk.services.resourcegroups.model.UngroupResourcesResponse;
import software.amazon.awssdk.services.resourcegroups.model.UntagRequest;
import software.amazon.awssdk.services.resourcegroups.model.UntagResponse;
import software.amazon.awssdk.services.resourcegroups.model.UpdateAccountSettingsRequest;
import software.amazon.awssdk.services.resourcegroups.model.UpdateAccountSettingsResponse;
import software.amazon.awssdk.services.resourcegroups.model.UpdateGroupQueryRequest;
import software.amazon.awssdk.services.resourcegroups.model.UpdateGroupQueryResponse;
import software.amazon.awssdk.services.resourcegroups.model.UpdateGroupRequest;
import software.amazon.awssdk.services.resourcegroups.model.UpdateGroupResponse;
import software.amazon.awssdk.services.resourcegroups.transform.CancelTagSyncTaskRequestMarshaller;
import software.amazon.awssdk.services.resourcegroups.transform.CreateGroupRequestMarshaller;
import software.amazon.awssdk.services.resourcegroups.transform.DeleteGroupRequestMarshaller;
import software.amazon.awssdk.services.resourcegroups.transform.GetAccountSettingsRequestMarshaller;
import software.amazon.awssdk.services.resourcegroups.transform.GetGroupConfigurationRequestMarshaller;
import software.amazon.awssdk.services.resourcegroups.transform.GetGroupQueryRequestMarshaller;
import software.amazon.awssdk.services.resourcegroups.transform.GetGroupRequestMarshaller;
import software.amazon.awssdk.services.resourcegroups.transform.GetTagSyncTaskRequestMarshaller;
import software.amazon.awssdk.services.resourcegroups.transform.GetTagsRequestMarshaller;
import software.amazon.awssdk.services.resourcegroups.transform.GroupResourcesRequestMarshaller;
import software.amazon.awssdk.services.resourcegroups.transform.ListGroupResourcesRequestMarshaller;
import software.amazon.awssdk.services.resourcegroups.transform.ListGroupingStatusesRequestMarshaller;
import software.amazon.awssdk.services.resourcegroups.transform.ListGroupsRequestMarshaller;
import software.amazon.awssdk.services.resourcegroups.transform.ListTagSyncTasksRequestMarshaller;
import software.amazon.awssdk.services.resourcegroups.transform.PutGroupConfigurationRequestMarshaller;
import software.amazon.awssdk.services.resourcegroups.transform.SearchResourcesRequestMarshaller;
import software.amazon.awssdk.services.resourcegroups.transform.StartTagSyncTaskRequestMarshaller;
import software.amazon.awssdk.services.resourcegroups.transform.TagRequestMarshaller;
import software.amazon.awssdk.services.resourcegroups.transform.UngroupResourcesRequestMarshaller;
import software.amazon.awssdk.services.resourcegroups.transform.UntagRequestMarshaller;
import software.amazon.awssdk.services.resourcegroups.transform.UpdateAccountSettingsRequestMarshaller;
import software.amazon.awssdk.services.resourcegroups.transform.UpdateGroupQueryRequestMarshaller;
import software.amazon.awssdk.services.resourcegroups.transform.UpdateGroupRequestMarshaller;
import software.amazon.awssdk.utils.CompletableFutureUtils;
/**
* Internal implementation of {@link ResourceGroupsAsyncClient}.
*
* @see ResourceGroupsAsyncClient#builder()
*/
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
final class DefaultResourceGroupsAsyncClient implements ResourceGroupsAsyncClient {
private static final Logger log = LoggerFactory.getLogger(DefaultResourceGroupsAsyncClient.class);
private static final AwsProtocolMetadata protocolMetadata = AwsProtocolMetadata.builder()
.serviceProtocol(AwsServiceProtocol.REST_JSON).build();
private final AsyncClientHandler clientHandler;
private final AwsJsonProtocolFactory protocolFactory;
private final SdkClientConfiguration clientConfiguration;
protected DefaultResourceGroupsAsyncClient(SdkClientConfiguration clientConfiguration) {
this.clientHandler = new AwsAsyncClientHandler(clientConfiguration);
this.clientConfiguration = clientConfiguration.toBuilder().option(SdkClientOption.SDK_CLIENT, this).build();
this.protocolFactory = init(AwsJsonProtocolFactory.builder()).build();
}
/**
*
* Cancels the specified tag-sync task.
*
*
* Minimum permissions
*
*
* To run this command, you must have the following permissions:
*
*
* -
*
* resource-groups:CancelTagSyncTask
on the application group
*
*
* -
*
* resource-groups:DeleteGroup
*
*
*
*
* @param cancelTagSyncTaskRequest
* @return A Java Future containing the result of the CancelTagSyncTask operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions. The exception returned is wrapped with CompletionException, so you need to invoke
* {@link Throwable#getCause} to retrieve the underlying exception.
*
* - UnauthorizedException The request was rejected because it doesn't have valid credentials for the
* target resource.
* - BadRequestException The request includes one or more parameters that violate validation rules.
* - ForbiddenException The caller isn't authorized to make the request. Check permissions.
* - MethodNotAllowedException The request uses an HTTP method that isn't allowed for the specified
* resource.
* - TooManyRequestsException You've exceeded throttling limits by making too many requests in a period of
* time.
* - InternalServerErrorException An internal error occurred while processing the request. Try again
* later.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - ResourceGroupsException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ResourceGroupsAsyncClient.CancelTagSyncTask
* @see AWS API Documentation
*/
@Override
public CompletableFuture cancelTagSyncTask(CancelTagSyncTaskRequest cancelTagSyncTaskRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(cancelTagSyncTaskRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, cancelTagSyncTaskRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Resource Groups");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "CancelTagSyncTask");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, CancelTagSyncTaskResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("CancelTagSyncTask").withProtocolMetadata(protocolMetadata)
.withMarshaller(new CancelTagSyncTaskRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(cancelTagSyncTaskRequest));
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Creates a resource group with the specified name and description. You can optionally include either a resource
* query or a service configuration. For more information about constructing a resource query, see Build queries and groups in
* Resource Groups in the Resource Groups User Guide. For more information about service-linked groups
* and service configurations, see Service configurations for Resource
* Groups.
*
*
* Minimum permissions
*
*
* To run this command, you must have the following permissions:
*
*
* -
*
* resource-groups:CreateGroup
*
*
*
*
* @param createGroupRequest
* @return A Java Future containing the result of the CreateGroup operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions. The exception returned is wrapped with CompletionException, so you need to invoke
* {@link Throwable#getCause} to retrieve the underlying exception.
*
* - BadRequestException The request includes one or more parameters that violate validation rules.
* - ForbiddenException The caller isn't authorized to make the request. Check permissions.
* - MethodNotAllowedException The request uses an HTTP method that isn't allowed for the specified
* resource.
* - TooManyRequestsException You've exceeded throttling limits by making too many requests in a period of
* time.
* - InternalServerErrorException An internal error occurred while processing the request. Try again
* later.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - ResourceGroupsException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ResourceGroupsAsyncClient.CreateGroup
* @see AWS
* API Documentation
*/
@Override
public CompletableFuture createGroup(CreateGroupRequest createGroupRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(createGroupRequest, this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, createGroupRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Resource Groups");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "CreateGroup");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
CreateGroupResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("CreateGroup").withProtocolMetadata(protocolMetadata)
.withMarshaller(new CreateGroupRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(createGroupRequest));
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Deletes the specified resource group. Deleting a resource group does not delete any resources that are members of
* the group; it only deletes the group structure.
*
*
* Minimum permissions
*
*
* To run this command, you must have the following permissions:
*
*
* -
*
* resource-groups:DeleteGroup
*
*
*
*
* @param deleteGroupRequest
* @return A Java Future containing the result of the DeleteGroup operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions. The exception returned is wrapped with CompletionException, so you need to invoke
* {@link Throwable#getCause} to retrieve the underlying exception.
*
* - BadRequestException The request includes one or more parameters that violate validation rules.
* - ForbiddenException The caller isn't authorized to make the request. Check permissions.
* - NotFoundException One or more of the specified resources don't exist.
* - MethodNotAllowedException The request uses an HTTP method that isn't allowed for the specified
* resource.
* - TooManyRequestsException You've exceeded throttling limits by making too many requests in a period of
* time.
* - InternalServerErrorException An internal error occurred while processing the request. Try again
* later.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - ResourceGroupsException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ResourceGroupsAsyncClient.DeleteGroup
* @see AWS
* API Documentation
*/
@Override
public CompletableFuture deleteGroup(DeleteGroupRequest deleteGroupRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(deleteGroupRequest, this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, deleteGroupRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Resource Groups");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DeleteGroup");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
DeleteGroupResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("DeleteGroup").withProtocolMetadata(protocolMetadata)
.withMarshaller(new DeleteGroupRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(deleteGroupRequest));
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Retrieves the current status of optional features in Resource Groups.
*
*
* @param getAccountSettingsRequest
* @return A Java Future containing the result of the GetAccountSettings operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions. The exception returned is wrapped with CompletionException, so you need to invoke
* {@link Throwable#getCause} to retrieve the underlying exception.
*
* - BadRequestException The request includes one or more parameters that violate validation rules.
* - ForbiddenException The caller isn't authorized to make the request. Check permissions.
* - MethodNotAllowedException The request uses an HTTP method that isn't allowed for the specified
* resource.
* - TooManyRequestsException You've exceeded throttling limits by making too many requests in a period of
* time.
* - InternalServerErrorException An internal error occurred while processing the request. Try again
* later.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - ResourceGroupsException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ResourceGroupsAsyncClient.GetAccountSettings
* @see AWS API Documentation
*/
@Override
public CompletableFuture getAccountSettings(GetAccountSettingsRequest getAccountSettingsRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getAccountSettingsRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, getAccountSettingsRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Resource Groups");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetAccountSettings");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, GetAccountSettingsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("GetAccountSettings").withProtocolMetadata(protocolMetadata)
.withMarshaller(new GetAccountSettingsRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(getAccountSettingsRequest));
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Returns information about a specified resource group.
*
*
* Minimum permissions
*
*
* To run this command, you must have the following permissions:
*
*
* -
*
* resource-groups:GetGroup
*
*
*
*
* @param getGroupRequest
* @return A Java Future containing the result of the GetGroup operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions. The exception returned is wrapped with CompletionException, so you need to invoke
* {@link Throwable#getCause} to retrieve the underlying exception.
*
* - BadRequestException The request includes one or more parameters that violate validation rules.
* - ForbiddenException The caller isn't authorized to make the request. Check permissions.
* - NotFoundException One or more of the specified resources don't exist.
* - MethodNotAllowedException The request uses an HTTP method that isn't allowed for the specified
* resource.
* - TooManyRequestsException You've exceeded throttling limits by making too many requests in a period of
* time.
* - InternalServerErrorException An internal error occurred while processing the request. Try again
* later.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - ResourceGroupsException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ResourceGroupsAsyncClient.GetGroup
* @see AWS API
* Documentation
*/
@Override
public CompletableFuture getGroup(GetGroupRequest getGroupRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getGroupRequest, this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, getGroupRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Resource Groups");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetGroup");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
GetGroupResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams().withOperationName("GetGroup")
.withProtocolMetadata(protocolMetadata)
.withMarshaller(new GetGroupRequestMarshaller(protocolFactory)).withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).withRequestConfiguration(clientConfiguration)
.withMetricCollector(apiCallMetricCollector).withInput(getGroupRequest));
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Retrieves the service configuration associated with the specified resource group. For details about the service
* configuration syntax, see Service
* configurations for Resource Groups.
*
*
* Minimum permissions
*
*
* To run this command, you must have the following permissions:
*
*
* -
*
* resource-groups:GetGroupConfiguration
*
*
*
*
* @param getGroupConfigurationRequest
* @return A Java Future containing the result of the GetGroupConfiguration operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions. The exception returned is wrapped with CompletionException, so you need to invoke
* {@link Throwable#getCause} to retrieve the underlying exception.
*
* - BadRequestException The request includes one or more parameters that violate validation rules.
* - ForbiddenException The caller isn't authorized to make the request. Check permissions.
* - NotFoundException One or more of the specified resources don't exist.
* - MethodNotAllowedException The request uses an HTTP method that isn't allowed for the specified
* resource.
* - TooManyRequestsException You've exceeded throttling limits by making too many requests in a period of
* time.
* - InternalServerErrorException An internal error occurred while processing the request. Try again
* later.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - ResourceGroupsException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ResourceGroupsAsyncClient.GetGroupConfiguration
* @see AWS API Documentation
*/
@Override
public CompletableFuture getGroupConfiguration(
GetGroupConfigurationRequest getGroupConfigurationRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getGroupConfigurationRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, getGroupConfigurationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Resource Groups");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetGroupConfiguration");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, GetGroupConfigurationResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("GetGroupConfiguration").withProtocolMetadata(protocolMetadata)
.withMarshaller(new GetGroupConfigurationRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(getGroupConfigurationRequest));
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Retrieves the resource query associated with the specified resource group. For more information about resource
* queries, see Create a tag-based group in Resource Groups.
*
*
* Minimum permissions
*
*
* To run this command, you must have the following permissions:
*
*
* -
*
* resource-groups:GetGroupQuery
*
*
*
*
* @param getGroupQueryRequest
* @return A Java Future containing the result of the GetGroupQuery operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions. The exception returned is wrapped with CompletionException, so you need to invoke
* {@link Throwable#getCause} to retrieve the underlying exception.
*
* - BadRequestException The request includes one or more parameters that violate validation rules.
* - ForbiddenException The caller isn't authorized to make the request. Check permissions.
* - NotFoundException One or more of the specified resources don't exist.
* - MethodNotAllowedException The request uses an HTTP method that isn't allowed for the specified
* resource.
* - TooManyRequestsException You've exceeded throttling limits by making too many requests in a period of
* time.
* - InternalServerErrorException An internal error occurred while processing the request. Try again
* later.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - ResourceGroupsException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ResourceGroupsAsyncClient.GetGroupQuery
* @see AWS
* API Documentation
*/
@Override
public CompletableFuture getGroupQuery(GetGroupQueryRequest getGroupQueryRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getGroupQueryRequest, this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, getGroupQueryRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Resource Groups");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetGroupQuery");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
GetGroupQueryResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("GetGroupQuery").withProtocolMetadata(protocolMetadata)
.withMarshaller(new GetGroupQueryRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(getGroupQueryRequest));
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Returns information about a specified tag-sync task.
*
*
* Minimum permissions
*
*
* To run this command, you must have the following permissions:
*
*
* -
*
* resource-groups:GetTagSyncTask
on the application group
*
*
*
*
* @param getTagSyncTaskRequest
* @return A Java Future containing the result of the GetTagSyncTask operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions. The exception returned is wrapped with CompletionException, so you need to invoke
* {@link Throwable#getCause} to retrieve the underlying exception.
*
* - UnauthorizedException The request was rejected because it doesn't have valid credentials for the
* target resource.
* - BadRequestException The request includes one or more parameters that violate validation rules.
* - ForbiddenException The caller isn't authorized to make the request. Check permissions.
* - NotFoundException One or more of the specified resources don't exist.
* - MethodNotAllowedException The request uses an HTTP method that isn't allowed for the specified
* resource.
* - TooManyRequestsException You've exceeded throttling limits by making too many requests in a period of
* time.
* - InternalServerErrorException An internal error occurred while processing the request. Try again
* later.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - ResourceGroupsException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ResourceGroupsAsyncClient.GetTagSyncTask
* @see AWS API Documentation
*/
@Override
public CompletableFuture getTagSyncTask(GetTagSyncTaskRequest getTagSyncTaskRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getTagSyncTaskRequest, this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, getTagSyncTaskRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Resource Groups");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetTagSyncTask");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, GetTagSyncTaskResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("GetTagSyncTask").withProtocolMetadata(protocolMetadata)
.withMarshaller(new GetTagSyncTaskRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(getTagSyncTaskRequest));
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Returns a list of tags that are associated with a resource group, specified by an Amazon resource name (ARN).
*
*
* Minimum permissions
*
*
* To run this command, you must have the following permissions:
*
*
* -
*
* resource-groups:GetTags
*
*
*
*
* @param getTagsRequest
* @return A Java Future containing the result of the GetTags operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions. The exception returned is wrapped with CompletionException, so you need to invoke
* {@link Throwable#getCause} to retrieve the underlying exception.
*
* - BadRequestException The request includes one or more parameters that violate validation rules.
* - ForbiddenException The caller isn't authorized to make the request. Check permissions.
* - NotFoundException One or more of the specified resources don't exist.
* - MethodNotAllowedException The request uses an HTTP method that isn't allowed for the specified
* resource.
* - TooManyRequestsException You've exceeded throttling limits by making too many requests in a period of
* time.
* - InternalServerErrorException An internal error occurred while processing the request. Try again
* later.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - ResourceGroupsException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ResourceGroupsAsyncClient.GetTags
* @see AWS API
* Documentation
*/
@Override
public CompletableFuture getTags(GetTagsRequest getTagsRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getTagsRequest, this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, getTagsRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Resource Groups");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetTags");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
GetTagsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams().withOperationName("GetTags")
.withProtocolMetadata(protocolMetadata).withMarshaller(new GetTagsRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(getTagsRequest));
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Adds the specified resources to the specified group.
*
*
*
* You can only use this operation with the following groups:
*
*
* -
*
* AWS::EC2::HostManagement
*
*
* -
*
* AWS::EC2::CapacityReservationPool
*
*
* -
*
* AWS::ResourceGroups::ApplicationGroup
*
*
*
*
* Other resource group types and resource types are not currently supported by this operation.
*
*
*
* Minimum permissions
*
*
* To run this command, you must have the following permissions:
*
*
* -
*
* resource-groups:GroupResources
*
*
*
*
* @param groupResourcesRequest
* @return A Java Future containing the result of the GroupResources operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions. The exception returned is wrapped with CompletionException, so you need to invoke
* {@link Throwable#getCause} to retrieve the underlying exception.
*
* - BadRequestException The request includes one or more parameters that violate validation rules.
* - ForbiddenException The caller isn't authorized to make the request. Check permissions.
* - NotFoundException One or more of the specified resources don't exist.
* - MethodNotAllowedException The request uses an HTTP method that isn't allowed for the specified
* resource.
* - TooManyRequestsException You've exceeded throttling limits by making too many requests in a period of
* time.
* - InternalServerErrorException An internal error occurred while processing the request. Try again
* later.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - ResourceGroupsException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ResourceGroupsAsyncClient.GroupResources
* @see AWS API Documentation
*/
@Override
public CompletableFuture groupResources(GroupResourcesRequest groupResourcesRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(groupResourcesRequest, this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, groupResourcesRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Resource Groups");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GroupResources");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, GroupResourcesResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("GroupResources").withProtocolMetadata(protocolMetadata)
.withMarshaller(new GroupResourcesRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(groupResourcesRequest));
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Returns a list of Amazon resource names (ARNs) of the resources that are members of a specified resource group.
*
*
* Minimum permissions
*
*
* To run this command, you must have the following permissions:
*
*
* -
*
* resource-groups:ListGroupResources
*
*
* -
*
* cloudformation:DescribeStacks
*
*
* -
*
* cloudformation:ListStackResources
*
*
* -
*
* tag:GetResources
*
*
*
*
* @param listGroupResourcesRequest
* @return A Java Future containing the result of the ListGroupResources operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions. The exception returned is wrapped with CompletionException, so you need to invoke
* {@link Throwable#getCause} to retrieve the underlying exception.
*
* - UnauthorizedException The request was rejected because it doesn't have valid credentials for the
* target resource.
* - BadRequestException The request includes one or more parameters that violate validation rules.
* - ForbiddenException The caller isn't authorized to make the request. Check permissions.
* - NotFoundException One or more of the specified resources don't exist.
* - MethodNotAllowedException The request uses an HTTP method that isn't allowed for the specified
* resource.
* - TooManyRequestsException You've exceeded throttling limits by making too many requests in a period of
* time.
* - InternalServerErrorException An internal error occurred while processing the request. Try again
* later.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - ResourceGroupsException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ResourceGroupsAsyncClient.ListGroupResources
* @see AWS API Documentation
*/
@Override
public CompletableFuture listGroupResources(ListGroupResourcesRequest listGroupResourcesRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(listGroupResourcesRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, listGroupResourcesRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Resource Groups");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListGroupResources");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, ListGroupResourcesResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("ListGroupResources").withProtocolMetadata(protocolMetadata)
.withMarshaller(new ListGroupResourcesRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(listGroupResourcesRequest));
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Returns the status of the last grouping or ungrouping action for each resource in the specified application
* group.
*
*
* @param listGroupingStatusesRequest
* @return A Java Future containing the result of the ListGroupingStatuses operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions. The exception returned is wrapped with CompletionException, so you need to invoke
* {@link Throwable#getCause} to retrieve the underlying exception.
*
* - BadRequestException The request includes one or more parameters that violate validation rules.
* - ForbiddenException The caller isn't authorized to make the request. Check permissions.
* - MethodNotAllowedException The request uses an HTTP method that isn't allowed for the specified
* resource.
* - TooManyRequestsException You've exceeded throttling limits by making too many requests in a period of
* time.
* - InternalServerErrorException An internal error occurred while processing the request. Try again
* later.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - ResourceGroupsException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ResourceGroupsAsyncClient.ListGroupingStatuses
* @see AWS API Documentation
*/
@Override
public CompletableFuture listGroupingStatuses(
ListGroupingStatusesRequest listGroupingStatusesRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(listGroupingStatusesRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, listGroupingStatusesRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Resource Groups");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListGroupingStatuses");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, ListGroupingStatusesResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("ListGroupingStatuses").withProtocolMetadata(protocolMetadata)
.withMarshaller(new ListGroupingStatusesRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(listGroupingStatusesRequest));
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Returns a list of existing Resource Groups in your account.
*
*
* Minimum permissions
*
*
* To run this command, you must have the following permissions:
*
*
* -
*
* resource-groups:ListGroups
*
*
*
*
* @param listGroupsRequest
* @return A Java Future containing the result of the ListGroups operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions. The exception returned is wrapped with CompletionException, so you need to invoke
* {@link Throwable#getCause} to retrieve the underlying exception.
*
* - BadRequestException The request includes one or more parameters that violate validation rules.
* - ForbiddenException The caller isn't authorized to make the request. Check permissions.
* - MethodNotAllowedException The request uses an HTTP method that isn't allowed for the specified
* resource.
* - TooManyRequestsException You've exceeded throttling limits by making too many requests in a period of
* time.
* - InternalServerErrorException An internal error occurred while processing the request. Try again
* later.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - ResourceGroupsException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ResourceGroupsAsyncClient.ListGroups
* @see AWS
* API Documentation
*/
@Override
public CompletableFuture listGroups(ListGroupsRequest listGroupsRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(listGroupsRequest, this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, listGroupsRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Resource Groups");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListGroups");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
ListGroupsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams().withOperationName("ListGroups")
.withProtocolMetadata(protocolMetadata)
.withMarshaller(new ListGroupsRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(listGroupsRequest));
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Returns a list of tag-sync tasks.
*
*
* Minimum permissions
*
*
* To run this command, you must have the following permissions:
*
*
* -
*
* resource-groups:ListTagSyncTasks
with the group passed in the filters as the resource or * if using
* no filters
*
*
*
*
* @param listTagSyncTasksRequest
* @return A Java Future containing the result of the ListTagSyncTasks operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions. The exception returned is wrapped with CompletionException, so you need to invoke
* {@link Throwable#getCause} to retrieve the underlying exception.
*
* - UnauthorizedException The request was rejected because it doesn't have valid credentials for the
* target resource.
* - BadRequestException The request includes one or more parameters that violate validation rules.
* - ForbiddenException The caller isn't authorized to make the request. Check permissions.
* - MethodNotAllowedException The request uses an HTTP method that isn't allowed for the specified
* resource.
* - TooManyRequestsException You've exceeded throttling limits by making too many requests in a period of
* time.
* - InternalServerErrorException An internal error occurred while processing the request. Try again
* later.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - ResourceGroupsException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ResourceGroupsAsyncClient.ListTagSyncTasks
* @see AWS API Documentation
*/
@Override
public CompletableFuture listTagSyncTasks(ListTagSyncTasksRequest listTagSyncTasksRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(listTagSyncTasksRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, listTagSyncTasksRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Resource Groups");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListTagSyncTasks");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, ListTagSyncTasksResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("ListTagSyncTasks").withProtocolMetadata(protocolMetadata)
.withMarshaller(new ListTagSyncTasksRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(listTagSyncTasksRequest));
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Attaches a service configuration to the specified group. This occurs asynchronously, and can take time to
* complete. You can use GetGroupConfiguration to check the status of the update.
*
*
* Minimum permissions
*
*
* To run this command, you must have the following permissions:
*
*
* -
*
* resource-groups:PutGroupConfiguration
*
*
*
*
* @param putGroupConfigurationRequest
* @return A Java Future containing the result of the PutGroupConfiguration operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions. The exception returned is wrapped with CompletionException, so you need to invoke
* {@link Throwable#getCause} to retrieve the underlying exception.
*
* - BadRequestException The request includes one or more parameters that violate validation rules.
* - ForbiddenException The caller isn't authorized to make the request. Check permissions.
* - NotFoundException One or more of the specified resources don't exist.
* - MethodNotAllowedException The request uses an HTTP method that isn't allowed for the specified
* resource.
* - TooManyRequestsException You've exceeded throttling limits by making too many requests in a period of
* time.
* - InternalServerErrorException An internal error occurred while processing the request. Try again
* later.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - ResourceGroupsException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ResourceGroupsAsyncClient.PutGroupConfiguration
* @see AWS API Documentation
*/
@Override
public CompletableFuture putGroupConfiguration(
PutGroupConfigurationRequest putGroupConfigurationRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(putGroupConfigurationRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, putGroupConfigurationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Resource Groups");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "PutGroupConfiguration");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, PutGroupConfigurationResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("PutGroupConfiguration").withProtocolMetadata(protocolMetadata)
.withMarshaller(new PutGroupConfigurationRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(putGroupConfigurationRequest));
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Returns a list of Amazon Web Services resource identifiers that matches the specified query. The query uses the
* same format as a resource query in a CreateGroup or UpdateGroupQuery operation.
*
*
* Minimum permissions
*
*
* To run this command, you must have the following permissions:
*
*
* -
*
* resource-groups:SearchResources
*
*
* -
*
* cloudformation:DescribeStacks
*
*
* -
*
* cloudformation:ListStackResources
*
*
* -
*
* tag:GetResources
*
*
*
*
* @param searchResourcesRequest
* @return A Java Future containing the result of the SearchResources operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions. The exception returned is wrapped with CompletionException, so you need to invoke
* {@link Throwable#getCause} to retrieve the underlying exception.
*
* - UnauthorizedException The request was rejected because it doesn't have valid credentials for the
* target resource.
* - BadRequestException The request includes one or more parameters that violate validation rules.
* - ForbiddenException The caller isn't authorized to make the request. Check permissions.
* - MethodNotAllowedException The request uses an HTTP method that isn't allowed for the specified
* resource.
* - TooManyRequestsException You've exceeded throttling limits by making too many requests in a period of
* time.
* - InternalServerErrorException An internal error occurred while processing the request. Try again
* later.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - ResourceGroupsException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ResourceGroupsAsyncClient.SearchResources
* @see AWS API Documentation
*/
@Override
public CompletableFuture searchResources(SearchResourcesRequest searchResourcesRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(searchResourcesRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, searchResourcesRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Resource Groups");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "SearchResources");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, SearchResourcesResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("SearchResources").withProtocolMetadata(protocolMetadata)
.withMarshaller(new SearchResourcesRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(searchResourcesRequest));
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Creates a new tag-sync task to onboard and sync resources tagged with a specific tag key-value pair to an
* application.
*
*
* Minimum permissions
*
*
* To run this command, you must have the following permissions:
*
*
* -
*
* resource-groups:StartTagSyncTask
on the application group
*
*
* -
*
* resource-groups:CreateGroup
*
*
* -
*
* iam:PassRole
on the role provided in the request
*
*
*
*
* @param startTagSyncTaskRequest
* @return A Java Future containing the result of the StartTagSyncTask operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions. The exception returned is wrapped with CompletionException, so you need to invoke
* {@link Throwable#getCause} to retrieve the underlying exception.
*
* - UnauthorizedException The request was rejected because it doesn't have valid credentials for the
* target resource.
* - BadRequestException The request includes one or more parameters that violate validation rules.
* - ForbiddenException The caller isn't authorized to make the request. Check permissions.
* - NotFoundException One or more of the specified resources don't exist.
* - MethodNotAllowedException The request uses an HTTP method that isn't allowed for the specified
* resource.
* - TooManyRequestsException You've exceeded throttling limits by making too many requests in a period of
* time.
* - InternalServerErrorException An internal error occurred while processing the request. Try again
* later.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - ResourceGroupsException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ResourceGroupsAsyncClient.StartTagSyncTask
* @see AWS API Documentation
*/
@Override
public CompletableFuture startTagSyncTask(StartTagSyncTaskRequest startTagSyncTaskRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(startTagSyncTaskRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, startTagSyncTaskRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Resource Groups");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StartTagSyncTask");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, StartTagSyncTaskResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("StartTagSyncTask").withProtocolMetadata(protocolMetadata)
.withMarshaller(new StartTagSyncTaskRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(startTagSyncTaskRequest));
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Adds tags to a resource group with the specified Amazon resource name (ARN). Existing tags on a resource group
* are not changed if they are not specified in the request parameters.
*
*
*
* Do not store personally identifiable information (PII) or other confidential or sensitive information in tags. We
* use tags to provide you with billing and administration services. Tags are not intended to be used for private or
* sensitive data.
*
*
*
* Minimum permissions
*
*
* To run this command, you must have the following permissions:
*
*
* -
*
* resource-groups:Tag
*
*
*
*
* @param tagRequest
* @return A Java Future containing the result of the Tag operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions. The exception returned is wrapped with CompletionException, so you need to invoke
* {@link Throwable#getCause} to retrieve the underlying exception.
*
* - BadRequestException The request includes one or more parameters that violate validation rules.
* - ForbiddenException The caller isn't authorized to make the request. Check permissions.
* - NotFoundException One or more of the specified resources don't exist.
* - MethodNotAllowedException The request uses an HTTP method that isn't allowed for the specified
* resource.
* - TooManyRequestsException You've exceeded throttling limits by making too many requests in a period of
* time.
* - InternalServerErrorException An internal error occurred while processing the request. Try again
* later.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - ResourceGroupsException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ResourceGroupsAsyncClient.Tag
* @see AWS API
* Documentation
*/
@Override
public CompletableFuture tag(TagRequest tagRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(tagRequest, this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, tagRequest.overrideConfiguration()
.orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Resource Groups");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "Tag");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
TagResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams().withOperationName("Tag")
.withProtocolMetadata(protocolMetadata).withMarshaller(new TagRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(tagRequest));
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Removes the specified resources from the specified group. This operation works only with static groups that you
* populated using the GroupResources operation. It doesn't work with any resource groups that are
* automatically populated by tag-based or CloudFormation stack-based queries.
*
*
* Minimum permissions
*
*
* To run this command, you must have the following permissions:
*
*
* -
*
* resource-groups:UngroupResources
*
*
*
*
* @param ungroupResourcesRequest
* @return A Java Future containing the result of the UngroupResources operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions. The exception returned is wrapped with CompletionException, so you need to invoke
* {@link Throwable#getCause} to retrieve the underlying exception.
*
* - BadRequestException The request includes one or more parameters that violate validation rules.
* - ForbiddenException The caller isn't authorized to make the request. Check permissions.
* - NotFoundException One or more of the specified resources don't exist.
* - MethodNotAllowedException The request uses an HTTP method that isn't allowed for the specified
* resource.
* - TooManyRequestsException You've exceeded throttling limits by making too many requests in a period of
* time.
* - InternalServerErrorException An internal error occurred while processing the request. Try again
* later.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - ResourceGroupsException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ResourceGroupsAsyncClient.UngroupResources
* @see AWS API Documentation
*/
@Override
public CompletableFuture ungroupResources(UngroupResourcesRequest ungroupResourcesRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(ungroupResourcesRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, ungroupResourcesRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Resource Groups");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "UngroupResources");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, UngroupResourcesResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("UngroupResources").withProtocolMetadata(protocolMetadata)
.withMarshaller(new UngroupResourcesRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(ungroupResourcesRequest));
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Deletes tags from a specified resource group.
*
*
* Minimum permissions
*
*
* To run this command, you must have the following permissions:
*
*
* -
*
* resource-groups:Untag
*
*
*
*
* @param untagRequest
* @return A Java Future containing the result of the Untag operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions. The exception returned is wrapped with CompletionException, so you need to invoke
* {@link Throwable#getCause} to retrieve the underlying exception.
*
* - BadRequestException The request includes one or more parameters that violate validation rules.
* - ForbiddenException The caller isn't authorized to make the request. Check permissions.
* - NotFoundException One or more of the specified resources don't exist.
* - MethodNotAllowedException The request uses an HTTP method that isn't allowed for the specified
* resource.
* - TooManyRequestsException You've exceeded throttling limits by making too many requests in a period of
* time.
* - InternalServerErrorException An internal error occurred while processing the request. Try again
* later.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - ResourceGroupsException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ResourceGroupsAsyncClient.Untag
* @see AWS API
* Documentation
*/
@Override
public CompletableFuture untag(UntagRequest untagRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(untagRequest, this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, untagRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Resource Groups");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "Untag");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
UntagResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams().withOperationName("Untag")
.withProtocolMetadata(protocolMetadata).withMarshaller(new UntagRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(untagRequest));
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Turns on or turns off optional features in Resource Groups.
*
*
* The preceding example shows that the request to turn on group lifecycle events is IN_PROGRESS
. You
* can call the GetAccountSettings operation to check for completion by looking for
* GroupLifecycleEventsStatus
to change to ACTIVE
.
*
*
* @param updateAccountSettingsRequest
* @return A Java Future containing the result of the UpdateAccountSettings operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions. The exception returned is wrapped with CompletionException, so you need to invoke
* {@link Throwable#getCause} to retrieve the underlying exception.
*
* - BadRequestException The request includes one or more parameters that violate validation rules.
* - ForbiddenException The caller isn't authorized to make the request. Check permissions.
* - MethodNotAllowedException The request uses an HTTP method that isn't allowed for the specified
* resource.
* - TooManyRequestsException You've exceeded throttling limits by making too many requests in a period of
* time.
* - InternalServerErrorException An internal error occurred while processing the request. Try again
* later.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - ResourceGroupsException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ResourceGroupsAsyncClient.UpdateAccountSettings
* @see AWS API Documentation
*/
@Override
public CompletableFuture updateAccountSettings(
UpdateAccountSettingsRequest updateAccountSettingsRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(updateAccountSettingsRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, updateAccountSettingsRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Resource Groups");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "UpdateAccountSettings");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, UpdateAccountSettingsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("UpdateAccountSettings").withProtocolMetadata(protocolMetadata)
.withMarshaller(new UpdateAccountSettingsRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(updateAccountSettingsRequest));
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Updates the description for an existing group. You cannot update the name of a resource group.
*
*
* Minimum permissions
*
*
* To run this command, you must have the following permissions:
*
*
* -
*
* resource-groups:UpdateGroup
*
*
*
*
* @param updateGroupRequest
* @return A Java Future containing the result of the UpdateGroup operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions. The exception returned is wrapped with CompletionException, so you need to invoke
* {@link Throwable#getCause} to retrieve the underlying exception.
*
* - BadRequestException The request includes one or more parameters that violate validation rules.
* - ForbiddenException The caller isn't authorized to make the request. Check permissions.
* - NotFoundException One or more of the specified resources don't exist.
* - MethodNotAllowedException The request uses an HTTP method that isn't allowed for the specified
* resource.
* - TooManyRequestsException You've exceeded throttling limits by making too many requests in a period of
* time.
* - InternalServerErrorException An internal error occurred while processing the request. Try again
* later.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - ResourceGroupsException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ResourceGroupsAsyncClient.UpdateGroup
* @see AWS
* API Documentation
*/
@Override
public CompletableFuture updateGroup(UpdateGroupRequest updateGroupRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(updateGroupRequest, this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, updateGroupRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Resource Groups");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "UpdateGroup");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
UpdateGroupResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("UpdateGroup").withProtocolMetadata(protocolMetadata)
.withMarshaller(new UpdateGroupRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(updateGroupRequest));
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Updates the resource query of a group. For more information about resource queries, see Create a tag-based group in Resource Groups.
*
*
* Minimum permissions
*
*
* To run this command, you must have the following permissions:
*
*
* -
*
* resource-groups:UpdateGroupQuery
*
*
*
*
* @param updateGroupQueryRequest
* @return A Java Future containing the result of the UpdateGroupQuery operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions. The exception returned is wrapped with CompletionException, so you need to invoke
* {@link Throwable#getCause} to retrieve the underlying exception.
*
* - BadRequestException The request includes one or more parameters that violate validation rules.
* - ForbiddenException The caller isn't authorized to make the request. Check permissions.
* - NotFoundException One or more of the specified resources don't exist.
* - MethodNotAllowedException The request uses an HTTP method that isn't allowed for the specified
* resource.
* - TooManyRequestsException You've exceeded throttling limits by making too many requests in a period of
* time.
* - InternalServerErrorException An internal error occurred while processing the request. Try again
* later.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - ResourceGroupsException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ResourceGroupsAsyncClient.UpdateGroupQuery
* @see AWS API Documentation
*/
@Override
public CompletableFuture updateGroupQuery(UpdateGroupQueryRequest updateGroupQueryRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(updateGroupQueryRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, updateGroupQueryRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Resource Groups");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "UpdateGroupQuery");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, UpdateGroupQueryResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("UpdateGroupQuery").withProtocolMetadata(protocolMetadata)
.withMarshaller(new UpdateGroupQueryRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
.withInput(updateGroupQueryRequest));
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
@Override
public final ResourceGroupsServiceClientConfiguration serviceClientConfiguration() {
return new ResourceGroupsServiceClientConfigurationBuilder(this.clientConfiguration.toBuilder()).build();
}
@Override
public final String serviceName() {
return SERVICE_NAME;
}
private > T init(T builder) {
return builder
.clientConfiguration(clientConfiguration)
.defaultServiceExceptionSupplier(ResourceGroupsException::builder)
.protocol(AwsJsonProtocol.REST_JSON)
.protocolVersion("1.1")
.registerModeledException(
ExceptionMetadata.builder().errorCode("NotFoundException")
.exceptionBuilderSupplier(NotFoundException::builder).httpStatusCode(404).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("UnauthorizedException")
.exceptionBuilderSupplier(UnauthorizedException::builder).httpStatusCode(401).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("ForbiddenException")
.exceptionBuilderSupplier(ForbiddenException::builder).httpStatusCode(403).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("MethodNotAllowedException")
.exceptionBuilderSupplier(MethodNotAllowedException::builder).httpStatusCode(405).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("TooManyRequestsException")
.exceptionBuilderSupplier(TooManyRequestsException::builder).httpStatusCode(429).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("BadRequestException")
.exceptionBuilderSupplier(BadRequestException::builder).httpStatusCode(400).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("InternalServerErrorException")
.exceptionBuilderSupplier(InternalServerErrorException::builder).httpStatusCode(500).build());
}
private static List resolveMetricPublishers(SdkClientConfiguration clientConfiguration,
RequestOverrideConfiguration requestOverrideConfiguration) {
List publishers = null;
if (requestOverrideConfiguration != null) {
publishers = requestOverrideConfiguration.metricPublishers();
}
if (publishers == null || publishers.isEmpty()) {
publishers = clientConfiguration.option(SdkClientOption.METRIC_PUBLISHERS);
}
if (publishers == null) {
publishers = Collections.emptyList();
}
return publishers;
}
private void updateRetryStrategyClientConfiguration(SdkClientConfiguration.Builder configuration) {
ClientOverrideConfiguration.Builder builder = configuration.asOverrideConfigurationBuilder();
RetryMode retryMode = builder.retryMode();
if (retryMode != null) {
configuration.option(SdkClientOption.RETRY_STRATEGY, AwsRetryStrategy.forRetryMode(retryMode));
} else {
Consumer> configurator = builder.retryStrategyConfigurator();
if (configurator != null) {
RetryStrategy.Builder, ?> defaultBuilder = AwsRetryStrategy.defaultRetryStrategy().toBuilder();
configurator.accept(defaultBuilder);
configuration.option(SdkClientOption.RETRY_STRATEGY, defaultBuilder.build());
} else {
RetryStrategy retryStrategy = builder.retryStrategy();
if (retryStrategy != null) {
configuration.option(SdkClientOption.RETRY_STRATEGY, retryStrategy);
}
}
}
configuration.option(SdkClientOption.CONFIGURED_RETRY_MODE, null);
configuration.option(SdkClientOption.CONFIGURED_RETRY_STRATEGY, null);
configuration.option(SdkClientOption.CONFIGURED_RETRY_CONFIGURATOR, null);
}
private SdkClientConfiguration updateSdkClientConfiguration(SdkRequest request, SdkClientConfiguration clientConfiguration) {
List plugins = request.overrideConfiguration().map(c -> c.plugins()).orElse(Collections.emptyList());
SdkClientConfiguration.Builder configuration = clientConfiguration.toBuilder();
if (plugins.isEmpty()) {
return configuration.build();
}
ResourceGroupsServiceClientConfigurationBuilder serviceConfigBuilder = new ResourceGroupsServiceClientConfigurationBuilder(
configuration);
for (SdkPlugin plugin : plugins) {
plugin.configureClient(serviceConfigBuilder);
}
updateRetryStrategyClientConfiguration(configuration);
return configuration.build();
}
private HttpResponseHandler createErrorResponseHandler(BaseAwsJsonProtocolFactory protocolFactory,
JsonOperationMetadata operationMetadata) {
return protocolFactory.createErrorResponseHandler(operationMetadata);
}
private HttpResponseHandler createErrorResponseHandler(BaseAwsJsonProtocolFactory protocolFactory,
JsonOperationMetadata operationMetadata, Function> exceptionMetadataMapper) {
return protocolFactory.createErrorResponseHandler(operationMetadata, exceptionMetadataMapper);
}
@Override
public void close() {
clientHandler.close();
}
}