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

com.azure.resourcemanager.advisor.implementation.SuppressionsImpl Maven / Gradle / Ivy

Go to download

This package contains Microsoft Azure SDK for Advisor Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. REST APIs for Azure Advisor. Package tag package-2020-01.

There is a newer version: 1.0.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.advisor.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.advisor.fluent.SuppressionsClient;
import com.azure.resourcemanager.advisor.fluent.models.SuppressionContractInner;
import com.azure.resourcemanager.advisor.models.SuppressionContract;
import com.azure.resourcemanager.advisor.models.Suppressions;

public final class SuppressionsImpl implements Suppressions {
    private static final ClientLogger LOGGER = new ClientLogger(SuppressionsImpl.class);

    private final SuppressionsClient innerClient;

    private final com.azure.resourcemanager.advisor.AdvisorManager serviceManager;

    public SuppressionsImpl(SuppressionsClient innerClient,
        com.azure.resourcemanager.advisor.AdvisorManager serviceManager) {
        this.innerClient = innerClient;
        this.serviceManager = serviceManager;
    }

    public Response getWithResponse(String resourceUri, String recommendationId, String name,
        Context context) {
        Response inner
            = this.serviceClient().getWithResponse(resourceUri, recommendationId, name, context);
        if (inner != null) {
            return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(),
                new SuppressionContractImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public SuppressionContract get(String resourceUri, String recommendationId, String name) {
        SuppressionContractInner inner = this.serviceClient().get(resourceUri, recommendationId, name);
        if (inner != null) {
            return new SuppressionContractImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public Response deleteWithResponse(String resourceUri, String recommendationId, String name,
        Context context) {
        return this.serviceClient().deleteWithResponse(resourceUri, recommendationId, name, context);
    }

    public void delete(String resourceUri, String recommendationId, String name) {
        this.serviceClient().delete(resourceUri, recommendationId, name);
    }

    public PagedIterable list() {
        PagedIterable inner = this.serviceClient().list();
        return ResourceManagerUtils.mapPage(inner, inner1 -> new SuppressionContractImpl(inner1, this.manager()));
    }

    public PagedIterable list(Integer top, String skipToken, Context context) {
        PagedIterable inner = this.serviceClient().list(top, skipToken, context);
        return ResourceManagerUtils.mapPage(inner, inner1 -> new SuppressionContractImpl(inner1, this.manager()));
    }

    public SuppressionContract getById(String id) {
        String resourceUri = ResourceManagerUtils.getValueFromIdByParameterName(id,
            "/{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}/suppressions/{name}",
            "resourceUri");
        if (resourceUri == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(
                String.format("The resource ID '%s' is not valid. Missing path segment 'resourceUri'.", id)));
        }
        String recommendationId = ResourceManagerUtils.getValueFromIdByParameterName(id,
            "/{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}/suppressions/{name}",
            "recommendationId");
        if (recommendationId == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(
                String.format("The resource ID '%s' is not valid. Missing path segment 'recommendations'.", id)));
        }
        String name = ResourceManagerUtils.getValueFromIdByParameterName(id,
            "/{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}/suppressions/{name}",
            "name");
        if (name == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(
                String.format("The resource ID '%s' is not valid. Missing path segment 'suppressions'.", id)));
        }
        return this.getWithResponse(resourceUri, recommendationId, name, Context.NONE).getValue();
    }

    public Response getByIdWithResponse(String id, Context context) {
        String resourceUri = ResourceManagerUtils.getValueFromIdByParameterName(id,
            "/{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}/suppressions/{name}",
            "resourceUri");
        if (resourceUri == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(
                String.format("The resource ID '%s' is not valid. Missing path segment 'resourceUri'.", id)));
        }
        String recommendationId = ResourceManagerUtils.getValueFromIdByParameterName(id,
            "/{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}/suppressions/{name}",
            "recommendationId");
        if (recommendationId == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(
                String.format("The resource ID '%s' is not valid. Missing path segment 'recommendations'.", id)));
        }
        String name = ResourceManagerUtils.getValueFromIdByParameterName(id,
            "/{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}/suppressions/{name}",
            "name");
        if (name == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(
                String.format("The resource ID '%s' is not valid. Missing path segment 'suppressions'.", id)));
        }
        return this.getWithResponse(resourceUri, recommendationId, name, context);
    }

    public void deleteById(String id) {
        String resourceUri = ResourceManagerUtils.getValueFromIdByParameterName(id,
            "/{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}/suppressions/{name}",
            "resourceUri");
        if (resourceUri == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(
                String.format("The resource ID '%s' is not valid. Missing path segment 'resourceUri'.", id)));
        }
        String recommendationId = ResourceManagerUtils.getValueFromIdByParameterName(id,
            "/{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}/suppressions/{name}",
            "recommendationId");
        if (recommendationId == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(
                String.format("The resource ID '%s' is not valid. Missing path segment 'recommendations'.", id)));
        }
        String name = ResourceManagerUtils.getValueFromIdByParameterName(id,
            "/{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}/suppressions/{name}",
            "name");
        if (name == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(
                String.format("The resource ID '%s' is not valid. Missing path segment 'suppressions'.", id)));
        }
        this.deleteWithResponse(resourceUri, recommendationId, name, Context.NONE);
    }

    public Response deleteByIdWithResponse(String id, Context context) {
        String resourceUri = ResourceManagerUtils.getValueFromIdByParameterName(id,
            "/{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}/suppressions/{name}",
            "resourceUri");
        if (resourceUri == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(
                String.format("The resource ID '%s' is not valid. Missing path segment 'resourceUri'.", id)));
        }
        String recommendationId = ResourceManagerUtils.getValueFromIdByParameterName(id,
            "/{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}/suppressions/{name}",
            "recommendationId");
        if (recommendationId == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(
                String.format("The resource ID '%s' is not valid. Missing path segment 'recommendations'.", id)));
        }
        String name = ResourceManagerUtils.getValueFromIdByParameterName(id,
            "/{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}/suppressions/{name}",
            "name");
        if (name == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(
                String.format("The resource ID '%s' is not valid. Missing path segment 'suppressions'.", id)));
        }
        return this.deleteWithResponse(resourceUri, recommendationId, name, context);
    }

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

    private com.azure.resourcemanager.advisor.AdvisorManager manager() {
        return this.serviceManager;
    }

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy