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

com.azure.resourcemanager.dnsresolver.implementation.DnsResolverPoliciesImpl Maven / Gradle / Ivy

Go to download

This package contains Microsoft Azure SDK for DnsResolver Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. The DNS Resolver Management Client. Package tag package-2022-07.

There is a newer version: 1.0.0-beta.3
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.dnsresolver.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.management.SubResource;
import com.azure.core.util.Context;
import com.azure.core.util.logging.ClientLogger;
import com.azure.resourcemanager.dnsresolver.fluent.DnsResolverPoliciesClient;
import com.azure.resourcemanager.dnsresolver.fluent.models.DnsResolverPolicyInner;
import com.azure.resourcemanager.dnsresolver.models.DnsResolverPolicies;
import com.azure.resourcemanager.dnsresolver.models.DnsResolverPolicy;

public final class DnsResolverPoliciesImpl implements DnsResolverPolicies {
    private static final ClientLogger LOGGER = new ClientLogger(DnsResolverPoliciesImpl.class);

    private final DnsResolverPoliciesClient innerClient;

    private final com.azure.resourcemanager.dnsresolver.DnsResolverManager serviceManager;

    public DnsResolverPoliciesImpl(DnsResolverPoliciesClient innerClient,
        com.azure.resourcemanager.dnsresolver.DnsResolverManager serviceManager) {
        this.innerClient = innerClient;
        this.serviceManager = serviceManager;
    }

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

    public void delete(String resourceGroupName, String dnsResolverPolicyName, String ifMatch, Context context) {
        this.serviceClient().delete(resourceGroupName, dnsResolverPolicyName, ifMatch, context);
    }

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

    public DnsResolverPolicy getByResourceGroup(String resourceGroupName, String dnsResolverPolicyName) {
        DnsResolverPolicyInner inner
            = this.serviceClient().getByResourceGroup(resourceGroupName, dnsResolverPolicyName);
        if (inner != null) {
            return new DnsResolverPolicyImpl(inner, this.manager());
        } else {
            return null;
        }
    }

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

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

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

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

    public PagedIterable listByVirtualNetwork(String resourceGroupName, String virtualNetworkName) {
        return this.serviceClient().listByVirtualNetwork(resourceGroupName, virtualNetworkName);
    }

    public PagedIterable listByVirtualNetwork(String resourceGroupName, String virtualNetworkName,
        Context context) {
        return this.serviceClient().listByVirtualNetwork(resourceGroupName, virtualNetworkName, context);
    }

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

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

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

    private com.azure.resourcemanager.dnsresolver.DnsResolverManager manager() {
        return this.serviceManager;
    }

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy