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

com.microsoft.azure.management.cosmosdb.implementation.PrivateEndpointConnectionsImpl Maven / Gradle / Ivy

Go to download

This package contains Microsoft Azure CosmosDB 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.cosmosdb.implementation;

import com.microsoft.azure.management.apigeneration.LangDefinition;
import com.microsoft.azure.management.cosmosdb.CosmosDBAccount;
import com.microsoft.azure.management.cosmosdb.PrivateEndpointConnection;
import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.ExternalChildResourcesCachedImpl;
import rx.Observable;
import rx.functions.Func1;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


/**
 * Represents a private endpoint connection collection.
 */
@LangDefinition
class PrivateEndpointConnectionsImpl extends
        ExternalChildResourcesCachedImpl {
    private final PrivateEndpointConnectionsInner client;

    PrivateEndpointConnectionsImpl(PrivateEndpointConnectionsInner client, CosmosDBAccountImpl parent) {
        super(parent, parent.taskGroup(), "PrivateEndpointConnection");
        this.client = client;
    }

    public PrivateEndpointConnectionImpl define(String name) {
        return this.prepareInlineDefine(name);
    }

    public PrivateEndpointConnectionImpl update(String name) {
        if (this.collection().size() == 0) {
            this.cacheCollection();
        }
        return this.prepareInlineUpdate(name);
    }

    public void remove(String name) {
        if (this.collection().size() == 0) {
            this.cacheCollection();
        }
        this.prepareInlineRemove(name);
    }

    public Map asMap() {
        return asMapAsync().toBlocking().last();
    }

    public Observable> asMapAsync() {
        return listAsync().map(new Func1, Map>() {
            @Override
            public Map call(List privateEndpointConnections) {
                Map privateEndpointConnectionMap = new HashMap<>();
                for (PrivateEndpointConnectionImpl privateEndpointConnection : privateEndpointConnections) {
                    privateEndpointConnectionMap.put(privateEndpointConnection.name(), privateEndpointConnection);
                }
                return privateEndpointConnectionMap;
            }
        });
    }
    
    public Observable> listAsync() {
        final PrivateEndpointConnectionsImpl self = this;
        return this.client.listByDatabaseAccountAsync(parent().resourceGroupName(), parent().name())
                .map(new Func1, List>() {
                    @Override
                    public List call(List privateEndpointConnectionInners) {
                        List privateEndpointConnections = new ArrayList<>();
                        for (PrivateEndpointConnectionInner inner : privateEndpointConnectionInners) {
                            PrivateEndpointConnectionImpl childResource = new PrivateEndpointConnectionImpl(inner.name(), parent(), inner, client);
                            self.addPrivateEndpointConnection(childResource);
                            privateEndpointConnections.add(childResource);
                        }
                        return Collections.unmodifiableList(privateEndpointConnections);
                    }
                });
    }

    public Observable getImplAsync(String name) {
        final PrivateEndpointConnectionsImpl self = this;
        return this.client.getAsync(parent().resourceGroupName(), parent().name(), name)
                .map(new Func1() {
                    @Override
                    public PrivateEndpointConnectionImpl call(PrivateEndpointConnectionInner privateEndpointConnectionInner) {
                        PrivateEndpointConnectionImpl childResource = new PrivateEndpointConnectionImpl(privateEndpointConnectionInner.name(),
                                parent(),
                                privateEndpointConnectionInner,
                                client);
                        self.addPrivateEndpointConnection(childResource);
                        return childResource;
                    }
                });
    }

    @Override
    protected List listChildResources() {
        return listAsync().toBlocking().last();
    }

    @Override
    protected PrivateEndpointConnectionImpl newChildResource(String name) {
        return new PrivateEndpointConnectionImpl(name, parent(), new PrivateEndpointConnectionInner(), this.client);
    }

    public void addPrivateEndpointConnection(PrivateEndpointConnectionImpl privateEndpointConnection) {
        this.addChildResource(privateEndpointConnection);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy