software.amazon.awssdk.services.apigateway.model.GetAccountResponse Maven / Gradle / Ivy
Show all versions of api-gateway Show documentation
/*
* 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.apigateway.model;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.function.Consumer;
import javax.annotation.Generated;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* Represents an AWS account that is associated with Amazon API Gateway.
*
*
*
* To view the account info, call GET
on this resource.
*
* Error Codes
*
* The following exception may be thrown when the request fails.
*
*
* - UnauthorizedException
* - NotFoundException
* - TooManyRequestsException
*
*
* For detailed error code information, including the corresponding HTTP Status Codes, see API Gateway Error
* Codes
*
* Example: Get the information about an account.
Request
*
*
* GET /account HTTP/1.1 Content-Type: application/json Host: apigateway.us-east-1.amazonaws.com X-Amz-Date: 20160531T184618Z Authorization: AWS4-HMAC-SHA256 Credential={access_key_ID}/us-east-1/apigateway/aws4_request, SignedHeaders=content-type;host;x-amz-date, Signature={sig4_hash}
*
*
* Response
*
* The successful response returns a 200 OK
status code and a payload similar to the following:
*
*
*
* { "_links": { "curies": { "href": "http://docs.aws.amazon.com/apigateway/latest/developerguide/account-apigateway-{rel}.html", "name": "account", "templated": true }, "self": { "href": "/account" }, "account:update": { "href": "/account" } }, "cloudwatchRoleArn": "arn:aws:iam::123456789012:role/apigAwsProxyRole", "throttleSettings": { "rateLimit": 500, "burstLimit": 1000 } }
*
*
* In addition to making the REST API call directly, you can use the AWS CLI and an AWS SDK to access this resource.
*
*
*/
@Generated("software.amazon.awssdk:codegen")
public class GetAccountResponse extends APIGatewayResponse implements
ToCopyableBuilder {
private final String cloudwatchRoleArn;
private final ThrottleSettings throttleSettings;
private final List features;
private final String apiKeyVersion;
private GetAccountResponse(BuilderImpl builder) {
super(builder);
this.cloudwatchRoleArn = builder.cloudwatchRoleArn;
this.throttleSettings = builder.throttleSettings;
this.features = builder.features;
this.apiKeyVersion = builder.apiKeyVersion;
}
/**
*
* The ARN of an Amazon CloudWatch role for the current Account.
*
*
* @return The ARN of an Amazon CloudWatch role for the current Account.
*/
public String cloudwatchRoleArn() {
return cloudwatchRoleArn;
}
/**
*
* Specifies the API request limits configured for the current Account.
*
*
* @return Specifies the API request limits configured for the current Account.
*/
public ThrottleSettings throttleSettings() {
return throttleSettings;
}
/**
*
* A list of features supported for the account. When usage plans are enabled, the features list will include an
* entry of "UsagePlans"
.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* @return A list of features supported for the account. When usage plans are enabled, the features list will
* include an entry of "UsagePlans"
.
*/
public List features() {
return features;
}
/**
*
* The version of the API keys used for the account.
*
*
* @return The version of the API keys used for the account.
*/
public String apiKeyVersion() {
return apiKeyVersion;
}
@Override
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public static Class serializableBuilderClass() {
return BuilderImpl.class;
}
@Override
public int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + Objects.hashCode(cloudwatchRoleArn());
hashCode = 31 * hashCode + Objects.hashCode(throttleSettings());
hashCode = 31 * hashCode + Objects.hashCode(features());
hashCode = 31 * hashCode + Objects.hashCode(apiKeyVersion());
return hashCode;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof GetAccountResponse)) {
return false;
}
GetAccountResponse other = (GetAccountResponse) obj;
return Objects.equals(cloudwatchRoleArn(), other.cloudwatchRoleArn())
&& Objects.equals(throttleSettings(), other.throttleSettings()) && Objects.equals(features(), other.features())
&& Objects.equals(apiKeyVersion(), other.apiKeyVersion());
}
@Override
public String toString() {
return ToString.builder("GetAccountResponse").add("CloudwatchRoleArn", cloudwatchRoleArn())
.add("ThrottleSettings", throttleSettings()).add("Features", features()).add("ApiKeyVersion", apiKeyVersion())
.build();
}
public Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "cloudwatchRoleArn":
return Optional.of(clazz.cast(cloudwatchRoleArn()));
case "throttleSettings":
return Optional.of(clazz.cast(throttleSettings()));
case "features":
return Optional.of(clazz.cast(features()));
case "apiKeyVersion":
return Optional.of(clazz.cast(apiKeyVersion()));
default:
return Optional.empty();
}
}
public interface Builder extends APIGatewayResponse.Builder, CopyableBuilder {
/**
*
* The ARN of an Amazon CloudWatch role for the current Account.
*
*
* @param cloudwatchRoleArn
* The ARN of an Amazon CloudWatch role for the current Account.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder cloudwatchRoleArn(String cloudwatchRoleArn);
/**
*
* Specifies the API request limits configured for the current Account.
*
*
* @param throttleSettings
* Specifies the API request limits configured for the current Account.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder throttleSettings(ThrottleSettings throttleSettings);
/**
*
* Specifies the API request limits configured for the current Account.
*
* This is a convenience that creates an instance of the {@link ThrottleSettings.Builder} avoiding the need to
* create one manually via {@link ThrottleSettings#builder()}.
*
* When the {@link Consumer} completes, {@link ThrottleSettings.Builder#build()} is called immediately and its
* result is passed to {@link #throttleSettings(ThrottleSettings)}.
*
* @param throttleSettings
* a consumer that will call methods on {@link ThrottleSettings.Builder}
* @return Returns a reference to this object so that method calls can be chained together.
* @see #throttleSettings(ThrottleSettings)
*/
default Builder throttleSettings(Consumer throttleSettings) {
return throttleSettings(ThrottleSettings.builder().apply(throttleSettings).build());
}
/**
*
* A list of features supported for the account. When usage plans are enabled, the features list will include an
* entry of "UsagePlans"
.
*
*
* @param features
* A list of features supported for the account. When usage plans are enabled, the features list will
* include an entry of "UsagePlans"
.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder features(Collection features);
/**
*
* A list of features supported for the account. When usage plans are enabled, the features list will include an
* entry of "UsagePlans"
.
*
*
* @param features
* A list of features supported for the account. When usage plans are enabled, the features list will
* include an entry of "UsagePlans"
.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder features(String... features);
/**
*
* The version of the API keys used for the account.
*
*
* @param apiKeyVersion
* The version of the API keys used for the account.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder apiKeyVersion(String apiKeyVersion);
}
static final class BuilderImpl extends APIGatewayResponse.BuilderImpl implements Builder {
private String cloudwatchRoleArn;
private ThrottleSettings throttleSettings;
private List features;
private String apiKeyVersion;
private BuilderImpl() {
}
private BuilderImpl(GetAccountResponse model) {
cloudwatchRoleArn(model.cloudwatchRoleArn);
throttleSettings(model.throttleSettings);
features(model.features);
apiKeyVersion(model.apiKeyVersion);
}
public final String getCloudwatchRoleArn() {
return cloudwatchRoleArn;
}
@Override
public final Builder cloudwatchRoleArn(String cloudwatchRoleArn) {
this.cloudwatchRoleArn = cloudwatchRoleArn;
return this;
}
public final void setCloudwatchRoleArn(String cloudwatchRoleArn) {
this.cloudwatchRoleArn = cloudwatchRoleArn;
}
public final ThrottleSettings.Builder getThrottleSettings() {
return throttleSettings != null ? throttleSettings.toBuilder() : null;
}
@Override
public final Builder throttleSettings(ThrottleSettings throttleSettings) {
this.throttleSettings = throttleSettings;
return this;
}
public final void setThrottleSettings(ThrottleSettings.BuilderImpl throttleSettings) {
this.throttleSettings = throttleSettings != null ? throttleSettings.build() : null;
}
public final Collection getFeatures() {
return features;
}
@Override
public final Builder features(Collection features) {
this.features = ListOfStringCopier.copy(features);
return this;
}
@Override
@SafeVarargs
public final Builder features(String... features) {
features(Arrays.asList(features));
return this;
}
public final void setFeatures(Collection features) {
this.features = ListOfStringCopier.copy(features);
}
public final String getApiKeyVersion() {
return apiKeyVersion;
}
@Override
public final Builder apiKeyVersion(String apiKeyVersion) {
this.apiKeyVersion = apiKeyVersion;
return this;
}
public final void setApiKeyVersion(String apiKeyVersion) {
this.apiKeyVersion = apiKeyVersion;
}
@Override
public GetAccountResponse build() {
return new GetAccountResponse(this);
}
}
}