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

com.azure.resourcemanager.network.implementation.PrivateDnsZoneGroupImpl 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.PrivateDnsZoneGroupInner;
import com.azure.resourcemanager.network.models.PrivateDnsZoneConfig;
import com.azure.resourcemanager.network.models.PrivateDnsZoneGroup;
import com.azure.resourcemanager.network.models.PrivateEndpoint;
import com.azure.resourcemanager.network.models.ProvisioningState;
import com.azure.resourcemanager.resources.fluentcore.arm.models.implementation.IndependentChildImpl;
import reactor.core.publisher.Mono;

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

class PrivateDnsZoneGroupImpl extends IndependentChildImpl<
    PrivateDnsZoneGroup, PrivateEndpoint, PrivateDnsZoneGroupInner, PrivateDnsZoneGroupImpl, NetworkManager>
    implements PrivateDnsZoneGroup, PrivateDnsZoneGroup.Definition, PrivateDnsZoneGroup.Update {

    private final PrivateEndpointImpl parent;

    protected PrivateDnsZoneGroupImpl(String name, PrivateDnsZoneGroupInner innerModel, PrivateEndpointImpl parent) {
        super(name, innerModel, parent.manager());
        this.parent = parent;
    }

    @Override
    public PrivateDnsZoneGroupImpl withPrivateDnsZoneConfigure(
        String name, String privateDnsZoneId) {
        if (innerModel().privateDnsZoneConfigs() == null) {
            innerModel().withPrivateDnsZoneConfigs(new ArrayList<>());
        }
        innerModel().privateDnsZoneConfigs().add(
            new PrivateDnsZoneConfig()
                .withName(name)
                .withPrivateDnsZoneId(privateDnsZoneId));
        return this;
    }

    @Override
    public Update withoutPrivateDnsZoneConfigure(String name) {
        if (innerModel().privateDnsZoneConfigs() != null) {
            innerModel().privateDnsZoneConfigs().removeIf(config -> config.name().equals(name));
        }
        return this;
    }

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

    @Override
    protected Mono createChildResourceAsync() {
        return this.manager().serviceClient().getPrivateDnsZoneGroups()
            .createOrUpdateAsync(parent.resourceGroupName(), parent.name(), this.name(), this.innerModel())
            .map(innerToFluentMap(this));
    }

    @Override
    protected Mono getInnerAsync() {
        return this.manager().serviceClient().getPrivateDnsZoneGroups()
            .getAsync(parent.resourceGroupName(), parent.name(), this.name());
    }

    @Override
    public ProvisioningState provisioningState() {
        return this.innerModel().provisioningState();
    }

    @Override
    public List privateDnsZoneConfigures() {
        if (this.innerModel().privateDnsZoneConfigs() == null) {
            return Collections.emptyList();
        }
        return Collections.unmodifiableList(this.innerModel().privateDnsZoneConfigs());
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy