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

com.azure.resourcemanager.servicelinker.fluent.models.ConfigurationNames 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.servicelinker.fluent.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 com.azure.resourcemanager.servicelinker.models.AuthType;
import com.azure.resourcemanager.servicelinker.models.ClientType;
import com.azure.resourcemanager.servicelinker.models.ConfigurationName;
import com.azure.resourcemanager.servicelinker.models.DaprProperties;
import com.azure.resourcemanager.servicelinker.models.SecretSourceType;
import java.io.IOException;
import java.util.List;

/**
 * The configuration names which will be set based on specific target resource, client type, auth type.
 */
@Fluent
public final class ConfigurationNames implements JsonSerializable {
    /*
     * The target service provider name and resource name.
     */
    private String targetService;

    /*
     * The client type for configuration names.
     */
    private ClientType clientType;

    /*
     * The auth type.
     */
    private AuthType authType;

    /*
     * Indicates where the secrets in configuration from. Used when secrets are from Keyvault.
     */
    private SecretSourceType secretType;

    /*
     * Deprecated, please use #/definitions/DaprConfigurationList instead
     */
    private DaprProperties daprProperties;

    /*
     * The configuration names to be set in compute service environment.
     */
    private List names;

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

    /**
     * Get the targetService property: The target service provider name and resource name.
     * 
     * @return the targetService value.
     */
    public String targetService() {
        return this.targetService;
    }

    /**
     * Set the targetService property: The target service provider name and resource name.
     * 
     * @param targetService the targetService value to set.
     * @return the ConfigurationNames object itself.
     */
    public ConfigurationNames withTargetService(String targetService) {
        this.targetService = targetService;
        return this;
    }

    /**
     * Get the clientType property: The client type for configuration names.
     * 
     * @return the clientType value.
     */
    public ClientType clientType() {
        return this.clientType;
    }

    /**
     * Set the clientType property: The client type for configuration names.
     * 
     * @param clientType the clientType value to set.
     * @return the ConfigurationNames object itself.
     */
    public ConfigurationNames withClientType(ClientType clientType) {
        this.clientType = clientType;
        return this;
    }

    /**
     * Get the authType property: The auth type.
     * 
     * @return the authType value.
     */
    public AuthType authType() {
        return this.authType;
    }

    /**
     * Set the authType property: The auth type.
     * 
     * @param authType the authType value to set.
     * @return the ConfigurationNames object itself.
     */
    public ConfigurationNames withAuthType(AuthType authType) {
        this.authType = authType;
        return this;
    }

    /**
     * Get the secretType property: Indicates where the secrets in configuration from. Used when secrets are from
     * Keyvault.
     * 
     * @return the secretType value.
     */
    public SecretSourceType secretType() {
        return this.secretType;
    }

    /**
     * Set the secretType property: Indicates where the secrets in configuration from. Used when secrets are from
     * Keyvault.
     * 
     * @param secretType the secretType value to set.
     * @return the ConfigurationNames object itself.
     */
    public ConfigurationNames withSecretType(SecretSourceType secretType) {
        this.secretType = secretType;
        return this;
    }

    /**
     * Get the daprProperties property: Deprecated, please use #/definitions/DaprConfigurationList instead.
     * 
     * @return the daprProperties value.
     */
    public DaprProperties daprProperties() {
        return this.daprProperties;
    }

    /**
     * Set the daprProperties property: Deprecated, please use #/definitions/DaprConfigurationList instead.
     * 
     * @param daprProperties the daprProperties value to set.
     * @return the ConfigurationNames object itself.
     */
    public ConfigurationNames withDaprProperties(DaprProperties daprProperties) {
        this.daprProperties = daprProperties;
        return this;
    }

    /**
     * Get the names property: The configuration names to be set in compute service environment.
     * 
     * @return the names value.
     */
    public List names() {
        return this.names;
    }

    /**
     * Set the names property: The configuration names to be set in compute service environment.
     * 
     * @param names the names value to set.
     * @return the ConfigurationNames object itself.
     */
    public ConfigurationNames withNames(List names) {
        this.names = names;
        return this;
    }

    /**
     * Validates the instance.
     * 
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (daprProperties() != null) {
            daprProperties().validate();
        }
        if (names() != null) {
            names().forEach(e -> e.validate());
        }
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeStringField("targetService", this.targetService);
        jsonWriter.writeStringField("clientType", this.clientType == null ? null : this.clientType.toString());
        jsonWriter.writeStringField("authType", this.authType == null ? null : this.authType.toString());
        jsonWriter.writeStringField("secretType", this.secretType == null ? null : this.secretType.toString());
        jsonWriter.writeJsonField("daprProperties", this.daprProperties);
        jsonWriter.writeArrayField("names", this.names, (writer, element) -> writer.writeJson(element));
        return jsonWriter.writeEndObject();
    }

    /**
     * Reads an instance of ConfigurationNames from the JsonReader.
     * 
     * @param jsonReader The JsonReader being read.
     * @return An instance of ConfigurationNames 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 ConfigurationNames.
     */
    public static ConfigurationNames fromJson(JsonReader jsonReader) throws IOException {
        return jsonReader.readObject(reader -> {
            ConfigurationNames deserializedConfigurationNames = new ConfigurationNames();
            while (reader.nextToken() != JsonToken.END_OBJECT) {
                String fieldName = reader.getFieldName();
                reader.nextToken();

                if ("targetService".equals(fieldName)) {
                    deserializedConfigurationNames.targetService = reader.getString();
                } else if ("clientType".equals(fieldName)) {
                    deserializedConfigurationNames.clientType = ClientType.fromString(reader.getString());
                } else if ("authType".equals(fieldName)) {
                    deserializedConfigurationNames.authType = AuthType.fromString(reader.getString());
                } else if ("secretType".equals(fieldName)) {
                    deserializedConfigurationNames.secretType = SecretSourceType.fromString(reader.getString());
                } else if ("daprProperties".equals(fieldName)) {
                    deserializedConfigurationNames.daprProperties = DaprProperties.fromJson(reader);
                } else if ("names".equals(fieldName)) {
                    List names = reader.readArray(reader1 -> ConfigurationName.fromJson(reader1));
                    deserializedConfigurationNames.names = names;
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedConfigurationNames;
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy