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

com.azure.resourcemanager.relay.implementation.HybridConnectionImpl 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.relay.implementation;

import com.azure.core.util.Context;
import com.azure.resourcemanager.relay.fluent.models.HybridConnectionInner;
import com.azure.resourcemanager.relay.models.HybridConnection;
import java.time.OffsetDateTime;

public final class HybridConnectionImpl
    implements HybridConnection, HybridConnection.Definition, HybridConnection.Update {
    private HybridConnectionInner innerObject;

    private final com.azure.resourcemanager.relay.RelayManager serviceManager;

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

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

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

    public OffsetDateTime createdAt() {
        return this.innerModel().createdAt();
    }

    public OffsetDateTime updatedAt() {
        return this.innerModel().updatedAt();
    }

    public Integer listenerCount() {
        return this.innerModel().listenerCount();
    }

    public Boolean requiresClientAuthorization() {
        return this.innerModel().requiresClientAuthorization();
    }

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

    public String resourceGroupName() {
        return resourceGroupName;
    }

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

    private com.azure.resourcemanager.relay.RelayManager manager() {
        return this.serviceManager;
    }

    private String resourceGroupName;

    private String namespaceName;

    private String hybridConnectionName;

    public HybridConnectionImpl withExistingNamespace(String resourceGroupName, String namespaceName) {
        this.resourceGroupName = resourceGroupName;
        this.namespaceName = namespaceName;
        return this;
    }

    public HybridConnection create() {
        this.innerObject = serviceManager.serviceClient()
            .getHybridConnections()
            .createOrUpdateWithResponse(resourceGroupName, namespaceName, hybridConnectionName, this.innerModel(),
                Context.NONE)
            .getValue();
        return this;
    }

    public HybridConnection create(Context context) {
        this.innerObject = serviceManager.serviceClient()
            .getHybridConnections()
            .createOrUpdateWithResponse(resourceGroupName, namespaceName, hybridConnectionName, this.innerModel(),
                context)
            .getValue();
        return this;
    }

    HybridConnectionImpl(String name, com.azure.resourcemanager.relay.RelayManager serviceManager) {
        this.innerObject = new HybridConnectionInner();
        this.serviceManager = serviceManager;
        this.hybridConnectionName = name;
    }

    public HybridConnectionImpl update() {
        return this;
    }

    public HybridConnection apply() {
        this.innerObject = serviceManager.serviceClient()
            .getHybridConnections()
            .createOrUpdateWithResponse(resourceGroupName, namespaceName, hybridConnectionName, this.innerModel(),
                Context.NONE)
            .getValue();
        return this;
    }

    public HybridConnection apply(Context context) {
        this.innerObject = serviceManager.serviceClient()
            .getHybridConnections()
            .createOrUpdateWithResponse(resourceGroupName, namespaceName, hybridConnectionName, this.innerModel(),
                context)
            .getValue();
        return this;
    }

    HybridConnectionImpl(HybridConnectionInner innerObject,
        com.azure.resourcemanager.relay.RelayManager serviceManager) {
        this.innerObject = innerObject;
        this.serviceManager = serviceManager;
        this.resourceGroupName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "resourceGroups");
        this.namespaceName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "namespaces");
        this.hybridConnectionName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "hybridConnections");
    }

    public HybridConnection refresh() {
        this.innerObject = serviceManager.serviceClient()
            .getHybridConnections()
            .getWithResponse(resourceGroupName, namespaceName, hybridConnectionName, Context.NONE)
            .getValue();
        return this;
    }

    public HybridConnection refresh(Context context) {
        this.innerObject = serviceManager.serviceClient()
            .getHybridConnections()
            .getWithResponse(resourceGroupName, namespaceName, hybridConnectionName, context)
            .getValue();
        return this;
    }

    public HybridConnectionImpl withRequiresClientAuthorization(Boolean requiresClientAuthorization) {
        this.innerModel().withRequiresClientAuthorization(requiresClientAuthorization);
        return this;
    }

    public HybridConnectionImpl withUserMetadata(String userMetadata) {
        this.innerModel().withUserMetadata(userMetadata);
        return this;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy