
com.azure.resourcemanager.recoveryservices.models.ResourceCertificateAndAcsDetails Maven / Gradle / Ivy
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
package com.azure.resourcemanager.recoveryservices.models;
import com.azure.core.annotation.Fluent;
import com.azure.core.util.CoreUtils;
import com.azure.core.util.logging.ClientLogger;
import com.azure.json.JsonReader;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import java.io.IOException;
import java.time.OffsetDateTime;
import java.time.format.DateTimeFormatter;
/**
* Certificate details representing the Vault credentials for ACS.
*/
@Fluent
public final class ResourceCertificateAndAcsDetails extends ResourceCertificateDetails {
/*
* This property will be used as the discriminator for deciding the specific types in the polymorphic chain of
* types.
*/
private String authType = "AccessControlService";
/*
* ACS namespace name - tenant for our service.
*/
private String globalAcsNamespace;
/*
* Acs mgmt host name to connect to.
*/
private String globalAcsHostname;
/*
* Global ACS namespace RP realm.
*/
private String globalAcsRPRealm;
/**
* Creates an instance of ResourceCertificateAndAcsDetails class.
*/
public ResourceCertificateAndAcsDetails() {
}
/**
* Get the authType property: This property will be used as the discriminator for deciding the specific types in the
* polymorphic chain of types.
*
* @return the authType value.
*/
@Override
public String authType() {
return this.authType;
}
/**
* Get the globalAcsNamespace property: ACS namespace name - tenant for our service.
*
* @return the globalAcsNamespace value.
*/
public String globalAcsNamespace() {
return this.globalAcsNamespace;
}
/**
* Set the globalAcsNamespace property: ACS namespace name - tenant for our service.
*
* @param globalAcsNamespace the globalAcsNamespace value to set.
* @return the ResourceCertificateAndAcsDetails object itself.
*/
public ResourceCertificateAndAcsDetails withGlobalAcsNamespace(String globalAcsNamespace) {
this.globalAcsNamespace = globalAcsNamespace;
return this;
}
/**
* Get the globalAcsHostname property: Acs mgmt host name to connect to.
*
* @return the globalAcsHostname value.
*/
public String globalAcsHostname() {
return this.globalAcsHostname;
}
/**
* Set the globalAcsHostname property: Acs mgmt host name to connect to.
*
* @param globalAcsHostname the globalAcsHostname value to set.
* @return the ResourceCertificateAndAcsDetails object itself.
*/
public ResourceCertificateAndAcsDetails withGlobalAcsHostname(String globalAcsHostname) {
this.globalAcsHostname = globalAcsHostname;
return this;
}
/**
* Get the globalAcsRPRealm property: Global ACS namespace RP realm.
*
* @return the globalAcsRPRealm value.
*/
public String globalAcsRPRealm() {
return this.globalAcsRPRealm;
}
/**
* Set the globalAcsRPRealm property: Global ACS namespace RP realm.
*
* @param globalAcsRPRealm the globalAcsRPRealm value to set.
* @return the ResourceCertificateAndAcsDetails object itself.
*/
public ResourceCertificateAndAcsDetails withGlobalAcsRPRealm(String globalAcsRPRealm) {
this.globalAcsRPRealm = globalAcsRPRealm;
return this;
}
/**
* {@inheritDoc}
*/
@Override
public ResourceCertificateAndAcsDetails withCertificate(byte[] certificate) {
super.withCertificate(certificate);
return this;
}
/**
* {@inheritDoc}
*/
@Override
public ResourceCertificateAndAcsDetails withFriendlyName(String friendlyName) {
super.withFriendlyName(friendlyName);
return this;
}
/**
* {@inheritDoc}
*/
@Override
public ResourceCertificateAndAcsDetails withIssuer(String issuer) {
super.withIssuer(issuer);
return this;
}
/**
* {@inheritDoc}
*/
@Override
public ResourceCertificateAndAcsDetails withResourceId(Long resourceId) {
super.withResourceId(resourceId);
return this;
}
/**
* {@inheritDoc}
*/
@Override
public ResourceCertificateAndAcsDetails withSubject(String subject) {
super.withSubject(subject);
return this;
}
/**
* {@inheritDoc}
*/
@Override
public ResourceCertificateAndAcsDetails withThumbprint(String thumbprint) {
super.withThumbprint(thumbprint);
return this;
}
/**
* {@inheritDoc}
*/
@Override
public ResourceCertificateAndAcsDetails withValidFrom(OffsetDateTime validFrom) {
super.withValidFrom(validFrom);
return this;
}
/**
* {@inheritDoc}
*/
@Override
public ResourceCertificateAndAcsDetails withValidTo(OffsetDateTime validTo) {
super.withValidTo(validTo);
return this;
}
/**
* Validates the instance.
*
* @throws IllegalArgumentException thrown if the instance is not valid.
*/
@Override
public void validate() {
if (globalAcsNamespace() == null) {
throw LOGGER.atError()
.log(new IllegalArgumentException(
"Missing required property globalAcsNamespace in model ResourceCertificateAndAcsDetails"));
}
if (globalAcsHostname() == null) {
throw LOGGER.atError()
.log(new IllegalArgumentException(
"Missing required property globalAcsHostname in model ResourceCertificateAndAcsDetails"));
}
if (globalAcsRPRealm() == null) {
throw LOGGER.atError()
.log(new IllegalArgumentException(
"Missing required property globalAcsRPRealm in model ResourceCertificateAndAcsDetails"));
}
}
private static final ClientLogger LOGGER = new ClientLogger(ResourceCertificateAndAcsDetails.class);
/**
* {@inheritDoc}
*/
@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeBinaryField("certificate", certificate());
jsonWriter.writeStringField("friendlyName", friendlyName());
jsonWriter.writeStringField("issuer", issuer());
jsonWriter.writeNumberField("resourceId", resourceId());
jsonWriter.writeStringField("subject", subject());
jsonWriter.writeStringField("thumbprint", thumbprint());
jsonWriter.writeStringField("validFrom",
validFrom() == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(validFrom()));
jsonWriter.writeStringField("validTo",
validTo() == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(validTo()));
jsonWriter.writeStringField("globalAcsNamespace", this.globalAcsNamespace);
jsonWriter.writeStringField("globalAcsHostName", this.globalAcsHostname);
jsonWriter.writeStringField("globalAcsRPRealm", this.globalAcsRPRealm);
jsonWriter.writeStringField("authType", this.authType);
return jsonWriter.writeEndObject();
}
/**
* Reads an instance of ResourceCertificateAndAcsDetails from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of ResourceCertificateAndAcsDetails if the JsonReader was pointing to an instance of it, or
* null if it was pointing to JSON null.
* @throws IllegalStateException If the deserialized JSON object was missing any required properties.
* @throws IOException If an error occurs while reading the ResourceCertificateAndAcsDetails.
*/
public static ResourceCertificateAndAcsDetails fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
ResourceCertificateAndAcsDetails deserializedResourceCertificateAndAcsDetails
= new ResourceCertificateAndAcsDetails();
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();
if ("certificate".equals(fieldName)) {
deserializedResourceCertificateAndAcsDetails.withCertificate(reader.getBinary());
} else if ("friendlyName".equals(fieldName)) {
deserializedResourceCertificateAndAcsDetails.withFriendlyName(reader.getString());
} else if ("issuer".equals(fieldName)) {
deserializedResourceCertificateAndAcsDetails.withIssuer(reader.getString());
} else if ("resourceId".equals(fieldName)) {
deserializedResourceCertificateAndAcsDetails
.withResourceId(reader.getNullable(JsonReader::getLong));
} else if ("subject".equals(fieldName)) {
deserializedResourceCertificateAndAcsDetails.withSubject(reader.getString());
} else if ("thumbprint".equals(fieldName)) {
deserializedResourceCertificateAndAcsDetails.withThumbprint(reader.getString());
} else if ("validFrom".equals(fieldName)) {
deserializedResourceCertificateAndAcsDetails.withValidFrom(reader
.getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())));
} else if ("validTo".equals(fieldName)) {
deserializedResourceCertificateAndAcsDetails.withValidTo(reader
.getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())));
} else if ("globalAcsNamespace".equals(fieldName)) {
deserializedResourceCertificateAndAcsDetails.globalAcsNamespace = reader.getString();
} else if ("globalAcsHostName".equals(fieldName)) {
deserializedResourceCertificateAndAcsDetails.globalAcsHostname = reader.getString();
} else if ("globalAcsRPRealm".equals(fieldName)) {
deserializedResourceCertificateAndAcsDetails.globalAcsRPRealm = reader.getString();
} else if ("authType".equals(fieldName)) {
deserializedResourceCertificateAndAcsDetails.authType = reader.getString();
} else {
reader.skipChildren();
}
}
return deserializedResourceCertificateAndAcsDetails;
});
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy