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

com.azure.resourcemanager.network.implementation.NetworkProfileImpl Maven / Gradle / Ivy

Go to download

This package contains Microsoft Azure Network Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt

The newest version!
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.resourcemanager.network.implementation;

import com.azure.resourcemanager.network.NetworkManager;
import com.azure.resourcemanager.network.fluent.models.IpConfigurationProfileInner;
import com.azure.resourcemanager.network.fluent.models.NetworkProfileInner;
import com.azure.resourcemanager.network.fluent.models.SubnetInner;
import com.azure.resourcemanager.network.models.ContainerNetworkInterfaceConfiguration;
import com.azure.resourcemanager.network.models.NetworkProfile;
import com.azure.resourcemanager.network.models.Subnet;
import com.azure.resourcemanager.network.models.TagsObject;
import reactor.core.publisher.Mono;

import java.util.Collections;
import java.util.List;

final class NetworkProfileImpl extends
    GroupableParentResourceWithTagsImpl
    implements NetworkProfile, NetworkProfile.Definition, NetworkProfile.Update {

    NetworkProfileImpl(String name, NetworkProfileInner innerObject, NetworkManager manager) {
        super(name, innerObject, manager);
    }

    @Override
    public List containerNetworkInterfaceConfigurations() {
        List inner =
            this.innerModel().containerNetworkInterfaceConfigurations();
        if (inner != null) {
            return Collections.unmodifiableList(inner);
        } else {
            return Collections.emptyList();
        }
    }

    @Override
    protected Mono applyTagsToInnerAsync() {
        return this
            .manager()
            .serviceClient()
            .getNetworkProfiles()
            .updateTagsAsync(resourceGroupName(), name(), new TagsObject().withTags(innerModel().tags()));
    }

    @Override
    protected Mono createInner() {
        return this
            .manager()
            .serviceClient()
            .getNetworkProfiles()
            .createOrUpdateAsync(this.resourceGroupName(), this.name(), this.innerModel());
    }

    @Override
    protected void initializeChildrenFromInner() {
    }

    @Override
    protected Mono getInnerAsync() {
        return this
            .manager()
            .serviceClient()
            .getNetworkProfiles()
            .getByResourceGroupAsync(this.resourceGroupName(), this.name());
    }


    @Override
    public NetworkProfileImpl withContainerNetworkInterfaceConfiguration(
        String name, String ipConfigName, String virtualNetworkId, String subnetName) {
        String subnetId = String.format("%s/subnets/%s", virtualNetworkId, subnetName);
        return withContainerNetworkInterfaceConfiguration(name, ipConfigName, subnetId);
    }

    @Override
    public NetworkProfileImpl withContainerNetworkInterfaceConfiguration(
        String name, String ipConfigName, Subnet subnet) {
        return withContainerNetworkInterfaceConfiguration(name, ipConfigName, subnet.id());
    }

    private NetworkProfileImpl withContainerNetworkInterfaceConfiguration(
        String name, String ipConfigName, String subnetId) {
        this.innerModel().withContainerNetworkInterfaceConfigurations(
            Collections
                .singletonList(
                    new ContainerNetworkInterfaceConfiguration()
                        .withName(name)
                        .withIpConfigurations(
                            Collections
                                .singletonList(
                                    new IpConfigurationProfileInner()
                                        .withName(ipConfigName)
                                        .withSubnet(new SubnetInner().withId(subnetId))))));
        return this;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy