software.amazon.awssdk.services.fms.DefaultFmsClient Maven / Gradle / Ivy
Show all versions of fms Show documentation
/*
* Copyright 2014-2019 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.fms;
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.core.ApiName;
import software.amazon.awssdk.core.client.config.SdkClientConfiguration;
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.util.VersionInfo;
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.services.fms.model.AssociateAdminAccountRequest;
import software.amazon.awssdk.services.fms.model.AssociateAdminAccountResponse;
import software.amazon.awssdk.services.fms.model.DeleteNotificationChannelRequest;
import software.amazon.awssdk.services.fms.model.DeleteNotificationChannelResponse;
import software.amazon.awssdk.services.fms.model.DeletePolicyRequest;
import software.amazon.awssdk.services.fms.model.DeletePolicyResponse;
import software.amazon.awssdk.services.fms.model.DisassociateAdminAccountRequest;
import software.amazon.awssdk.services.fms.model.DisassociateAdminAccountResponse;
import software.amazon.awssdk.services.fms.model.FmsException;
import software.amazon.awssdk.services.fms.model.FmsRequest;
import software.amazon.awssdk.services.fms.model.GetAdminAccountRequest;
import software.amazon.awssdk.services.fms.model.GetAdminAccountResponse;
import software.amazon.awssdk.services.fms.model.GetComplianceDetailRequest;
import software.amazon.awssdk.services.fms.model.GetComplianceDetailResponse;
import software.amazon.awssdk.services.fms.model.GetNotificationChannelRequest;
import software.amazon.awssdk.services.fms.model.GetNotificationChannelResponse;
import software.amazon.awssdk.services.fms.model.GetPolicyRequest;
import software.amazon.awssdk.services.fms.model.GetPolicyResponse;
import software.amazon.awssdk.services.fms.model.GetProtectionStatusRequest;
import software.amazon.awssdk.services.fms.model.GetProtectionStatusResponse;
import software.amazon.awssdk.services.fms.model.InternalErrorException;
import software.amazon.awssdk.services.fms.model.InvalidInputException;
import software.amazon.awssdk.services.fms.model.InvalidOperationException;
import software.amazon.awssdk.services.fms.model.InvalidTypeException;
import software.amazon.awssdk.services.fms.model.LimitExceededException;
import software.amazon.awssdk.services.fms.model.ListComplianceStatusRequest;
import software.amazon.awssdk.services.fms.model.ListComplianceStatusResponse;
import software.amazon.awssdk.services.fms.model.ListMemberAccountsRequest;
import software.amazon.awssdk.services.fms.model.ListMemberAccountsResponse;
import software.amazon.awssdk.services.fms.model.ListPoliciesRequest;
import software.amazon.awssdk.services.fms.model.ListPoliciesResponse;
import software.amazon.awssdk.services.fms.model.PutNotificationChannelRequest;
import software.amazon.awssdk.services.fms.model.PutNotificationChannelResponse;
import software.amazon.awssdk.services.fms.model.PutPolicyRequest;
import software.amazon.awssdk.services.fms.model.PutPolicyResponse;
import software.amazon.awssdk.services.fms.model.ResourceNotFoundException;
import software.amazon.awssdk.services.fms.paginators.ListComplianceStatusIterable;
import software.amazon.awssdk.services.fms.paginators.ListMemberAccountsIterable;
import software.amazon.awssdk.services.fms.paginators.ListPoliciesIterable;
import software.amazon.awssdk.services.fms.transform.AssociateAdminAccountRequestMarshaller;
import software.amazon.awssdk.services.fms.transform.DeleteNotificationChannelRequestMarshaller;
import software.amazon.awssdk.services.fms.transform.DeletePolicyRequestMarshaller;
import software.amazon.awssdk.services.fms.transform.DisassociateAdminAccountRequestMarshaller;
import software.amazon.awssdk.services.fms.transform.GetAdminAccountRequestMarshaller;
import software.amazon.awssdk.services.fms.transform.GetComplianceDetailRequestMarshaller;
import software.amazon.awssdk.services.fms.transform.GetNotificationChannelRequestMarshaller;
import software.amazon.awssdk.services.fms.transform.GetPolicyRequestMarshaller;
import software.amazon.awssdk.services.fms.transform.GetProtectionStatusRequestMarshaller;
import software.amazon.awssdk.services.fms.transform.ListComplianceStatusRequestMarshaller;
import software.amazon.awssdk.services.fms.transform.ListMemberAccountsRequestMarshaller;
import software.amazon.awssdk.services.fms.transform.ListPoliciesRequestMarshaller;
import software.amazon.awssdk.services.fms.transform.PutNotificationChannelRequestMarshaller;
import software.amazon.awssdk.services.fms.transform.PutPolicyRequestMarshaller;
/**
* Internal implementation of {@link FmsClient}.
*
* @see FmsClient#builder()
*/
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
final class DefaultFmsClient implements FmsClient {
private final SyncClientHandler clientHandler;
private final AwsJsonProtocolFactory protocolFactory;
private final SdkClientConfiguration clientConfiguration;
protected DefaultFmsClient(SdkClientConfiguration clientConfiguration) {
this.clientHandler = new AwsSyncClientHandler(clientConfiguration);
this.clientConfiguration = clientConfiguration;
this.protocolFactory = init(AwsJsonProtocolFactory.builder()).build();
}
@Override
public final String serviceName() {
return SERVICE_NAME;
}
/**
*
* Sets the AWS Firewall Manager administrator account. AWS Firewall Manager must be associated with the master
* account of your AWS organization or associated with a member account that has the appropriate permissions. If the
* account ID that you submit is not an AWS Organizations master account, AWS Firewall Manager will set the
* appropriate permissions for the given member account.
*
*
* The account that you associate with AWS Firewall Manager is called the AWS Firewall Manager administrator
* account.
*
*
* @param associateAdminAccountRequest
* @return Result of the AssociateAdminAccount operation returned by the service.
* @throws InvalidOperationException
* The operation failed because there was nothing to do. For example, you might have submitted an
* AssociateAdminAccount
request, but the account ID that you submitted was already set as the
* AWS Firewall Manager administrator.
* @throws InvalidInputException
* The parameters of the request were invalid.
* @throws ResourceNotFoundException
* The specified resource was not found.
* @throws InternalErrorException
* The operation failed because of a system problem, even though the request was valid. Retry your 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 FmsException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample FmsClient.AssociateAdminAccount
* @see AWS API
* Documentation
*/
@Override
public AssociateAdminAccountResponse associateAdminAccount(AssociateAdminAccountRequest associateAdminAccountRequest)
throws InvalidOperationException, InvalidInputException, ResourceNotFoundException, InternalErrorException,
AwsServiceException, SdkClientException, FmsException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, AssociateAdminAccountResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("AssociateAdminAccount").withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).withInput(associateAdminAccountRequest)
.withMarshaller(new AssociateAdminAccountRequestMarshaller(protocolFactory)));
}
/**
*
* Deletes an AWS Firewall Manager association with the IAM role and the Amazon Simple Notification Service (SNS)
* topic that is used to record AWS Firewall Manager SNS logs.
*
*
* @param deleteNotificationChannelRequest
* @return Result of the DeleteNotificationChannel operation returned by the service.
* @throws ResourceNotFoundException
* The specified resource was not found.
* @throws InvalidOperationException
* The operation failed because there was nothing to do. For example, you might have submitted an
* AssociateAdminAccount
request, but the account ID that you submitted was already set as the
* AWS Firewall Manager administrator.
* @throws InternalErrorException
* The operation failed because of a system problem, even though the request was valid. Retry your 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 FmsException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample FmsClient.DeleteNotificationChannel
* @see AWS
* API Documentation
*/
@Override
public DeleteNotificationChannelResponse deleteNotificationChannel(
DeleteNotificationChannelRequest deleteNotificationChannelRequest) throws ResourceNotFoundException,
InvalidOperationException, InternalErrorException, AwsServiceException, SdkClientException, FmsException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, DeleteNotificationChannelResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
return clientHandler
.execute(new ClientExecutionParams()
.withOperationName("DeleteNotificationChannel").withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).withInput(deleteNotificationChannelRequest)
.withMarshaller(new DeleteNotificationChannelRequestMarshaller(protocolFactory)));
}
/**
*
* Permanently deletes an AWS Firewall Manager policy.
*
*
* @param deletePolicyRequest
* @return Result of the DeletePolicy operation returned by the service.
* @throws ResourceNotFoundException
* The specified resource was not found.
* @throws InvalidOperationException
* The operation failed because there was nothing to do. For example, you might have submitted an
* AssociateAdminAccount
request, but the account ID that you submitted was already set as the
* AWS Firewall Manager administrator.
* @throws InternalErrorException
* The operation failed because of a system problem, even though the request was valid. Retry your 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 FmsException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample FmsClient.DeletePolicy
* @see AWS API
* Documentation
*/
@Override
public DeletePolicyResponse deletePolicy(DeletePolicyRequest deletePolicyRequest) throws ResourceNotFoundException,
InvalidOperationException, InternalErrorException, AwsServiceException, SdkClientException, FmsException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
DeletePolicyResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("DeletePolicy").withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).withInput(deletePolicyRequest)
.withMarshaller(new DeletePolicyRequestMarshaller(protocolFactory)));
}
/**
*
* Disassociates the account that has been set as the AWS Firewall Manager administrator account. To set a different
* account as the administrator account, you must submit an AssociateAdminAccount
request.
*
*
* @param disassociateAdminAccountRequest
* @return Result of the DisassociateAdminAccount operation returned by the service.
* @throws InvalidOperationException
* The operation failed because there was nothing to do. For example, you might have submitted an
* AssociateAdminAccount
request, but the account ID that you submitted was already set as the
* AWS Firewall Manager administrator.
* @throws ResourceNotFoundException
* The specified resource was not found.
* @throws InternalErrorException
* The operation failed because of a system problem, even though the request was valid. Retry your 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 FmsException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample FmsClient.DisassociateAdminAccount
* @see AWS
* API Documentation
*/
@Override
public DisassociateAdminAccountResponse disassociateAdminAccount(
DisassociateAdminAccountRequest disassociateAdminAccountRequest) throws InvalidOperationException,
ResourceNotFoundException, InternalErrorException, AwsServiceException, SdkClientException, FmsException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, DisassociateAdminAccountResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
return clientHandler
.execute(new ClientExecutionParams()
.withOperationName("DisassociateAdminAccount").withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).withInput(disassociateAdminAccountRequest)
.withMarshaller(new DisassociateAdminAccountRequestMarshaller(protocolFactory)));
}
/**
*
* Returns the AWS Organizations master account that is associated with AWS Firewall Manager as the AWS Firewall
* Manager administrator.
*
*
* @param getAdminAccountRequest
* @return Result of the GetAdminAccount operation returned by the service.
* @throws InvalidOperationException
* The operation failed because there was nothing to do. For example, you might have submitted an
* AssociateAdminAccount
request, but the account ID that you submitted was already set as the
* AWS Firewall Manager administrator.
* @throws ResourceNotFoundException
* The specified resource was not found.
* @throws InternalErrorException
* The operation failed because of a system problem, even though the request was valid. Retry your 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 FmsException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample FmsClient.GetAdminAccount
* @see AWS API
* Documentation
*/
@Override
public GetAdminAccountResponse getAdminAccount(GetAdminAccountRequest getAdminAccountRequest)
throws InvalidOperationException, ResourceNotFoundException, InternalErrorException, AwsServiceException,
SdkClientException, FmsException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
GetAdminAccountResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("GetAdminAccount").withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).withInput(getAdminAccountRequest)
.withMarshaller(new GetAdminAccountRequestMarshaller(protocolFactory)));
}
/**
*
* Returns detailed compliance information about the specified member account. Details include resources that are in
* and out of compliance with the specified policy. Resources are considered noncompliant for AWS WAF and Shield
* Advanced policies if the specified policy has not been applied to them. Resources are considered noncompliant for
* security group policies if they are in scope of the policy, they violate one or more of the policy rules, and
* remediation is disabled or not possible.
*
*
* @param getComplianceDetailRequest
* @return Result of the GetComplianceDetail operation returned by the service.
* @throws ResourceNotFoundException
* The specified resource was not found.
* @throws InternalErrorException
* The operation failed because of a system problem, even though the request was valid. Retry your 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 FmsException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample FmsClient.GetComplianceDetail
* @see AWS API
* Documentation
*/
@Override
public GetComplianceDetailResponse getComplianceDetail(GetComplianceDetailRequest getComplianceDetailRequest)
throws ResourceNotFoundException, InternalErrorException, AwsServiceException, SdkClientException, FmsException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, GetComplianceDetailResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("GetComplianceDetail").withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).withInput(getComplianceDetailRequest)
.withMarshaller(new GetComplianceDetailRequestMarshaller(protocolFactory)));
}
/**
*
* Information about the Amazon Simple Notification Service (SNS) topic that is used to record AWS Firewall Manager
* SNS logs.
*
*
* @param getNotificationChannelRequest
* @return Result of the GetNotificationChannel operation returned by the service.
* @throws ResourceNotFoundException
* The specified resource was not found.
* @throws InvalidOperationException
* The operation failed because there was nothing to do. For example, you might have submitted an
* AssociateAdminAccount
request, but the account ID that you submitted was already set as the
* AWS Firewall Manager administrator.
* @throws InternalErrorException
* The operation failed because of a system problem, even though the request was valid. Retry your 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 FmsException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample FmsClient.GetNotificationChannel
* @see AWS API
* Documentation
*/
@Override
public GetNotificationChannelResponse getNotificationChannel(GetNotificationChannelRequest getNotificationChannelRequest)
throws ResourceNotFoundException, InvalidOperationException, InternalErrorException, AwsServiceException,
SdkClientException, FmsException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, GetNotificationChannelResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("GetNotificationChannel").withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).withInput(getNotificationChannelRequest)
.withMarshaller(new GetNotificationChannelRequestMarshaller(protocolFactory)));
}
/**
*
* Returns information about the specified AWS Firewall Manager policy.
*
*
* @param getPolicyRequest
* @return Result of the GetPolicy operation returned by the service.
* @throws ResourceNotFoundException
* The specified resource was not found.
* @throws InvalidOperationException
* The operation failed because there was nothing to do. For example, you might have submitted an
* AssociateAdminAccount
request, but the account ID that you submitted was already set as the
* AWS Firewall Manager administrator.
* @throws InternalErrorException
* The operation failed because of a system problem, even though the request was valid. Retry your request.
* @throws InvalidTypeException
* The value of the Type
parameter is invalid.
* @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 FmsException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample FmsClient.GetPolicy
* @see AWS API
* Documentation
*/
@Override
public GetPolicyResponse getPolicy(GetPolicyRequest getPolicyRequest) throws ResourceNotFoundException,
InvalidOperationException, InternalErrorException, InvalidTypeException, AwsServiceException, SdkClientException,
FmsException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
GetPolicyResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("GetPolicy").withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).withInput(getPolicyRequest)
.withMarshaller(new GetPolicyRequestMarshaller(protocolFactory)));
}
/**
*
* If you created a Shield Advanced policy, returns policy-level attack summary information in the event of a
* potential DDoS attack. Other policy types are currently unsupported.
*
*
* @param getProtectionStatusRequest
* @return Result of the GetProtectionStatus operation returned by the service.
* @throws InvalidInputException
* The parameters of the request were invalid.
* @throws ResourceNotFoundException
* The specified resource was not found.
* @throws InternalErrorException
* The operation failed because of a system problem, even though the request was valid. Retry your 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 FmsException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample FmsClient.GetProtectionStatus
* @see AWS API
* Documentation
*/
@Override
public GetProtectionStatusResponse getProtectionStatus(GetProtectionStatusRequest getProtectionStatusRequest)
throws InvalidInputException, ResourceNotFoundException, InternalErrorException, AwsServiceException,
SdkClientException, FmsException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, GetProtectionStatusResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("GetProtectionStatus").withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).withInput(getProtectionStatusRequest)
.withMarshaller(new GetProtectionStatusRequestMarshaller(protocolFactory)));
}
/**
*
* Returns an array of PolicyComplianceStatus
objects in the response. Use
* PolicyComplianceStatus
to get a summary of which member accounts are protected by the specified
* policy.
*
*
* @param listComplianceStatusRequest
* @return Result of the ListComplianceStatus operation returned by the service.
* @throws ResourceNotFoundException
* The specified resource was not found.
* @throws InternalErrorException
* The operation failed because of a system problem, even though the request was valid. Retry your 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 FmsException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample FmsClient.ListComplianceStatus
* @see AWS API
* Documentation
*/
@Override
public ListComplianceStatusResponse listComplianceStatus(ListComplianceStatusRequest listComplianceStatusRequest)
throws ResourceNotFoundException, InternalErrorException, AwsServiceException, SdkClientException, FmsException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, ListComplianceStatusResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("ListComplianceStatus").withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).withInput(listComplianceStatusRequest)
.withMarshaller(new ListComplianceStatusRequestMarshaller(protocolFactory)));
}
/**
*
* Returns an array of PolicyComplianceStatus
objects in the response. Use
* PolicyComplianceStatus
to get a summary of which member accounts are protected by the specified
* policy.
*
*
*
* This is a variant of
* {@link #listComplianceStatus(software.amazon.awssdk.services.fms.model.ListComplianceStatusRequest)} 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.fms.paginators.ListComplianceStatusIterable responses = client.listComplianceStatusPaginator(request);
* responses.stream().forEach(....);
* }
*
*
* 2) Using For loop
*
*
* {
* @code
* software.amazon.awssdk.services.fms.paginators.ListComplianceStatusIterable responses = client
* .listComplianceStatusPaginator(request);
* for (software.amazon.awssdk.services.fms.model.ListComplianceStatusResponse response : responses) {
* // do something;
* }
* }
*
*
* 3) Use iterator directly
*
*
* {@code
* software.amazon.awssdk.services.fms.paginators.ListComplianceStatusIterable responses = client.listComplianceStatusPaginator(request);
* responses.iterator().forEachRemaining(....);
* }
*
*
* Note: If you prefer to have control on service calls, use the
* {@link #listComplianceStatus(software.amazon.awssdk.services.fms.model.ListComplianceStatusRequest)}
* operation.
*
*
* @param listComplianceStatusRequest
* @return A custom iterable that can be used to iterate through all the response pages.
* @throws ResourceNotFoundException
* The specified resource was not found.
* @throws InternalErrorException
* The operation failed because of a system problem, even though the request was valid. Retry your 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 FmsException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample FmsClient.ListComplianceStatus
* @see AWS API
* Documentation
*/
@Override
public ListComplianceStatusIterable listComplianceStatusPaginator(ListComplianceStatusRequest listComplianceStatusRequest)
throws ResourceNotFoundException, InternalErrorException, AwsServiceException, SdkClientException, FmsException {
return new ListComplianceStatusIterable(this, applyPaginatorUserAgent(listComplianceStatusRequest));
}
/**
*
* Returns a MemberAccounts
object that lists the member accounts in the administrator's AWS
* organization.
*
*
* The ListMemberAccounts
must be submitted by the account that is set as the AWS Firewall Manager
* administrator.
*
*
* @param listMemberAccountsRequest
* @return Result of the ListMemberAccounts operation returned by the service.
* @throws ResourceNotFoundException
* The specified resource was not found.
* @throws InternalErrorException
* The operation failed because of a system problem, even though the request was valid. Retry your 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 FmsException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample FmsClient.ListMemberAccounts
* @see AWS API
* Documentation
*/
@Override
public ListMemberAccountsResponse listMemberAccounts(ListMemberAccountsRequest listMemberAccountsRequest)
throws ResourceNotFoundException, InternalErrorException, AwsServiceException, SdkClientException, FmsException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, ListMemberAccountsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("ListMemberAccounts").withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).withInput(listMemberAccountsRequest)
.withMarshaller(new ListMemberAccountsRequestMarshaller(protocolFactory)));
}
/**
*
* Returns a MemberAccounts
object that lists the member accounts in the administrator's AWS
* organization.
*
*
* The ListMemberAccounts
must be submitted by the account that is set as the AWS Firewall Manager
* administrator.
*
*
*
* This is a variant of
* {@link #listMemberAccounts(software.amazon.awssdk.services.fms.model.ListMemberAccountsRequest)} 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.fms.paginators.ListMemberAccountsIterable responses = client.listMemberAccountsPaginator(request);
* responses.stream().forEach(....);
* }
*
*
* 2) Using For loop
*
*
* {
* @code
* software.amazon.awssdk.services.fms.paginators.ListMemberAccountsIterable responses = client
* .listMemberAccountsPaginator(request);
* for (software.amazon.awssdk.services.fms.model.ListMemberAccountsResponse response : responses) {
* // do something;
* }
* }
*
*
* 3) Use iterator directly
*
*
* {@code
* software.amazon.awssdk.services.fms.paginators.ListMemberAccountsIterable responses = client.listMemberAccountsPaginator(request);
* responses.iterator().forEachRemaining(....);
* }
*
*
* Note: If you prefer to have control on service calls, use the
* {@link #listMemberAccounts(software.amazon.awssdk.services.fms.model.ListMemberAccountsRequest)} operation.
*
*
* @param listMemberAccountsRequest
* @return A custom iterable that can be used to iterate through all the response pages.
* @throws ResourceNotFoundException
* The specified resource was not found.
* @throws InternalErrorException
* The operation failed because of a system problem, even though the request was valid. Retry your 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 FmsException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample FmsClient.ListMemberAccounts
* @see AWS API
* Documentation
*/
@Override
public ListMemberAccountsIterable listMemberAccountsPaginator(ListMemberAccountsRequest listMemberAccountsRequest)
throws ResourceNotFoundException, InternalErrorException, AwsServiceException, SdkClientException, FmsException {
return new ListMemberAccountsIterable(this, applyPaginatorUserAgent(listMemberAccountsRequest));
}
/**
*
* Returns an array of PolicySummary
objects in the response.
*
*
* @param listPoliciesRequest
* @return Result of the ListPolicies operation returned by the service.
* @throws ResourceNotFoundException
* The specified resource was not found.
* @throws InvalidOperationException
* The operation failed because there was nothing to do. For example, you might have submitted an
* AssociateAdminAccount
request, but the account ID that you submitted was already set as the
* AWS Firewall Manager administrator.
* @throws LimitExceededException
* The operation exceeds a resource limit, for example, the maximum number of policy
objects
* that you can create for an AWS account. For more information, see Firewall Manager Limits
* in the AWS WAF Developer Guide.
* @throws InternalErrorException
* The operation failed because of a system problem, even though the request was valid. Retry your 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 FmsException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample FmsClient.ListPolicies
* @see AWS API
* Documentation
*/
@Override
public ListPoliciesResponse listPolicies(ListPoliciesRequest listPoliciesRequest) throws ResourceNotFoundException,
InvalidOperationException, LimitExceededException, InternalErrorException, AwsServiceException, SdkClientException,
FmsException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
ListPoliciesResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("ListPolicies").withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).withInput(listPoliciesRequest)
.withMarshaller(new ListPoliciesRequestMarshaller(protocolFactory)));
}
/**
*
* Returns an array of PolicySummary
objects in the response.
*
*
*
* This is a variant of {@link #listPolicies(software.amazon.awssdk.services.fms.model.ListPoliciesRequest)}
* 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.fms.paginators.ListPoliciesIterable responses = client.listPoliciesPaginator(request);
* responses.stream().forEach(....);
* }
*
*
* 2) Using For loop
*
*
* {
* @code
* software.amazon.awssdk.services.fms.paginators.ListPoliciesIterable responses = client.listPoliciesPaginator(request);
* for (software.amazon.awssdk.services.fms.model.ListPoliciesResponse response : responses) {
* // do something;
* }
* }
*
*
* 3) Use iterator directly
*
*
* {@code
* software.amazon.awssdk.services.fms.paginators.ListPoliciesIterable responses = client.listPoliciesPaginator(request);
* responses.iterator().forEachRemaining(....);
* }
*
*
* Note: If you prefer to have control on service calls, use the
* {@link #listPolicies(software.amazon.awssdk.services.fms.model.ListPoliciesRequest)} operation.
*
*
* @param listPoliciesRequest
* @return A custom iterable that can be used to iterate through all the response pages.
* @throws ResourceNotFoundException
* The specified resource was not found.
* @throws InvalidOperationException
* The operation failed because there was nothing to do. For example, you might have submitted an
* AssociateAdminAccount
request, but the account ID that you submitted was already set as the
* AWS Firewall Manager administrator.
* @throws LimitExceededException
* The operation exceeds a resource limit, for example, the maximum number of policy
objects
* that you can create for an AWS account. For more information, see Firewall Manager Limits
* in the AWS WAF Developer Guide.
* @throws InternalErrorException
* The operation failed because of a system problem, even though the request was valid. Retry your 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 FmsException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample FmsClient.ListPolicies
* @see AWS API
* Documentation
*/
@Override
public ListPoliciesIterable listPoliciesPaginator(ListPoliciesRequest listPoliciesRequest) throws ResourceNotFoundException,
InvalidOperationException, LimitExceededException, InternalErrorException, AwsServiceException, SdkClientException,
FmsException {
return new ListPoliciesIterable(this, applyPaginatorUserAgent(listPoliciesRequest));
}
/**
*
* Designates the IAM role and Amazon Simple Notification Service (SNS) topic that AWS Firewall Manager uses to
* record SNS logs.
*
*
* @param putNotificationChannelRequest
* @return Result of the PutNotificationChannel operation returned by the service.
* @throws ResourceNotFoundException
* The specified resource was not found.
* @throws InvalidOperationException
* The operation failed because there was nothing to do. For example, you might have submitted an
* AssociateAdminAccount
request, but the account ID that you submitted was already set as the
* AWS Firewall Manager administrator.
* @throws InternalErrorException
* The operation failed because of a system problem, even though the request was valid. Retry your 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 FmsException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample FmsClient.PutNotificationChannel
* @see AWS API
* Documentation
*/
@Override
public PutNotificationChannelResponse putNotificationChannel(PutNotificationChannelRequest putNotificationChannelRequest)
throws ResourceNotFoundException, InvalidOperationException, InternalErrorException, AwsServiceException,
SdkClientException, FmsException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, PutNotificationChannelResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("PutNotificationChannel").withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).withInput(putNotificationChannelRequest)
.withMarshaller(new PutNotificationChannelRequestMarshaller(protocolFactory)));
}
/**
*
* Creates an AWS Firewall Manager policy.
*
*
* Firewall Manager provides the following types of policies:
*
*
* -
*
* A Shield Advanced policy, which applies Shield Advanced protection to specified accounts and resources
*
*
* -
*
* An AWS WAF policy, which contains a rule group and defines which resources are to be protected by that rule group
*
*
* -
*
* A security group policy, which manages VPC security groups across your AWS organization.
*
*
*
*
* Each policy is specific to one of the three types. If you want to enforce more than one policy type across
* accounts, you can create multiple policies. You can create multiple policies for each type.
*
*
* You must be subscribed to Shield Advanced to create a Shield Advanced policy. For more information about
* subscribing to Shield Advanced, see CreateSubscription.
*
*
* @param putPolicyRequest
* @return Result of the PutPolicy operation returned by the service.
* @throws ResourceNotFoundException
* The specified resource was not found.
* @throws InvalidOperationException
* The operation failed because there was nothing to do. For example, you might have submitted an
* AssociateAdminAccount
request, but the account ID that you submitted was already set as the
* AWS Firewall Manager administrator.
* @throws InvalidInputException
* The parameters of the request were invalid.
* @throws LimitExceededException
* The operation exceeds a resource limit, for example, the maximum number of policy
objects
* that you can create for an AWS account. For more information, see Firewall Manager Limits
* in the AWS WAF Developer Guide.
* @throws InternalErrorException
* The operation failed because of a system problem, even though the request was valid. Retry your request.
* @throws InvalidTypeException
* The value of the Type
parameter is invalid.
* @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 FmsException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample FmsClient.PutPolicy
* @see AWS API
* Documentation
*/
@Override
public PutPolicyResponse putPolicy(PutPolicyRequest putPolicyRequest) throws ResourceNotFoundException,
InvalidOperationException, InvalidInputException, LimitExceededException, InternalErrorException,
InvalidTypeException, AwsServiceException, SdkClientException, FmsException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
PutPolicyResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("PutPolicy").withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).withInput(putPolicyRequest)
.withMarshaller(new PutPolicyRequestMarshaller(protocolFactory)));
}
private HttpResponseHandler createErrorResponseHandler(BaseAwsJsonProtocolFactory protocolFactory,
JsonOperationMetadata operationMetadata) {
return protocolFactory.createErrorResponseHandler(operationMetadata);
}
private > T init(T builder) {
return builder
.clientConfiguration(clientConfiguration)
.defaultServiceExceptionSupplier(FmsException::builder)
.protocol(AwsJsonProtocol.AWS_JSON)
.protocolVersion("1.1")
.registerModeledException(
ExceptionMetadata.builder().errorCode("InvalidOperationException")
.exceptionBuilderSupplier(InvalidOperationException::builder).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("ResourceNotFoundException")
.exceptionBuilderSupplier(ResourceNotFoundException::builder).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("InvalidInputException")
.exceptionBuilderSupplier(InvalidInputException::builder).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("InternalErrorException")
.exceptionBuilderSupplier(InternalErrorException::builder).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("LimitExceededException")
.exceptionBuilderSupplier(LimitExceededException::builder).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("InvalidTypeException")
.exceptionBuilderSupplier(InvalidTypeException::builder).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();
}
}