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

com.azure.resourcemanager.devcenter.implementation.DevCentersImpl 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.devcenter.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.devcenter.fluent.DevCentersClient;
import com.azure.resourcemanager.devcenter.fluent.models.DevCenterInner;
import com.azure.resourcemanager.devcenter.models.DevCenter;
import com.azure.resourcemanager.devcenter.models.DevCenters;

public final class DevCentersImpl implements DevCenters {
    private static final ClientLogger LOGGER = new ClientLogger(DevCentersImpl.class);

    private final DevCentersClient innerClient;

    private final com.azure.resourcemanager.devcenter.DevCenterManager serviceManager;

    public DevCentersImpl(DevCentersClient innerClient,
        com.azure.resourcemanager.devcenter.DevCenterManager serviceManager) {
        this.innerClient = innerClient;
        this.serviceManager = serviceManager;
    }

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

    public PagedIterable list(Integer top, Context context) {
        PagedIterable inner = this.serviceClient().list(top, context);
        return ResourceManagerUtils.mapPage(inner, inner1 -> new DevCenterImpl(inner1, this.manager()));
    }

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

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

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

    public DevCenter getByResourceGroup(String resourceGroupName, String devCenterName) {
        DevCenterInner inner = this.serviceClient().getByResourceGroup(resourceGroupName, devCenterName);
        if (inner != null) {
            return new DevCenterImpl(inner, this.manager());
        } else {
            return null;
        }
    }

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

    public void delete(String resourceGroupName, String devCenterName, Context context) {
        this.serviceClient().delete(resourceGroupName, devCenterName, context);
    }

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

    public void 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 devCenterName = ResourceManagerUtils.getValueFromIdByName(id, "devcenters");
        if (devCenterName == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(
                String.format("The resource ID '%s' is not valid. Missing path segment 'devcenters'.", id)));
        }
        this.delete(resourceGroupName, devCenterName, context);
    }

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

    private com.azure.resourcemanager.devcenter.DevCenterManager manager() {
        return this.serviceManager;
    }

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy