
software.amazon.awssdk.services.resourcegroups.DefaultResourceGroupsClient Maven / Gradle / Ivy
/*
* Copyright 2013-2018 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.function.Consumer;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.awscore.AwsRequestOverrideConfiguration;
import software.amazon.awssdk.awscore.client.handler.AwsSyncClientHandler;
import software.amazon.awssdk.awscore.exception.AwsServiceException;
import software.amazon.awssdk.awscore.internal.protocol.json.AwsJsonProtocol;
import software.amazon.awssdk.awscore.protocol.json.AwsJsonProtocolFactory;
import software.amazon.awssdk.awscore.protocol.json.AwsJsonProtocolMetadata;
import software.amazon.awssdk.core.ApiName;
import software.amazon.awssdk.core.client.handler.ClientExecutionParams;
import software.amazon.awssdk.core.client.handler.SyncClientHandler;
import software.amazon.awssdk.core.exception.SdkClientException;
import software.amazon.awssdk.core.http.HttpResponseHandler;
import software.amazon.awssdk.core.internal.client.config.SdkClientConfiguration;
import software.amazon.awssdk.core.protocol.json.JsonClientMetadata;
import software.amazon.awssdk.core.protocol.json.JsonErrorResponseMetadata;
import software.amazon.awssdk.core.protocol.json.JsonErrorShapeMetadata;
import software.amazon.awssdk.core.protocol.json.JsonOperationMetadata;
import software.amazon.awssdk.core.util.VersionInfo;
import software.amazon.awssdk.services.resourcegroups.model.BadRequestException;
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.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.GetTagsRequest;
import software.amazon.awssdk.services.resourcegroups.model.GetTagsResponse;
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.ListGroupsRequest;
import software.amazon.awssdk.services.resourcegroups.model.ListGroupsResponse;
import software.amazon.awssdk.services.resourcegroups.model.MethodNotAllowedException;
import software.amazon.awssdk.services.resourcegroups.model.NotFoundException;
import software.amazon.awssdk.services.resourcegroups.model.ResourceGroupsException;
import software.amazon.awssdk.services.resourcegroups.model.ResourceGroupsRequest;
import software.amazon.awssdk.services.resourcegroups.model.SearchResourcesRequest;
import software.amazon.awssdk.services.resourcegroups.model.SearchResourcesResponse;
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.UntagRequest;
import software.amazon.awssdk.services.resourcegroups.model.UntagResponse;
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.paginators.ListGroupResourcesIterable;
import software.amazon.awssdk.services.resourcegroups.paginators.ListGroupsIterable;
import software.amazon.awssdk.services.resourcegroups.paginators.SearchResourcesIterable;
import software.amazon.awssdk.services.resourcegroups.transform.CreateGroupRequestMarshaller;
import software.amazon.awssdk.services.resourcegroups.transform.CreateGroupResponseUnmarshaller;
import software.amazon.awssdk.services.resourcegroups.transform.DeleteGroupRequestMarshaller;
import software.amazon.awssdk.services.resourcegroups.transform.DeleteGroupResponseUnmarshaller;
import software.amazon.awssdk.services.resourcegroups.transform.GetGroupQueryRequestMarshaller;
import software.amazon.awssdk.services.resourcegroups.transform.GetGroupQueryResponseUnmarshaller;
import software.amazon.awssdk.services.resourcegroups.transform.GetGroupRequestMarshaller;
import software.amazon.awssdk.services.resourcegroups.transform.GetGroupResponseUnmarshaller;
import software.amazon.awssdk.services.resourcegroups.transform.GetTagsRequestMarshaller;
import software.amazon.awssdk.services.resourcegroups.transform.GetTagsResponseUnmarshaller;
import software.amazon.awssdk.services.resourcegroups.transform.ListGroupResourcesRequestMarshaller;
import software.amazon.awssdk.services.resourcegroups.transform.ListGroupResourcesResponseUnmarshaller;
import software.amazon.awssdk.services.resourcegroups.transform.ListGroupsRequestMarshaller;
import software.amazon.awssdk.services.resourcegroups.transform.ListGroupsResponseUnmarshaller;
import software.amazon.awssdk.services.resourcegroups.transform.SearchResourcesRequestMarshaller;
import software.amazon.awssdk.services.resourcegroups.transform.SearchResourcesResponseUnmarshaller;
import software.amazon.awssdk.services.resourcegroups.transform.TagRequestMarshaller;
import software.amazon.awssdk.services.resourcegroups.transform.TagResponseUnmarshaller;
import software.amazon.awssdk.services.resourcegroups.transform.UntagRequestMarshaller;
import software.amazon.awssdk.services.resourcegroups.transform.UntagResponseUnmarshaller;
import software.amazon.awssdk.services.resourcegroups.transform.UpdateGroupQueryRequestMarshaller;
import software.amazon.awssdk.services.resourcegroups.transform.UpdateGroupQueryResponseUnmarshaller;
import software.amazon.awssdk.services.resourcegroups.transform.UpdateGroupRequestMarshaller;
import software.amazon.awssdk.services.resourcegroups.transform.UpdateGroupResponseUnmarshaller;
/**
* Internal implementation of {@link ResourceGroupsClient}.
*
* @see ResourceGroupsClient#builder()
*/
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
final class DefaultResourceGroupsClient implements ResourceGroupsClient {
private final SyncClientHandler clientHandler;
private final AwsJsonProtocolFactory protocolFactory;
private final SdkClientConfiguration clientConfiguration;
protected DefaultResourceGroupsClient(SdkClientConfiguration clientConfiguration) {
this.clientHandler = new AwsSyncClientHandler(clientConfiguration);
this.protocolFactory = init();
this.clientConfiguration = clientConfiguration;
}
@Override
public final String serviceName() {
return SERVICE_NAME;
}
/**
*
* Creates a group with a specified name, description, and resource query.
*
*
* @param createGroupRequest
* @return Result of the CreateGroup operation returned by the service.
* @throws BadRequestException
* The request does not comply with validation rules that are defined for the request parameters.
* @throws ForbiddenException
* The caller is not authorized to make the request.
* @throws MethodNotAllowedException
* The request uses an HTTP method which is not allowed for the specified resource.
* @throws TooManyRequestsException
* The caller has exceeded throttling limits.
* @throws InternalServerErrorException
* An internal error occurred while processing the request.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws ResourceGroupsException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample ResourceGroupsClient.CreateGroup
* @see AWS
* API Documentation
*/
@Override
public CreateGroupResponse createGroup(CreateGroupRequest createGroupRequest) throws BadRequestException, ForbiddenException,
MethodNotAllowedException, TooManyRequestsException, InternalServerErrorException, AwsServiceException,
SdkClientException, ResourceGroupsException {
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
new JsonOperationMetadata().withPayloadJson(true).withHasStreamingSuccessResponse(false),
new CreateGroupResponseUnmarshaller());
HttpResponseHandler errorResponseHandler = createErrorResponseHandler();
return clientHandler.execute(new ClientExecutionParams()
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withInput(createGroupRequest).withMarshaller(new CreateGroupRequestMarshaller(protocolFactory)));
}
/**
*
* Deletes a specified resource group. Deleting a resource group does not delete resources that are members of the
* group; it only deletes the group structure.
*
*
* @param deleteGroupRequest
* @return Result of the DeleteGroup operation returned by the service.
* @throws BadRequestException
* The request does not comply with validation rules that are defined for the request parameters.
* @throws ForbiddenException
* The caller is not authorized to make the request.
* @throws NotFoundException
* One or more resources specified in the request do not exist.
* @throws MethodNotAllowedException
* The request uses an HTTP method which is not allowed for the specified resource.
* @throws TooManyRequestsException
* The caller has exceeded throttling limits.
* @throws InternalServerErrorException
* An internal error occurred while processing the request.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws ResourceGroupsException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample ResourceGroupsClient.DeleteGroup
* @see AWS
* API Documentation
*/
@Override
public DeleteGroupResponse deleteGroup(DeleteGroupRequest deleteGroupRequest) throws BadRequestException, ForbiddenException,
NotFoundException, MethodNotAllowedException, TooManyRequestsException, InternalServerErrorException,
AwsServiceException, SdkClientException, ResourceGroupsException {
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
new JsonOperationMetadata().withPayloadJson(true).withHasStreamingSuccessResponse(false),
new DeleteGroupResponseUnmarshaller());
HttpResponseHandler errorResponseHandler = createErrorResponseHandler();
return clientHandler.execute(new ClientExecutionParams()
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withInput(deleteGroupRequest).withMarshaller(new DeleteGroupRequestMarshaller(protocolFactory)));
}
/**
*
* Returns information about a specified resource group.
*
*
* @param getGroupRequest
* @return Result of the GetGroup operation returned by the service.
* @throws BadRequestException
* The request does not comply with validation rules that are defined for the request parameters.
* @throws ForbiddenException
* The caller is not authorized to make the request.
* @throws NotFoundException
* One or more resources specified in the request do not exist.
* @throws MethodNotAllowedException
* The request uses an HTTP method which is not allowed for the specified resource.
* @throws TooManyRequestsException
* The caller has exceeded throttling limits.
* @throws InternalServerErrorException
* An internal error occurred while processing the request.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws ResourceGroupsException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample ResourceGroupsClient.GetGroup
* @see AWS API
* Documentation
*/
@Override
public GetGroupResponse getGroup(GetGroupRequest getGroupRequest) throws BadRequestException, ForbiddenException,
NotFoundException, MethodNotAllowedException, TooManyRequestsException, InternalServerErrorException,
AwsServiceException, SdkClientException, ResourceGroupsException {
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(new JsonOperationMetadata()
.withPayloadJson(true).withHasStreamingSuccessResponse(false), new GetGroupResponseUnmarshaller());
HttpResponseHandler errorResponseHandler = createErrorResponseHandler();
return clientHandler.execute(new ClientExecutionParams()
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler).withInput(getGroupRequest)
.withMarshaller(new GetGroupRequestMarshaller(protocolFactory)));
}
/**
*
* Returns the resource query associated with the specified resource group.
*
*
* @param getGroupQueryRequest
* @return Result of the GetGroupQuery operation returned by the service.
* @throws BadRequestException
* The request does not comply with validation rules that are defined for the request parameters.
* @throws ForbiddenException
* The caller is not authorized to make the request.
* @throws NotFoundException
* One or more resources specified in the request do not exist.
* @throws MethodNotAllowedException
* The request uses an HTTP method which is not allowed for the specified resource.
* @throws TooManyRequestsException
* The caller has exceeded throttling limits.
* @throws InternalServerErrorException
* An internal error occurred while processing the request.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws ResourceGroupsException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample ResourceGroupsClient.GetGroupQuery
* @see AWS
* API Documentation
*/
@Override
public GetGroupQueryResponse getGroupQuery(GetGroupQueryRequest getGroupQueryRequest) throws BadRequestException,
ForbiddenException, NotFoundException, MethodNotAllowedException, TooManyRequestsException,
InternalServerErrorException, AwsServiceException, SdkClientException, ResourceGroupsException {
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
new JsonOperationMetadata().withPayloadJson(true).withHasStreamingSuccessResponse(false),
new GetGroupQueryResponseUnmarshaller());
HttpResponseHandler errorResponseHandler = createErrorResponseHandler();
return clientHandler.execute(new ClientExecutionParams()
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withInput(getGroupQueryRequest).withMarshaller(new GetGroupQueryRequestMarshaller(protocolFactory)));
}
/**
*
* Returns a list of tags that are associated with a resource, specified by an ARN.
*
*
* @param getTagsRequest
* @return Result of the GetTags operation returned by the service.
* @throws BadRequestException
* The request does not comply with validation rules that are defined for the request parameters.
* @throws ForbiddenException
* The caller is not authorized to make the request.
* @throws NotFoundException
* One or more resources specified in the request do not exist.
* @throws MethodNotAllowedException
* The request uses an HTTP method which is not allowed for the specified resource.
* @throws TooManyRequestsException
* The caller has exceeded throttling limits.
* @throws InternalServerErrorException
* An internal error occurred while processing the request.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws ResourceGroupsException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample ResourceGroupsClient.GetTags
* @see AWS API
* Documentation
*/
@Override
public GetTagsResponse getTags(GetTagsRequest getTagsRequest) throws BadRequestException, ForbiddenException,
NotFoundException, MethodNotAllowedException, TooManyRequestsException, InternalServerErrorException,
AwsServiceException, SdkClientException, ResourceGroupsException {
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(new JsonOperationMetadata()
.withPayloadJson(true).withHasStreamingSuccessResponse(false), new GetTagsResponseUnmarshaller());
HttpResponseHandler errorResponseHandler = createErrorResponseHandler();
return clientHandler.execute(new ClientExecutionParams()
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler).withInput(getTagsRequest)
.withMarshaller(new GetTagsRequestMarshaller(protocolFactory)));
}
/**
*
* Returns a list of ARNs of resources that are members of a specified resource group.
*
*
* @param listGroupResourcesRequest
* @return Result of the ListGroupResources operation returned by the service.
* @throws UnauthorizedException
* The request has not been applied because it lacks valid authentication credentials for the target
* resource.
* @throws BadRequestException
* The request does not comply with validation rules that are defined for the request parameters.
* @throws ForbiddenException
* The caller is not authorized to make the request.
* @throws NotFoundException
* One or more resources specified in the request do not exist.
* @throws MethodNotAllowedException
* The request uses an HTTP method which is not allowed for the specified resource.
* @throws TooManyRequestsException
* The caller has exceeded throttling limits.
* @throws InternalServerErrorException
* An internal error occurred while processing the request.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws ResourceGroupsException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample ResourceGroupsClient.ListGroupResources
* @see AWS API Documentation
*/
@Override
public ListGroupResourcesResponse listGroupResources(ListGroupResourcesRequest listGroupResourcesRequest)
throws UnauthorizedException, BadRequestException, ForbiddenException, NotFoundException, MethodNotAllowedException,
TooManyRequestsException, InternalServerErrorException, AwsServiceException, SdkClientException,
ResourceGroupsException {
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
new JsonOperationMetadata().withPayloadJson(true).withHasStreamingSuccessResponse(false),
new ListGroupResourcesResponseUnmarshaller());
HttpResponseHandler errorResponseHandler = createErrorResponseHandler();
return clientHandler.execute(new ClientExecutionParams()
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withInput(listGroupResourcesRequest).withMarshaller(new ListGroupResourcesRequestMarshaller(protocolFactory)));
}
/**
*
* Returns a list of ARNs of resources that are members of a specified resource group.
*
*
*
* This is a variant of
* {@link #listGroupResources(software.amazon.awssdk.services.resourcegroups.model.ListGroupResourcesRequest)}
* operation. The return type is a custom iterable that can be used to iterate through all the pages. SDK will
* internally handle making service calls for you.
*
*
* When this operation is called, a custom iterable is returned but no service calls are made yet. So there is no
* guarantee that the request is valid. As you iterate through the iterable, SDK will start lazily loading response
* pages by making service calls until there are no pages left or your iteration stops. If there are errors in your
* request, you will see the failures only after you start iterating through the iterable.
*
*
*
* The following are few ways to iterate through the response pages:
*
* 1) Using a Stream
*
*
* {@code
* software.amazon.awssdk.services.resourcegroups.paginators.ListGroupResourcesIterable responses = client.listGroupResourcesPaginator(request);
* responses.stream().forEach(....);
* }
*
*
* 2) Using For loop
*
*
* {
* @code
* software.amazon.awssdk.services.resourcegroups.paginators.ListGroupResourcesIterable responses = client
* .listGroupResourcesPaginator(request);
* for (software.amazon.awssdk.services.resourcegroups.model.ListGroupResourcesResponse response : responses) {
* // do something;
* }
* }
*
*
* 3) Use iterator directly
*
*
* {@code
* software.amazon.awssdk.services.resourcegroups.paginators.ListGroupResourcesIterable responses = client.listGroupResourcesPaginator(request);
* responses.iterator().forEachRemaining(....);
* }
*
*
* Note: If you prefer to have control on service calls, use the
* {@link #listGroupResources(software.amazon.awssdk.services.resourcegroups.model.ListGroupResourcesRequest)}
* operation.
*
*
* @param listGroupResourcesRequest
* @return A custom iterable that can be used to iterate through all the response pages.
* @throws UnauthorizedException
* The request has not been applied because it lacks valid authentication credentials for the target
* resource.
* @throws BadRequestException
* The request does not comply with validation rules that are defined for the request parameters.
* @throws ForbiddenException
* The caller is not authorized to make the request.
* @throws NotFoundException
* One or more resources specified in the request do not exist.
* @throws MethodNotAllowedException
* The request uses an HTTP method which is not allowed for the specified resource.
* @throws TooManyRequestsException
* The caller has exceeded throttling limits.
* @throws InternalServerErrorException
* An internal error occurred while processing the request.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws ResourceGroupsException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample ResourceGroupsClient.ListGroupResources
* @see AWS API Documentation
*/
@Override
public ListGroupResourcesIterable listGroupResourcesPaginator(ListGroupResourcesRequest listGroupResourcesRequest)
throws UnauthorizedException, BadRequestException, ForbiddenException, NotFoundException, MethodNotAllowedException,
TooManyRequestsException, InternalServerErrorException, AwsServiceException, SdkClientException,
ResourceGroupsException {
return new ListGroupResourcesIterable(this, applyPaginatorUserAgent(listGroupResourcesRequest));
}
/**
*
* Returns a list of existing resource groups in your account.
*
*
* @param listGroupsRequest
* @return Result of the ListGroups operation returned by the service.
* @throws BadRequestException
* The request does not comply with validation rules that are defined for the request parameters.
* @throws ForbiddenException
* The caller is not authorized to make the request.
* @throws MethodNotAllowedException
* The request uses an HTTP method which is not allowed for the specified resource.
* @throws TooManyRequestsException
* The caller has exceeded throttling limits.
* @throws InternalServerErrorException
* An internal error occurred while processing the request.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws ResourceGroupsException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample ResourceGroupsClient.ListGroups
* @see AWS API
* Documentation
*/
@Override
public ListGroupsResponse listGroups(ListGroupsRequest listGroupsRequest) throws BadRequestException, ForbiddenException,
MethodNotAllowedException, TooManyRequestsException, InternalServerErrorException, AwsServiceException,
SdkClientException, ResourceGroupsException {
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
new JsonOperationMetadata().withPayloadJson(true).withHasStreamingSuccessResponse(false),
new ListGroupsResponseUnmarshaller());
HttpResponseHandler errorResponseHandler = createErrorResponseHandler();
return clientHandler.execute(new ClientExecutionParams()
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler).withInput(listGroupsRequest)
.withMarshaller(new ListGroupsRequestMarshaller(protocolFactory)));
}
/**
*
* Returns a list of existing resource groups in your account.
*
*
*
* This is a variant of {@link #listGroups(software.amazon.awssdk.services.resourcegroups.model.ListGroupsRequest)}
* operation. The return type is a custom iterable that can be used to iterate through all the pages. SDK will
* internally handle making service calls for you.
*
*
* When this operation is called, a custom iterable is returned but no service calls are made yet. So there is no
* guarantee that the request is valid. As you iterate through the iterable, SDK will start lazily loading response
* pages by making service calls until there are no pages left or your iteration stops. If there are errors in your
* request, you will see the failures only after you start iterating through the iterable.
*
*
*
* The following are few ways to iterate through the response pages:
*
* 1) Using a Stream
*
*
* {@code
* software.amazon.awssdk.services.resourcegroups.paginators.ListGroupsIterable responses = client.listGroupsPaginator(request);
* responses.stream().forEach(....);
* }
*
*
* 2) Using For loop
*
*
* {
* @code
* software.amazon.awssdk.services.resourcegroups.paginators.ListGroupsIterable responses = client.listGroupsPaginator(request);
* for (software.amazon.awssdk.services.resourcegroups.model.ListGroupsResponse response : responses) {
* // do something;
* }
* }
*
*
* 3) Use iterator directly
*
*
* {@code
* software.amazon.awssdk.services.resourcegroups.paginators.ListGroupsIterable responses = client.listGroupsPaginator(request);
* responses.iterator().forEachRemaining(....);
* }
*
*
* Note: If you prefer to have control on service calls, use the
* {@link #listGroups(software.amazon.awssdk.services.resourcegroups.model.ListGroupsRequest)} operation.
*
*
* @param listGroupsRequest
* @return A custom iterable that can be used to iterate through all the response pages.
* @throws BadRequestException
* The request does not comply with validation rules that are defined for the request parameters.
* @throws ForbiddenException
* The caller is not authorized to make the request.
* @throws MethodNotAllowedException
* The request uses an HTTP method which is not allowed for the specified resource.
* @throws TooManyRequestsException
* The caller has exceeded throttling limits.
* @throws InternalServerErrorException
* An internal error occurred while processing the request.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws ResourceGroupsException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample ResourceGroupsClient.ListGroups
* @see AWS API
* Documentation
*/
@Override
public ListGroupsIterable listGroupsPaginator(ListGroupsRequest listGroupsRequest) throws BadRequestException,
ForbiddenException, MethodNotAllowedException, TooManyRequestsException, InternalServerErrorException,
AwsServiceException, SdkClientException, ResourceGroupsException {
return new ListGroupsIterable(this, applyPaginatorUserAgent(listGroupsRequest));
}
/**
*
* Returns a list of AWS resource identifiers that matches a specified query. The query uses the same format as a
* resource query in a CreateGroup or UpdateGroupQuery operation.
*
*
* @param searchResourcesRequest
* @return Result of the SearchResources operation returned by the service.
* @throws UnauthorizedException
* The request has not been applied because it lacks valid authentication credentials for the target
* resource.
* @throws BadRequestException
* The request does not comply with validation rules that are defined for the request parameters.
* @throws ForbiddenException
* The caller is not authorized to make the request.
* @throws MethodNotAllowedException
* The request uses an HTTP method which is not allowed for the specified resource.
* @throws TooManyRequestsException
* The caller has exceeded throttling limits.
* @throws InternalServerErrorException
* An internal error occurred while processing the request.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws ResourceGroupsException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample ResourceGroupsClient.SearchResources
* @see AWS API Documentation
*/
@Override
public SearchResourcesResponse searchResources(SearchResourcesRequest searchResourcesRequest) throws UnauthorizedException,
BadRequestException, ForbiddenException, MethodNotAllowedException, TooManyRequestsException,
InternalServerErrorException, AwsServiceException, SdkClientException, ResourceGroupsException {
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
new JsonOperationMetadata().withPayloadJson(true).withHasStreamingSuccessResponse(false),
new SearchResourcesResponseUnmarshaller());
HttpResponseHandler errorResponseHandler = createErrorResponseHandler();
return clientHandler.execute(new ClientExecutionParams()
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withInput(searchResourcesRequest).withMarshaller(new SearchResourcesRequestMarshaller(protocolFactory)));
}
/**
*
* Returns a list of AWS resource identifiers that matches a specified query. The query uses the same format as a
* resource query in a CreateGroup or UpdateGroupQuery operation.
*
*
*
* This is a variant of
* {@link #searchResources(software.amazon.awssdk.services.resourcegroups.model.SearchResourcesRequest)} operation.
* The return type is a custom iterable that can be used to iterate through all the pages. SDK will internally
* handle making service calls for you.
*
*
* When this operation is called, a custom iterable is returned but no service calls are made yet. So there is no
* guarantee that the request is valid. As you iterate through the iterable, SDK will start lazily loading response
* pages by making service calls until there are no pages left or your iteration stops. If there are errors in your
* request, you will see the failures only after you start iterating through the iterable.
*
*
*
* The following are few ways to iterate through the response pages:
*
* 1) Using a Stream
*
*
* {@code
* software.amazon.awssdk.services.resourcegroups.paginators.SearchResourcesIterable responses = client.searchResourcesPaginator(request);
* responses.stream().forEach(....);
* }
*
*
* 2) Using For loop
*
*
* {
* @code
* software.amazon.awssdk.services.resourcegroups.paginators.SearchResourcesIterable responses = client
* .searchResourcesPaginator(request);
* for (software.amazon.awssdk.services.resourcegroups.model.SearchResourcesResponse response : responses) {
* // do something;
* }
* }
*
*
* 3) Use iterator directly
*
*
* {@code
* software.amazon.awssdk.services.resourcegroups.paginators.SearchResourcesIterable responses = client.searchResourcesPaginator(request);
* responses.iterator().forEachRemaining(....);
* }
*
*
* Note: If you prefer to have control on service calls, use the
* {@link #searchResources(software.amazon.awssdk.services.resourcegroups.model.SearchResourcesRequest)}
* operation.
*
*
* @param searchResourcesRequest
* @return A custom iterable that can be used to iterate through all the response pages.
* @throws UnauthorizedException
* The request has not been applied because it lacks valid authentication credentials for the target
* resource.
* @throws BadRequestException
* The request does not comply with validation rules that are defined for the request parameters.
* @throws ForbiddenException
* The caller is not authorized to make the request.
* @throws MethodNotAllowedException
* The request uses an HTTP method which is not allowed for the specified resource.
* @throws TooManyRequestsException
* The caller has exceeded throttling limits.
* @throws InternalServerErrorException
* An internal error occurred while processing the request.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws ResourceGroupsException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample ResourceGroupsClient.SearchResources
* @see AWS API Documentation
*/
@Override
public SearchResourcesIterable searchResourcesPaginator(SearchResourcesRequest searchResourcesRequest)
throws UnauthorizedException, BadRequestException, ForbiddenException, MethodNotAllowedException,
TooManyRequestsException, InternalServerErrorException, AwsServiceException, SdkClientException,
ResourceGroupsException {
return new SearchResourcesIterable(this, applyPaginatorUserAgent(searchResourcesRequest));
}
/**
*
* Adds specified tags to a resource with the specified ARN. Existing tags on a resource are not changed if they are
* not specified in the request parameters.
*
*
* @param tagRequest
* @return Result of the Tag operation returned by the service.
* @throws BadRequestException
* The request does not comply with validation rules that are defined for the request parameters.
* @throws ForbiddenException
* The caller is not authorized to make the request.
* @throws NotFoundException
* One or more resources specified in the request do not exist.
* @throws MethodNotAllowedException
* The request uses an HTTP method which is not allowed for the specified resource.
* @throws TooManyRequestsException
* The caller has exceeded throttling limits.
* @throws InternalServerErrorException
* An internal error occurred while processing the request.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws ResourceGroupsException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample ResourceGroupsClient.Tag
* @see AWS API
* Documentation
*/
@Override
public TagResponse tag(TagRequest tagRequest) throws BadRequestException, ForbiddenException, NotFoundException,
MethodNotAllowedException, TooManyRequestsException, InternalServerErrorException, AwsServiceException,
SdkClientException, ResourceGroupsException {
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(new JsonOperationMetadata()
.withPayloadJson(true).withHasStreamingSuccessResponse(false), new TagResponseUnmarshaller());
HttpResponseHandler errorResponseHandler = createErrorResponseHandler();
return clientHandler.execute(new ClientExecutionParams().withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).withInput(tagRequest)
.withMarshaller(new TagRequestMarshaller(protocolFactory)));
}
/**
*
* Deletes specified tags from a specified resource.
*
*
* @param untagRequest
* @return Result of the Untag operation returned by the service.
* @throws BadRequestException
* The request does not comply with validation rules that are defined for the request parameters.
* @throws ForbiddenException
* The caller is not authorized to make the request.
* @throws NotFoundException
* One or more resources specified in the request do not exist.
* @throws MethodNotAllowedException
* The request uses an HTTP method which is not allowed for the specified resource.
* @throws TooManyRequestsException
* The caller has exceeded throttling limits.
* @throws InternalServerErrorException
* An internal error occurred while processing the request.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws ResourceGroupsException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample ResourceGroupsClient.Untag
* @see AWS API
* Documentation
*/
@Override
public UntagResponse untag(UntagRequest untagRequest) throws BadRequestException, ForbiddenException, NotFoundException,
MethodNotAllowedException, TooManyRequestsException, InternalServerErrorException, AwsServiceException,
SdkClientException, ResourceGroupsException {
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(new JsonOperationMetadata()
.withPayloadJson(true).withHasStreamingSuccessResponse(false), new UntagResponseUnmarshaller());
HttpResponseHandler errorResponseHandler = createErrorResponseHandler();
return clientHandler.execute(new ClientExecutionParams()
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler).withInput(untagRequest)
.withMarshaller(new UntagRequestMarshaller(protocolFactory)));
}
/**
*
* Updates an existing group with a new or changed description. You cannot update the name of a resource group.
*
*
* @param updateGroupRequest
* @return Result of the UpdateGroup operation returned by the service.
* @throws BadRequestException
* The request does not comply with validation rules that are defined for the request parameters.
* @throws ForbiddenException
* The caller is not authorized to make the request.
* @throws NotFoundException
* One or more resources specified in the request do not exist.
* @throws MethodNotAllowedException
* The request uses an HTTP method which is not allowed for the specified resource.
* @throws TooManyRequestsException
* The caller has exceeded throttling limits.
* @throws InternalServerErrorException
* An internal error occurred while processing the request.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws ResourceGroupsException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample ResourceGroupsClient.UpdateGroup
* @see AWS
* API Documentation
*/
@Override
public UpdateGroupResponse updateGroup(UpdateGroupRequest updateGroupRequest) throws BadRequestException, ForbiddenException,
NotFoundException, MethodNotAllowedException, TooManyRequestsException, InternalServerErrorException,
AwsServiceException, SdkClientException, ResourceGroupsException {
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
new JsonOperationMetadata().withPayloadJson(true).withHasStreamingSuccessResponse(false),
new UpdateGroupResponseUnmarshaller());
HttpResponseHandler errorResponseHandler = createErrorResponseHandler();
return clientHandler.execute(new ClientExecutionParams()
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withInput(updateGroupRequest).withMarshaller(new UpdateGroupRequestMarshaller(protocolFactory)));
}
/**
*
* Updates the resource query of a group.
*
*
* @param updateGroupQueryRequest
* @return Result of the UpdateGroupQuery operation returned by the service.
* @throws BadRequestException
* The request does not comply with validation rules that are defined for the request parameters.
* @throws ForbiddenException
* The caller is not authorized to make the request.
* @throws NotFoundException
* One or more resources specified in the request do not exist.
* @throws MethodNotAllowedException
* The request uses an HTTP method which is not allowed for the specified resource.
* @throws TooManyRequestsException
* The caller has exceeded throttling limits.
* @throws InternalServerErrorException
* An internal error occurred while processing the request.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws ResourceGroupsException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample ResourceGroupsClient.UpdateGroupQuery
* @see AWS API Documentation
*/
@Override
public UpdateGroupQueryResponse updateGroupQuery(UpdateGroupQueryRequest updateGroupQueryRequest) throws BadRequestException,
ForbiddenException, NotFoundException, MethodNotAllowedException, TooManyRequestsException,
InternalServerErrorException, AwsServiceException, SdkClientException, ResourceGroupsException {
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
new JsonOperationMetadata().withPayloadJson(true).withHasStreamingSuccessResponse(false),
new UpdateGroupQueryResponseUnmarshaller());
HttpResponseHandler errorResponseHandler = createErrorResponseHandler();
return clientHandler.execute(new ClientExecutionParams()
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withInput(updateGroupQueryRequest).withMarshaller(new UpdateGroupQueryRequestMarshaller(protocolFactory)));
}
private HttpResponseHandler createErrorResponseHandler() {
return protocolFactory.createErrorResponseHandler(new JsonErrorResponseMetadata());
}
private software.amazon.awssdk.awscore.protocol.json.AwsJsonProtocolFactory init() {
return new AwsJsonProtocolFactory(
new JsonClientMetadata()
.withSupportsCbor(false)
.withSupportsIon(false)
.withBaseServiceExceptionClass(
software.amazon.awssdk.services.resourcegroups.model.ResourceGroupsException.class)
.withContentTypeOverride("")
.addErrorMetadata(
new JsonErrorShapeMetadata().withErrorCode("NotFoundException").withModeledClass(
NotFoundException.class))
.addErrorMetadata(
new JsonErrorShapeMetadata().withErrorCode("UnauthorizedException").withModeledClass(
UnauthorizedException.class))
.addErrorMetadata(
new JsonErrorShapeMetadata().withErrorCode("ForbiddenException").withModeledClass(
ForbiddenException.class))
.addErrorMetadata(
new JsonErrorShapeMetadata().withErrorCode("MethodNotAllowedException").withModeledClass(
MethodNotAllowedException.class))
.addErrorMetadata(
new JsonErrorShapeMetadata().withErrorCode("TooManyRequestsException").withModeledClass(
TooManyRequestsException.class))
.addErrorMetadata(
new JsonErrorShapeMetadata().withErrorCode("BadRequestException").withModeledClass(
BadRequestException.class))
.addErrorMetadata(
new JsonErrorShapeMetadata().withErrorCode("InternalServerErrorException").withModeledClass(
InternalServerErrorException.class)), AwsJsonProtocolMetadata.builder()
.protocolVersion("1.1").protocol(AwsJsonProtocol.REST_JSON).build());
}
@Override
public void close() {
clientHandler.close();
}
private T applyPaginatorUserAgent(T request) {
Consumer userAgentApplier = b -> b.addApiName(ApiName.builder()
.version(VersionInfo.SDK_VERSION).name("PAGINATED").build());
AwsRequestOverrideConfiguration overrideConfiguration = request.overrideConfiguration()
.map(c -> c.toBuilder().applyMutation(userAgentApplier).build())
.orElse((AwsRequestOverrideConfiguration.builder().applyMutation(userAgentApplier).build()));
return (T) request.toBuilder().overrideConfiguration(overrideConfiguration).build();
}
}