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

com.azure.resourcemanager.dataprotection.models.DatasourceSet Maven / Gradle / Ivy

Go to download

This package contains Microsoft Azure SDK for DataProtection Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. Open API 2.0 Specs for Azure Data Protection service. Package tag package-2024-04.

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

/**
 * DatasourceSet
 * 
 * DatasourceSet details of datasource to be backed up.
 */
@Fluent
public final class DatasourceSet implements JsonSerializable {
    /*
     * DatasourceType of the resource.
     */
    private String datasourceType;

    /*
     * Type of Datasource object, used to initialize the right inherited type
     */
    private String objectType;

    /*
     * Full ARM ID of the resource. For azure resources, this is ARM ID. For non azure resources, this will be the ID
     * created by backup service via Fabric/Vault.
     */
    private String resourceId;

    /*
     * Location of datasource.
     */
    private String resourceLocation;

    /*
     * Unique identifier of the resource in the context of parent.
     */
    private String resourceName;

    /*
     * Resource Type of Datasource.
     */
    private String resourceType;

    /*
     * Uri of the resource.
     */
    private String resourceUri;

    /*
     * Properties specific to data source set
     */
    private BaseResourceProperties resourceProperties;

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

    /**
     * Get the datasourceType property: DatasourceType of the resource.
     * 
     * @return the datasourceType value.
     */
    public String datasourceType() {
        return this.datasourceType;
    }

    /**
     * Set the datasourceType property: DatasourceType of the resource.
     * 
     * @param datasourceType the datasourceType value to set.
     * @return the DatasourceSet object itself.
     */
    public DatasourceSet withDatasourceType(String datasourceType) {
        this.datasourceType = datasourceType;
        return this;
    }

    /**
     * Get the objectType property: Type of Datasource object, used to initialize the right inherited type.
     * 
     * @return the objectType value.
     */
    public String objectType() {
        return this.objectType;
    }

    /**
     * Set the objectType property: Type of Datasource object, used to initialize the right inherited type.
     * 
     * @param objectType the objectType value to set.
     * @return the DatasourceSet object itself.
     */
    public DatasourceSet withObjectType(String objectType) {
        this.objectType = objectType;
        return this;
    }

    /**
     * Get the resourceId property: Full ARM ID of the resource. For azure resources, this is ARM ID. For non azure
     * resources, this will be the ID created by backup service via Fabric/Vault.
     * 
     * @return the resourceId value.
     */
    public String resourceId() {
        return this.resourceId;
    }

    /**
     * Set the resourceId property: Full ARM ID of the resource. For azure resources, this is ARM ID. For non azure
     * resources, this will be the ID created by backup service via Fabric/Vault.
     * 
     * @param resourceId the resourceId value to set.
     * @return the DatasourceSet object itself.
     */
    public DatasourceSet withResourceId(String resourceId) {
        this.resourceId = resourceId;
        return this;
    }

    /**
     * Get the resourceLocation property: Location of datasource.
     * 
     * @return the resourceLocation value.
     */
    public String resourceLocation() {
        return this.resourceLocation;
    }

    /**
     * Set the resourceLocation property: Location of datasource.
     * 
     * @param resourceLocation the resourceLocation value to set.
     * @return the DatasourceSet object itself.
     */
    public DatasourceSet withResourceLocation(String resourceLocation) {
        this.resourceLocation = resourceLocation;
        return this;
    }

    /**
     * Get the resourceName property: Unique identifier of the resource in the context of parent.
     * 
     * @return the resourceName value.
     */
    public String resourceName() {
        return this.resourceName;
    }

    /**
     * Set the resourceName property: Unique identifier of the resource in the context of parent.
     * 
     * @param resourceName the resourceName value to set.
     * @return the DatasourceSet object itself.
     */
    public DatasourceSet withResourceName(String resourceName) {
        this.resourceName = resourceName;
        return this;
    }

    /**
     * Get the resourceType property: Resource Type of Datasource.
     * 
     * @return the resourceType value.
     */
    public String resourceType() {
        return this.resourceType;
    }

    /**
     * Set the resourceType property: Resource Type of Datasource.
     * 
     * @param resourceType the resourceType value to set.
     * @return the DatasourceSet object itself.
     */
    public DatasourceSet withResourceType(String resourceType) {
        this.resourceType = resourceType;
        return this;
    }

    /**
     * Get the resourceUri property: Uri of the resource.
     * 
     * @return the resourceUri value.
     */
    public String resourceUri() {
        return this.resourceUri;
    }

    /**
     * Set the resourceUri property: Uri of the resource.
     * 
     * @param resourceUri the resourceUri value to set.
     * @return the DatasourceSet object itself.
     */
    public DatasourceSet withResourceUri(String resourceUri) {
        this.resourceUri = resourceUri;
        return this;
    }

    /**
     * Get the resourceProperties property: Properties specific to data source set.
     * 
     * @return the resourceProperties value.
     */
    public BaseResourceProperties resourceProperties() {
        return this.resourceProperties;
    }

    /**
     * Set the resourceProperties property: Properties specific to data source set.
     * 
     * @param resourceProperties the resourceProperties value to set.
     * @return the DatasourceSet object itself.
     */
    public DatasourceSet withResourceProperties(BaseResourceProperties resourceProperties) {
        this.resourceProperties = resourceProperties;
        return this;
    }

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

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

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeStringField("resourceID", this.resourceId);
        jsonWriter.writeStringField("datasourceType", this.datasourceType);
        jsonWriter.writeStringField("objectType", this.objectType);
        jsonWriter.writeStringField("resourceLocation", this.resourceLocation);
        jsonWriter.writeStringField("resourceName", this.resourceName);
        jsonWriter.writeStringField("resourceType", this.resourceType);
        jsonWriter.writeStringField("resourceUri", this.resourceUri);
        jsonWriter.writeJsonField("resourceProperties", this.resourceProperties);
        return jsonWriter.writeEndObject();
    }

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

                if ("resourceID".equals(fieldName)) {
                    deserializedDatasourceSet.resourceId = reader.getString();
                } else if ("datasourceType".equals(fieldName)) {
                    deserializedDatasourceSet.datasourceType = reader.getString();
                } else if ("objectType".equals(fieldName)) {
                    deserializedDatasourceSet.objectType = reader.getString();
                } else if ("resourceLocation".equals(fieldName)) {
                    deserializedDatasourceSet.resourceLocation = reader.getString();
                } else if ("resourceName".equals(fieldName)) {
                    deserializedDatasourceSet.resourceName = reader.getString();
                } else if ("resourceType".equals(fieldName)) {
                    deserializedDatasourceSet.resourceType = reader.getString();
                } else if ("resourceUri".equals(fieldName)) {
                    deserializedDatasourceSet.resourceUri = reader.getString();
                } else if ("resourceProperties".equals(fieldName)) {
                    deserializedDatasourceSet.resourceProperties = BaseResourceProperties.fromJson(reader);
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedDatasourceSet;
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy