// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.resourcemanager.machinelearningservices.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonTypeName;
import java.util.Map;

/**
 * The base service response. The correct inherited response based on computeType will be returned (ex.
 * ACIServiceResponse).
 */
@JsonTypeInfo(
    use = JsonTypeInfo.Id.NAME,
    include = JsonTypeInfo.As.PROPERTY,
    property = "computeType",
    defaultImpl = ServiceResponseBase.class)
@JsonTypeName("ServiceResponseBase")
@JsonSubTypes({
    @JsonSubTypes.Type(name = "ACI", value = AciServiceResponse.class),
    @JsonSubTypes.Type(name = "Custom", value = AksVariantResponse.class)
})
@Fluent
public class ServiceResponseBase {
    @JsonIgnore private final ClientLogger logger = new ClientLogger(ServiceResponseBase.class);

    /*
     * The service description.
     */
    @JsonProperty(value = "description")
    private String description;

    /*
     * The service tag dictionary. Tags are mutable.
     */
    @JsonProperty(value = "kvTags")
    private Map<String, String> kvTags;

    /*
     * The service property dictionary. Properties are immutable.
     */
    @JsonProperty(value = "properties")
    private Map<String, String> properties;

    /*
     * The current state of the service.
     */
    @JsonProperty(value = "state", access = JsonProperty.Access.WRITE_ONLY)
    private WebServiceState state;

    /*
     * The error details.
     */
    @JsonProperty(value = "error", access = JsonProperty.Access.WRITE_ONLY)
    private ServiceResponseBaseError error;

    /*
     * The deployment type for the service.
     */
    @JsonProperty(value = "deploymentType")
    private DeploymentType deploymentType;

    /**
     * Get the description property: The service description.
     *
     * @return the description value.
     */
    public String description() {
        return this.description;
    }

    /**
     * Set the description property: The service description.
     *
     * @param description the description value to set.
     * @return the ServiceResponseBase object itself.
     */
    public ServiceResponseBase withDescription(String description) {
        this.description = description;
        return this;
    }

    /**
     * Get the kvTags property: The service tag dictionary. Tags are mutable.
     *
     * @return the kvTags value.
     */
    public Map<String, String> kvTags() {
        return this.kvTags;
    }

    /**
     * Set the kvTags property: The service tag dictionary. Tags are mutable.
     *
     * @param kvTags the kvTags value to set.
     * @return the ServiceResponseBase object itself.
     */
    public ServiceResponseBase withKvTags(Map<String, String> kvTags) {
        this.kvTags = kvTags;
        return this;
    }

    /**
     * Get the properties property: The service property dictionary. Properties are immutable.
     *
     * @return the properties value.
     */
    public Map<String, String> properties() {
        return this.properties;
    }

    /**
     * Set the properties property: The service property dictionary. Properties are immutable.
     *
     * @param properties the properties value to set.
     * @return the ServiceResponseBase object itself.
     */
    public ServiceResponseBase withProperties(Map<String, String> properties) {
        this.properties = properties;
        return this;
    }

    /**
     * Get the state property: The current state of the service.
     *
     * @return the state value.
     */
    public WebServiceState state() {
        return this.state;
    }

    /**
     * Get the error property: The error details.
     *
     * @return the error value.
     */
    public ServiceResponseBaseError error() {
        return this.error;
    }

    /**
     * Get the deploymentType property: The deployment type for the service.
     *
     * @return the deploymentType value.
     */
    public DeploymentType deploymentType() {
        return this.deploymentType;
    }

    /**
     * Set the deploymentType property: The deployment type for the service.
     *
     * @param deploymentType the deploymentType value to set.
     * @return the ServiceResponseBase object itself.
     */
    public ServiceResponseBase withDeploymentType(DeploymentType deploymentType) {
        this.deploymentType = deploymentType;
        return this;
    }

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