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

com.azure.resourcemanager.desktopvirtualization.implementation.ScalingPlanImpl Maven / Gradle / Ivy

Go to download

This package contains Microsoft Azure SDK for DesktopVirtualization Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. 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.desktopvirtualization.implementation;

import com.azure.core.management.Region;
import com.azure.core.management.SystemData;
import com.azure.core.util.Context;
import com.azure.resourcemanager.desktopvirtualization.fluent.models.ScalingPlanInner;
import com.azure.resourcemanager.desktopvirtualization.models.ResourceModelWithAllowedPropertySetIdentity;
import com.azure.resourcemanager.desktopvirtualization.models.ResourceModelWithAllowedPropertySetPlan;
import com.azure.resourcemanager.desktopvirtualization.models.ResourceModelWithAllowedPropertySetSku;
import com.azure.resourcemanager.desktopvirtualization.models.ScalingHostPoolReference;
import com.azure.resourcemanager.desktopvirtualization.models.ScalingHostPoolType;
import com.azure.resourcemanager.desktopvirtualization.models.ScalingPlan;
import com.azure.resourcemanager.desktopvirtualization.models.ScalingPlanPatch;
import com.azure.resourcemanager.desktopvirtualization.models.ScalingSchedule;
import java.util.Collections;
import java.util.List;
import java.util.Map;

public final class ScalingPlanImpl implements ScalingPlan, ScalingPlan.Definition, ScalingPlan.Update {
    private ScalingPlanInner innerObject;

    private final com.azure.resourcemanager.desktopvirtualization.DesktopVirtualizationManager serviceManager;

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

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

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

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

    public Map tags() {
        Map inner = this.innerModel().tags();
        if (inner != null) {
            return Collections.unmodifiableMap(inner);
        } else {
            return Collections.emptyMap();
        }
    }

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

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

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

    public ResourceModelWithAllowedPropertySetIdentity identity() {
        return this.innerModel().identity();
    }

    public ResourceModelWithAllowedPropertySetSku sku() {
        return this.innerModel().sku();
    }

    public ResourceModelWithAllowedPropertySetPlan plan() {
        return this.innerModel().plan();
    }

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

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

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

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

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

    public ScalingHostPoolType hostPoolType() {
        return this.innerModel().hostPoolType();
    }

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

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

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

    public Region region() {
        return Region.fromName(this.regionName());
    }

    public String regionName() {
        return this.location();
    }

    public String resourceGroupName() {
        return resourceGroupName;
    }

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

    private com.azure.resourcemanager.desktopvirtualization.DesktopVirtualizationManager manager() {
        return this.serviceManager;
    }

    private String resourceGroupName;

    private String scalingPlanName;

    private ScalingPlanPatch updateScalingPlan;

    public ScalingPlanImpl withExistingResourceGroup(String resourceGroupName) {
        this.resourceGroupName = resourceGroupName;
        return this;
    }

    public ScalingPlan create() {
        this.innerObject = serviceManager.serviceClient()
            .getScalingPlans()
            .createWithResponse(resourceGroupName, scalingPlanName, this.innerModel(), Context.NONE)
            .getValue();
        return this;
    }

    public ScalingPlan create(Context context) {
        this.innerObject = serviceManager.serviceClient()
            .getScalingPlans()
            .createWithResponse(resourceGroupName, scalingPlanName, this.innerModel(), context)
            .getValue();
        return this;
    }

    ScalingPlanImpl(String name,
        com.azure.resourcemanager.desktopvirtualization.DesktopVirtualizationManager serviceManager) {
        this.innerObject = new ScalingPlanInner();
        this.serviceManager = serviceManager;
        this.scalingPlanName = name;
    }

    public ScalingPlanImpl update() {
        this.updateScalingPlan = new ScalingPlanPatch();
        return this;
    }

    public ScalingPlan apply() {
        this.innerObject = serviceManager.serviceClient()
            .getScalingPlans()
            .updateWithResponse(resourceGroupName, scalingPlanName, updateScalingPlan, Context.NONE)
            .getValue();
        return this;
    }

    public ScalingPlan apply(Context context) {
        this.innerObject = serviceManager.serviceClient()
            .getScalingPlans()
            .updateWithResponse(resourceGroupName, scalingPlanName, updateScalingPlan, context)
            .getValue();
        return this;
    }

    ScalingPlanImpl(ScalingPlanInner innerObject,
        com.azure.resourcemanager.desktopvirtualization.DesktopVirtualizationManager serviceManager) {
        this.innerObject = innerObject;
        this.serviceManager = serviceManager;
        this.resourceGroupName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "resourceGroups");
        this.scalingPlanName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "scalingPlans");
    }

    public ScalingPlan refresh() {
        this.innerObject = serviceManager.serviceClient()
            .getScalingPlans()
            .getByResourceGroupWithResponse(resourceGroupName, scalingPlanName, Context.NONE)
            .getValue();
        return this;
    }

    public ScalingPlan refresh(Context context) {
        this.innerObject = serviceManager.serviceClient()
            .getScalingPlans()
            .getByResourceGroupWithResponse(resourceGroupName, scalingPlanName, context)
            .getValue();
        return this;
    }

    public ScalingPlanImpl withRegion(Region location) {
        this.innerModel().withLocation(location.toString());
        return this;
    }

    public ScalingPlanImpl withRegion(String location) {
        this.innerModel().withLocation(location);
        return this;
    }

    public ScalingPlanImpl withTimeZone(String timeZone) {
        if (isInCreateMode()) {
            this.innerModel().withTimeZone(timeZone);
            return this;
        } else {
            this.updateScalingPlan.withTimeZone(timeZone);
            return this;
        }
    }

    public ScalingPlanImpl withTags(Map tags) {
        if (isInCreateMode()) {
            this.innerModel().withTags(tags);
            return this;
        } else {
            this.updateScalingPlan.withTags(tags);
            return this;
        }
    }

    public ScalingPlanImpl withManagedBy(String managedBy) {
        this.innerModel().withManagedBy(managedBy);
        return this;
    }

    public ScalingPlanImpl withKind(String kind) {
        this.innerModel().withKind(kind);
        return this;
    }

    public ScalingPlanImpl withIdentity(ResourceModelWithAllowedPropertySetIdentity identity) {
        this.innerModel().withIdentity(identity);
        return this;
    }

    public ScalingPlanImpl withSku(ResourceModelWithAllowedPropertySetSku sku) {
        this.innerModel().withSku(sku);
        return this;
    }

    public ScalingPlanImpl withPlan(ResourceModelWithAllowedPropertySetPlan plan) {
        this.innerModel().withPlan(plan);
        return this;
    }

    public ScalingPlanImpl withDescription(String description) {
        if (isInCreateMode()) {
            this.innerModel().withDescription(description);
            return this;
        } else {
            this.updateScalingPlan.withDescription(description);
            return this;
        }
    }

    public ScalingPlanImpl withFriendlyName(String friendlyName) {
        if (isInCreateMode()) {
            this.innerModel().withFriendlyName(friendlyName);
            return this;
        } else {
            this.updateScalingPlan.withFriendlyName(friendlyName);
            return this;
        }
    }

    public ScalingPlanImpl withHostPoolType(ScalingHostPoolType hostPoolType) {
        this.innerModel().withHostPoolType(hostPoolType);
        return this;
    }

    public ScalingPlanImpl withExclusionTag(String exclusionTag) {
        if (isInCreateMode()) {
            this.innerModel().withExclusionTag(exclusionTag);
            return this;
        } else {
            this.updateScalingPlan.withExclusionTag(exclusionTag);
            return this;
        }
    }

    public ScalingPlanImpl withSchedules(List schedules) {
        if (isInCreateMode()) {
            this.innerModel().withSchedules(schedules);
            return this;
        } else {
            this.updateScalingPlan.withSchedules(schedules);
            return this;
        }
    }

    public ScalingPlanImpl withHostPoolReferences(List hostPoolReferences) {
        if (isInCreateMode()) {
            this.innerModel().withHostPoolReferences(hostPoolReferences);
            return this;
        } else {
            this.updateScalingPlan.withHostPoolReferences(hostPoolReferences);
            return this;
        }
    }

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy