Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion azure-mgmt-network/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-mgmt-resources</artifactId>
<version>1.0.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/**
* 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.network;

import com.microsoft.azure.management.network.implementation.api.PublicIPAddressInner;
import com.microsoft.azure.management.resources.fluentcore.arm.models.GroupableResource;
import com.microsoft.azure.management.resources.fluentcore.model.Provisionable;
import com.microsoft.azure.management.resources.fluentcore.model.Refreshable;
import com.microsoft.azure.management.resources.fluentcore.model.Wrapper;

public interface PublicIpAddress extends
GroupableResource,
Refreshable<PublicIpAddress>,
Wrapper<PublicIPAddressInner> {

/***********************************************************
* Getters
***********************************************************/
String ipAddress();
String leafDomainLabel();

/**************************************************************
* Fluent interfaces for provisioning
**************************************************************/
interface Definitions extends
DefinitionBlank,
DefinitionWithGroup,
DefinitionWithIpAddress,
DefinitionWithLeafDomainLabel,
DefinitionProvisionable {}


interface DefinitionBlank extends GroupableResource.DefinitionWithRegion<DefinitionWithGroup> {
}

interface DefinitionWithGroup extends GroupableResource.DefinitionWithGroup<DefinitionProvisionable> {
}

public interface DefinitionWithIpAddress {
/**
* Enables static IP address allocation. The actual IP address allocated for this resource by Azure can be obtained
* after the provisioning process is complete from ipAddress().
* @return The next stage of the public IP address definition
*/
DefinitionProvisionable withStaticIp();

/**
* Enables dynamic IP address allocation.
* @return The next stage of the public IP address definition
*/
DefinitionProvisionable withDynamicIp();
}

/**
* A public IP address definition allowing to specify the leaf domain label, if any
*/
public interface DefinitionWithLeafDomainLabel {
/**
* Specifies the leaf domain label to associate with this public IP address. The fully qualified domain name (FQDN)
* will be constructed automatically by appending the rest of the domain to this label.
* @param dnsName The leaf domain label to use. This must follow the required naming convention for leaf domain names.
* @return The next stage of the public IP address definition
*/
DefinitionProvisionable withLeafDomainLabel(String dnsName);

/**
* Ensures that no leaf domain label will be used. This means that this public IP address will not be associated with a domain name.
* @return The next stage of the public IP address definition
*/
DefinitionProvisionable withoutLeafDomainLabel();
}


interface DefinitionProvisionable extends
Provisionable<PublicIpAddress>,
DefinitionWithLeafDomainLabel,
DefinitionWithIpAddress {
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* 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.network;

import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsDeletingByGroup;
import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingByGroup;
import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsListingByGroup;
import com.microsoft.azure.management.resources.fluentcore.collection.SupportsCreating;
import com.microsoft.azure.management.resources.fluentcore.collection.SupportsDeleting;
import com.microsoft.azure.management.resources.fluentcore.collection.SupportsGetting;
import com.microsoft.azure.management.resources.fluentcore.collection.SupportsListing;

public interface PublicIpAddresses extends
SupportsCreating<PublicIpAddress.DefinitionBlank>,
SupportsListing<PublicIpAddress>,
SupportsListingByGroup<PublicIpAddress>,
SupportsGetting<PublicIpAddress>,
SupportsGettingByGroup<PublicIpAddress>,
SupportsDeleting,
SupportsDeletingByGroup {

interface InGroup extends
SupportsListing<PublicIpAddress>,
SupportsCreating<PublicIpAddress.DefinitionProvisionable>,
SupportsDeleting {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/**
* 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.network.implementation;

import com.microsoft.azure.management.network.PublicIpAddresses;
import com.microsoft.azure.management.network.implementation.api.NetworkManagementClientImpl;
import com.microsoft.azure.management.resources.fluentcore.arm.AzureConfigurable;
import com.microsoft.azure.management.resources.fluentcore.arm.implementation.AzureConfigurableImpl;
import com.microsoft.azure.management.resources.implementation.ResourceManager;
import com.microsoft.rest.RestClient;
import com.microsoft.rest.credentials.ServiceClientCredentials;

public final class NetworkManager {
private final NetworkManagementClientImpl networkManagementClient;

// Dependent managers
private final ResourceManager resourceManager;

// Collections
private PublicIpAddresses publicIpAddresses;

public static Configurable configure() {
return new NetworkManager.ConfigurableImpl();
}

public static NetworkManager authenticate(ServiceClientCredentials credentials, String subscriptionId) {
return new NetworkManager(new RestClient
.Builder("https://management.azure.com")
.withCredentials(credentials)
.build(), subscriptionId);
}

public static NetworkManager authenticate(RestClient restClient, String subscriptionId) {
return new NetworkManager(restClient, subscriptionId);
}

public interface Configurable extends AzureConfigurable<Configurable> {
NetworkManager authenticate(ServiceClientCredentials credentials, String subscriptionId);
}

private static class ConfigurableImpl extends AzureConfigurableImpl<Configurable> implements Configurable {
public NetworkManager authenticate(ServiceClientCredentials credentials, String subscriptionId) {
return NetworkManager.authenticate(buildRestClient(credentials), subscriptionId);
}
}

private NetworkManager(RestClient restClient, String subscriptionId) {
networkManagementClient = new NetworkManagementClientImpl(restClient);
networkManagementClient.setSubscriptionId(subscriptionId);
this.resourceManager = ResourceManager.authenticate(restClient).withSubscription(subscriptionId);
}

public PublicIpAddresses publicIpAddresses() {
if(this.publicIpAddresses == null) {
this.publicIpAddresses = new PublicIpAddressesImpl(
this.networkManagementClient.publicIPAddresses(),
this.resourceManager.resourceGroups());
}
return this.publicIpAddresses;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
/**
* 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.network.implementation;

import com.microsoft.azure.management.network.PublicIpAddress;
import com.microsoft.azure.management.network.implementation.api.PublicIPAddressDnsSettings;
import com.microsoft.azure.management.network.implementation.api.PublicIPAddressInner;
import com.microsoft.azure.management.network.implementation.api.PublicIPAddressesInner;
import com.microsoft.azure.management.resources.ResourceGroups;
import com.microsoft.azure.management.resources.fluentcore.arm.models.implementation.GroupableResourceImpl;
import com.microsoft.rest.ServiceResponse;

class PublicIpAddressImpl
extends GroupableResourceImpl<PublicIpAddress, PublicIPAddressInner, PublicIpAddressImpl>
implements
PublicIpAddress,
PublicIpAddress.Definitions
{

private String name;

private final PublicIPAddressesInner client;

PublicIpAddressImpl(String name,
PublicIPAddressInner innerModel,
final PublicIPAddressesInner client,
final ResourceGroups resourceGroups) {
super(innerModel.id(), innerModel, resourceGroups);
this.name = name;
this.client = client;
}

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

@Override
public PublicIpAddress refresh() throws Exception {
ServiceResponse<PublicIPAddressInner> response =
this.client.get(this.group(), this.name());
PublicIPAddressInner inner = response.getBody();
this.setInner(inner);
clearWrapperProperties();
return this;
}

@Override
public PublicIpAddressImpl provision() throws Exception {
ensureGroup();

ServiceResponse<PublicIPAddressInner> response =
this.client.createOrUpdate(this.group(), this.name(), this.inner());
this.setInner(response.getBody());
clearWrapperProperties();
return this;
}

private void clearWrapperProperties() {

}


@Override
public PublicIpAddressImpl withStaticIp() {
this.inner().setPublicIPAllocationMethod("Static"); // TODO: Replace with IpAllocationMethod.STATIC
return this;
}


@Override
public PublicIpAddressImpl withDynamicIp() {
this.inner().setPublicIPAllocationMethod("Dynamic"); // TODO: Replace with IpAllocationMethod.DYNAMIC
return this;
}

@Override
public PublicIpAddressImpl withLeafDomainLabel(String dnsName) {
PublicIPAddressDnsSettings dnsSettings;
if(dnsName == null) {
this.inner().setDnsSettings(null);
return this;
} else if(null == (dnsSettings = this.inner().dnsSettings())) {
dnsSettings = new PublicIPAddressDnsSettings();
this.inner().setDnsSettings(dnsSettings);
}
dnsSettings.setDomainNameLabel(dnsName);
return this;
}

@Override
public PublicIpAddressImpl withoutLeafDomainLabel() {
return this.withLeafDomainLabel(null);
}

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

@Override
public String leafDomainLabel() {
if(this.inner().dnsSettings() == null) {
return null;
} else {
return this.inner().dnsSettings().domainNameLabel();
}
}
}
Loading