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

package com.azure.resourcemanager.apimanagement.fluent.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.fasterxml.jackson.annotation.JsonProperty;

/** API Schema create or update contract Properties. */
@Fluent
public final class SchemaContractProperties {
    /*
     * Must be a valid a media type used in a Content-Type header as defined in
     * the RFC 2616. Media type of the schema document (e.g. application/json,
     * application/xml). </br> - `Swagger` Schema use
     * `application/vnd.ms-azure-apim.swagger.definitions+json` </br> - `WSDL`
     * Schema use `application/vnd.ms-azure-apim.xsd+xml` </br> - `OpenApi`
     * Schema use `application/vnd.oai.openapi.components+json` </br> - `WADL
     * Schema` use `application/vnd.ms-azure-apim.wadl.grammars+xml`.
     */
    @JsonProperty(value = "contentType", required = true)
    private String contentType;

    /*
     * Create or update Properties of the API Schema Document.
     */
    @JsonProperty(value = "document")
    private SchemaDocumentProperties innerDocument;

    /**
     * Get the contentType property: Must be a valid a media type used in a Content-Type header as defined in the RFC
     * 2616. Media type of the schema document (e.g. application/json, application/xml). &lt;/br&gt; - `Swagger` Schema
     * use `application/vnd.ms-azure-apim.swagger.definitions+json` &lt;/br&gt; - `WSDL` Schema use
     * `application/vnd.ms-azure-apim.xsd+xml` &lt;/br&gt; - `OpenApi` Schema use
     * `application/vnd.oai.openapi.components+json` &lt;/br&gt; - `WADL Schema` use
     * `application/vnd.ms-azure-apim.wadl.grammars+xml`.
     *
     * @return the contentType value.
     */
    public String contentType() {
        return this.contentType;
    }

    /**
     * Set the contentType property: Must be a valid a media type used in a Content-Type header as defined in the RFC
     * 2616. Media type of the schema document (e.g. application/json, application/xml). &lt;/br&gt; - `Swagger` Schema
     * use `application/vnd.ms-azure-apim.swagger.definitions+json` &lt;/br&gt; - `WSDL` Schema use
     * `application/vnd.ms-azure-apim.xsd+xml` &lt;/br&gt; - `OpenApi` Schema use
     * `application/vnd.oai.openapi.components+json` &lt;/br&gt; - `WADL Schema` use
     * `application/vnd.ms-azure-apim.wadl.grammars+xml`.
     *
     * @param contentType the contentType value to set.
     * @return the SchemaContractProperties object itself.
     */
    public SchemaContractProperties withContentType(String contentType) {
        this.contentType = contentType;
        return this;
    }

    /**
     * Get the innerDocument property: Create or update Properties of the API Schema Document.
     *
     * @return the innerDocument value.
     */
    private SchemaDocumentProperties innerDocument() {
        return this.innerDocument;
    }

    /**
     * Get the value property: Json escaped string defining the document representing the Schema. Used for schemas other
     * than Swagger/OpenAPI.
     *
     * @return the value value.
     */
    public String value() {
        return this.innerDocument() == null ? null : this.innerDocument().value();
    }

    /**
     * Set the value property: Json escaped string defining the document representing the Schema. Used for schemas other
     * than Swagger/OpenAPI.
     *
     * @param value the value value to set.
     * @return the SchemaContractProperties object itself.
     */
    public SchemaContractProperties withValue(String value) {
        if (this.innerDocument() == null) {
            this.innerDocument = new SchemaDocumentProperties();
        }
        this.innerDocument().withValue(value);
        return this;
    }

    /**
     * Get the definitions property: Types definitions. Used for Swagger/OpenAPI v1 schemas only, null otherwise.
     *
     * @return the definitions value.
     */
    public Object definitions() {
        return this.innerDocument() == null ? null : this.innerDocument().definitions();
    }

    /**
     * Set the definitions property: Types definitions. Used for Swagger/OpenAPI v1 schemas only, null otherwise.
     *
     * @param definitions the definitions value to set.
     * @return the SchemaContractProperties object itself.
     */
    public SchemaContractProperties withDefinitions(Object definitions) {
        if (this.innerDocument() == null) {
            this.innerDocument = new SchemaDocumentProperties();
        }
        this.innerDocument().withDefinitions(definitions);
        return this;
    }

    /**
     * Get the components property: Types definitions. Used for Swagger/OpenAPI v2/v3 schemas only, null otherwise.
     *
     * @return the components value.
     */
    public Object components() {
        return this.innerDocument() == null ? null : this.innerDocument().components();
    }

    /**
     * Set the components property: Types definitions. Used for Swagger/OpenAPI v2/v3 schemas only, null otherwise.
     *
     * @param components the components value to set.
     * @return the SchemaContractProperties object itself.
     */
    public SchemaContractProperties withComponents(Object components) {
        if (this.innerDocument() == null) {
            this.innerDocument = new SchemaDocumentProperties();
        }
        this.innerDocument().withComponents(components);
        return this;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (contentType() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property contentType in model SchemaContractProperties"));
        }
        if (innerDocument() != null) {
            innerDocument().validate();
        }
    }

    private static final ClientLogger LOGGER = new ClientLogger(SchemaContractProperties.class);
}
