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

com.azure.resourcemanager.servicelinker.models.DaprProperties 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.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.List;

/**
 * Indicates some additional properties for dapr client type.
 */
@Fluent
public final class DaprProperties implements JsonSerializable {
    /*
     * The dapr component version
     */
    private String version;

    /*
     * The dapr component type
     */
    private String componentType;

    /*
     * The name of a secret store dapr to retrieve secret
     */
    private String secretStoreComponent;

    /*
     * Additional dapr metadata
     */
    private List metadata;

    /*
     * The dapr component scopes
     */
    private List scopes;

    /*
     * The runtime version supported by the properties
     */
    private String runtimeVersion;

    /*
     * The direction supported by the dapr binding component
     */
    private DaprBindingComponentDirection bindingComponentDirection;

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

    /**
     * Get the version property: The dapr component version.
     * 
     * @return the version value.
     */
    public String version() {
        return this.version;
    }

    /**
     * Set the version property: The dapr component version.
     * 
     * @param version the version value to set.
     * @return the DaprProperties object itself.
     */
    public DaprProperties withVersion(String version) {
        this.version = version;
        return this;
    }

    /**
     * Get the componentType property: The dapr component type.
     * 
     * @return the componentType value.
     */
    public String componentType() {
        return this.componentType;
    }

    /**
     * Set the componentType property: The dapr component type.
     * 
     * @param componentType the componentType value to set.
     * @return the DaprProperties object itself.
     */
    public DaprProperties withComponentType(String componentType) {
        this.componentType = componentType;
        return this;
    }

    /**
     * Get the secretStoreComponent property: The name of a secret store dapr to retrieve secret.
     * 
     * @return the secretStoreComponent value.
     */
    public String secretStoreComponent() {
        return this.secretStoreComponent;
    }

    /**
     * Set the secretStoreComponent property: The name of a secret store dapr to retrieve secret.
     * 
     * @param secretStoreComponent the secretStoreComponent value to set.
     * @return the DaprProperties object itself.
     */
    public DaprProperties withSecretStoreComponent(String secretStoreComponent) {
        this.secretStoreComponent = secretStoreComponent;
        return this;
    }

    /**
     * Get the metadata property: Additional dapr metadata.
     * 
     * @return the metadata value.
     */
    public List metadata() {
        return this.metadata;
    }

    /**
     * Set the metadata property: Additional dapr metadata.
     * 
     * @param metadata the metadata value to set.
     * @return the DaprProperties object itself.
     */
    public DaprProperties withMetadata(List metadata) {
        this.metadata = metadata;
        return this;
    }

    /**
     * Get the scopes property: The dapr component scopes.
     * 
     * @return the scopes value.
     */
    public List scopes() {
        return this.scopes;
    }

    /**
     * Set the scopes property: The dapr component scopes.
     * 
     * @param scopes the scopes value to set.
     * @return the DaprProperties object itself.
     */
    public DaprProperties withScopes(List scopes) {
        this.scopes = scopes;
        return this;
    }

    /**
     * Get the runtimeVersion property: The runtime version supported by the properties.
     * 
     * @return the runtimeVersion value.
     */
    public String runtimeVersion() {
        return this.runtimeVersion;
    }

    /**
     * Get the bindingComponentDirection property: The direction supported by the dapr binding component.
     * 
     * @return the bindingComponentDirection value.
     */
    public DaprBindingComponentDirection bindingComponentDirection() {
        return this.bindingComponentDirection;
    }

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

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeStringField("version", this.version);
        jsonWriter.writeStringField("componentType", this.componentType);
        jsonWriter.writeStringField("secretStoreComponent", this.secretStoreComponent);
        jsonWriter.writeArrayField("metadata", this.metadata, (writer, element) -> writer.writeJson(element));
        jsonWriter.writeArrayField("scopes", this.scopes, (writer, element) -> writer.writeString(element));
        return jsonWriter.writeEndObject();
    }

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

                if ("version".equals(fieldName)) {
                    deserializedDaprProperties.version = reader.getString();
                } else if ("componentType".equals(fieldName)) {
                    deserializedDaprProperties.componentType = reader.getString();
                } else if ("secretStoreComponent".equals(fieldName)) {
                    deserializedDaprProperties.secretStoreComponent = reader.getString();
                } else if ("metadata".equals(fieldName)) {
                    List metadata = reader.readArray(reader1 -> DaprMetadata.fromJson(reader1));
                    deserializedDaprProperties.metadata = metadata;
                } else if ("scopes".equals(fieldName)) {
                    List scopes = reader.readArray(reader1 -> reader1.getString());
                    deserializedDaprProperties.scopes = scopes;
                } else if ("runtimeVersion".equals(fieldName)) {
                    deserializedDaprProperties.runtimeVersion = reader.getString();
                } else if ("bindingComponentDirection".equals(fieldName)) {
                    deserializedDaprProperties.bindingComponentDirection
                        = DaprBindingComponentDirection.fromString(reader.getString());
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedDaprProperties;
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy