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

com.azure.resourcemanager.servicefabricmanagedclusters.models.ServiceCorrelation Maven / Gradle / Ivy

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

package com.azure.resourcemanager.servicefabricmanagedclusters.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;

/**
 * Creates a particular correlation between services.
 */
@Fluent
public final class ServiceCorrelation implements JsonSerializable {
    /*
     * The ServiceCorrelationScheme which describes the relationship between this service and the service specified via
     * ServiceName.
     */
    private ServiceCorrelationScheme scheme;

    /*
     * The Arm Resource ID of the service that the correlation relationship is established with.
     */
    private String serviceName;

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

    /**
     * Get the scheme property: The ServiceCorrelationScheme which describes the relationship between this service and
     * the service specified via ServiceName.
     * 
     * @return the scheme value.
     */
    public ServiceCorrelationScheme scheme() {
        return this.scheme;
    }

    /**
     * Set the scheme property: The ServiceCorrelationScheme which describes the relationship between this service and
     * the service specified via ServiceName.
     * 
     * @param scheme the scheme value to set.
     * @return the ServiceCorrelation object itself.
     */
    public ServiceCorrelation withScheme(ServiceCorrelationScheme scheme) {
        this.scheme = scheme;
        return this;
    }

    /**
     * Get the serviceName property: The Arm Resource ID of the service that the correlation relationship is established
     * with.
     * 
     * @return the serviceName value.
     */
    public String serviceName() {
        return this.serviceName;
    }

    /**
     * Set the serviceName property: The Arm Resource ID of the service that the correlation relationship is established
     * with.
     * 
     * @param serviceName the serviceName value to set.
     * @return the ServiceCorrelation object itself.
     */
    public ServiceCorrelation withServiceName(String serviceName) {
        this.serviceName = serviceName;
        return this;
    }

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

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

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

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

                if ("scheme".equals(fieldName)) {
                    deserializedServiceCorrelation.scheme = ServiceCorrelationScheme.fromString(reader.getString());
                } else if ("serviceName".equals(fieldName)) {
                    deserializedServiceCorrelation.serviceName = reader.getString();
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedServiceCorrelation;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy