All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.azure.resourcemanager.devcenter.models.CustomerManagedKeyEncryptionKeyIdentity 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.devcenter.models;

import com.azure.core.annotation.Fluent;
import com.azure.json.JsonReader;
import com.azure.json.JsonSerializable;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import java.io.IOException;
import java.util.Objects;
import java.util.UUID;

/**
 * All identity configuration for Customer-managed key settings defining which identity should be used to auth to Key
 * Vault.
 */
@Fluent
public final class CustomerManagedKeyEncryptionKeyIdentity
    implements JsonSerializable {
    /*
     * Values can be systemAssignedIdentity or userAssignedIdentity
     */
    private IdentityType identityType;

    /*
     * user assigned identity to use for accessing key encryption key Url. Ex:
     * /subscriptions/fa5fc227-a624-475e-b696-cdd604c735bc/resourceGroups//providers/Microsoft.ManagedIdentity/userAssignedIdentities/myId. Mutually exclusive with identityType
     * systemAssignedIdentity and delegatedResourceIdentity.
     */
    private String userAssignedIdentityResourceId;

    /*
     * delegated identity to use for accessing key encryption key Url. Ex:
     * /subscriptions/fa5fc227-a624-475e-b696-cdd604c735bc/resourceGroups//providers/Microsoft.ManagedIdentity/userAssignedIdentities/myId. Mutually exclusive with identityType
     * systemAssignedIdentity and userAssignedIdentity - internal use only.
     */
    private UUID delegatedIdentityClientId;

    /**
     * Creates an instance of CustomerManagedKeyEncryptionKeyIdentity class.
     */
    public CustomerManagedKeyEncryptionKeyIdentity() {
    }

    /**
     * Get the identityType property: Values can be systemAssignedIdentity or userAssignedIdentity.
     * 
     * @return the identityType value.
     */
    public IdentityType identityType() {
        return this.identityType;
    }

    /**
     * Set the identityType property: Values can be systemAssignedIdentity or userAssignedIdentity.
     * 
     * @param identityType the identityType value to set.
     * @return the CustomerManagedKeyEncryptionKeyIdentity object itself.
     */
    public CustomerManagedKeyEncryptionKeyIdentity withIdentityType(IdentityType identityType) {
        this.identityType = identityType;
        return this;
    }

    /**
     * Get the userAssignedIdentityResourceId property: user assigned identity to use for accessing key encryption key
     * Url. Ex: /subscriptions/fa5fc227-a624-475e-b696-cdd604c735bc/resourceGroups/<resource
     * group>/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myId. Mutually exclusive with identityType
     * systemAssignedIdentity and delegatedResourceIdentity.
     * 
     * @return the userAssignedIdentityResourceId value.
     */
    public String userAssignedIdentityResourceId() {
        return this.userAssignedIdentityResourceId;
    }

    /**
     * Set the userAssignedIdentityResourceId property: user assigned identity to use for accessing key encryption key
     * Url. Ex: /subscriptions/fa5fc227-a624-475e-b696-cdd604c735bc/resourceGroups/<resource
     * group>/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myId. Mutually exclusive with identityType
     * systemAssignedIdentity and delegatedResourceIdentity.
     * 
     * @param userAssignedIdentityResourceId the userAssignedIdentityResourceId value to set.
     * @return the CustomerManagedKeyEncryptionKeyIdentity object itself.
     */
    public CustomerManagedKeyEncryptionKeyIdentity
        withUserAssignedIdentityResourceId(String userAssignedIdentityResourceId) {
        this.userAssignedIdentityResourceId = userAssignedIdentityResourceId;
        return this;
    }

    /**
     * Get the delegatedIdentityClientId property: delegated identity to use for accessing key encryption key Url. Ex:
     * /subscriptions/fa5fc227-a624-475e-b696-cdd604c735bc/resourceGroups/<resource
     * group>/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myId. Mutually exclusive with identityType
     * systemAssignedIdentity and userAssignedIdentity - internal use only.
     * 
     * @return the delegatedIdentityClientId value.
     */
    public UUID delegatedIdentityClientId() {
        return this.delegatedIdentityClientId;
    }

    /**
     * Set the delegatedIdentityClientId property: delegated identity to use for accessing key encryption key Url. Ex:
     * /subscriptions/fa5fc227-a624-475e-b696-cdd604c735bc/resourceGroups/<resource
     * group>/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myId. Mutually exclusive with identityType
     * systemAssignedIdentity and userAssignedIdentity - internal use only.
     * 
     * @param delegatedIdentityClientId the delegatedIdentityClientId value to set.
     * @return the CustomerManagedKeyEncryptionKeyIdentity object itself.
     */
    public CustomerManagedKeyEncryptionKeyIdentity withDelegatedIdentityClientId(UUID delegatedIdentityClientId) {
        this.delegatedIdentityClientId = delegatedIdentityClientId;
        return this;
    }

    /**
     * Validates the instance.
     * 
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeStringField("identityType", this.identityType == null ? null : this.identityType.toString());
        jsonWriter.writeStringField("userAssignedIdentityResourceId", this.userAssignedIdentityResourceId);
        jsonWriter.writeStringField("delegatedIdentityClientId",
            Objects.toString(this.delegatedIdentityClientId, null));
        return jsonWriter.writeEndObject();
    }

    /**
     * Reads an instance of CustomerManagedKeyEncryptionKeyIdentity from the JsonReader.
     * 
     * @param jsonReader The JsonReader being read.
     * @return An instance of CustomerManagedKeyEncryptionKeyIdentity if the JsonReader was pointing to an instance of
     * it, or null if it was pointing to JSON null.
     * @throws IOException If an error occurs while reading the CustomerManagedKeyEncryptionKeyIdentity.
     */
    public static CustomerManagedKeyEncryptionKeyIdentity fromJson(JsonReader jsonReader) throws IOException {
        return jsonReader.readObject(reader -> {
            CustomerManagedKeyEncryptionKeyIdentity deserializedCustomerManagedKeyEncryptionKeyIdentity
                = new CustomerManagedKeyEncryptionKeyIdentity();
            while (reader.nextToken() != JsonToken.END_OBJECT) {
                String fieldName = reader.getFieldName();
                reader.nextToken();

                if ("identityType".equals(fieldName)) {
                    deserializedCustomerManagedKeyEncryptionKeyIdentity.identityType
                        = IdentityType.fromString(reader.getString());
                } else if ("userAssignedIdentityResourceId".equals(fieldName)) {
                    deserializedCustomerManagedKeyEncryptionKeyIdentity.userAssignedIdentityResourceId
                        = reader.getString();
                } else if ("delegatedIdentityClientId".equals(fieldName)) {
                    deserializedCustomerManagedKeyEncryptionKeyIdentity.delegatedIdentityClientId
                        = reader.getNullable(nonNullReader -> UUID.fromString(nonNullReader.getString()));
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedCustomerManagedKeyEncryptionKeyIdentity;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy