com.azure.resourcemanager.netapp.implementation.BackupVaultsImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of azure-resourcemanager-netapp Show documentation
Show all versions of azure-resourcemanager-netapp Show documentation
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.
// 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.BackupVaultsClient;
import com.azure.resourcemanager.netapp.fluent.models.BackupVaultInner;
import com.azure.resourcemanager.netapp.models.BackupVault;
import com.azure.resourcemanager.netapp.models.BackupVaults;
public final class BackupVaultsImpl implements BackupVaults {
private static final ClientLogger LOGGER = new ClientLogger(BackupVaultsImpl.class);
private final BackupVaultsClient innerClient;
private final com.azure.resourcemanager.netapp.NetAppFilesManager serviceManager;
public BackupVaultsImpl(BackupVaultsClient innerClient,
com.azure.resourcemanager.netapp.NetAppFilesManager serviceManager) {
this.innerClient = innerClient;
this.serviceManager = serviceManager;
}
public PagedIterable listByNetAppAccount(String resourceGroupName, String accountName) {
PagedIterable inner
= this.serviceClient().listByNetAppAccount(resourceGroupName, accountName);
return ResourceManagerUtils.mapPage(inner, inner1 -> new BackupVaultImpl(inner1, this.manager()));
}
public PagedIterable listByNetAppAccount(String resourceGroupName, String accountName,
Context context) {
PagedIterable inner
= this.serviceClient().listByNetAppAccount(resourceGroupName, accountName, context);
return ResourceManagerUtils.mapPage(inner, inner1 -> new BackupVaultImpl(inner1, this.manager()));
}
public Response getWithResponse(String resourceGroupName, String accountName, String backupVaultName,
Context context) {
Response inner
= this.serviceClient().getWithResponse(resourceGroupName, accountName, backupVaultName, context);
if (inner != null) {
return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(),
new BackupVaultImpl(inner.getValue(), this.manager()));
} else {
return null;
}
}
public BackupVault get(String resourceGroupName, String accountName, String backupVaultName) {
BackupVaultInner inner = this.serviceClient().get(resourceGroupName, accountName, backupVaultName);
if (inner != null) {
return new BackupVaultImpl(inner, this.manager());
} else {
return null;
}
}
public void delete(String resourceGroupName, String accountName, String backupVaultName) {
this.serviceClient().delete(resourceGroupName, accountName, backupVaultName);
}
public void delete(String resourceGroupName, String accountName, String backupVaultName, Context context) {
this.serviceClient().delete(resourceGroupName, accountName, backupVaultName, context);
}
public BackupVault 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 backupVaultName = ResourceManagerUtils.getValueFromIdByName(id, "backupVaults");
if (backupVaultName == null) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
String.format("The resource ID '%s' is not valid. Missing path segment 'backupVaults'.", id)));
}
return this.getWithResponse(resourceGroupName, accountName, backupVaultName, 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 backupVaultName = ResourceManagerUtils.getValueFromIdByName(id, "backupVaults");
if (backupVaultName == null) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
String.format("The resource ID '%s' is not valid. Missing path segment 'backupVaults'.", id)));
}
return this.getWithResponse(resourceGroupName, accountName, backupVaultName, 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 backupVaultName = ResourceManagerUtils.getValueFromIdByName(id, "backupVaults");
if (backupVaultName == null) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
String.format("The resource ID '%s' is not valid. Missing path segment 'backupVaults'.", id)));
}
this.delete(resourceGroupName, accountName, backupVaultName, 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 backupVaultName = ResourceManagerUtils.getValueFromIdByName(id, "backupVaults");
if (backupVaultName == null) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
String.format("The resource ID '%s' is not valid. Missing path segment 'backupVaults'.", id)));
}
this.delete(resourceGroupName, accountName, backupVaultName, context);
}
private BackupVaultsClient serviceClient() {
return this.innerClient;
}
private com.azure.resourcemanager.netapp.NetAppFilesManager manager() {
return this.serviceManager;
}
public BackupVaultImpl define(String name) {
return new BackupVaultImpl(name, this.manager());
}
}