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

com.azure.resourcemanager.appcontainers.implementation.ContainerAppsSourceControlsImpl Maven / Gradle / Ivy

Go to download

This package contains Microsoft Azure SDK for ContainerAppsApi Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. Package tag package-2024-03.

The 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.appcontainers.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.appcontainers.fluent.ContainerAppsSourceControlsClient;
import com.azure.resourcemanager.appcontainers.fluent.models.SourceControlInner;
import com.azure.resourcemanager.appcontainers.models.ContainerAppsSourceControls;
import com.azure.resourcemanager.appcontainers.models.SourceControl;

public final class ContainerAppsSourceControlsImpl implements ContainerAppsSourceControls {
    private static final ClientLogger LOGGER = new ClientLogger(ContainerAppsSourceControlsImpl.class);

    private final ContainerAppsSourceControlsClient innerClient;

    private final com.azure.resourcemanager.appcontainers.ContainerAppsApiManager serviceManager;

    public ContainerAppsSourceControlsImpl(ContainerAppsSourceControlsClient innerClient,
        com.azure.resourcemanager.appcontainers.ContainerAppsApiManager serviceManager) {
        this.innerClient = innerClient;
        this.serviceManager = serviceManager;
    }

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

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

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

    public SourceControl get(String resourceGroupName, String containerAppName, String sourceControlName) {
        SourceControlInner inner = this.serviceClient().get(resourceGroupName, containerAppName, sourceControlName);
        if (inner != null) {
            return new SourceControlImpl(inner, this.manager());
        } else {
            return null;
        }
    }

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

    public void delete(String resourceGroupName, String containerAppName, String sourceControlName,
        String xMsGithubAuxiliary, Boolean ignoreWorkflowDeletionFailure, Boolean deleteWorkflow, Context context) {
        this.serviceClient()
            .delete(resourceGroupName, containerAppName, sourceControlName, xMsGithubAuxiliary,
                ignoreWorkflowDeletionFailure, deleteWorkflow, context);
    }

    public SourceControl 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 containerAppName = ResourceManagerUtils.getValueFromIdByName(id, "containerApps");
        if (containerAppName == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(
                String.format("The resource ID '%s' is not valid. Missing path segment 'containerApps'.", id)));
        }
        String sourceControlName = ResourceManagerUtils.getValueFromIdByName(id, "sourcecontrols");
        if (sourceControlName == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(
                String.format("The resource ID '%s' is not valid. Missing path segment 'sourcecontrols'.", id)));
        }
        return this.getWithResponse(resourceGroupName, containerAppName, sourceControlName, 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 containerAppName = ResourceManagerUtils.getValueFromIdByName(id, "containerApps");
        if (containerAppName == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(
                String.format("The resource ID '%s' is not valid. Missing path segment 'containerApps'.", id)));
        }
        String sourceControlName = ResourceManagerUtils.getValueFromIdByName(id, "sourcecontrols");
        if (sourceControlName == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(
                String.format("The resource ID '%s' is not valid. Missing path segment 'sourcecontrols'.", id)));
        }
        return this.getWithResponse(resourceGroupName, containerAppName, sourceControlName, 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 containerAppName = ResourceManagerUtils.getValueFromIdByName(id, "containerApps");
        if (containerAppName == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(
                String.format("The resource ID '%s' is not valid. Missing path segment 'containerApps'.", id)));
        }
        String sourceControlName = ResourceManagerUtils.getValueFromIdByName(id, "sourcecontrols");
        if (sourceControlName == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(
                String.format("The resource ID '%s' is not valid. Missing path segment 'sourcecontrols'.", id)));
        }
        String localXMsGithubAuxiliary = null;
        Boolean localIgnoreWorkflowDeletionFailure = null;
        Boolean localDeleteWorkflow = null;
        this.delete(resourceGroupName, containerAppName, sourceControlName, localXMsGithubAuxiliary,
            localIgnoreWorkflowDeletionFailure, localDeleteWorkflow, Context.NONE);
    }

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

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

    private com.azure.resourcemanager.appcontainers.ContainerAppsApiManager manager() {
        return this.serviceManager;
    }

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy