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

com.azure.resourcemanager.keyvault.models.RotationPolicy Maven / Gradle / Ivy

Go to download

This package contains Microsoft Azure Key Vault Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt

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.keyvault.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;

/**
 * The RotationPolicy model.
 */
@Fluent
public final class RotationPolicy implements JsonSerializable {
    /*
     * The attributes of key rotation policy.
     */
    private KeyRotationPolicyAttributes attributes;

    /*
     * The lifetimeActions for key rotation action.
     */
    private List lifetimeActions;

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

    /**
     * Get the attributes property: The attributes of key rotation policy.
     * 
     * @return the attributes value.
     */
    public KeyRotationPolicyAttributes attributes() {
        return this.attributes;
    }

    /**
     * Set the attributes property: The attributes of key rotation policy.
     * 
     * @param attributes the attributes value to set.
     * @return the RotationPolicy object itself.
     */
    public RotationPolicy withAttributes(KeyRotationPolicyAttributes attributes) {
        this.attributes = attributes;
        return this;
    }

    /**
     * Get the lifetimeActions property: The lifetimeActions for key rotation action.
     * 
     * @return the lifetimeActions value.
     */
    public List lifetimeActions() {
        return this.lifetimeActions;
    }

    /**
     * Set the lifetimeActions property: The lifetimeActions for key rotation action.
     * 
     * @param lifetimeActions the lifetimeActions value to set.
     * @return the RotationPolicy object itself.
     */
    public RotationPolicy withLifetimeActions(List lifetimeActions) {
        this.lifetimeActions = lifetimeActions;
        return this;
    }

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

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeJsonField("attributes", this.attributes);
        jsonWriter.writeArrayField("lifetimeActions", this.lifetimeActions,
            (writer, element) -> writer.writeJson(element));
        return jsonWriter.writeEndObject();
    }

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

                if ("attributes".equals(fieldName)) {
                    deserializedRotationPolicy.attributes = KeyRotationPolicyAttributes.fromJson(reader);
                } else if ("lifetimeActions".equals(fieldName)) {
                    List lifetimeActions
                        = reader.readArray(reader1 -> LifetimeAction.fromJson(reader1));
                    deserializedRotationPolicy.lifetimeActions = lifetimeActions;
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedRotationPolicy;
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy