/* * Copyright 2018-2023 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 com.amazonaws.services.codegurusecurity; import org.w3c.dom.*; import java.net.*; import java.util.*; import javax.annotation.Generated; import org.apache.commons.logging.*; import com.amazonaws.*; import com.amazonaws.annotation.SdkInternalApi; import com.amazonaws.auth.*; import com.amazonaws.handlers.*; import com.amazonaws.http.*; import com.amazonaws.internal.*; import com.amazonaws.internal.auth.*; import com.amazonaws.metrics.*; import com.amazonaws.regions.*; import com.amazonaws.transform.*; import com.amazonaws.util.*; import com.amazonaws.protocol.json.*; import com.amazonaws.util.AWSRequestMetrics.Field; import com.amazonaws.annotation.ThreadSafe; import com.amazonaws.client.AwsSyncClientParams; import com.amazonaws.client.builder.AdvancedConfig; import com.amazonaws.services.codegurusecurity.AmazonCodeGuruSecurityClientBuilder; import com.amazonaws.AmazonServiceException; import com.amazonaws.services.codegurusecurity.model.*; import com.amazonaws.services.codegurusecurity.model.transform.*; /** * Client for accessing Amazon CodeGuru Security. All service calls made using this client are blocking, and will not * return until the service call completes. *
*
* Amazon CodeGuru Security is in preview release and is subject to change.
*
* This section provides documentation for the Amazon CodeGuru Security API operations. CodeGuru Security is a service * that uses program analysis and machine learning to detect security policy violations and vulnerabilities, and * recommends ways to address these security risks. *
** By proactively detecting and providing recommendations for addressing security risks, CodeGuru Security improves the * overall security of your application code. For more information about CodeGuru Security, see the Amazon CodeGuru * Security User Guide. *
*/ @ThreadSafe @Generated("com.amazonaws:aws-java-sdk-code-generator") public class AmazonCodeGuruSecurityClient extends AmazonWebServiceClient implements AmazonCodeGuruSecurity { /** Provider for AWS credentials. */ private final AWSCredentialsProvider awsCredentialsProvider; private static final Log log = LogFactory.getLog(AmazonCodeGuruSecurity.class); /** Default signing name for the service. */ private static final String DEFAULT_SIGNING_NAME = "codeguru-security"; /** Client configuration factory providing ClientConfigurations tailored to this client */ protected static final ClientConfigurationFactory configFactory = new ClientConfigurationFactory(); private final AdvancedConfig advancedConfig; private static final com.amazonaws.protocol.json.SdkJsonProtocolFactory protocolFactory = new com.amazonaws.protocol.json.SdkJsonProtocolFactory( new JsonClientMetadata() .withProtocolVersion("1.1") .withSupportsCbor(false) .withSupportsIon(false) .withContentTypeOverride("application/json") .addErrorMetadata( new JsonErrorShapeMetadata().withErrorCode("AccessDeniedException").withExceptionUnmarshaller( com.amazonaws.services.codegurusecurity.model.transform.AccessDeniedExceptionUnmarshaller.getInstance())) .addErrorMetadata( new JsonErrorShapeMetadata().withErrorCode("ConflictException").withExceptionUnmarshaller( com.amazonaws.services.codegurusecurity.model.transform.ConflictExceptionUnmarshaller.getInstance())) .addErrorMetadata( new JsonErrorShapeMetadata().withErrorCode("ResourceNotFoundException").withExceptionUnmarshaller( com.amazonaws.services.codegurusecurity.model.transform.ResourceNotFoundExceptionUnmarshaller.getInstance())) .addErrorMetadata( new JsonErrorShapeMetadata().withErrorCode("ThrottlingException").withExceptionUnmarshaller( com.amazonaws.services.codegurusecurity.model.transform.ThrottlingExceptionUnmarshaller.getInstance())) .addErrorMetadata( new JsonErrorShapeMetadata().withErrorCode("ValidationException").withExceptionUnmarshaller( com.amazonaws.services.codegurusecurity.model.transform.ValidationExceptionUnmarshaller.getInstance())) .addErrorMetadata( new JsonErrorShapeMetadata().withErrorCode("InternalServerException").withExceptionUnmarshaller( com.amazonaws.services.codegurusecurity.model.transform.InternalServerExceptionUnmarshaller.getInstance())) .withBaseServiceExceptionClass(com.amazonaws.services.codegurusecurity.model.AmazonCodeGuruSecurityException.class)); public static AmazonCodeGuruSecurityClientBuilder builder() { return AmazonCodeGuruSecurityClientBuilder.standard(); } /** * Constructs a new client to invoke service methods on Amazon CodeGuru Security using the specified parameters. * ** All service calls made using this new client object are blocking, and will not return until the service call * completes. * * @param clientParams * Object providing client parameters. */ AmazonCodeGuruSecurityClient(AwsSyncClientParams clientParams) { this(clientParams, false); } /** * Constructs a new client to invoke service methods on Amazon CodeGuru Security using the specified parameters. * *
* All service calls made using this new client object are blocking, and will not return until the service call * completes. * * @param clientParams * Object providing client parameters. */ AmazonCodeGuruSecurityClient(AwsSyncClientParams clientParams, boolean endpointDiscoveryEnabled) { super(clientParams); this.awsCredentialsProvider = clientParams.getCredentialsProvider(); this.advancedConfig = clientParams.getAdvancedConfig(); init(); } private void init() { setServiceNameIntern(DEFAULT_SIGNING_NAME); setEndpointPrefix(ENDPOINT_PREFIX); // calling this.setEndPoint(...) will also modify the signer accordingly setEndpoint("codeguru-security.us-east-1.amazonaws.com"); HandlerChainFactory chainFactory = new HandlerChainFactory(); requestHandler2s.addAll(chainFactory.newRequestHandlerChain("/com/amazonaws/services/codegurusecurity/request.handlers")); requestHandler2s.addAll(chainFactory.newRequestHandler2Chain("/com/amazonaws/services/codegurusecurity/request.handler2s")); requestHandler2s.addAll(chainFactory.getGlobalHandlers()); } /** *
* Returns a list of all requested findings. *
* * @param batchGetFindingsRequest * @return Result of the BatchGetFindings operation returned by the service. * @throws InternalServerException * The server encountered an internal error and is unable to complete the request. * @throws ThrottlingException * The request was denied due to request throttling. * @throws ValidationException * The input fails to satisfy the specified constraints. * @throws AccessDeniedException * You do not have sufficient access to perform this action. * @sample AmazonCodeGuruSecurity.BatchGetFindings * @see AWS API Documentation */ @Override public BatchGetFindingsResult batchGetFindings(BatchGetFindingsRequest request) { request = beforeClientExecution(request); return executeBatchGetFindings(request); } @SdkInternalApi final BatchGetFindingsResult executeBatchGetFindings(BatchGetFindingsRequest batchGetFindingsRequest) { ExecutionContext executionContext = createExecutionContext(batchGetFindingsRequest); AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics(); awsRequestMetrics.startEvent(Field.ClientExecuteTime); Request* Use to create a scan using code uploaded to an S3 bucket. *
* * @param createScanRequest * @return Result of the CreateScan operation returned by the service. * @throws InternalServerException * The server encountered an internal error and is unable to complete the request. * @throws ConflictException * The requested operation would cause a conflict with the current state of a service resource associated * with the request. Resolve the conflict before retrying this request. * @throws ResourceNotFoundException * The resource specified in the request was not found. * @throws ThrottlingException * The request was denied due to request throttling. * @throws ValidationException * The input fails to satisfy the specified constraints. * @throws AccessDeniedException * You do not have sufficient access to perform this action. * @sample AmazonCodeGuruSecurity.CreateScan * @see AWS * API Documentation */ @Override public CreateScanResult createScan(CreateScanRequest request) { request = beforeClientExecution(request); return executeCreateScan(request); } @SdkInternalApi final CreateScanResult executeCreateScan(CreateScanRequest createScanRequest) { ExecutionContext executionContext = createExecutionContext(createScanRequest); AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics(); awsRequestMetrics.startEvent(Field.ClientExecuteTime); Request* Generates a pre-signed URL and request headers used to upload a code resource. *
** You can upload your code resource to the URL and add the request headers using any HTTP client. *
* * @param createUploadUrlRequest * @return Result of the CreateUploadUrl operation returned by the service. * @throws InternalServerException * The server encountered an internal error and is unable to complete the request. * @throws ThrottlingException * The request was denied due to request throttling. * @throws ValidationException * The input fails to satisfy the specified constraints. * @throws AccessDeniedException * You do not have sufficient access to perform this action. * @sample AmazonCodeGuruSecurity.CreateUploadUrl * @see AWS API Documentation */ @Override public CreateUploadUrlResult createUploadUrl(CreateUploadUrlRequest request) { request = beforeClientExecution(request); return executeCreateUploadUrl(request); } @SdkInternalApi final CreateUploadUrlResult executeCreateUploadUrl(CreateUploadUrlRequest createUploadUrlRequest) { ExecutionContext executionContext = createExecutionContext(createUploadUrlRequest); AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics(); awsRequestMetrics.startEvent(Field.ClientExecuteTime); Request* Use to get account level configuration. *
* * @param getAccountConfigurationRequest * @return Result of the GetAccountConfiguration operation returned by the service. * @throws InternalServerException * The server encountered an internal error and is unable to complete the request. * @throws ThrottlingException * The request was denied due to request throttling. * @throws ValidationException * The input fails to satisfy the specified constraints. * @throws AccessDeniedException * You do not have sufficient access to perform this action. * @sample AmazonCodeGuruSecurity.GetAccountConfiguration * @see AWS API Documentation */ @Override public GetAccountConfigurationResult getAccountConfiguration(GetAccountConfigurationRequest request) { request = beforeClientExecution(request); return executeGetAccountConfiguration(request); } @SdkInternalApi final GetAccountConfigurationResult executeGetAccountConfiguration(GetAccountConfigurationRequest getAccountConfigurationRequest) { ExecutionContext executionContext = createExecutionContext(getAccountConfigurationRequest); AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics(); awsRequestMetrics.startEvent(Field.ClientExecuteTime); Request* Returns a list of all findings generated by a particular scan. *
* * @param getFindingsRequest * @return Result of the GetFindings operation returned by the service. * @throws InternalServerException * The server encountered an internal error and is unable to complete the request. * @throws ConflictException * The requested operation would cause a conflict with the current state of a service resource associated * with the request. Resolve the conflict before retrying this request. * @throws ResourceNotFoundException * The resource specified in the request was not found. * @throws ThrottlingException * The request was denied due to request throttling. * @throws ValidationException * The input fails to satisfy the specified constraints. * @throws AccessDeniedException * You do not have sufficient access to perform this action. * @sample AmazonCodeGuruSecurity.GetFindings * @see AWS * API Documentation */ @Override public GetFindingsResult getFindings(GetFindingsRequest request) { request = beforeClientExecution(request); return executeGetFindings(request); } @SdkInternalApi final GetFindingsResult executeGetFindings(GetFindingsRequest getFindingsRequest) { ExecutionContext executionContext = createExecutionContext(getFindingsRequest); AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics(); awsRequestMetrics.startEvent(Field.ClientExecuteTime); Request* Returns top level metrics about an account from a specified date, including number of open findings, the * categories with most findings, the scans with most open findings, and scans with most open critical findings. *
* * @param getMetricsSummaryRequest * @return Result of the GetMetricsSummary operation returned by the service. * @throws InternalServerException * The server encountered an internal error and is unable to complete the request. * @throws ThrottlingException * The request was denied due to request throttling. * @throws ValidationException * The input fails to satisfy the specified constraints. * @throws AccessDeniedException * You do not have sufficient access to perform this action. * @sample AmazonCodeGuruSecurity.GetMetricsSummary * @see AWS API Documentation */ @Override public GetMetricsSummaryResult getMetricsSummary(GetMetricsSummaryRequest request) { request = beforeClientExecution(request); return executeGetMetricsSummary(request); } @SdkInternalApi final GetMetricsSummaryResult executeGetMetricsSummary(GetMetricsSummaryRequest getMetricsSummaryRequest) { ExecutionContext executionContext = createExecutionContext(getMetricsSummaryRequest); AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics(); awsRequestMetrics.startEvent(Field.ClientExecuteTime); Request* Returns details about a scan, including whether or not a scan has completed. *
* * @param getScanRequest * @return Result of the GetScan operation returned by the service. * @throws InternalServerException * The server encountered an internal error and is unable to complete the request. * @throws ResourceNotFoundException * The resource specified in the request was not found. * @throws ThrottlingException * The request was denied due to request throttling. * @throws AccessDeniedException * You do not have sufficient access to perform this action. * @sample AmazonCodeGuruSecurity.GetScan * @see AWS API * Documentation */ @Override public GetScanResult getScan(GetScanRequest request) { request = beforeClientExecution(request); return executeGetScan(request); } @SdkInternalApi final GetScanResult executeGetScan(GetScanRequest getScanRequest) { ExecutionContext executionContext = createExecutionContext(getScanRequest); AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics(); awsRequestMetrics.startEvent(Field.ClientExecuteTime); Request* Returns metrics about all findings in an account within a specified time range. *
* * @param listFindingsMetricsRequest * @return Result of the ListFindingsMetrics operation returned by the service. * @throws InternalServerException * The server encountered an internal error and is unable to complete the request. * @throws ThrottlingException * The request was denied due to request throttling. * @throws ValidationException * The input fails to satisfy the specified constraints. * @throws AccessDeniedException * You do not have sufficient access to perform this action. * @sample AmazonCodeGuruSecurity.ListFindingsMetrics * @see AWS API Documentation */ @Override public ListFindingsMetricsResult listFindingsMetrics(ListFindingsMetricsRequest request) { request = beforeClientExecution(request); return executeListFindingsMetrics(request); } @SdkInternalApi final ListFindingsMetricsResult executeListFindingsMetrics(ListFindingsMetricsRequest listFindingsMetricsRequest) { ExecutionContext executionContext = createExecutionContext(listFindingsMetricsRequest); AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics(); awsRequestMetrics.startEvent(Field.ClientExecuteTime); Request* Returns a list of all the standard scans in an account. Does not return express scans. *
* * @param listScansRequest * @return Result of the ListScans operation returned by the service. * @throws InternalServerException * The server encountered an internal error and is unable to complete the request. * @throws ThrottlingException * The request was denied due to request throttling. * @throws ValidationException * The input fails to satisfy the specified constraints. * @throws AccessDeniedException * You do not have sufficient access to perform this action. * @sample AmazonCodeGuruSecurity.ListScans * @see AWS * API Documentation */ @Override public ListScansResult listScans(ListScansRequest request) { request = beforeClientExecution(request); return executeListScans(request); } @SdkInternalApi final ListScansResult executeListScans(ListScansRequest listScansRequest) { ExecutionContext executionContext = createExecutionContext(listScansRequest); AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics(); awsRequestMetrics.startEvent(Field.ClientExecuteTime); Request* Returns a list of all tags associated with a scan. *
* * @param listTagsForResourceRequest * @return Result of the ListTagsForResource operation returned by the service. * @throws InternalServerException * The server encountered an internal error and is unable to complete the request. * @throws ConflictException * The requested operation would cause a conflict with the current state of a service resource associated * with the request. Resolve the conflict before retrying this request. * @throws ResourceNotFoundException * The resource specified in the request was not found. * @throws ThrottlingException * The request was denied due to request throttling. * @throws ValidationException * The input fails to satisfy the specified constraints. * @throws AccessDeniedException * You do not have sufficient access to perform this action. * @sample AmazonCodeGuruSecurity.ListTagsForResource * @see AWS API Documentation */ @Override public ListTagsForResourceResult listTagsForResource(ListTagsForResourceRequest request) { request = beforeClientExecution(request); return executeListTagsForResource(request); } @SdkInternalApi final ListTagsForResourceResult executeListTagsForResource(ListTagsForResourceRequest listTagsForResourceRequest) { ExecutionContext executionContext = createExecutionContext(listTagsForResourceRequest); AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics(); awsRequestMetrics.startEvent(Field.ClientExecuteTime); Request* Use to add one or more tags to an existing scan. *
* * @param tagResourceRequest * @return Result of the TagResource operation returned by the service. * @throws InternalServerException * The server encountered an internal error and is unable to complete the request. * @throws ConflictException * The requested operation would cause a conflict with the current state of a service resource associated * with the request. Resolve the conflict before retrying this request. * @throws ResourceNotFoundException * The resource specified in the request was not found. * @throws ThrottlingException * The request was denied due to request throttling. * @throws ValidationException * The input fails to satisfy the specified constraints. * @throws AccessDeniedException * You do not have sufficient access to perform this action. * @sample AmazonCodeGuruSecurity.TagResource * @see AWS * API Documentation */ @Override public TagResourceResult tagResource(TagResourceRequest request) { request = beforeClientExecution(request); return executeTagResource(request); } @SdkInternalApi final TagResourceResult executeTagResource(TagResourceRequest tagResourceRequest) { ExecutionContext executionContext = createExecutionContext(tagResourceRequest); AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics(); awsRequestMetrics.startEvent(Field.ClientExecuteTime); Request* Use to remove one or more tags from an existing scan. *
* * @param untagResourceRequest * @return Result of the UntagResource operation returned by the service. * @throws InternalServerException * The server encountered an internal error and is unable to complete the request. * @throws ConflictException * The requested operation would cause a conflict with the current state of a service resource associated * with the request. Resolve the conflict before retrying this request. * @throws ResourceNotFoundException * The resource specified in the request was not found. * @throws ThrottlingException * The request was denied due to request throttling. * @throws ValidationException * The input fails to satisfy the specified constraints. * @throws AccessDeniedException * You do not have sufficient access to perform this action. * @sample AmazonCodeGuruSecurity.UntagResource * @see AWS API Documentation */ @Override public UntagResourceResult untagResource(UntagResourceRequest request) { request = beforeClientExecution(request); return executeUntagResource(request); } @SdkInternalApi final UntagResourceResult executeUntagResource(UntagResourceRequest untagResourceRequest) { ExecutionContext executionContext = createExecutionContext(untagResourceRequest); AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics(); awsRequestMetrics.startEvent(Field.ClientExecuteTime); Request* Use to update account-level configuration with an encryption key. *
* * @param updateAccountConfigurationRequest * @return Result of the UpdateAccountConfiguration operation returned by the service. * @throws InternalServerException * The server encountered an internal error and is unable to complete the request. * @throws ResourceNotFoundException * The resource specified in the request was not found. * @throws ThrottlingException * The request was denied due to request throttling. * @throws ValidationException * The input fails to satisfy the specified constraints. * @throws AccessDeniedException * You do not have sufficient access to perform this action. * @sample AmazonCodeGuruSecurity.UpdateAccountConfiguration * @see AWS API Documentation */ @Override public UpdateAccountConfigurationResult updateAccountConfiguration(UpdateAccountConfigurationRequest request) { request = beforeClientExecution(request); return executeUpdateAccountConfiguration(request); } @SdkInternalApi final UpdateAccountConfigurationResult executeUpdateAccountConfiguration(UpdateAccountConfigurationRequest updateAccountConfigurationRequest) { ExecutionContext executionContext = createExecutionContext(updateAccountConfigurationRequest); AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics(); awsRequestMetrics.startEvent(Field.ClientExecuteTime); Request
* Response metadata is only cached for a limited period of time, so if you need to access this extra diagnostic
* information for an executed request, you should use this method to retrieve it as soon as possible after
* executing the request.
*
* @param request
* The originally executed request
*
* @return The response metadata for the specified request, or null if none is available.
*/
public ResponseMetadata getCachedResponseMetadata(AmazonWebServiceRequest request) {
return client.getResponseMetadataForRequest(request);
}
/**
* Normal invoke with authentication. Credentials are required and may be overriden at the request level.
**/
private