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

com.azure.resourcemanager.hybridcompute.implementation.MachineExtensionImpl Maven / Gradle / Ivy

Go to download

This package contains Microsoft Azure SDK for HybridCompute Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. The Hybrid Compute Management Client. Package tag package-preview-2024-05.

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.hybridcompute.implementation;

import com.azure.core.management.Region;
import com.azure.core.management.SystemData;
import com.azure.core.util.Context;
import com.azure.resourcemanager.hybridcompute.fluent.models.MachineExtensionInner;
import com.azure.resourcemanager.hybridcompute.models.MachineExtension;
import com.azure.resourcemanager.hybridcompute.models.MachineExtensionProperties;
import com.azure.resourcemanager.hybridcompute.models.MachineExtensionUpdate;
import java.util.Collections;
import java.util.Map;

public final class MachineExtensionImpl
    implements MachineExtension, MachineExtension.Definition, MachineExtension.Update {
    private MachineExtensionInner innerObject;

    private final com.azure.resourcemanager.hybridcompute.HybridComputeManager 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 MachineExtensionProperties properties() {
        return this.innerModel().properties();
    }

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

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

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

    public String resourceGroupName() {
        return resourceGroupName;
    }

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

    private com.azure.resourcemanager.hybridcompute.HybridComputeManager manager() {
        return this.serviceManager;
    }

    private String resourceGroupName;

    private String machineName;

    private String extensionName;

    private MachineExtensionUpdate updateExtensionParameters;

    public MachineExtensionImpl withExistingMachine(String resourceGroupName, String machineName) {
        this.resourceGroupName = resourceGroupName;
        this.machineName = machineName;
        return this;
    }

    public MachineExtension create() {
        this.innerObject = serviceManager.serviceClient()
            .getMachineExtensions()
            .createOrUpdate(resourceGroupName, machineName, extensionName, this.innerModel(), Context.NONE);
        return this;
    }

    public MachineExtension create(Context context) {
        this.innerObject = serviceManager.serviceClient()
            .getMachineExtensions()
            .createOrUpdate(resourceGroupName, machineName, extensionName, this.innerModel(), context);
        return this;
    }

    MachineExtensionImpl(String name, com.azure.resourcemanager.hybridcompute.HybridComputeManager serviceManager) {
        this.innerObject = new MachineExtensionInner();
        this.serviceManager = serviceManager;
        this.extensionName = name;
    }

    public MachineExtensionImpl update() {
        this.updateExtensionParameters = new MachineExtensionUpdate();
        return this;
    }

    public MachineExtension apply() {
        this.innerObject = serviceManager.serviceClient()
            .getMachineExtensions()
            .update(resourceGroupName, machineName, extensionName, updateExtensionParameters, Context.NONE);
        return this;
    }

    public MachineExtension apply(Context context) {
        this.innerObject = serviceManager.serviceClient()
            .getMachineExtensions()
            .update(resourceGroupName, machineName, extensionName, updateExtensionParameters, context);
        return this;
    }

    MachineExtensionImpl(MachineExtensionInner innerObject,
        com.azure.resourcemanager.hybridcompute.HybridComputeManager serviceManager) {
        this.innerObject = innerObject;
        this.serviceManager = serviceManager;
        this.resourceGroupName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "resourceGroups");
        this.machineName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "machines");
        this.extensionName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "extensions");
    }

    public MachineExtension refresh() {
        this.innerObject = serviceManager.serviceClient()
            .getMachineExtensions()
            .getWithResponse(resourceGroupName, machineName, extensionName, Context.NONE)
            .getValue();
        return this;
    }

    public MachineExtension refresh(Context context) {
        this.innerObject = serviceManager.serviceClient()
            .getMachineExtensions()
            .getWithResponse(resourceGroupName, machineName, extensionName, context)
            .getValue();
        return this;
    }

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

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

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

    public MachineExtensionImpl withProperties(MachineExtensionProperties properties) {
        this.innerModel().withProperties(properties);
        return this;
    }

    public MachineExtensionImpl withForceUpdateTag(String forceUpdateTag) {
        this.updateExtensionParameters.withForceUpdateTag(forceUpdateTag);
        return this;
    }

    public MachineExtensionImpl withPublisher(String publisher) {
        this.updateExtensionParameters.withPublisher(publisher);
        return this;
    }

    public MachineExtensionImpl withType(String type) {
        this.updateExtensionParameters.withType(type);
        return this;
    }

    public MachineExtensionImpl withTypeHandlerVersion(String typeHandlerVersion) {
        this.updateExtensionParameters.withTypeHandlerVersion(typeHandlerVersion);
        return this;
    }

    public MachineExtensionImpl withEnableAutomaticUpgrade(Boolean enableAutomaticUpgrade) {
        this.updateExtensionParameters.withEnableAutomaticUpgrade(enableAutomaticUpgrade);
        return this;
    }

    public MachineExtensionImpl withAutoUpgradeMinorVersion(Boolean autoUpgradeMinorVersion) {
        this.updateExtensionParameters.withAutoUpgradeMinorVersion(autoUpgradeMinorVersion);
        return this;
    }

    public MachineExtensionImpl withSettings(Map settings) {
        this.updateExtensionParameters.withSettings(settings);
        return this;
    }

    public MachineExtensionImpl withProtectedSettings(Map protectedSettings) {
        this.updateExtensionParameters.withProtectedSettings(protectedSettings);
        return this;
    }

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy