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

com.azure.resourcemanager.automation.fluent.models.HybridRunbookWorkerGroupProperties Maven / Gradle / Ivy

Go to download

This package contains Microsoft Azure SDK for Automation Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. Automation Client. Package tag package-2022-02-22.

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.automation.fluent.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 com.azure.resourcemanager.automation.models.GroupTypeEnum;
import com.azure.resourcemanager.automation.models.RunAsCredentialAssociationProperty;
import java.io.IOException;

/**
 * Definition of hybrid runbook worker group property.
 */
@Fluent
public final class HybridRunbookWorkerGroupProperties implements JsonSerializable {
    /*
     * Type of the HybridWorkerGroup.
     */
    private GroupTypeEnum groupType;

    /*
     * Sets the credential of a worker group.
     */
    private RunAsCredentialAssociationProperty credential;

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

    /**
     * Get the groupType property: Type of the HybridWorkerGroup.
     * 
     * @return the groupType value.
     */
    public GroupTypeEnum groupType() {
        return this.groupType;
    }

    /**
     * Set the groupType property: Type of the HybridWorkerGroup.
     * 
     * @param groupType the groupType value to set.
     * @return the HybridRunbookWorkerGroupProperties object itself.
     */
    public HybridRunbookWorkerGroupProperties withGroupType(GroupTypeEnum groupType) {
        this.groupType = groupType;
        return this;
    }

    /**
     * Get the credential property: Sets the credential of a worker group.
     * 
     * @return the credential value.
     */
    public RunAsCredentialAssociationProperty credential() {
        return this.credential;
    }

    /**
     * Set the credential property: Sets the credential of a worker group.
     * 
     * @param credential the credential value to set.
     * @return the HybridRunbookWorkerGroupProperties object itself.
     */
    public HybridRunbookWorkerGroupProperties withCredential(RunAsCredentialAssociationProperty credential) {
        this.credential = credential;
        return this;
    }

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

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

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

                if ("groupType".equals(fieldName)) {
                    deserializedHybridRunbookWorkerGroupProperties.groupType
                        = GroupTypeEnum.fromString(reader.getString());
                } else if ("credential".equals(fieldName)) {
                    deserializedHybridRunbookWorkerGroupProperties.credential
                        = RunAsCredentialAssociationProperty.fromJson(reader);
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedHybridRunbookWorkerGroupProperties;
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy