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

com.azure.resourcemanager.servicelinker.implementation.DryrunResourceImpl 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.servicelinker.implementation;

import com.azure.core.management.SystemData;
import com.azure.core.util.Context;
import com.azure.resourcemanager.servicelinker.fluent.models.DryrunResourceInner;
import com.azure.resourcemanager.servicelinker.models.DryrunOperationPreview;
import com.azure.resourcemanager.servicelinker.models.DryrunParameters;
import com.azure.resourcemanager.servicelinker.models.DryrunPatch;
import com.azure.resourcemanager.servicelinker.models.DryrunPrerequisiteResult;
import com.azure.resourcemanager.servicelinker.models.DryrunResource;
import java.util.Collections;
import java.util.List;

public final class DryrunResourceImpl implements DryrunResource, DryrunResource.Definition, DryrunResource.Update {
    private DryrunResourceInner innerObject;

    private final com.azure.resourcemanager.servicelinker.ServiceLinkerManager serviceManager;

    public String id() {
        return this.innerModel().id();
    }

    public String name() {
        return this.innerModel().name();
    }

    public String type() {
        return this.innerModel().type();
    }

    public SystemData systemData() {
        return this.innerModel().systemData();
    }

    public DryrunParameters parameters() {
        return this.innerModel().parameters();
    }

    public List prerequisiteResults() {
        List inner = this.innerModel().prerequisiteResults();
        if (inner != null) {
            return Collections.unmodifiableList(inner);
        } else {
            return Collections.emptyList();
        }
    }

    public List operationPreviews() {
        List inner = this.innerModel().operationPreviews();
        if (inner != null) {
            return Collections.unmodifiableList(inner);
        } else {
            return Collections.emptyList();
        }
    }

    public String provisioningState() {
        return this.innerModel().provisioningState();
    }

    public String resourceGroupName() {
        return resourceGroupName;
    }

    public DryrunResourceInner innerModel() {
        return this.innerObject;
    }

    private com.azure.resourcemanager.servicelinker.ServiceLinkerManager manager() {
        return this.serviceManager;
    }

    private String subscriptionId;

    private String resourceGroupName;

    private String location;

    private String dryrunName;

    private DryrunPatch updateParameters;

    public DryrunResourceImpl withExistingLocation(String subscriptionId, String resourceGroupName, String location) {
        this.subscriptionId = subscriptionId;
        this.resourceGroupName = resourceGroupName;
        this.location = location;
        return this;
    }

    public DryrunResource create() {
        this.innerObject = serviceManager.serviceClient()
            .getConnectors()
            .createDryrun(subscriptionId, resourceGroupName, location, dryrunName, this.innerModel(), Context.NONE);
        return this;
    }

    public DryrunResource create(Context context) {
        this.innerObject = serviceManager.serviceClient()
            .getConnectors()
            .createDryrun(subscriptionId, resourceGroupName, location, dryrunName, this.innerModel(), context);
        return this;
    }

    DryrunResourceImpl(String name, com.azure.resourcemanager.servicelinker.ServiceLinkerManager serviceManager) {
        this.innerObject = new DryrunResourceInner();
        this.serviceManager = serviceManager;
        this.dryrunName = name;
    }

    public DryrunResourceImpl update() {
        this.updateParameters = new DryrunPatch();
        return this;
    }

    public DryrunResource apply() {
        this.innerObject = serviceManager.serviceClient()
            .getConnectors()
            .updateDryrun(subscriptionId, resourceGroupName, location, dryrunName, updateParameters, Context.NONE);
        return this;
    }

    public DryrunResource apply(Context context) {
        this.innerObject = serviceManager.serviceClient()
            .getConnectors()
            .updateDryrun(subscriptionId, resourceGroupName, location, dryrunName, updateParameters, context);
        return this;
    }

    DryrunResourceImpl(DryrunResourceInner innerObject,
        com.azure.resourcemanager.servicelinker.ServiceLinkerManager serviceManager) {
        this.innerObject = innerObject;
        this.serviceManager = serviceManager;
        this.subscriptionId = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "subscriptions");
        this.resourceGroupName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "resourcegroups");
        this.location = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "locations");
        this.dryrunName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "dryruns");
    }

    public DryrunResource refresh() {
        this.innerObject = serviceManager.serviceClient()
            .getConnectors()
            .getDryrunWithResponse(subscriptionId, resourceGroupName, location, dryrunName, Context.NONE)
            .getValue();
        return this;
    }

    public DryrunResource refresh(Context context) {
        this.innerObject = serviceManager.serviceClient()
            .getConnectors()
            .getDryrunWithResponse(subscriptionId, resourceGroupName, location, dryrunName, context)
            .getValue();
        return this;
    }

    public DryrunResourceImpl withParameters(DryrunParameters parameters) {
        if (isInCreateMode()) {
            this.innerModel().withParameters(parameters);
            return this;
        } else {
            this.updateParameters.withParameters(parameters);
            return this;
        }
    }

    private boolean isInCreateMode() {
        return this.innerModel().id() == null;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy