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

com.microsoft.azure.management.sql.implementation.ReplicationLinkImpl Maven / Gradle / Ivy

Go to download

This package contains Microsoft Azure Sql Management SDK. A new set of management libraries are now Generally Available. For documentation on how to use the new libraries, please see https://aka.ms/azsdk/java/mgmt

There is a newer version: 1.41.4
Show newest version
/**
 * Copyright (c) Microsoft Corporation. All rights reserved.
 * Licensed under the MIT License. See License.txt in the project root for
 * license information.
 */
package com.microsoft.azure.management.sql.implementation;

import com.microsoft.azure.management.apigeneration.LangDefinition;
import com.microsoft.azure.management.resources.fluentcore.arm.ResourceId;
import com.microsoft.azure.management.resources.fluentcore.model.implementation.RefreshableWrapperImpl;
import com.microsoft.azure.management.resources.fluentcore.utils.Utils;
import com.microsoft.azure.management.sql.ReplicationLink;
import com.microsoft.azure.management.sql.ReplicationRole;
import com.microsoft.azure.management.sql.ReplicationState;
import com.microsoft.rest.ServiceCallback;
import com.microsoft.rest.ServiceFuture;
import org.joda.time.DateTime;
import rx.Completable;
import rx.Observable;

/**
 * Implementation for SQL replication link interface.
 */
@LangDefinition
class ReplicationLinkImpl
        extends RefreshableWrapperImpl
        implements ReplicationLink {

    private final String sqlServerName;
    private final String resourceGroupName;
    private final SqlServerManager sqlServerManager;
    private final ResourceId resourceId;

    protected ReplicationLinkImpl(String resourceGroupName, String sqlServerName, ReplicationLinkInner innerObject, SqlServerManager sqlServerManager) {
        super(innerObject);
        this.resourceGroupName = resourceGroupName;
        this.sqlServerName = sqlServerName;
        this.sqlServerManager = sqlServerManager;
        this.resourceId = ResourceId.fromString(this.inner().id());
    }

    @Override
    protected Observable getInnerAsync() {
        return this.sqlServerManager.inner().replicationLinks()
            .getAsync(this.resourceGroupName,
                this.sqlServerName,
                this.databaseName(),
                this.name());
    }

    @Override
    public String sqlServerName() {
        return this.sqlServerName;
    }

    @Override
    public String databaseName() {
        return this.resourceId.parent().name();
    }

    @Override
    public String partnerServer() {
        return this.inner().partnerServer();
    }

    @Override
    public String partnerDatabase() {
        return this.inner().partnerDatabase();
    }

    @Override
    public String partnerLocation() {
        return this.inner().partnerLocation();
    }

    @Override
    public ReplicationRole role() {
        return this.inner().role();
    }

    @Override
    public ReplicationRole partnerRole() {
        return this.inner().partnerRole();
    }

    @Override
    public DateTime startTime() {
        return this.inner().startTime();
    }

    @Override
    public int percentComplete() {
        return Utils.toPrimitiveInt(this.inner().percentComplete());
    }

    @Override
    public ReplicationState replicationState() {
        return this.inner().replicationState();
    }

    @Override
    public String location() {
        return this.inner().location();
    }

    @Override
    public boolean isTerminationAllowed() {
        return this.inner().isTerminationAllowed();
    }

    @Override
    public String replicationMode() {
        return this.inner().replicationMode();
    }

    @Override
    public void delete() {
        this.sqlServerManager.inner().replicationLinks()
            .delete(this.resourceGroupName,
                this.sqlServerName,
                this.databaseName(),
                this.name());
    }

    @Override
    public void failover() {
        this.sqlServerManager.inner().replicationLinks()
            .failover(this.resourceGroupName,
                this.sqlServerName,
                this.databaseName(),
                this.name());
    }

    @Override
    public Completable failoverAsync() {
        return this.sqlServerManager.inner().replicationLinks()
            .failoverAsync(this.resourceGroupName,
                this.sqlServerName,
                this.databaseName(),
                this.name()).toCompletable();
    }

    @Override
    public ServiceFuture failoverAsync(ServiceCallback callback) {
        return ServiceFuture.fromBody(this.failoverAsync(), callback);
    }

    @Override
    public void forceFailoverAllowDataLoss() {
        this.sqlServerManager.inner().replicationLinks()
            .failoverAllowDataLoss(this.resourceGroupName,
                this.sqlServerName,
                this.databaseName(),
                this.name());
    }

    @Override
    public Completable forceFailoverAllowDataLossAsync() {
        return this.sqlServerManager.inner().replicationLinks()
            .failoverAllowDataLossAsync(this.resourceGroupName,
                this.sqlServerName,
                this.databaseName(),
                this.name()).toCompletable();
    }

    @Override
    public ServiceFuture forceFailoverAllowDataLossAsync(ServiceCallback callback) {
        return ServiceFuture.fromBody(this.forceFailoverAllowDataLossAsync(), callback);
    }

    @Override
    public String name() {
        return this.inner().name();
    }

    @Override
    public String id() {
        return this.inner().id();
    }

    @Override
    public String resourceGroupName() {
        return this.resourceGroupName;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy