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

com.azure.resourcemanager.migrationdiscoverysap.implementation.ServerInstanceImpl Maven / Gradle / Ivy

Go to download

This package contains Microsoft Azure SDK for MigrationDiscoverySap Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. Migration Discovery SAP Client. Package tag package-preview-2023-10.

There is a newer version: 1.0.0-beta.2
Show 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.migrationdiscoverysap.implementation;

import com.azure.core.management.SystemData;
import com.azure.core.util.Context;
import com.azure.resourcemanager.migrationdiscoverysap.fluent.models.ServerInstanceInner;
import com.azure.resourcemanager.migrationdiscoverysap.models.ServerInstance;
import com.azure.resourcemanager.migrationdiscoverysap.models.ServerInstanceProperties;
import com.azure.resourcemanager.migrationdiscoverysap.models.UpdateServerInstanceRequest;

public final class ServerInstanceImpl implements ServerInstance, ServerInstance.Definition, ServerInstance.Update {
    private ServerInstanceInner innerObject;

    private final com.azure.resourcemanager.migrationdiscoverysap.MigrationDiscoverySapManager serviceManager;

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

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

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

    public ServerInstanceProperties properties() {
        return this.innerModel().properties();
    }

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

    public String resourceGroupName() {
        return resourceGroupName;
    }

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

    private com.azure.resourcemanager.migrationdiscoverysap.MigrationDiscoverySapManager manager() {
        return this.serviceManager;
    }

    private String resourceGroupName;

    private String sapDiscoverySiteName;

    private String sapInstanceName;

    private String serverInstanceName;

    private UpdateServerInstanceRequest updateProperties;

    public ServerInstanceImpl withExistingSapInstance(String resourceGroupName, String sapDiscoverySiteName,
        String sapInstanceName) {
        this.resourceGroupName = resourceGroupName;
        this.sapDiscoverySiteName = sapDiscoverySiteName;
        this.sapInstanceName = sapInstanceName;
        return this;
    }

    public ServerInstance create() {
        this.innerObject = serviceManager.serviceClient().getServerInstances().create(resourceGroupName,
            sapDiscoverySiteName, sapInstanceName, serverInstanceName, this.innerModel(), Context.NONE);
        return this;
    }

    public ServerInstance create(Context context) {
        this.innerObject = serviceManager.serviceClient().getServerInstances().create(resourceGroupName,
            sapDiscoverySiteName, sapInstanceName, serverInstanceName, this.innerModel(), context);
        return this;
    }

    ServerInstanceImpl(String name,
        com.azure.resourcemanager.migrationdiscoverysap.MigrationDiscoverySapManager serviceManager) {
        this.innerObject = new ServerInstanceInner();
        this.serviceManager = serviceManager;
        this.serverInstanceName = name;
    }

    public ServerInstanceImpl update() {
        this.updateProperties = new UpdateServerInstanceRequest();
        return this;
    }

    public ServerInstance apply() {
        this.innerObject = serviceManager.serviceClient().getServerInstances().updateWithResponse(resourceGroupName,
            sapDiscoverySiteName, sapInstanceName, serverInstanceName, updateProperties, Context.NONE).getValue();
        return this;
    }

    public ServerInstance apply(Context context) {
        this.innerObject = serviceManager.serviceClient().getServerInstances().updateWithResponse(resourceGroupName,
            sapDiscoverySiteName, sapInstanceName, serverInstanceName, updateProperties, context).getValue();
        return this;
    }

    ServerInstanceImpl(ServerInstanceInner innerObject,
        com.azure.resourcemanager.migrationdiscoverysap.MigrationDiscoverySapManager serviceManager) {
        this.innerObject = innerObject;
        this.serviceManager = serviceManager;
        this.resourceGroupName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "resourceGroups");
        this.sapDiscoverySiteName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "sapDiscoverySites");
        this.sapInstanceName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "sapInstances");
        this.serverInstanceName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "serverInstances");
    }

    public ServerInstance refresh() {
        this.innerObject = serviceManager.serviceClient().getServerInstances()
            .getWithResponse(resourceGroupName, sapDiscoverySiteName, sapInstanceName, serverInstanceName, Context.NONE)
            .getValue();
        return this;
    }

    public ServerInstance refresh(Context context) {
        this.innerObject = serviceManager.serviceClient().getServerInstances()
            .getWithResponse(resourceGroupName, sapDiscoverySiteName, sapInstanceName, serverInstanceName, context)
            .getValue();
        return this;
    }

    public ServerInstanceImpl withProperties(ServerInstanceProperties properties) {
        if (isInCreateMode()) {
            this.innerModel().withProperties(properties);
            return this;
        } else {
            this.updateProperties.withProperties(properties);
            return this;
        }
    }

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy