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

com.microsoft.azure.management.eventhub.implementation.DisasterRecoveryPairingAuthorizationRuleImpl Maven / Gradle / Ivy

Go to download

This package contains Microsoft EventHub Management SDK. This package has been deprecated. A replacement package com.azure.resourcemanager:azure-resourcemanager-eventhubs is available as of 31-March-2022. We strongly encourage you to upgrade to continue receiving updates. See Migration Guide https://aka.ms/java-track2-migration-guide for guidance on upgrading. Refer to our deprecation policy https://azure.github.io/azure-sdk/policies_support.html for more details.

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

import com.microsoft.azure.management.apigeneration.LangDefinition;
import com.microsoft.azure.management.eventhub.AccessRights;
import com.microsoft.azure.management.eventhub.DisasterRecoveryPairingAuthorizationKey;
import com.microsoft.azure.management.eventhub.DisasterRecoveryPairingAuthorizationRule;
import com.microsoft.azure.management.resources.fluentcore.model.implementation.WrapperImpl;
import rx.Observable;
import rx.functions.Func1;

import java.util.List;
import java.util.Objects;

/**
 * Implementation for {@link DisasterRecoveryPairingAuthorizationRule}.
 */
@LangDefinition
class DisasterRecoveryPairingAuthorizationRuleImpl
        extends WrapperImpl
        implements DisasterRecoveryPairingAuthorizationRule {

    private final EventHubManager manager;
    private final Ancestors.TwoAncestor ancestor;

    protected DisasterRecoveryPairingAuthorizationRuleImpl(AuthorizationRuleInner inner, EventHubManager manager) {
        super(inner);
        this.manager = manager;
        this.ancestor =  new Ancestors().new TwoAncestor(inner.id());
    }

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

    @Override
    public List rights() {
        return this.inner().rights();
    }

    @Override
    public Observable getKeysAsync() {
        return this.manager.inner().disasterRecoveryConfigs()
                .listKeysAsync(this.ancestor().resourceGroupName(), this.ancestor.ancestor2Name(), this.ancestor().ancestor1Name(), this.name())
                .map(new Func1() {
                    @Override
                    public DisasterRecoveryPairingAuthorizationKey call(AccessKeysInner accessKeysInner) {
                        return new DisasterRecoveryPairingAuthorizationKeyImpl(accessKeysInner);
                    }
                });
    }

    @Override
    public DisasterRecoveryPairingAuthorizationKey getKeys() {
        return this.getKeysAsync().toBlocking().last();
    }

    @Override
    public EventHubManager manager() {
        return this.manager;
    }

    private Ancestors.TwoAncestor ancestor() {
        Objects.requireNonNull(this.ancestor);
        return this.ancestor;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy