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

com.azure.resourcemanager.devcenter.implementation.NetworkConnectionImpl 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.NetworkConnectionInner;
import com.azure.resourcemanager.devcenter.models.DomainJoinType;
import com.azure.resourcemanager.devcenter.models.HealthCheckStatus;
import com.azure.resourcemanager.devcenter.models.NetworkConnection;
import com.azure.resourcemanager.devcenter.models.NetworkConnectionUpdate;
import com.azure.resourcemanager.devcenter.models.ProvisioningState;
import java.util.Collections;
import java.util.Map;

public final class NetworkConnectionImpl
    implements NetworkConnection, NetworkConnection.Definition, NetworkConnection.Update {
    private NetworkConnectionInner 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 SystemData systemData() {
        return this.innerModel().systemData();
    }

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

    public HealthCheckStatus healthCheckStatus() {
        return this.innerModel().healthCheckStatus();
    }

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

    public DomainJoinType domainJoinType() {
        return this.innerModel().domainJoinType();
    }

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

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

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

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

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

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

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

    public String resourceGroupName() {
        return resourceGroupName;
    }

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

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

    private String resourceGroupName;

    private String networkConnectionName;

    private NetworkConnectionUpdate updateBody;

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

    public NetworkConnection create() {
        this.innerObject = serviceManager.serviceClient()
            .getNetworkConnections()
            .createOrUpdate(resourceGroupName, networkConnectionName, this.innerModel(), Context.NONE);
        return this;
    }

    public NetworkConnection create(Context context) {
        this.innerObject = serviceManager.serviceClient()
            .getNetworkConnections()
            .createOrUpdate(resourceGroupName, networkConnectionName, this.innerModel(), context);
        return this;
    }

    NetworkConnectionImpl(String name, com.azure.resourcemanager.devcenter.DevCenterManager serviceManager) {
        this.innerObject = new NetworkConnectionInner();
        this.serviceManager = serviceManager;
        this.networkConnectionName = name;
    }

    public NetworkConnectionImpl update() {
        this.updateBody = new NetworkConnectionUpdate();
        return this;
    }

    public NetworkConnection apply() {
        this.innerObject = serviceManager.serviceClient()
            .getNetworkConnections()
            .update(resourceGroupName, networkConnectionName, updateBody, Context.NONE);
        return this;
    }

    public NetworkConnection apply(Context context) {
        this.innerObject = serviceManager.serviceClient()
            .getNetworkConnections()
            .update(resourceGroupName, networkConnectionName, updateBody, context);
        return this;
    }

    NetworkConnectionImpl(NetworkConnectionInner innerObject,
        com.azure.resourcemanager.devcenter.DevCenterManager serviceManager) {
        this.innerObject = innerObject;
        this.serviceManager = serviceManager;
        this.resourceGroupName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "resourceGroups");
        this.networkConnectionName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "networkConnections");
    }

    public NetworkConnection refresh() {
        this.innerObject = serviceManager.serviceClient()
            .getNetworkConnections()
            .getByResourceGroupWithResponse(resourceGroupName, networkConnectionName, Context.NONE)
            .getValue();
        return this;
    }

    public NetworkConnection refresh(Context context) {
        this.innerObject = serviceManager.serviceClient()
            .getNetworkConnections()
            .getByResourceGroupWithResponse(resourceGroupName, networkConnectionName, context)
            .getValue();
        return this;
    }

    public void runHealthChecks() {
        serviceManager.networkConnections().runHealthChecks(resourceGroupName, networkConnectionName);
    }

    public void runHealthChecks(Context context) {
        serviceManager.networkConnections().runHealthChecks(resourceGroupName, networkConnectionName, context);
    }

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

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

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

    public NetworkConnectionImpl withNetworkingResourceGroupName(String networkingResourceGroupName) {
        this.innerModel().withNetworkingResourceGroupName(networkingResourceGroupName);
        return this;
    }

    public NetworkConnectionImpl withDomainJoinType(DomainJoinType domainJoinType) {
        this.innerModel().withDomainJoinType(domainJoinType);
        return this;
    }

    public NetworkConnectionImpl withSubnetId(String subnetId) {
        if (isInCreateMode()) {
            this.innerModel().withSubnetId(subnetId);
            return this;
        } else {
            this.updateBody.withSubnetId(subnetId);
            return this;
        }
    }

    public NetworkConnectionImpl withDomainName(String domainName) {
        if (isInCreateMode()) {
            this.innerModel().withDomainName(domainName);
            return this;
        } else {
            this.updateBody.withDomainName(domainName);
            return this;
        }
    }

    public NetworkConnectionImpl withOrganizationUnit(String organizationUnit) {
        if (isInCreateMode()) {
            this.innerModel().withOrganizationUnit(organizationUnit);
            return this;
        } else {
            this.updateBody.withOrganizationUnit(organizationUnit);
            return this;
        }
    }

    public NetworkConnectionImpl withDomainUsername(String domainUsername) {
        if (isInCreateMode()) {
            this.innerModel().withDomainUsername(domainUsername);
            return this;
        } else {
            this.updateBody.withDomainUsername(domainUsername);
            return this;
        }
    }

    public NetworkConnectionImpl withDomainPassword(String domainPassword) {
        if (isInCreateMode()) {
            this.innerModel().withDomainPassword(domainPassword);
            return this;
        } else {
            this.updateBody.withDomainPassword(domainPassword);
            return this;
        }
    }

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy