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

com.azure.resourcemanager.storagecache.implementation.StorageTargetsImpl Maven / Gradle / Ivy

Go to download

This package contains Microsoft Azure SDK for StorageCache Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. Azure Managed Lustre provides a fully managed Lustre® file system, integrated with Blob storage, for use on demand. These operations create and manage Azure Managed Lustre file systems. Package tag package-2024-03.

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.storagecache.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.storagecache.fluent.StorageTargetsClient;
import com.azure.resourcemanager.storagecache.fluent.models.StorageTargetInner;
import com.azure.resourcemanager.storagecache.models.StorageTarget;
import com.azure.resourcemanager.storagecache.models.StorageTargets;

public final class StorageTargetsImpl implements StorageTargets {
    private static final ClientLogger LOGGER = new ClientLogger(StorageTargetsImpl.class);

    private final StorageTargetsClient innerClient;

    private final com.azure.resourcemanager.storagecache.StorageCacheManager serviceManager;

    public StorageTargetsImpl(StorageTargetsClient innerClient,
        com.azure.resourcemanager.storagecache.StorageCacheManager serviceManager) {
        this.innerClient = innerClient;
        this.serviceManager = serviceManager;
    }

    public void dnsRefresh(String resourceGroupName, String cacheName, String storageTargetName) {
        this.serviceClient().dnsRefresh(resourceGroupName, cacheName, storageTargetName);
    }

    public void dnsRefresh(String resourceGroupName, String cacheName, String storageTargetName, Context context) {
        this.serviceClient().dnsRefresh(resourceGroupName, cacheName, storageTargetName, context);
    }

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

    public PagedIterable listByCache(String resourceGroupName, String cacheName, Context context) {
        PagedIterable inner
            = this.serviceClient().listByCache(resourceGroupName, cacheName, context);
        return ResourceManagerUtils.mapPage(inner, inner1 -> new StorageTargetImpl(inner1, this.manager()));
    }

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

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

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

    public StorageTarget get(String resourceGroupName, String cacheName, String storageTargetName) {
        StorageTargetInner inner = this.serviceClient().get(resourceGroupName, cacheName, storageTargetName);
        if (inner != null) {
            return new StorageTargetImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public void restoreDefaults(String resourceGroupName, String cacheName, String storageTargetName) {
        this.serviceClient().restoreDefaults(resourceGroupName, cacheName, storageTargetName);
    }

    public void restoreDefaults(String resourceGroupName, String cacheName, String storageTargetName, Context context) {
        this.serviceClient().restoreDefaults(resourceGroupName, cacheName, storageTargetName, context);
    }

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

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

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

    private com.azure.resourcemanager.storagecache.StorageCacheManager manager() {
        return this.serviceManager;
    }

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy