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

com.azure.resourcemanager.servicebus.models.RegenerateAccessKeyParameters Maven / Gradle / Ivy

Go to download

This package contains Microsoft Azure ServiceBus 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.servicebus.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;

/**
 * Parameters supplied to the Regenerate Authorization Rule operation, specifies which key needs to be reset.
 */
@Fluent
public final class RegenerateAccessKeyParameters implements JsonSerializable {
    /*
     * The access key to regenerate.
     */
    private KeyType keyType;

    /*
     * Optional, if the key value provided, is reset for KeyType value or autogenerate Key value set for keyType
     */
    private String key;

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

    /**
     * Get the keyType property: The access key to regenerate.
     * 
     * @return the keyType value.
     */
    public KeyType keyType() {
        return this.keyType;
    }

    /**
     * Set the keyType property: The access key to regenerate.
     * 
     * @param keyType the keyType value to set.
     * @return the RegenerateAccessKeyParameters object itself.
     */
    public RegenerateAccessKeyParameters withKeyType(KeyType keyType) {
        this.keyType = keyType;
        return this;
    }

    /**
     * Get the key property: Optional, if the key value provided, is reset for KeyType value or autogenerate Key value
     * set for keyType.
     * 
     * @return the key value.
     */
    public String key() {
        return this.key;
    }

    /**
     * Set the key property: Optional, if the key value provided, is reset for KeyType value or autogenerate Key value
     * set for keyType.
     * 
     * @param key the key value to set.
     * @return the RegenerateAccessKeyParameters object itself.
     */
    public RegenerateAccessKeyParameters withKey(String key) {
        this.key = key;
        return this;
    }

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

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

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeStringField("keyType", this.keyType == null ? null : this.keyType.toString());
        jsonWriter.writeStringField("key", this.key);
        return jsonWriter.writeEndObject();
    }

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

                if ("keyType".equals(fieldName)) {
                    deserializedRegenerateAccessKeyParameters.keyType = KeyType.fromString(reader.getString());
                } else if ("key".equals(fieldName)) {
                    deserializedRegenerateAccessKeyParameters.key = reader.getString();
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedRegenerateAccessKeyParameters;
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy