com.azure.resourcemanager.recoveryservicesbackup.implementation.ProtectionPoliciesImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of azure-resourcemanager-recoveryservicesbackup Show documentation
Show all versions of azure-resourcemanager-recoveryservicesbackup Show documentation
This package contains Microsoft Azure SDK for RecoveryServicesBackup Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. Open API 2.0 Specs for Azure RecoveryServices Backup service. Package tag package-2024-04.
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
package com.azure.resourcemanager.recoveryservicesbackup.implementation;
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.recoveryservicesbackup.fluent.ProtectionPoliciesClient;
import com.azure.resourcemanager.recoveryservicesbackup.fluent.models.ProtectionPolicyResourceInner;
import com.azure.resourcemanager.recoveryservicesbackup.models.ProtectionPolicies;
import com.azure.resourcemanager.recoveryservicesbackup.models.ProtectionPolicyResource;
public final class ProtectionPoliciesImpl implements ProtectionPolicies {
private static final ClientLogger LOGGER = new ClientLogger(ProtectionPoliciesImpl.class);
private final ProtectionPoliciesClient innerClient;
private final com.azure.resourcemanager.recoveryservicesbackup.RecoveryServicesBackupManager serviceManager;
public ProtectionPoliciesImpl(ProtectionPoliciesClient innerClient,
com.azure.resourcemanager.recoveryservicesbackup.RecoveryServicesBackupManager serviceManager) {
this.innerClient = innerClient;
this.serviceManager = serviceManager;
}
public Response getWithResponse(String vaultName, String resourceGroupName,
String policyName, Context context) {
Response inner
= this.serviceClient().getWithResponse(vaultName, resourceGroupName, policyName, context);
if (inner != null) {
return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(),
new ProtectionPolicyResourceImpl(inner.getValue(), this.manager()));
} else {
return null;
}
}
public ProtectionPolicyResource get(String vaultName, String resourceGroupName, String policyName) {
ProtectionPolicyResourceInner inner = this.serviceClient().get(vaultName, resourceGroupName, policyName);
if (inner != null) {
return new ProtectionPolicyResourceImpl(inner, this.manager());
} else {
return null;
}
}
public void delete(String vaultName, String resourceGroupName, String policyName) {
this.serviceClient().delete(vaultName, resourceGroupName, policyName);
}
public void delete(String vaultName, String resourceGroupName, String policyName, Context context) {
this.serviceClient().delete(vaultName, resourceGroupName, policyName, context);
}
public ProtectionPolicyResource getById(String id) {
String vaultName = ResourceManagerUtils.getValueFromIdByName(id, "vaults");
if (vaultName == null) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
String.format("The resource ID '%s' is not valid. Missing path segment 'vaults'.", 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 policyName = ResourceManagerUtils.getValueFromIdByName(id, "backupPolicies");
if (policyName == null) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
String.format("The resource ID '%s' is not valid. Missing path segment 'backupPolicies'.", id)));
}
return this.getWithResponse(vaultName, resourceGroupName, policyName, Context.NONE).getValue();
}
public Response getByIdWithResponse(String id, Context context) {
String vaultName = ResourceManagerUtils.getValueFromIdByName(id, "vaults");
if (vaultName == null) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
String.format("The resource ID '%s' is not valid. Missing path segment 'vaults'.", 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 policyName = ResourceManagerUtils.getValueFromIdByName(id, "backupPolicies");
if (policyName == null) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
String.format("The resource ID '%s' is not valid. Missing path segment 'backupPolicies'.", id)));
}
return this.getWithResponse(vaultName, resourceGroupName, policyName, context);
}
public void deleteById(String id) {
String vaultName = ResourceManagerUtils.getValueFromIdByName(id, "vaults");
if (vaultName == null) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
String.format("The resource ID '%s' is not valid. Missing path segment 'vaults'.", 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 policyName = ResourceManagerUtils.getValueFromIdByName(id, "backupPolicies");
if (policyName == null) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
String.format("The resource ID '%s' is not valid. Missing path segment 'backupPolicies'.", id)));
}
this.delete(vaultName, resourceGroupName, policyName, Context.NONE);
}
public void deleteByIdWithResponse(String id, Context context) {
String vaultName = ResourceManagerUtils.getValueFromIdByName(id, "vaults");
if (vaultName == null) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
String.format("The resource ID '%s' is not valid. Missing path segment 'vaults'.", 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 policyName = ResourceManagerUtils.getValueFromIdByName(id, "backupPolicies");
if (policyName == null) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
String.format("The resource ID '%s' is not valid. Missing path segment 'backupPolicies'.", id)));
}
this.delete(vaultName, resourceGroupName, policyName, context);
}
private ProtectionPoliciesClient serviceClient() {
return this.innerClient;
}
private com.azure.resourcemanager.recoveryservicesbackup.RecoveryServicesBackupManager manager() {
return this.serviceManager;
}
public ProtectionPolicyResourceImpl define(String name) {
return new ProtectionPolicyResourceImpl(name, this.manager());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy