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

com.azure.resourcemanager.mediaservices.models.ContentKeyPolicyOption Maven / Gradle / Ivy

Go to download

This package contains Microsoft Azure SDK for MediaServices Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. This Swagger was generated by the API Framework. Package tag package-account-2023-01.

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

package com.azure.resourcemanager.mediaservices.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
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.UUID;

/**
 * Represents a policy option.
 */
@Fluent
public final class ContentKeyPolicyOption implements JsonSerializable {
    /*
     * The legacy Policy Option ID.
     */
    private UUID policyOptionId;

    /*
     * The Policy Option description.
     */
    private String name;

    /*
     * The key delivery configuration.
     */
    private ContentKeyPolicyConfiguration configuration;

    /*
     * The requirements that must be met to deliver keys with this configuration
     */
    private ContentKeyPolicyRestriction restriction;

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

    /**
     * Get the policyOptionId property: The legacy Policy Option ID.
     * 
     * @return the policyOptionId value.
     */
    public UUID policyOptionId() {
        return this.policyOptionId;
    }

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

    /**
     * Set the name property: The Policy Option description.
     * 
     * @param name the name value to set.
     * @return the ContentKeyPolicyOption object itself.
     */
    public ContentKeyPolicyOption withName(String name) {
        this.name = name;
        return this;
    }

    /**
     * Get the configuration property: The key delivery configuration.
     * 
     * @return the configuration value.
     */
    public ContentKeyPolicyConfiguration configuration() {
        return this.configuration;
    }

    /**
     * Set the configuration property: The key delivery configuration.
     * 
     * @param configuration the configuration value to set.
     * @return the ContentKeyPolicyOption object itself.
     */
    public ContentKeyPolicyOption withConfiguration(ContentKeyPolicyConfiguration configuration) {
        this.configuration = configuration;
        return this;
    }

    /**
     * Get the restriction property: The requirements that must be met to deliver keys with this configuration.
     * 
     * @return the restriction value.
     */
    public ContentKeyPolicyRestriction restriction() {
        return this.restriction;
    }

    /**
     * Set the restriction property: The requirements that must be met to deliver keys with this configuration.
     * 
     * @param restriction the restriction value to set.
     * @return the ContentKeyPolicyOption object itself.
     */
    public ContentKeyPolicyOption withRestriction(ContentKeyPolicyRestriction restriction) {
        this.restriction = restriction;
        return this;
    }

    /**
     * Validates the instance.
     * 
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (configuration() == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException(
                    "Missing required property configuration in model ContentKeyPolicyOption"));
        } else {
            configuration().validate();
        }
        if (restriction() == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException(
                    "Missing required property restriction in model ContentKeyPolicyOption"));
        } else {
            restriction().validate();
        }
    }

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

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeJsonField("configuration", this.configuration);
        jsonWriter.writeJsonField("restriction", this.restriction);
        jsonWriter.writeStringField("name", this.name);
        return jsonWriter.writeEndObject();
    }

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

                if ("configuration".equals(fieldName)) {
                    deserializedContentKeyPolicyOption.configuration = ContentKeyPolicyConfiguration.fromJson(reader);
                } else if ("restriction".equals(fieldName)) {
                    deserializedContentKeyPolicyOption.restriction = ContentKeyPolicyRestriction.fromJson(reader);
                } else if ("policyOptionId".equals(fieldName)) {
                    deserializedContentKeyPolicyOption.policyOptionId
                        = reader.getNullable(nonNullReader -> UUID.fromString(nonNullReader.getString()));
                } else if ("name".equals(fieldName)) {
                    deserializedContentKeyPolicyOption.name = reader.getString();
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedContentKeyPolicyOption;
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy