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

com.azure.resourcemanager.netapp.implementation.SubvolumesImpl Maven / Gradle / Ivy

Go to download

This package contains Microsoft Azure SDK for NetAppFiles Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. Microsoft NetApp Files Azure Resource Provider specification. Package tag package-2024-03.

There is a newer version: 1.4.0
Show 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.netapp.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.netapp.fluent.SubvolumesClient;
import com.azure.resourcemanager.netapp.fluent.models.SubvolumeInfoInner;
import com.azure.resourcemanager.netapp.fluent.models.SubvolumeModelInner;
import com.azure.resourcemanager.netapp.models.SubvolumeInfo;
import com.azure.resourcemanager.netapp.models.SubvolumeModel;
import com.azure.resourcemanager.netapp.models.Subvolumes;

public final class SubvolumesImpl implements Subvolumes {
    private static final ClientLogger LOGGER = new ClientLogger(SubvolumesImpl.class);

    private final SubvolumesClient innerClient;

    private final com.azure.resourcemanager.netapp.NetAppFilesManager serviceManager;

    public SubvolumesImpl(SubvolumesClient innerClient,
        com.azure.resourcemanager.netapp.NetAppFilesManager serviceManager) {
        this.innerClient = innerClient;
        this.serviceManager = serviceManager;
    }

    public PagedIterable listByVolume(String resourceGroupName, String accountName, String poolName,
        String volumeName) {
        PagedIterable inner
            = this.serviceClient().listByVolume(resourceGroupName, accountName, poolName, volumeName);
        return ResourceManagerUtils.mapPage(inner, inner1 -> new SubvolumeInfoImpl(inner1, this.manager()));
    }

    public PagedIterable listByVolume(String resourceGroupName, String accountName, String poolName,
        String volumeName, Context context) {
        PagedIterable inner
            = this.serviceClient().listByVolume(resourceGroupName, accountName, poolName, volumeName, context);
        return ResourceManagerUtils.mapPage(inner, inner1 -> new SubvolumeInfoImpl(inner1, this.manager()));
    }

    public Response getWithResponse(String resourceGroupName, String accountName, String poolName,
        String volumeName, String subvolumeName, Context context) {
        Response inner = this.serviceClient()
            .getWithResponse(resourceGroupName, accountName, poolName, volumeName, subvolumeName, context);
        if (inner != null) {
            return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(),
                new SubvolumeInfoImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public SubvolumeInfo get(String resourceGroupName, String accountName, String poolName, String volumeName,
        String subvolumeName) {
        SubvolumeInfoInner inner
            = this.serviceClient().get(resourceGroupName, accountName, poolName, volumeName, subvolumeName);
        if (inner != null) {
            return new SubvolumeInfoImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public void delete(String resourceGroupName, String accountName, String poolName, String volumeName,
        String subvolumeName) {
        this.serviceClient().delete(resourceGroupName, accountName, poolName, volumeName, subvolumeName);
    }

    public void delete(String resourceGroupName, String accountName, String poolName, String volumeName,
        String subvolumeName, Context context) {
        this.serviceClient().delete(resourceGroupName, accountName, poolName, volumeName, subvolumeName, context);
    }

    public SubvolumeModel getMetadata(String resourceGroupName, String accountName, String poolName, String volumeName,
        String subvolumeName) {
        SubvolumeModelInner inner
            = this.serviceClient().getMetadata(resourceGroupName, accountName, poolName, volumeName, subvolumeName);
        if (inner != null) {
            return new SubvolumeModelImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public SubvolumeModel getMetadata(String resourceGroupName, String accountName, String poolName, String volumeName,
        String subvolumeName, Context context) {
        SubvolumeModelInner inner = this.serviceClient()
            .getMetadata(resourceGroupName, accountName, poolName, volumeName, subvolumeName, context);
        if (inner != null) {
            return new SubvolumeModelImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public SubvolumeInfo 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 accountName = ResourceManagerUtils.getValueFromIdByName(id, "netAppAccounts");
        if (accountName == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(
                String.format("The resource ID '%s' is not valid. Missing path segment 'netAppAccounts'.", id)));
        }
        String poolName = ResourceManagerUtils.getValueFromIdByName(id, "capacityPools");
        if (poolName == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(
                String.format("The resource ID '%s' is not valid. Missing path segment 'capacityPools'.", id)));
        }
        String volumeName = ResourceManagerUtils.getValueFromIdByName(id, "volumes");
        if (volumeName == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(
                String.format("The resource ID '%s' is not valid. Missing path segment 'volumes'.", id)));
        }
        String subvolumeName = ResourceManagerUtils.getValueFromIdByName(id, "subvolumes");
        if (subvolumeName == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(
                String.format("The resource ID '%s' is not valid. Missing path segment 'subvolumes'.", id)));
        }
        return this.getWithResponse(resourceGroupName, accountName, poolName, volumeName, subvolumeName, 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 accountName = ResourceManagerUtils.getValueFromIdByName(id, "netAppAccounts");
        if (accountName == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(
                String.format("The resource ID '%s' is not valid. Missing path segment 'netAppAccounts'.", id)));
        }
        String poolName = ResourceManagerUtils.getValueFromIdByName(id, "capacityPools");
        if (poolName == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(
                String.format("The resource ID '%s' is not valid. Missing path segment 'capacityPools'.", id)));
        }
        String volumeName = ResourceManagerUtils.getValueFromIdByName(id, "volumes");
        if (volumeName == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(
                String.format("The resource ID '%s' is not valid. Missing path segment 'volumes'.", id)));
        }
        String subvolumeName = ResourceManagerUtils.getValueFromIdByName(id, "subvolumes");
        if (subvolumeName == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(
                String.format("The resource ID '%s' is not valid. Missing path segment 'subvolumes'.", id)));
        }
        return this.getWithResponse(resourceGroupName, accountName, poolName, volumeName, subvolumeName, 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 accountName = ResourceManagerUtils.getValueFromIdByName(id, "netAppAccounts");
        if (accountName == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(
                String.format("The resource ID '%s' is not valid. Missing path segment 'netAppAccounts'.", id)));
        }
        String poolName = ResourceManagerUtils.getValueFromIdByName(id, "capacityPools");
        if (poolName == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(
                String.format("The resource ID '%s' is not valid. Missing path segment 'capacityPools'.", id)));
        }
        String volumeName = ResourceManagerUtils.getValueFromIdByName(id, "volumes");
        if (volumeName == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(
                String.format("The resource ID '%s' is not valid. Missing path segment 'volumes'.", id)));
        }
        String subvolumeName = ResourceManagerUtils.getValueFromIdByName(id, "subvolumes");
        if (subvolumeName == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(
                String.format("The resource ID '%s' is not valid. Missing path segment 'subvolumes'.", id)));
        }
        this.delete(resourceGroupName, accountName, poolName, volumeName, subvolumeName, 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 accountName = ResourceManagerUtils.getValueFromIdByName(id, "netAppAccounts");
        if (accountName == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(
                String.format("The resource ID '%s' is not valid. Missing path segment 'netAppAccounts'.", id)));
        }
        String poolName = ResourceManagerUtils.getValueFromIdByName(id, "capacityPools");
        if (poolName == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(
                String.format("The resource ID '%s' is not valid. Missing path segment 'capacityPools'.", id)));
        }
        String volumeName = ResourceManagerUtils.getValueFromIdByName(id, "volumes");
        if (volumeName == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(
                String.format("The resource ID '%s' is not valid. Missing path segment 'volumes'.", id)));
        }
        String subvolumeName = ResourceManagerUtils.getValueFromIdByName(id, "subvolumes");
        if (subvolumeName == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(
                String.format("The resource ID '%s' is not valid. Missing path segment 'subvolumes'.", id)));
        }
        this.delete(resourceGroupName, accountName, poolName, volumeName, subvolumeName, context);
    }

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

    private com.azure.resourcemanager.netapp.NetAppFilesManager manager() {
        return this.serviceManager;
    }

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy