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

com.azure.resourcemanager.relay.implementation.HybridConnectionsImpl Maven / Gradle / Ivy

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.resourcemanager.relay.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.relay.fluent.HybridConnectionsClient;
import com.azure.resourcemanager.relay.fluent.models.AccessKeysInner;
import com.azure.resourcemanager.relay.fluent.models.AuthorizationRuleInner;
import com.azure.resourcemanager.relay.fluent.models.HybridConnectionInner;
import com.azure.resourcemanager.relay.models.AccessKeys;
import com.azure.resourcemanager.relay.models.AuthorizationRule;
import com.azure.resourcemanager.relay.models.HybridConnection;
import com.azure.resourcemanager.relay.models.HybridConnections;
import com.azure.resourcemanager.relay.models.RegenerateAccessKeyParameters;

public final class HybridConnectionsImpl implements HybridConnections {
    private static final ClientLogger LOGGER = new ClientLogger(HybridConnectionsImpl.class);

    private final HybridConnectionsClient innerClient;

    private final com.azure.resourcemanager.relay.RelayManager serviceManager;

    public HybridConnectionsImpl(HybridConnectionsClient innerClient,
        com.azure.resourcemanager.relay.RelayManager serviceManager) {
        this.innerClient = innerClient;
        this.serviceManager = serviceManager;
    }

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

    public PagedIterable listByNamespace(String resourceGroupName, String namespaceName,
        Context context) {
        PagedIterable inner
            = this.serviceClient().listByNamespace(resourceGroupName, namespaceName, context);
        return ResourceManagerUtils.mapPage(inner, inner1 -> new HybridConnectionImpl(inner1, this.manager()));
    }

    public Response deleteWithResponse(String resourceGroupName, String namespaceName,
        String hybridConnectionName, Context context) {
        return this.serviceClient().deleteWithResponse(resourceGroupName, namespaceName, hybridConnectionName, context);
    }

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

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

    public HybridConnection get(String resourceGroupName, String namespaceName, String hybridConnectionName) {
        HybridConnectionInner inner = this.serviceClient().get(resourceGroupName, namespaceName, hybridConnectionName);
        if (inner != null) {
            return new HybridConnectionImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public PagedIterable listAuthorizationRules(String resourceGroupName, String namespaceName,
        String hybridConnectionName) {
        PagedIterable inner
            = this.serviceClient().listAuthorizationRules(resourceGroupName, namespaceName, hybridConnectionName);
        return ResourceManagerUtils.mapPage(inner, inner1 -> new AuthorizationRuleImpl(inner1, this.manager()));
    }

    public PagedIterable listAuthorizationRules(String resourceGroupName, String namespaceName,
        String hybridConnectionName, Context context) {
        PagedIterable inner = this.serviceClient()
            .listAuthorizationRules(resourceGroupName, namespaceName, hybridConnectionName, context);
        return ResourceManagerUtils.mapPage(inner, inner1 -> new AuthorizationRuleImpl(inner1, this.manager()));
    }

    public Response createOrUpdateAuthorizationRuleWithResponse(String resourceGroupName,
        String namespaceName, String hybridConnectionName, String authorizationRuleName,
        AuthorizationRuleInner parameters, Context context) {
        Response inner = this.serviceClient()
            .createOrUpdateAuthorizationRuleWithResponse(resourceGroupName, namespaceName, hybridConnectionName,
                authorizationRuleName, parameters, context);
        if (inner != null) {
            return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(),
                new AuthorizationRuleImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public AuthorizationRule createOrUpdateAuthorizationRule(String resourceGroupName, String namespaceName,
        String hybridConnectionName, String authorizationRuleName, AuthorizationRuleInner parameters) {
        AuthorizationRuleInner inner = this.serviceClient()
            .createOrUpdateAuthorizationRule(resourceGroupName, namespaceName, hybridConnectionName,
                authorizationRuleName, parameters);
        if (inner != null) {
            return new AuthorizationRuleImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public Response deleteAuthorizationRuleWithResponse(String resourceGroupName, String namespaceName,
        String hybridConnectionName, String authorizationRuleName, Context context) {
        return this.serviceClient()
            .deleteAuthorizationRuleWithResponse(resourceGroupName, namespaceName, hybridConnectionName,
                authorizationRuleName, context);
    }

    public void deleteAuthorizationRule(String resourceGroupName, String namespaceName, String hybridConnectionName,
        String authorizationRuleName) {
        this.serviceClient()
            .deleteAuthorizationRule(resourceGroupName, namespaceName, hybridConnectionName, authorizationRuleName);
    }

    public Response getAuthorizationRuleWithResponse(String resourceGroupName, String namespaceName,
        String hybridConnectionName, String authorizationRuleName, Context context) {
        Response inner = this.serviceClient()
            .getAuthorizationRuleWithResponse(resourceGroupName, namespaceName, hybridConnectionName,
                authorizationRuleName, context);
        if (inner != null) {
            return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(),
                new AuthorizationRuleImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public AuthorizationRule getAuthorizationRule(String resourceGroupName, String namespaceName,
        String hybridConnectionName, String authorizationRuleName) {
        AuthorizationRuleInner inner = this.serviceClient()
            .getAuthorizationRule(resourceGroupName, namespaceName, hybridConnectionName, authorizationRuleName);
        if (inner != null) {
            return new AuthorizationRuleImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public Response listKeysWithResponse(String resourceGroupName, String namespaceName,
        String hybridConnectionName, String authorizationRuleName, Context context) {
        Response inner = this.serviceClient()
            .listKeysWithResponse(resourceGroupName, namespaceName, hybridConnectionName, authorizationRuleName,
                context);
        if (inner != null) {
            return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(),
                new AccessKeysImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public AccessKeys listKeys(String resourceGroupName, String namespaceName, String hybridConnectionName,
        String authorizationRuleName) {
        AccessKeysInner inner = this.serviceClient()
            .listKeys(resourceGroupName, namespaceName, hybridConnectionName, authorizationRuleName);
        if (inner != null) {
            return new AccessKeysImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public Response regenerateKeysWithResponse(String resourceGroupName, String namespaceName,
        String hybridConnectionName, String authorizationRuleName, RegenerateAccessKeyParameters parameters,
        Context context) {
        Response inner = this.serviceClient()
            .regenerateKeysWithResponse(resourceGroupName, namespaceName, hybridConnectionName, authorizationRuleName,
                parameters, context);
        if (inner != null) {
            return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(),
                new AccessKeysImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public AccessKeys regenerateKeys(String resourceGroupName, String namespaceName, String hybridConnectionName,
        String authorizationRuleName, RegenerateAccessKeyParameters parameters) {
        AccessKeysInner inner = this.serviceClient()
            .regenerateKeys(resourceGroupName, namespaceName, hybridConnectionName, authorizationRuleName, parameters);
        if (inner != null) {
            return new AccessKeysImpl(inner, this.manager());
        } else {
            return null;
        }
    }

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

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

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

    private com.azure.resourcemanager.relay.RelayManager manager() {
        return this.serviceManager;
    }

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy