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

com.azure.resourcemanager.devcenter.implementation.DevCenterImpl 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.devcenter.implementation;

import com.azure.core.management.Region;
import com.azure.core.management.SystemData;
import com.azure.core.util.Context;
import com.azure.resourcemanager.devcenter.fluent.models.DevCenterInner;
import com.azure.resourcemanager.devcenter.models.DevCenter;
import com.azure.resourcemanager.devcenter.models.DevCenterProjectCatalogSettings;
import com.azure.resourcemanager.devcenter.models.DevCenterUpdate;
import com.azure.resourcemanager.devcenter.models.Encryption;
import com.azure.resourcemanager.devcenter.models.ManagedServiceIdentity;
import com.azure.resourcemanager.devcenter.models.ProvisioningState;
import java.util.Collections;
import java.util.Map;

public final class DevCenterImpl implements DevCenter, DevCenter.Definition, DevCenter.Update {
    private DevCenterInner innerObject;

    private final com.azure.resourcemanager.devcenter.DevCenterManager serviceManager;

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

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

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

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

    public Map tags() {
        Map inner = this.innerModel().tags();
        if (inner != null) {
            return Collections.unmodifiableMap(inner);
        } else {
            return Collections.emptyMap();
        }
    }

    public ManagedServiceIdentity identity() {
        return this.innerModel().identity();
    }

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

    public ProvisioningState provisioningState() {
        return this.innerModel().provisioningState();
    }

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

    public Encryption encryption() {
        return this.innerModel().encryption();
    }

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

    public DevCenterProjectCatalogSettings projectCatalogSettings() {
        return this.innerModel().projectCatalogSettings();
    }

    public Region region() {
        return Region.fromName(this.regionName());
    }

    public String regionName() {
        return this.location();
    }

    public String resourceGroupName() {
        return resourceGroupName;
    }

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

    private com.azure.resourcemanager.devcenter.DevCenterManager manager() {
        return this.serviceManager;
    }

    private String resourceGroupName;

    private String devCenterName;

    private DevCenterUpdate updateBody;

    public DevCenterImpl withExistingResourceGroup(String resourceGroupName) {
        this.resourceGroupName = resourceGroupName;
        return this;
    }

    public DevCenter create() {
        this.innerObject = serviceManager.serviceClient()
            .getDevCenters()
            .createOrUpdate(resourceGroupName, devCenterName, this.innerModel(), Context.NONE);
        return this;
    }

    public DevCenter create(Context context) {
        this.innerObject = serviceManager.serviceClient()
            .getDevCenters()
            .createOrUpdate(resourceGroupName, devCenterName, this.innerModel(), context);
        return this;
    }

    DevCenterImpl(String name, com.azure.resourcemanager.devcenter.DevCenterManager serviceManager) {
        this.innerObject = new DevCenterInner();
        this.serviceManager = serviceManager;
        this.devCenterName = name;
    }

    public DevCenterImpl update() {
        this.updateBody = new DevCenterUpdate();
        return this;
    }

    public DevCenter apply() {
        this.innerObject = serviceManager.serviceClient()
            .getDevCenters()
            .update(resourceGroupName, devCenterName, updateBody, Context.NONE);
        return this;
    }

    public DevCenter apply(Context context) {
        this.innerObject = serviceManager.serviceClient()
            .getDevCenters()
            .update(resourceGroupName, devCenterName, updateBody, context);
        return this;
    }

    DevCenterImpl(DevCenterInner innerObject, com.azure.resourcemanager.devcenter.DevCenterManager serviceManager) {
        this.innerObject = innerObject;
        this.serviceManager = serviceManager;
        this.resourceGroupName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "resourceGroups");
        this.devCenterName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "devcenters");
    }

    public DevCenter refresh() {
        this.innerObject = serviceManager.serviceClient()
            .getDevCenters()
            .getByResourceGroupWithResponse(resourceGroupName, devCenterName, Context.NONE)
            .getValue();
        return this;
    }

    public DevCenter refresh(Context context) {
        this.innerObject = serviceManager.serviceClient()
            .getDevCenters()
            .getByResourceGroupWithResponse(resourceGroupName, devCenterName, context)
            .getValue();
        return this;
    }

    public DevCenterImpl withRegion(Region location) {
        this.innerModel().withLocation(location.toString());
        return this;
    }

    public DevCenterImpl withRegion(String location) {
        this.innerModel().withLocation(location);
        return this;
    }

    public DevCenterImpl withTags(Map tags) {
        if (isInCreateMode()) {
            this.innerModel().withTags(tags);
            return this;
        } else {
            this.updateBody.withTags(tags);
            return this;
        }
    }

    public DevCenterImpl withIdentity(ManagedServiceIdentity identity) {
        if (isInCreateMode()) {
            this.innerModel().withIdentity(identity);
            return this;
        } else {
            this.updateBody.withIdentity(identity);
            return this;
        }
    }

    public DevCenterImpl withEncryption(Encryption encryption) {
        if (isInCreateMode()) {
            this.innerModel().withEncryption(encryption);
            return this;
        } else {
            this.updateBody.withEncryption(encryption);
            return this;
        }
    }

    public DevCenterImpl withDisplayName(String displayName) {
        if (isInCreateMode()) {
            this.innerModel().withDisplayName(displayName);
            return this;
        } else {
            this.updateBody.withDisplayName(displayName);
            return this;
        }
    }

    public DevCenterImpl withProjectCatalogSettings(DevCenterProjectCatalogSettings projectCatalogSettings) {
        if (isInCreateMode()) {
            this.innerModel().withProjectCatalogSettings(projectCatalogSettings);
            return this;
        } else {
            this.updateBody.withProjectCatalogSettings(projectCatalogSettings);
            return this;
        }
    }

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy