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

com.azure.resourcemanager.desktopvirtualization.implementation.HostPoolsImpl 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.HostPoolsClient;
import com.azure.resourcemanager.desktopvirtualization.fluent.models.HostPoolInner;
import com.azure.resourcemanager.desktopvirtualization.fluent.models.RegistrationInfoInner;
import com.azure.resourcemanager.desktopvirtualization.fluent.models.RegistrationTokenListInner;
import com.azure.resourcemanager.desktopvirtualization.models.HostPool;
import com.azure.resourcemanager.desktopvirtualization.models.HostPools;
import com.azure.resourcemanager.desktopvirtualization.models.RegistrationInfo;
import com.azure.resourcemanager.desktopvirtualization.models.RegistrationTokenList;

public final class HostPoolsImpl implements HostPools {
    private static final ClientLogger LOGGER = new ClientLogger(HostPoolsImpl.class);

    private final HostPoolsClient innerClient;

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

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

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

    public HostPool getByResourceGroup(String resourceGroupName, String hostPoolName) {
        HostPoolInner inner = this.serviceClient().getByResourceGroup(resourceGroupName, hostPoolName);
        if (inner != null) {
            return new HostPoolImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public Response deleteWithResponse(String resourceGroupName, String hostPoolName, Boolean force,
        Context context) {
        return this.serviceClient().deleteWithResponse(resourceGroupName, hostPoolName, force, context);
    }

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

    public PagedIterable listByResourceGroup(String resourceGroupName) {
        PagedIterable inner = this.serviceClient().listByResourceGroup(resourceGroupName);
        return ResourceManagerUtils.mapPage(inner, inner1 -> new HostPoolImpl(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 HostPoolImpl(inner1, this.manager()));
    }

    public PagedIterable list() {
        PagedIterable inner = this.serviceClient().list();
        return ResourceManagerUtils.mapPage(inner, inner1 -> new HostPoolImpl(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 HostPoolImpl(inner1, this.manager()));
    }

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

    public RegistrationInfo retrieveRegistrationToken(String resourceGroupName, String hostPoolName) {
        RegistrationInfoInner inner = this.serviceClient().retrieveRegistrationToken(resourceGroupName, hostPoolName);
        if (inner != null) {
            return new RegistrationInfoImpl(inner, this.manager());
        } else {
            return null;
        }
    }

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

    public RegistrationTokenList listRegistrationTokens(String resourceGroupName, String hostPoolName) {
        RegistrationTokenListInner inner = this.serviceClient().listRegistrationTokens(resourceGroupName, hostPoolName);
        if (inner != null) {
            return new RegistrationTokenListImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public HostPool 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 hostPoolName = ResourceManagerUtils.getValueFromIdByName(id, "hostPools");
        if (hostPoolName == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(
                String.format("The resource ID '%s' is not valid. Missing path segment 'hostPools'.", id)));
        }
        return this.getByResourceGroupWithResponse(resourceGroupName, hostPoolName, 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 hostPoolName = ResourceManagerUtils.getValueFromIdByName(id, "hostPools");
        if (hostPoolName == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(
                String.format("The resource ID '%s' is not valid. Missing path segment 'hostPools'.", id)));
        }
        return this.getByResourceGroupWithResponse(resourceGroupName, hostPoolName, 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 hostPoolName = ResourceManagerUtils.getValueFromIdByName(id, "hostPools");
        if (hostPoolName == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(
                String.format("The resource ID '%s' is not valid. Missing path segment 'hostPools'.", id)));
        }
        Boolean localForce = null;
        this.deleteWithResponse(resourceGroupName, hostPoolName, localForce, Context.NONE);
    }

    public Response deleteByIdWithResponse(String id, Boolean force, 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 hostPoolName = ResourceManagerUtils.getValueFromIdByName(id, "hostPools");
        if (hostPoolName == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(
                String.format("The resource ID '%s' is not valid. Missing path segment 'hostPools'.", id)));
        }
        return this.deleteWithResponse(resourceGroupName, hostPoolName, force, context);
    }

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

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

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy