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

com.azure.resourcemanager.webpubsub.implementation.ReplicaImpl 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.webpubsub.implementation;

import com.azure.core.management.Region;
import com.azure.core.management.SystemData;
import com.azure.core.util.Context;
import com.azure.resourcemanager.webpubsub.fluent.models.ReplicaInner;
import com.azure.resourcemanager.webpubsub.models.ProvisioningState;
import com.azure.resourcemanager.webpubsub.models.Replica;
import com.azure.resourcemanager.webpubsub.models.ResourceSku;
import java.util.Collections;
import java.util.Map;

public final class ReplicaImpl implements Replica, Replica.Definition, Replica.Update {
    private ReplicaInner innerObject;

    private final com.azure.resourcemanager.webpubsub.WebPubSubManager 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 ResourceSku sku() {
        return this.innerModel().sku();
    }

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

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

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

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

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

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

    public String resourceGroupName() {
        return resourceGroupName;
    }

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

    private com.azure.resourcemanager.webpubsub.WebPubSubManager manager() {
        return this.serviceManager;
    }

    private String resourceGroupName;

    private String resourceName;

    private String replicaName;

    public ReplicaImpl withExistingWebPubSub(String resourceGroupName, String resourceName) {
        this.resourceGroupName = resourceGroupName;
        this.resourceName = resourceName;
        return this;
    }

    public Replica create() {
        this.innerObject = serviceManager.serviceClient()
            .getWebPubSubReplicas()
            .createOrUpdate(resourceGroupName, resourceName, replicaName, this.innerModel(), Context.NONE);
        return this;
    }

    public Replica create(Context context) {
        this.innerObject = serviceManager.serviceClient()
            .getWebPubSubReplicas()
            .createOrUpdate(resourceGroupName, resourceName, replicaName, this.innerModel(), context);
        return this;
    }

    ReplicaImpl(String name, com.azure.resourcemanager.webpubsub.WebPubSubManager serviceManager) {
        this.innerObject = new ReplicaInner();
        this.serviceManager = serviceManager;
        this.replicaName = name;
    }

    public ReplicaImpl update() {
        return this;
    }

    public Replica apply() {
        this.innerObject = serviceManager.serviceClient()
            .getWebPubSubReplicas()
            .update(resourceGroupName, resourceName, replicaName, this.innerModel(), Context.NONE);
        return this;
    }

    public Replica apply(Context context) {
        this.innerObject = serviceManager.serviceClient()
            .getWebPubSubReplicas()
            .update(resourceGroupName, resourceName, replicaName, this.innerModel(), context);
        return this;
    }

    ReplicaImpl(ReplicaInner innerObject, com.azure.resourcemanager.webpubsub.WebPubSubManager serviceManager) {
        this.innerObject = innerObject;
        this.serviceManager = serviceManager;
        this.resourceGroupName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "resourceGroups");
        this.resourceName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "webPubSub");
        this.replicaName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "replicas");
    }

    public Replica refresh() {
        this.innerObject = serviceManager.serviceClient()
            .getWebPubSubReplicas()
            .getWithResponse(resourceGroupName, resourceName, replicaName, Context.NONE)
            .getValue();
        return this;
    }

    public Replica refresh(Context context) {
        this.innerObject = serviceManager.serviceClient()
            .getWebPubSubReplicas()
            .getWithResponse(resourceGroupName, resourceName, replicaName, context)
            .getValue();
        return this;
    }

    public void restart() {
        serviceManager.webPubSubReplicas().restart(resourceGroupName, resourceName, replicaName);
    }

    public void restart(Context context) {
        serviceManager.webPubSubReplicas().restart(resourceGroupName, resourceName, replicaName, context);
    }

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

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

    public ReplicaImpl withTags(Map tags) {
        this.innerModel().withTags(tags);
        return this;
    }

    public ReplicaImpl withSku(ResourceSku sku) {
        this.innerModel().withSku(sku);
        return this;
    }

    public ReplicaImpl withRegionEndpointEnabled(String regionEndpointEnabled) {
        this.innerModel().withRegionEndpointEnabled(regionEndpointEnabled);
        return this;
    }

    public ReplicaImpl withResourceStopped(String resourceStopped) {
        this.innerModel().withResourceStopped(resourceStopped);
        return this;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy