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

com.azure.resourcemanager.appcontainers.implementation.SourceControlImpl 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.management.SystemData;
import com.azure.core.util.Context;
import com.azure.resourcemanager.appcontainers.fluent.models.SourceControlInner;
import com.azure.resourcemanager.appcontainers.models.GithubActionConfiguration;
import com.azure.resourcemanager.appcontainers.models.SourceControl;
import com.azure.resourcemanager.appcontainers.models.SourceControlOperationState;

public final class SourceControlImpl implements SourceControl, SourceControl.Definition, SourceControl.Update {
    private SourceControlInner innerObject;

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

    public String id() {
        return this.innerModel().id();
    }

    public String name() {
        return this.innerModel().name();
    }

    public String type() {
        return this.innerModel().type();
    }

    public SystemData systemData() {
        return this.innerModel().systemData();
    }

    public SourceControlOperationState operationState() {
        return this.innerModel().operationState();
    }

    public String repoUrl() {
        return this.innerModel().repoUrl();
    }

    public String branch() {
        return this.innerModel().branch();
    }

    public GithubActionConfiguration githubActionConfiguration() {
        return this.innerModel().githubActionConfiguration();
    }

    public String resourceGroupName() {
        return resourceGroupName;
    }

    public SourceControlInner innerModel() {
        return this.innerObject;
    }

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

    private String resourceGroupName;

    private String containerAppName;

    private String sourceControlName;

    private String createXMsGithubAuxiliary;

    private String updateXMsGithubAuxiliary;

    public SourceControlImpl withExistingContainerApp(String resourceGroupName, String containerAppName) {
        this.resourceGroupName = resourceGroupName;
        this.containerAppName = containerAppName;
        return this;
    }

    public SourceControl create() {
        this.innerObject = serviceManager.serviceClient()
            .getContainerAppsSourceControls()
            .createOrUpdate(resourceGroupName, containerAppName, sourceControlName, this.innerModel(),
                createXMsGithubAuxiliary, Context.NONE);
        return this;
    }

    public SourceControl create(Context context) {
        this.innerObject = serviceManager.serviceClient()
            .getContainerAppsSourceControls()
            .createOrUpdate(resourceGroupName, containerAppName, sourceControlName, this.innerModel(),
                createXMsGithubAuxiliary, context);
        return this;
    }

    SourceControlImpl(String name, com.azure.resourcemanager.appcontainers.ContainerAppsApiManager serviceManager) {
        this.innerObject = new SourceControlInner();
        this.serviceManager = serviceManager;
        this.sourceControlName = name;
        this.createXMsGithubAuxiliary = null;
    }

    public SourceControlImpl update() {
        this.updateXMsGithubAuxiliary = null;
        return this;
    }

    public SourceControl apply() {
        this.innerObject = serviceManager.serviceClient()
            .getContainerAppsSourceControls()
            .createOrUpdate(resourceGroupName, containerAppName, sourceControlName, this.innerModel(),
                updateXMsGithubAuxiliary, Context.NONE);
        return this;
    }

    public SourceControl apply(Context context) {
        this.innerObject = serviceManager.serviceClient()
            .getContainerAppsSourceControls()
            .createOrUpdate(resourceGroupName, containerAppName, sourceControlName, this.innerModel(),
                updateXMsGithubAuxiliary, context);
        return this;
    }

    SourceControlImpl(SourceControlInner innerObject,
        com.azure.resourcemanager.appcontainers.ContainerAppsApiManager serviceManager) {
        this.innerObject = innerObject;
        this.serviceManager = serviceManager;
        this.resourceGroupName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "resourceGroups");
        this.containerAppName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "containerApps");
        this.sourceControlName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "sourcecontrols");
    }

    public SourceControl refresh() {
        this.innerObject = serviceManager.serviceClient()
            .getContainerAppsSourceControls()
            .getWithResponse(resourceGroupName, containerAppName, sourceControlName, Context.NONE)
            .getValue();
        return this;
    }

    public SourceControl refresh(Context context) {
        this.innerObject = serviceManager.serviceClient()
            .getContainerAppsSourceControls()
            .getWithResponse(resourceGroupName, containerAppName, sourceControlName, context)
            .getValue();
        return this;
    }

    public SourceControlImpl withRepoUrl(String repoUrl) {
        this.innerModel().withRepoUrl(repoUrl);
        return this;
    }

    public SourceControlImpl withBranch(String branch) {
        this.innerModel().withBranch(branch);
        return this;
    }

    public SourceControlImpl withGithubActionConfiguration(GithubActionConfiguration githubActionConfiguration) {
        this.innerModel().withGithubActionConfiguration(githubActionConfiguration);
        return this;
    }

    public SourceControlImpl withXMsGithubAuxiliary(String xMsGithubAuxiliary) {
        if (isInCreateMode()) {
            this.createXMsGithubAuxiliary = xMsGithubAuxiliary;
            return this;
        } else {
            this.updateXMsGithubAuxiliary = xMsGithubAuxiliary;
            return this;
        }
    }

    private boolean isInCreateMode() {
        return this.innerModel().id() == null;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy