software.amazon.awssdk.services.acmpca.model.RevokeCertificateRequest Maven / Gradle / Ivy
Show all versions of acmpca 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.acmpca.model;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.awscore.AwsRequestOverrideConfiguration;
import software.amazon.awssdk.core.SdkField;
import software.amazon.awssdk.core.SdkPojo;
import software.amazon.awssdk.core.protocol.MarshallLocation;
import software.amazon.awssdk.core.protocol.MarshallingType;
import software.amazon.awssdk.core.traits.LocationTrait;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*/
@Generated("software.amazon.awssdk:codegen")
public final class RevokeCertificateRequest extends AcmPcaRequest implements
ToCopyableBuilder {
private static final SdkField CERTIFICATE_AUTHORITY_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(RevokeCertificateRequest::certificateAuthorityArn)).setter(setter(Builder::certificateAuthorityArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CertificateAuthorityArn").build())
.build();
private static final SdkField CERTIFICATE_SERIAL_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(RevokeCertificateRequest::certificateSerial)).setter(setter(Builder::certificateSerial))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CertificateSerial").build()).build();
private static final SdkField REVOCATION_REASON_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(RevokeCertificateRequest::revocationReasonAsString)).setter(setter(Builder::revocationReason))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RevocationReason").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(
CERTIFICATE_AUTHORITY_ARN_FIELD, CERTIFICATE_SERIAL_FIELD, REVOCATION_REASON_FIELD));
private final String certificateAuthorityArn;
private final String certificateSerial;
private final String revocationReason;
private RevokeCertificateRequest(BuilderImpl builder) {
super(builder);
this.certificateAuthorityArn = builder.certificateAuthorityArn;
this.certificateSerial = builder.certificateSerial;
this.revocationReason = builder.revocationReason;
}
/**
*
* Amazon Resource Name (ARN) of the private CA that issued the certificate to be revoked. This must be of the form:
*
*
* arn:aws:acm-pca:region:account:certificate-authority/12345678-1234-1234-1234-123456789012
*
*
* @return Amazon Resource Name (ARN) of the private CA that issued the certificate to be revoked. This must be of
* the form:
*
* arn:aws:acm-pca:region:account:certificate-authority/12345678-1234-1234-1234-123456789012
*/
public String certificateAuthorityArn() {
return certificateAuthorityArn;
}
/**
*
* Serial number of the certificate to be revoked. This must be in hexadecimal format. You can retrieve the serial
* number by calling GetCertificate with the Amazon Resource Name (ARN) of the certificate you want and the
* ARN of your private CA. The GetCertificate operation retrieves the certificate in the PEM format. You can
* use the following OpenSSL command to list the certificate in text format and copy the hexadecimal serial number.
*
*
* openssl x509 -in file_path -text -noout
*
*
* You can also copy the serial number from the console or use the DescribeCertificate
* operation in the AWS Certificate Manager API Reference.
*
*
* @return Serial number of the certificate to be revoked. This must be in hexadecimal format. You can retrieve the
* serial number by calling GetCertificate with the Amazon Resource Name (ARN) of the certificate you
* want and the ARN of your private CA. The GetCertificate operation retrieves the certificate in the
* PEM format. You can use the following OpenSSL command to list the certificate in text format and copy the
* hexadecimal serial number.
*
* openssl x509 -in file_path -text -noout
*
*
* You can also copy the serial number from the console or use the DescribeCertificate operation in the AWS Certificate Manager API Reference.
*/
public String certificateSerial() {
return certificateSerial;
}
/**
*
* Specifies why you revoked the certificate.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #revocationReason}
* will return {@link RevocationReason#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #revocationReasonAsString}.
*
*
* @return Specifies why you revoked the certificate.
* @see RevocationReason
*/
public RevocationReason revocationReason() {
return RevocationReason.fromValue(revocationReason);
}
/**
*
* Specifies why you revoked the certificate.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #revocationReason}
* will return {@link RevocationReason#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #revocationReasonAsString}.
*
*
* @return Specifies why you revoked the certificate.
* @see RevocationReason
*/
public String revocationReasonAsString() {
return revocationReason;
}
@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(certificateAuthorityArn());
hashCode = 31 * hashCode + Objects.hashCode(certificateSerial());
hashCode = 31 * hashCode + Objects.hashCode(revocationReasonAsString());
return hashCode;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof RevokeCertificateRequest)) {
return false;
}
RevokeCertificateRequest other = (RevokeCertificateRequest) obj;
return Objects.equals(certificateAuthorityArn(), other.certificateAuthorityArn())
&& Objects.equals(certificateSerial(), other.certificateSerial())
&& Objects.equals(revocationReasonAsString(), other.revocationReasonAsString());
}
/**
* Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be
* redacted from this string using a placeholder value.
*/
@Override
public String toString() {
return ToString.builder("RevokeCertificateRequest").add("CertificateAuthorityArn", certificateAuthorityArn())
.add("CertificateSerial", certificateSerial()).add("RevocationReason", revocationReasonAsString()).build();
}
public Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "CertificateAuthorityArn":
return Optional.ofNullable(clazz.cast(certificateAuthorityArn()));
case "CertificateSerial":
return Optional.ofNullable(clazz.cast(certificateSerial()));
case "RevocationReason":
return Optional.ofNullable(clazz.cast(revocationReasonAsString()));
default:
return Optional.empty();
}
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
private static Function