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

com.azure.resourcemanager.recoveryservicesbackup.implementation.ProtectionIntentsImpl Maven / Gradle / Ivy

Go to download

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.

There is a newer version: 1.5.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.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.ProtectionIntentsClient;
import com.azure.resourcemanager.recoveryservicesbackup.fluent.models.PreValidateEnableBackupResponseInner;
import com.azure.resourcemanager.recoveryservicesbackup.fluent.models.ProtectionIntentResourceInner;
import com.azure.resourcemanager.recoveryservicesbackup.models.PreValidateEnableBackupRequest;
import com.azure.resourcemanager.recoveryservicesbackup.models.PreValidateEnableBackupResponse;
import com.azure.resourcemanager.recoveryservicesbackup.models.ProtectionIntentResource;
import com.azure.resourcemanager.recoveryservicesbackup.models.ProtectionIntents;

public final class ProtectionIntentsImpl implements ProtectionIntents {
    private static final ClientLogger LOGGER = new ClientLogger(ProtectionIntentsImpl.class);

    private final ProtectionIntentsClient innerClient;

    private final com.azure.resourcemanager.recoveryservicesbackup.RecoveryServicesBackupManager serviceManager;

    public ProtectionIntentsImpl(ProtectionIntentsClient innerClient,
        com.azure.resourcemanager.recoveryservicesbackup.RecoveryServicesBackupManager serviceManager) {
        this.innerClient = innerClient;
        this.serviceManager = serviceManager;
    }

    public Response validateWithResponse(String azureRegion,
        PreValidateEnableBackupRequest parameters, Context context) {
        Response inner
            = this.serviceClient().validateWithResponse(azureRegion, parameters, context);
        if (inner != null) {
            return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(),
                new PreValidateEnableBackupResponseImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public PreValidateEnableBackupResponse validate(String azureRegion, PreValidateEnableBackupRequest parameters) {
        PreValidateEnableBackupResponseInner inner = this.serviceClient().validate(azureRegion, parameters);
        if (inner != null) {
            return new PreValidateEnableBackupResponseImpl(inner, this.manager());
        } else {
            return null;
        }
    }

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

    public ProtectionIntentResource get(String vaultName, String resourceGroupName, String fabricName,
        String intentObjectName) {
        ProtectionIntentResourceInner inner
            = this.serviceClient().get(vaultName, resourceGroupName, fabricName, intentObjectName);
        if (inner != null) {
            return new ProtectionIntentResourceImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public Response deleteWithResponse(String vaultName, String resourceGroupName, String fabricName,
        String intentObjectName, Context context) {
        return this.serviceClient().deleteWithResponse(vaultName, resourceGroupName, fabricName, intentObjectName,
            context);
    }

    public void delete(String vaultName, String resourceGroupName, String fabricName, String intentObjectName) {
        this.serviceClient().delete(vaultName, resourceGroupName, fabricName, intentObjectName);
    }

    public ProtectionIntentResource 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 fabricName = ResourceManagerUtils.getValueFromIdByName(id, "backupFabrics");
        if (fabricName == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(
                String.format("The resource ID '%s' is not valid. Missing path segment 'backupFabrics'.", id)));
        }
        String intentObjectName = ResourceManagerUtils.getValueFromIdByName(id, "backupProtectionIntent");
        if (intentObjectName == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(String
                .format("The resource ID '%s' is not valid. Missing path segment 'backupProtectionIntent'.", id)));
        }
        return this.getWithResponse(vaultName, resourceGroupName, fabricName, intentObjectName, 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 fabricName = ResourceManagerUtils.getValueFromIdByName(id, "backupFabrics");
        if (fabricName == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(
                String.format("The resource ID '%s' is not valid. Missing path segment 'backupFabrics'.", id)));
        }
        String intentObjectName = ResourceManagerUtils.getValueFromIdByName(id, "backupProtectionIntent");
        if (intentObjectName == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(String
                .format("The resource ID '%s' is not valid. Missing path segment 'backupProtectionIntent'.", id)));
        }
        return this.getWithResponse(vaultName, resourceGroupName, fabricName, intentObjectName, 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 fabricName = ResourceManagerUtils.getValueFromIdByName(id, "backupFabrics");
        if (fabricName == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(
                String.format("The resource ID '%s' is not valid. Missing path segment 'backupFabrics'.", id)));
        }
        String intentObjectName = ResourceManagerUtils.getValueFromIdByName(id, "backupProtectionIntent");
        if (intentObjectName == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(String
                .format("The resource ID '%s' is not valid. Missing path segment 'backupProtectionIntent'.", id)));
        }
        this.deleteWithResponse(vaultName, resourceGroupName, fabricName, intentObjectName, Context.NONE);
    }

    public Response 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 fabricName = ResourceManagerUtils.getValueFromIdByName(id, "backupFabrics");
        if (fabricName == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(
                String.format("The resource ID '%s' is not valid. Missing path segment 'backupFabrics'.", id)));
        }
        String intentObjectName = ResourceManagerUtils.getValueFromIdByName(id, "backupProtectionIntent");
        if (intentObjectName == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(String
                .format("The resource ID '%s' is not valid. Missing path segment 'backupProtectionIntent'.", id)));
        }
        return this.deleteWithResponse(vaultName, resourceGroupName, fabricName, intentObjectName, context);
    }

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

    private com.azure.resourcemanager.recoveryservicesbackup.RecoveryServicesBackupManager manager() {
        return this.serviceManager;
    }

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy