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

com.azure.resourcemanager.desktopvirtualization.implementation.ScalingPlansImpl 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.http.rest.PagedIterable;
import com.azure.core.http.rest.Response;
import com.azure.core.http.rest.SimpleResponse;
import com.azure.core.util.Context;
import com.azure.core.util.logging.ClientLogger;
import com.azure.resourcemanager.desktopvirtualization.fluent.ScalingPlansClient;
import com.azure.resourcemanager.desktopvirtualization.fluent.models.ScalingPlanInner;
import com.azure.resourcemanager.desktopvirtualization.models.ScalingPlan;
import com.azure.resourcemanager.desktopvirtualization.models.ScalingPlans;

public final class ScalingPlansImpl implements ScalingPlans {
    private static final ClientLogger LOGGER = new ClientLogger(ScalingPlansImpl.class);

    private final ScalingPlansClient innerClient;

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

    public ScalingPlansImpl(ScalingPlansClient innerClient,
        com.azure.resourcemanager.desktopvirtualization.DesktopVirtualizationManager serviceManager) {
        this.innerClient = innerClient;
        this.serviceManager = serviceManager;
    }

    public Response getByResourceGroupWithResponse(String resourceGroupName, String scalingPlanName,
        Context context) {
        Response inner
            = this.serviceClient().getByResourceGroupWithResponse(resourceGroupName, scalingPlanName, context);
        if (inner != null) {
            return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(),
                new ScalingPlanImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public ScalingPlan getByResourceGroup(String resourceGroupName, String scalingPlanName) {
        ScalingPlanInner inner = this.serviceClient().getByResourceGroup(resourceGroupName, scalingPlanName);
        if (inner != null) {
            return new ScalingPlanImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public Response deleteByResourceGroupWithResponse(String resourceGroupName, String scalingPlanName,
        Context context) {
        return this.serviceClient().deleteWithResponse(resourceGroupName, scalingPlanName, context);
    }

    public void deleteByResourceGroup(String resourceGroupName, String scalingPlanName) {
        this.serviceClient().delete(resourceGroupName, scalingPlanName);
    }

    public PagedIterable listByResourceGroup(String resourceGroupName) {
        PagedIterable inner = this.serviceClient().listByResourceGroup(resourceGroupName);
        return ResourceManagerUtils.mapPage(inner, inner1 -> new ScalingPlanImpl(inner1, this.manager()));
    }

    public PagedIterable listByResourceGroup(String resourceGroupName, Integer pageSize,
        Boolean isDescending, Integer initialSkip, Context context) {
        PagedIterable inner
            = this.serviceClient().listByResourceGroup(resourceGroupName, pageSize, isDescending, initialSkip, context);
        return ResourceManagerUtils.mapPage(inner, inner1 -> new ScalingPlanImpl(inner1, this.manager()));
    }

    public PagedIterable list() {
        PagedIterable inner = this.serviceClient().list();
        return ResourceManagerUtils.mapPage(inner, inner1 -> new ScalingPlanImpl(inner1, this.manager()));
    }

    public PagedIterable list(Integer pageSize, Boolean isDescending, Integer initialSkip,
        Context context) {
        PagedIterable inner = this.serviceClient().list(pageSize, isDescending, initialSkip, context);
        return ResourceManagerUtils.mapPage(inner, inner1 -> new ScalingPlanImpl(inner1, this.manager()));
    }

    public PagedIterable listByHostPool(String resourceGroupName, String hostPoolName) {
        PagedIterable inner = this.serviceClient().listByHostPool(resourceGroupName, hostPoolName);
        return ResourceManagerUtils.mapPage(inner, inner1 -> new ScalingPlanImpl(inner1, this.manager()));
    }

    public PagedIterable listByHostPool(String resourceGroupName, String hostPoolName, Integer pageSize,
        Boolean isDescending, Integer initialSkip, Context context) {
        PagedIterable inner = this.serviceClient()
            .listByHostPool(resourceGroupName, hostPoolName, pageSize, isDescending, initialSkip, context);
        return ResourceManagerUtils.mapPage(inner, inner1 -> new ScalingPlanImpl(inner1, this.manager()));
    }

    public ScalingPlan getById(String id) {
        String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups");
        if (resourceGroupName == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(
                String.format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id)));
        }
        String scalingPlanName = ResourceManagerUtils.getValueFromIdByName(id, "scalingPlans");
        if (scalingPlanName == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(
                String.format("The resource ID '%s' is not valid. Missing path segment 'scalingPlans'.", id)));
        }
        return this.getByResourceGroupWithResponse(resourceGroupName, scalingPlanName, Context.NONE).getValue();
    }

    public Response getByIdWithResponse(String id, Context context) {
        String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups");
        if (resourceGroupName == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(
                String.format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id)));
        }
        String scalingPlanName = ResourceManagerUtils.getValueFromIdByName(id, "scalingPlans");
        if (scalingPlanName == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(
                String.format("The resource ID '%s' is not valid. Missing path segment 'scalingPlans'.", id)));
        }
        return this.getByResourceGroupWithResponse(resourceGroupName, scalingPlanName, context);
    }

    public void deleteById(String id) {
        String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups");
        if (resourceGroupName == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(
                String.format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id)));
        }
        String scalingPlanName = ResourceManagerUtils.getValueFromIdByName(id, "scalingPlans");
        if (scalingPlanName == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(
                String.format("The resource ID '%s' is not valid. Missing path segment 'scalingPlans'.", id)));
        }
        this.deleteByResourceGroupWithResponse(resourceGroupName, scalingPlanName, Context.NONE);
    }

    public Response deleteByIdWithResponse(String id, Context context) {
        String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups");
        if (resourceGroupName == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(
                String.format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id)));
        }
        String scalingPlanName = ResourceManagerUtils.getValueFromIdByName(id, "scalingPlans");
        if (scalingPlanName == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(
                String.format("The resource ID '%s' is not valid. Missing path segment 'scalingPlans'.", id)));
        }
        return this.deleteByResourceGroupWithResponse(resourceGroupName, scalingPlanName, context);
    }

    private ScalingPlansClient serviceClient() {
        return this.innerClient;
    }

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

    public ScalingPlanImpl define(String name) {
        return new ScalingPlanImpl(name, this.manager());
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy