JCLOUDS-664 Azurecompute-arm NicApi PublicIPApi and VMApi

This commit is contained in:
Rita Zhang 2016-04-27 16:36:14 -07:00 committed by Ignasi Barrera
parent 8c7573164f
commit a266511f18
48 changed files with 3625 additions and 10 deletions

View File

@ -16,21 +16,23 @@
*/
package org.jclouds.azurecompute.arm;
import java.io.Closeable;
import org.jclouds.azurecompute.arm.features.JobApi;
import org.jclouds.azurecompute.arm.features.LocationApi;
import org.jclouds.azurecompute.arm.features.NetworkInterfaceCardApi;
import org.jclouds.azurecompute.arm.features.PublicIPAddressApi;
import org.jclouds.azurecompute.arm.features.ResourceGroupApi;
import org.jclouds.azurecompute.arm.features.StorageAccountApi;
import org.jclouds.azurecompute.arm.features.SubnetApi;
import org.jclouds.azurecompute.arm.features.VirtualMachineApi;
import org.jclouds.azurecompute.arm.features.VirtualNetworkApi;
import org.jclouds.rest.annotations.Delegate;
import javax.ws.rs.PathParam;
import java.io.Closeable;
/**
* The Azure Resource Manager API is a REST API for managing your services and deployments.
* <p/>
* <p>
*
* @see <a href="https://msdn.microsoft.com/en-us/library/azure/dn790568.aspx" >doc</a>
*/
@ -62,6 +64,7 @@ public interface AzureComputeApi extends Closeable {
*/
@Delegate
StorageAccountApi getStorageAccountApi(@PathParam("resourceGroup") String resourceGroup);
/**
* The Subnet API includes operations for managing the subnets in your virtual network.
*
@ -79,4 +82,30 @@ public interface AzureComputeApi extends Closeable {
@Delegate
VirtualNetworkApi getVirtualNetworkApi(@PathParam("resourcegroup") String resourcegroup);
/**
* The Network Interface Card API includes operations for managing the NICs in your subscription.
*
* @see <a href="https://msdn.microsoft.com/en-us/library/mt163668.aspx">docs</a>
*/
@Delegate
NetworkInterfaceCardApi getNetworkInterfaceCardApi(@PathParam("resourcegroup") String resourcegroup);
/**
* The Public IP Address API includes operations for managing public ID Addresses for NICs in your subscription.
*
* @see <a href="https://msdn.microsoft.com/en-us/library/azure/mt163638.aspx">docs</a>
*/
@Delegate
PublicIPAddressApi getPublicIPAddressApi(@PathParam("resourcegroup") String resourcegroup);
/**
* The Virtual Machine API includes operations for managing the virtual machines in your subscription.
*
* @see <a href="https://msdn.microsoft.com/en-us/library/azure/mt163630.aspx">docs</a>
*/
@Delegate
VirtualMachineApi getVirtualMachineApi(@PathParam("resourceGroup") String resourceGroup);
}

View File

@ -0,0 +1,104 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jclouds.azurecompute.arm.domain;
import com.google.auto.value.AutoValue;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.json.SerializedNames;
import java.util.Map;
import java.util.List;
/**
* AvailabilitySet for subscription
*/
@AutoValue
public abstract class AvailabilitySet {
@AutoValue
public abstract static class AvailabilitySetProperties {
/**
* A platform Update Domain Count
*/
public abstract int platformUpdateDomainCount();
/**
* A platform Fault Domain Count
*/
public abstract int platformFaultDomainCount();
/**
* A list of virtual machines in availability set
*/
@Nullable
public abstract List<AvailabilitySetVirtualMachine> virtualMachines();
@SerializedNames({"platformUpdateDomainCount", "platformFaultDomainCount", "virtualMachines"})
public static AvailabilitySetProperties create(final int platformUpdateDomainCount,
final int platformFaultDomainCount,
List<AvailabilitySetVirtualMachine> virtualMachines) {
return new AutoValue_AvailabilitySet_AvailabilitySetProperties(platformUpdateDomainCount,
platformFaultDomainCount,
virtualMachines == null ? null : ImmutableList.copyOf(virtualMachines));
}
}
/**
* The id of the availability set
*/
public abstract String id();
/**
* The name of the availability set.
*/
@Nullable
public abstract String name();
/**
* The name of the availability set.
*/
@Nullable
public abstract String type();
/**
* The location of the availability set
*/
@Nullable
public abstract String location();
/**
* Specifies the tags of the availability set
*/
@Nullable
public abstract Map<String, String> tags();
/**
* Specifies the properties of the availability set
*/
@Nullable
public abstract AvailabilitySetProperties properties();
@SerializedNames({"id", "name", "type", "location", "tags", "properties"})
public static AvailabilitySet create(final String id, final String name, final String type, final String location,
final Map<String, String> tags, AvailabilitySetProperties properties) {
return new AutoValue_AvailabilitySet(id, name, type, location, tags == null ? null : ImmutableMap.copyOf(tags), properties);
}
}

View File

@ -0,0 +1,37 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jclouds.azurecompute.arm.domain;
import com.google.auto.value.AutoValue;
import org.jclouds.json.SerializedNames;
/**
* The virtual machine id
*/
@AutoValue
public abstract class AvailabilitySetVirtualMachine {
/**
* The id of the virtual machine.
*/
public abstract String id();
@SerializedNames({"id"})
public static AvailabilitySetVirtualMachine create(final String id) {
return new AutoValue_AvailabilitySetVirtualMachine(id);
}
}

View File

@ -0,0 +1,80 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jclouds.azurecompute.arm.domain;
import com.google.auto.value.AutoValue;
import org.jclouds.json.SerializedNames;
@AutoValue
public abstract class DataDisk {
/**
* The name of the data disk
*/
public abstract String name();
/**
* The size of the data disk
*/
public abstract String diskSizeGB();
/**
* The lun value of the data disk
*/
public abstract int lun();
/**
* The vhd of the data disk
*/
public abstract VHD vhd();
/**
* The create option of the data disk
*/
public abstract String createOption();
@SerializedNames({"name", "diskSizeGB", "lun", "vhd", "createOption"})
public static DataDisk create(final String name, final String diskSizeGB, final int lun,
final VHD vhd, final String createOption) {
return builder()
.name(name)
.diskSizeGB(diskSizeGB)
.lun(lun)
.createOption(createOption)
.vhd(vhd)
.build();
}
public static Builder builder() {
return new AutoValue_DataDisk.Builder();
}
@AutoValue.Builder
public abstract static class Builder {
public abstract Builder name(String name);
public abstract Builder diskSizeGB(String diskSizeGB);
public abstract Builder createOption(String createOption);
public abstract Builder lun(int lun);
public abstract Builder vhd(VHD vhd);
public abstract DataDisk build();
}
}

View File

@ -0,0 +1,68 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jclouds.azurecompute.arm.domain;
import com.google.auto.value.AutoValue;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.json.SerializedNames;
@AutoValue
public abstract class DiagnosticsProfile {
@AutoValue
public abstract static class BootDiagnostics{
public abstract boolean enabled();
@Nullable
public abstract String storageUri();
@SerializedNames({"enabled", "storageUri"})
public static BootDiagnostics create(final boolean enabled, final String storageUri) {
return builder()
.enabled(enabled)
.storageUri(storageUri)
.build();
}
public static Builder builder() {
return new AutoValue_DiagnosticsProfile_BootDiagnostics.Builder();
}
@AutoValue.Builder
public abstract static class Builder {
public abstract Builder enabled(boolean enabled);
public abstract Builder storageUri(String storageUri);
public abstract BootDiagnostics build();
}
}
public abstract BootDiagnostics bootDiagnostics();
@SerializedNames({"bootDiagnostics"})
public static DiagnosticsProfile create(final BootDiagnostics bootDiagnostics) {
return builder().bootDiagnostics(bootDiagnostics).build();
}
public static Builder builder() {
return new AutoValue_DiagnosticsProfile.Builder();
}
@AutoValue.Builder
public abstract static class Builder {
public abstract Builder bootDiagnostics(BootDiagnostics bootDiagnostics);
public abstract DiagnosticsProfile build();
}
}

View File

@ -0,0 +1,57 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jclouds.azurecompute.arm.domain;
import com.google.auto.value.AutoValue;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.json.SerializedNames;
@AutoValue
public abstract class DnsSettings {
public abstract String domainNameLabel();
@Nullable
public abstract String fqdn();
@Nullable
public abstract String reverseFqdn();
@SerializedNames({"domainNameLabel", "fqdn", "reverseFqdn"})
public static DnsSettings create(final String domainNameLabel, final String fqdn, final String reverseFqdn) {
return builder()
.domainNameLabel(domainNameLabel)
.fqdn(fqdn)
.reverseFqdn(reverseFqdn)
.build();
}
public static Builder builder() {
return new AutoValue_DnsSettings.Builder();
}
@AutoValue.Builder
public abstract static class Builder {
public abstract Builder domainNameLabel(String domainNameLabel);
public abstract Builder fqdn(String fqdn);
public abstract Builder reverseFqdn(String reverseFqdn);
public abstract DnsSettings build();
}
}

View File

@ -0,0 +1,45 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jclouds.azurecompute.arm.domain;
import com.google.auto.value.AutoValue;
import org.jclouds.json.SerializedNames;
@AutoValue
public abstract class HardwareProfile {
/**
* The vm size of the virtual machine.
*/
public abstract String vmSize();
@SerializedNames({"vmSize"})
public static HardwareProfile create(final String vmSize) {
return builder().vmSize(vmSize).build();
}
public static Builder builder() {
return new AutoValue_HardwareProfile.Builder();
}
@AutoValue.Builder
public abstract static class Builder {
public abstract Builder vmSize(String vmSize);
public abstract HardwareProfile build();
}
}

View File

@ -0,0 +1,34 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jclouds.azurecompute.arm.domain;
import com.google.auto.value.AutoValue;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.json.SerializedNames;
// Simple helper class to serialize / deserialize id reference.
@AutoValue
public abstract class IdReference {
@Nullable
public abstract String id();
@SerializedNames({"id"})
public static IdReference create(final String id) {
return new AutoValue_IdReference(id);
}
}

View File

@ -0,0 +1,80 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jclouds.azurecompute.arm.domain;
import com.google.auto.value.AutoValue;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.json.SerializedNames;
@AutoValue
public abstract class ImageReference {
/**
* The publisher of the image reference.
*/
@Nullable
public abstract String publisher();
/**
* The offer of the image reference.
*/
@Nullable
public abstract String offer();
/**
* The sku of the image reference.
*/
@Nullable
public abstract String sku();
/**
* The version of the image reference.
*/
@Nullable
public abstract String version();
@SerializedNames({"publisher", "offer", "sku", "version"})
public static ImageReference create(final String publisher,
final String offer,
final String sku,
final String version) {
return builder()
.publisher(publisher)
.offer(offer)
.sku(sku)
.version(version)
.build();
}
public static Builder builder() {
return new AutoValue_ImageReference.Builder();
}
@AutoValue.Builder
public abstract static class Builder {
public abstract Builder publisher(String publisher);
public abstract Builder offer(String offer);
public abstract Builder sku(String sku);
public abstract Builder version(String version);
public abstract ImageReference build();
}
}

View File

@ -0,0 +1,66 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jclouds.azurecompute.arm.domain;
import com.google.auto.value.AutoValue;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.json.SerializedNames;
@AutoValue
public abstract class IpConfiguration {
@Nullable
public abstract String name();
@Nullable
public abstract String id();
@Nullable
public abstract String etag();
@Nullable
public abstract Boolean primary();
@Nullable
public abstract IpConfigurationProperties properties();
@SerializedNames({"name", "id", "etag", "primary", "properties"})
public static IpConfiguration create(final String name, final String id, final String etag, final Boolean primary, final IpConfigurationProperties properties) {
return builder()
.name(name)
.id(id)
.etag(etag)
.primary(primary)
.properties(properties)
.build();
}
public static Builder builder() {
return new AutoValue_IpConfiguration.Builder();
}
@AutoValue.Builder
public abstract static class Builder {
public abstract Builder name(String name);
public abstract Builder id(String id);
public abstract Builder etag(String etag);
public abstract Builder primary(Boolean primary);
public abstract Builder properties(IpConfigurationProperties properties);
public abstract IpConfiguration build();
}
}

View File

@ -0,0 +1,72 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jclouds.azurecompute.arm.domain;
import com.google.auto.value.AutoValue;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.json.SerializedNames;
@AutoValue
public abstract class IpConfigurationProperties {
@Nullable
public abstract String provisioningState();
@Nullable
public abstract String privateIPAddress();
@Nullable
public abstract String privateIPAllocationMethod();
@Nullable
public abstract IdReference subnet();
@Nullable
public abstract IdReference publicIPAddress();
@SerializedNames({"provisioningState", "privateIPAddress", "privateIPAllocationMethod", "subnet", "publicIPAddress"})
public static IpConfigurationProperties create(final String provisioningState, final String privateIPAddress, final String privateIPAllocationMethod, final IdReference subnet, final IdReference publicIPAddress) {
return builder()
.provisioningState(provisioningState)
.privateIPAddress(privateIPAddress)
.privateIPAllocationMethod(privateIPAllocationMethod)
.subnet(subnet)
.publicIPAddress(publicIPAddress)
.build();
}
public static Builder builder() {
return new AutoValue_IpConfigurationProperties.Builder();
}
@AutoValue.Builder
public abstract static class Builder {
public abstract Builder provisioningState(String provisioningState);
public abstract Builder privateIPAddress(String privateIPAddress);
public abstract Builder privateIPAllocationMethod(String privateIPAllocationMethod);
public abstract Builder subnet(IdReference subnet);
public abstract Builder publicIPAddress(IdReference publicIPAddress);
public abstract IpConfigurationProperties build();
}
}

View File

@ -0,0 +1,56 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jclouds.azurecompute.arm.domain;
import com.google.auto.value.AutoValue;
import com.google.common.collect.ImmutableMap;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.json.SerializedNames;
import java.util.Map;
@AutoValue
public abstract class NetworkInterfaceCard {
@Nullable
public abstract String name();
@Nullable
public abstract String id();
@Nullable
public abstract String etag();
@Nullable
public abstract String location();
@Nullable
public abstract NetworkInterfaceCardProperties properties();
@Nullable
public abstract Map<String, String> tags();
@SerializedNames({"name", "id", "etag", "location", "properties", "tags"})
public static NetworkInterfaceCard create(final String name,
final String id,
final String etag,
final String location,
final NetworkInterfaceCardProperties properties,
final Map<String, String> tags) {
return new AutoValue_NetworkInterfaceCard(name, id, etag, location, properties, tags == null ? null : ImmutableMap.copyOf(tags));
}
}

View File

@ -0,0 +1,78 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jclouds.azurecompute.arm.domain;
import com.google.auto.value.AutoValue;
import com.google.common.collect.ImmutableList;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.json.SerializedNames;
import java.util.List;
@AutoValue
public abstract class NetworkInterfaceCardProperties {
@Nullable
public abstract String provisioningState();
@Nullable
public abstract String resourceGuid();
@Nullable
public abstract Boolean enableIPForwarding();
@Nullable
public abstract List<IpConfiguration> ipConfigurations();
@SerializedNames({"provisioningState", "resourceGuid", "enableIPForwarding", "ipConfigurations"})
public static NetworkInterfaceCardProperties create(final String provisioningState, final String resourceGuid, final Boolean enableIPForwarding, final List<IpConfiguration> ipConfigurations) {
NetworkInterfaceCardProperties.Builder builder = NetworkInterfaceCardProperties.builder()
.provisioningState(provisioningState)
.resourceGuid(resourceGuid)
.enableIPForwarding(enableIPForwarding)
.ipConfigurations(ipConfigurations == null ? null : ImmutableList.copyOf(ipConfigurations));
return builder.build();
}
public static Builder builder() {
return new AutoValue_NetworkInterfaceCardProperties.Builder();
}
@AutoValue.Builder
public abstract static class Builder {
public abstract Builder provisioningState(String provisioningState);
public abstract Builder resourceGuid(String resourceGuid);
public abstract Builder enableIPForwarding(Boolean enableIPForwarding);
public abstract Builder ipConfigurations(List<IpConfiguration> ipConfigurations);
abstract List<IpConfiguration> ipConfigurations();
abstract NetworkInterfaceCardProperties autoBuild();
public NetworkInterfaceCardProperties build() {
ipConfigurations(ipConfigurations() != null ? ImmutableList.copyOf(ipConfigurations()) : null);
return autoBuild();
}
}
}

View File

@ -0,0 +1,55 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jclouds.azurecompute.arm.domain;
import com.google.auto.value.AutoValue;
import com.google.common.collect.ImmutableList;
import org.jclouds.json.SerializedNames;
import java.util.List;
@AutoValue
public abstract class NetworkProfile {
/**
* List of network interfaces
*/
public abstract List<IdReference> networkInterfaces();
@SerializedNames({"networkInterfaces"})
public static NetworkProfile create(final List<IdReference> networkInterfaces) {
return builder().networkInterfaces(networkInterfaces).build();
}
public static Builder builder() {
return new AutoValue_NetworkProfile.Builder();
}
@AutoValue.Builder
public abstract static class Builder {
public abstract Builder networkInterfaces(List<IdReference> networkInterfaces);
abstract List<IdReference> networkInterfaces();
abstract NetworkProfile autoBuild();
public NetworkProfile build() {
networkInterfaces(networkInterfaces() != null ? ImmutableList.copyOf(networkInterfaces()) : ImmutableList.<IdReference>of());
return autoBuild();
}
}
}

View File

@ -0,0 +1,85 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jclouds.azurecompute.arm.domain;
import com.google.auto.value.AutoValue;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.json.SerializedNames;
@AutoValue
public abstract class OSDisk {
/**
* The OS type of the os disk
*/
@Nullable
public abstract String osType();
/**
* The name of the os disk
*/
@Nullable
public abstract String name();
/**
* The vhd of the os disk
*/
@Nullable
public abstract VHD vhd();
/**
* The caching mode of the os disk
*/
@Nullable
public abstract String caching();
/**
* The create options of the os disk
*/
@Nullable
public abstract String createOption();
@SerializedNames({"osType", "name", "vhd", "caching", "createOption"})
public static OSDisk create(final String osType, final String name, final VHD vhd,
final String caching, final String createOption) {
return builder()
.osType(osType)
.name(name)
.vhd(vhd)
.caching(caching)
.createOption(createOption)
.build();
}
public static Builder builder() {
return new AutoValue_OSDisk.Builder();
}
@AutoValue.Builder
public abstract static class Builder {
public abstract Builder osType(String osType);
public abstract Builder name(String name);
public abstract Builder caching(String caching);
public abstract Builder createOption(String createOption);
public abstract Builder vhd(VHD vhd);
public abstract OSDisk build();
}
}

View File

@ -0,0 +1,236 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jclouds.azurecompute.arm.domain;
import com.google.auto.value.AutoValue;
import com.google.common.collect.ImmutableList;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.json.SerializedNames;
import java.util.List;
import java.util.Map;
import com.google.common.collect.ImmutableMap;
@AutoValue
public abstract class OSProfile {
@AutoValue
public abstract static class LinuxConfiguration {
@AutoValue
public abstract static class SSH {
@AutoValue
public abstract static class SSHPublicKey {
@Nullable
public abstract String path();
@Nullable
public abstract String keyData();
@SerializedNames({"path", "keyData"})
public static SSHPublicKey create(final String path, final String keyData) {
return new AutoValue_OSProfile_LinuxConfiguration_SSH_SSHPublicKey(
path, keyData);
}
}
/**
* The list of public keys and paths
*/
@Nullable
public abstract List<SSHPublicKey> publicKeys();
@SerializedNames({"publicKeys"})
public static SSH create(final List<SSHPublicKey> publicKeys) {
return new AutoValue_OSProfile_LinuxConfiguration_SSH(
publicKeys);
}
}
/**
* The authentication method password or ssh
*/
public abstract String disablePasswordAuthentication();
/**
* ssh keys
*/
@Nullable
public abstract SSH ssh();
@SerializedNames({"disablePasswordAuthentication", "ssh"})
public static LinuxConfiguration create(final String disablePasswordAuthentication,
final SSH ssh) {
return new AutoValue_OSProfile_LinuxConfiguration(disablePasswordAuthentication,
ssh);
}
}
@AutoValue
public abstract static class WindowsConfiguration {
@AutoValue
public abstract static class WinRM {
/**
* Map of different settings
*/
public abstract Map<String, String> listeners();
@SerializedNames({"listeners"})
public static WinRM create(final Map<String, String> listeners) {
return new AutoValue_OSProfile_WindowsConfiguration_WinRM(listeners == null ? ImmutableMap.<String, String>of() : ImmutableMap.copyOf(listeners));
}
}
@AutoValue
public abstract static class AdditionalUnattendContent {
public abstract String pass();
public abstract String component();
public abstract String settingName();
public abstract String content();
@SerializedNames({"pass", "component", "settingName", "content"})
public static AdditionalUnattendContent create(final String pass, final String component,
final String settingName,
final String content) {
return new AutoValue_OSProfile_WindowsConfiguration_AdditionalUnattendContent(
pass, component, settingName, content);
}
}
/**
* The provision VM Agent true of false.
*/
public abstract boolean provisionVMAgent();
/**
* winR
*/
@Nullable
public abstract WinRM winRM();
/**
* unattend content
*/
@Nullable
public abstract AdditionalUnattendContent additionalUnattendContent();
/**
* is automatic updates enabled
*/
public abstract boolean enableAutomaticUpdates();
/**
* list of certificates
*/
@Nullable
public abstract List<String> secrets();
@SerializedNames({"provisionVMAgent", "winRM", "additionalUnattendContent", "enableAutomaticUpdates",
"secrets"})
public static WindowsConfiguration create(final boolean provisionVMAgent, final WinRM winRM,
final AdditionalUnattendContent additionalUnattendContent,
final boolean enableAutomaticUpdates, final List<String> secrets) {
return new AutoValue_OSProfile_WindowsConfiguration(provisionVMAgent, winRM,
additionalUnattendContent, enableAutomaticUpdates, secrets == null ? null : ImmutableList.copyOf(secrets));
}
}
/**
* The computer name of the VM
*/
@Nullable
public abstract String computerName();
/**
* The admin username of the VM
*/
@Nullable
public abstract String adminUsername();
/**
* The admin password of the VM
*/
@Nullable
public abstract String adminPassword();
/**
* The custom data of the VM
*/
@Nullable
public abstract String customData();
/**
* The linux configuration of the VM
*/
@Nullable
public abstract LinuxConfiguration linuxConfiguration();
/**
* The windows configuration of the VM
*/
@Nullable
public abstract WindowsConfiguration windowsConfiguration();
@SerializedNames({"computerName", "adminUsername", "adminPassword", "customData", "linuxConfiguration",
"windowsConfiguration"})
public static OSProfile create(final String computerName, final String adminUsername, final String adminPassword,
final String customData, final LinuxConfiguration linuxConfiguration,
final WindowsConfiguration windowsConfiguration) {
return builder()
.computerName(computerName)
.adminUsername(adminUsername)
.adminPassword(adminPassword)
.customData(customData)
.linuxConfiguration(linuxConfiguration)
.windowsConfiguration(windowsConfiguration)
.build();
}
public static Builder builder() {
return new AutoValue_OSProfile.Builder();
}
@AutoValue.Builder
public abstract static class Builder {
public abstract Builder computerName(String computerName);
public abstract Builder adminUsername(String adminUsername);
public abstract Builder adminPassword(String adminPassword);
public abstract Builder customData(String customData);
public abstract Builder linuxConfiguration(LinuxConfiguration linuxConfiguration);
public abstract Builder windowsConfiguration(WindowsConfiguration windowsConfiguration);
public abstract OSProfile build();
}
}

View File

@ -0,0 +1,52 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jclouds.azurecompute.arm.domain;
import com.google.auto.value.AutoValue;
import com.google.common.collect.ImmutableMap;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.json.SerializedNames;
import java.util.Map;
@AutoValue
public abstract class PublicIPAddress {
public abstract String name();
public abstract String id();
public abstract String etag();
public abstract String location();
@Nullable
public abstract Map<String, String> tags();
public abstract PublicIPAddressProperties properties();
@SerializedNames({"name", "id", "etag", "location", "tags", "properties"})
public static PublicIPAddress create(final String name,
final String id,
final String etag,
final String location,
final Map<String, String> tags,
final PublicIPAddressProperties properties) {
return new AutoValue_PublicIPAddress(name, id, etag, location, tags == null ? null : ImmutableMap.copyOf(tags), properties);
}
}

View File

@ -0,0 +1,83 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jclouds.azurecompute.arm.domain;
import com.google.auto.value.AutoValue;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.json.SerializedNames;
@AutoValue
public abstract class PublicIPAddressProperties {
@Nullable // needs to be nullable to create the payload for create request
public abstract String provisioningState();
@Nullable // only set in succeeded provisioningState for Static IP and for Dynamic when attached to a NIC
public abstract String ipAddress();
public abstract String publicIPAllocationMethod();
@Nullable
public abstract Integer idleTimeoutInMinutes();
@Nullable // only if attached to NIC
public abstract IdReference ipConfiguration();
@Nullable // only if DNS name is set
public abstract DnsSettings dnsSettings();
@SerializedNames({"provisioningState", "ipAddress", "publicIPAllocationMethod", "idleTimeoutInMinutes", "ipConfiguration", "dnsSettings"})
public static PublicIPAddressProperties create(final String provisioningState,
final String ipAddress,
final String publicIPAllocationMethod,
final Integer idleTimeoutInMinutes,
final IdReference ipConfiguration,
final DnsSettings dnsSettings) {
return builder()
.provisioningState(provisioningState)
.ipAddress(ipAddress)
.publicIPAllocationMethod(publicIPAllocationMethod)
.idleTimeoutInMinutes(idleTimeoutInMinutes)
.ipConfiguration(ipConfiguration)
.dnsSettings(dnsSettings)
.publicIPAllocationMethod(publicIPAllocationMethod)
.dnsSettings(dnsSettings)
.build();
}
public static Builder builder() {
return new AutoValue_PublicIPAddressProperties.Builder();
}
@AutoValue.Builder
public abstract static class Builder {
public abstract Builder provisioningState(String provisioningState);
public abstract Builder ipAddress(String ipAddress);
public abstract Builder publicIPAllocationMethod(String publicIPAllocationMethod);
public abstract Builder idleTimeoutInMinutes(Integer idleTimeoutInMinutes);
public abstract Builder ipConfiguration(IdReference ipConfiguration);
public abstract Builder dnsSettings(DnsSettings dnsSettings);
public abstract PublicIPAddressProperties build();
}
}

View File

@ -0,0 +1,78 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jclouds.azurecompute.arm.domain;
import com.google.auto.value.AutoValue;
import com.google.common.collect.ImmutableList;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.json.SerializedNames;
import java.util.List;
@AutoValue
public abstract class StorageProfile {
/**
* The image reference of the storage profile
*/
public abstract ImageReference imageReference();
/**
* The image reference of the storage profile
*/
public abstract OSDisk osDisk();
/**
* The list of the data disks of the storage profile
*/
@Nullable
public abstract List<DataDisk> dataDisks();
@SerializedNames({"imageReference", "osDisk", "dataDisks"})
public static StorageProfile create(final ImageReference imageReference,
final OSDisk osDisk, final List<DataDisk> dataDisks) {
StorageProfile.Builder builder = StorageProfile.builder()
.imageReference(imageReference)
.osDisk(osDisk)
.dataDisks(dataDisks != null ? ImmutableList.copyOf(dataDisks) : null);
return builder.build();
}
public static Builder builder() {
return new AutoValue_StorageProfile.Builder();
}
@AutoValue.Builder
public abstract static class Builder {
public abstract Builder imageReference(ImageReference imageReference);
public abstract Builder osDisk(OSDisk osDisk);
public abstract Builder dataDisks(List<DataDisk> dataDisks);
abstract List<DataDisk> dataDisks();
abstract StorageProfile autoBuild();
public StorageProfile build() {
dataDisks(dataDisks() != null ? ImmutableList.copyOf(dataDisks()) : null);
return autoBuild();
}
}
}

View File

@ -20,6 +20,7 @@ import static com.google.common.collect.ImmutableList.copyOf;
import java.util.List;
import com.google.common.collect.ImmutableList;
import org.jclouds.javax.annotation.Nullable;
import com.google.auto.value.AutoValue;
import org.jclouds.json.SerializedNames;
@ -71,7 +72,14 @@ public abstract class Subnet {
public abstract Builder ipConfigurations(List<IpConfiguration> ipConfigurations);
public abstract SubnetProperties build();
abstract List<IpConfiguration> ipConfigurations();
abstract SubnetProperties autoBuild();
public SubnetProperties build() {
ipConfigurations(ipConfigurations() != null ? ImmutableList.copyOf(ipConfigurations()) : null);
return autoBuild();
}
}
}

View File

@ -0,0 +1,45 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jclouds.azurecompute.arm.domain;
import com.google.auto.value.AutoValue;
import org.jclouds.json.SerializedNames;
@AutoValue
public abstract class VHD {
/**
* The uri of the vhd.
*/
public abstract String uri();
@SerializedNames({"uri"})
public static VHD create(final String uri) {
return builder().uri(uri).build();
}
public static Builder builder() {
return new AutoValue_VHD.Builder();
}
@AutoValue.Builder
public abstract static class Builder {
public abstract Builder uri(String uri);
public abstract VHD build();
}
}

View File

@ -0,0 +1,69 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jclouds.azurecompute.arm.domain;
import com.google.auto.value.AutoValue;
import com.google.common.collect.ImmutableMap;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.json.SerializedNames;
import java.util.Map;
/**
* A virtual machine that is valid for your subscription.
*/
@AutoValue
public abstract class VirtualMachine {
/**
* The id of the virtual machine.
*/
public abstract String id();
/**
* The name of the virtual machine
*/
public abstract String name();
/**
* The type of the virtual machine .
*/
public abstract String type();
/**
* The localized name of the virtual machine .
*/
public abstract String location();
/**
* Specifies the tags of the vm
*/
@Nullable
public abstract Map<String, String> tags();
/**
* Specifies the properties of the vm
*/
public abstract VirtualMachineProperties properties();
@SerializedNames({"id", "name", "type", "location", "tags", "properties"})
public static VirtualMachine create(final String id, final String name, final String type, final String location,
@Nullable final Map<String, String> tags, VirtualMachineProperties properties) {
return new AutoValue_VirtualMachine(id, name, location, type, tags == null ? null : ImmutableMap.copyOf(tags), properties);
}
}

View File

@ -0,0 +1,72 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jclouds.azurecompute.arm.domain;
import com.google.auto.value.AutoValue;
import com.google.common.collect.ImmutableList;
import java.util.List;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.json.SerializedNames;
import java.util.Date;
/**
* A virtual machine instance view that is valid for your subscription.
*/
@AutoValue
public abstract class VirtualMachineInstance {
@AutoValue
public abstract static class VirtualMachineStatus {
@Nullable
public abstract String code();
@Nullable
public abstract String level();
@Nullable
public abstract String displayStatus();
@Nullable
public abstract Date time();
@SerializedNames({"code", "level", "displayStatus", "time"})
public static VirtualMachineStatus create(final String code, final String level, final String displayStatus,
final Date time) {
return new AutoValue_VirtualMachineInstance_VirtualMachineStatus(code, level, displayStatus, time);
}
}
@Nullable
public abstract String platformUpdateDomain();
@Nullable
public abstract String platformFaultDomain();
@Nullable
public abstract List<VirtualMachineStatus> statuses();
@SerializedNames({"platformUpdateDomain", "platformFaultDomain", "statuses"})
public static VirtualMachineInstance create(final String platformUpdateDomain, final String platformFaultDomain,
final List<VirtualMachineStatus> statuses) {
return new AutoValue_VirtualMachineInstance(platformUpdateDomain, platformFaultDomain, statuses == null ? null : ImmutableList.copyOf(statuses));
}
}

View File

@ -0,0 +1,133 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jclouds.azurecompute.arm.domain;
import com.google.auto.value.AutoValue;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.json.SerializedNames;
/**
* A virtual machine properties for the virtual machine.
*/
@AutoValue
public abstract class VirtualMachineProperties {
/**
* The id of the virtual machine.
*/
@Nullable
public abstract String vmId();
/**
* The license type of the virtual machine.
*/
@Nullable
public abstract String licenseType();
/**
* The availability set of the virtual machine
*/
@Nullable
public abstract AvailabilitySet availabilitySet();
/**
* The hardware Profile of the virtual machine .
*/
@Nullable
public abstract HardwareProfile hardwareProfile();
/**
* The Storage Profile of the virtual machine .
*/
@Nullable
public abstract StorageProfile storageProfile();
/**
* The OS Profile of the virtual machine .
*/
@Nullable
public abstract OSProfile osProfile();
/**
* The network profile of the VM
*/
@Nullable
public abstract NetworkProfile networkProfile();
/**
* The diagnostics profile of the VM
*/
@Nullable
public abstract DiagnosticsProfile diagnosticsProfile();
/**
* The provisioning state of the VM
*/
@Nullable
public abstract String provisioningState();
@SerializedNames({"vmId", "licenseType", "availabilitySet", "hardwareProfile", "storageProfile", "osProfile",
"networkProfile", "diagnosticsProfile", "provisioningState"})
public static VirtualMachineProperties create(final String vmId,
final String licenseType,
final AvailabilitySet availabilitySet,
final HardwareProfile hardwareProfile,
final StorageProfile storageProfile,
final OSProfile osProfile,
final NetworkProfile networkProfile,
final DiagnosticsProfile diagnosticsProfile,
final String provisioningState) {
return builder()
.vmId(vmId)
.licenseType(licenseType)
.availabilitySet(availabilitySet)
.hardwareProfile(hardwareProfile)
.storageProfile(storageProfile)
.osProfile(osProfile)
.networkProfile(networkProfile)
.diagnosticsProfile(diagnosticsProfile)
.provisioningState(provisioningState)
.build();
}
public static Builder builder() {
return new AutoValue_VirtualMachineProperties.Builder();
}
@AutoValue.Builder
public abstract static class Builder {
public abstract Builder vmId(String vmId);
public abstract Builder licenseType(String licenseType);
public abstract Builder availabilitySet(AvailabilitySet availabilitySet);
public abstract Builder hardwareProfile(HardwareProfile hardwareProfile);
public abstract Builder storageProfile(StorageProfile storageProfile);
public abstract Builder osProfile(OSProfile osProfile);
public abstract Builder networkProfile(NetworkProfile networkProfile);
public abstract Builder diagnosticsProfile(DiagnosticsProfile diagnosticsProfile);
public abstract Builder provisioningState(String provisioningState);
public abstract VirtualMachineProperties build();
}
}

View File

@ -20,6 +20,7 @@ import static com.google.common.collect.ImmutableList.copyOf;
import java.util.Map;
import java.util.List;
import com.google.common.collect.ImmutableList;
import com.google.auto.value.AutoValue;
import com.google.common.collect.ImmutableMap;
@ -36,7 +37,7 @@ public abstract class VirtualNetwork {
@SerializedNames({"addressPrefixes"})
public static AddressSpace create(final List<String> addressPrefixes) {
return new AutoValue_VirtualNetwork_AddressSpace(copyOf(addressPrefixes));
return new AutoValue_VirtualNetwork_AddressSpace(addressPrefixes == null ? ImmutableList.<String>of() : ImmutableList.copyOf(addressPrefixes));
}
}
@ -79,7 +80,14 @@ public abstract class VirtualNetwork {
public abstract Builder subnets(List<Subnet> subnets);
public abstract VirtualNetworkProperties build();
abstract List<Subnet> subnets();
abstract VirtualNetworkProperties autoBuild();
public VirtualNetworkProperties build() {
subnets(subnets() != null ? ImmutableList.copyOf(subnets()) : null);
return autoBuild();
}
}
}

View File

@ -0,0 +1,78 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jclouds.azurecompute.arm.features;
import org.jclouds.Fallbacks.EmptyListOnNotFoundOr404;
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
import org.jclouds.azurecompute.arm.domain.NetworkInterfaceCard;
import org.jclouds.azurecompute.arm.domain.NetworkInterfaceCardProperties;
import org.jclouds.azurecompute.arm.functions.FalseOn204;
import org.jclouds.oauth.v2.filters.OAuthFilter;
import org.jclouds.rest.annotations.Fallback;
import org.jclouds.rest.annotations.MapBinder;
import org.jclouds.rest.annotations.PayloadParam;
import org.jclouds.rest.annotations.QueryParams;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.ResponseParser;
import org.jclouds.rest.annotations.SelectJson;
import org.jclouds.rest.binders.BindToJsonPayload;
import javax.inject.Named;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.core.MediaType;
import java.util.List;
import java.util.Map;
@Path("/resourcegroups/{resourcegroup}/providers/Microsoft.Network/networkInterfaces")
@QueryParams(keys = "api-version", values = "2015-06-15")
@RequestFilters(OAuthFilter.class)
@Consumes(MediaType.APPLICATION_JSON)
public interface NetworkInterfaceCardApi {
@Named("networkinterfacecard:list")
@SelectJson("value")
@GET
@Fallback(EmptyListOnNotFoundOr404.class)
List<NetworkInterfaceCard> list();
@Named("networkinterfacecard:create_or_update")
@Path("/{networkinterfacecardname}")
@MapBinder(BindToJsonPayload.class)
@PUT
NetworkInterfaceCard createOrUpdate(@PathParam("networkinterfacecardname") String networkinterfacecardname,
@PayloadParam("location") String location,
@PayloadParam("properties") NetworkInterfaceCardProperties properties,
@PayloadParam("tags") Map<String, String> tags);
@Named("networkinterfacecard:get")
@Path("/{networkinterfacecardname}")
@GET
@Fallback(NullOnNotFoundOr404.class)
NetworkInterfaceCard get(@PathParam("networkinterfacecardname") String networkinterfacecardname);
@Named("networkinterfacecard:delete")
@Path("/{networkinterfacecardname}")
@DELETE
@ResponseParser(FalseOn204.class)
boolean delete(@PathParam("networkinterfacecardname") String networkinterfacecardname);
}

View File

@ -0,0 +1,78 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jclouds.azurecompute.arm.features;
import org.jclouds.Fallbacks.EmptyListOnNotFoundOr404;
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
import org.jclouds.azurecompute.arm.domain.PublicIPAddress;
import org.jclouds.azurecompute.arm.domain.PublicIPAddressProperties;
import org.jclouds.azurecompute.arm.functions.FalseOn204;
import org.jclouds.oauth.v2.filters.OAuthFilter;
import org.jclouds.rest.annotations.Fallback;
import org.jclouds.rest.annotations.MapBinder;
import org.jclouds.rest.annotations.PayloadParam;
import org.jclouds.rest.annotations.QueryParams;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.ResponseParser;
import org.jclouds.rest.annotations.SelectJson;
import org.jclouds.rest.binders.BindToJsonPayload;
import javax.inject.Named;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.core.MediaType;
import java.util.List;
import java.util.Map;
@Path("/resourcegroups/{resourcegroup}/providers/Microsoft.Network/publicIPAddresses")
@QueryParams(keys = "api-version", values = "2015-06-15")
@RequestFilters(OAuthFilter.class)
@Consumes(MediaType.APPLICATION_JSON)
public interface PublicIPAddressApi {
@Named("publicipaddress:list")
@SelectJson("value")
@GET
@Fallback(EmptyListOnNotFoundOr404.class)
List<PublicIPAddress> list();
@Named("publicipaddress:create_or_update")
@Path("/{publicipaddressname}")
@MapBinder(BindToJsonPayload.class)
@PUT
PublicIPAddress createOrUpdate(@PathParam("publicipaddressname") String publicipaddressname,
@PayloadParam("location") String location,
@PayloadParam("tags") Map<String, String> tags,
@PayloadParam("properties") PublicIPAddressProperties properties);
@Named("publicipaddress:get")
@Path("/{publicipaddressname}")
@GET
@Fallback(NullOnNotFoundOr404.class)
PublicIPAddress get(@PathParam("publicipaddressname") String publicipaddressname);
@Named("publicipaddress:delete")
@Path("/{publicipaddressname}")
@DELETE
@ResponseParser(FalseOn204.class)
boolean delete(@PathParam("publicipaddressname") String publicipaddressname);
}

View File

@ -0,0 +1,135 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jclouds.azurecompute.arm.features;
import org.jclouds.Fallbacks;
import org.jclouds.azurecompute.arm.domain.VirtualMachine;
import org.jclouds.azurecompute.arm.domain.VirtualMachineInstance;
import org.jclouds.azurecompute.arm.domain.VirtualMachineProperties;
import org.jclouds.azurecompute.arm.functions.URIParser;
import org.jclouds.oauth.v2.filters.OAuthFilter;
import org.jclouds.rest.annotations.Fallback;
import org.jclouds.rest.annotations.MapBinder;
import org.jclouds.rest.annotations.Payload;
import org.jclouds.rest.annotations.PayloadParam;
import org.jclouds.rest.annotations.QueryParams;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.ResponseParser;
import org.jclouds.rest.annotations.SelectJson;
import org.jclouds.rest.binders.BindToJsonPayload;
import javax.inject.Named;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import java.net.URI;
import java.util.List;
/**
* The Virtual Machine API includes operations for managing the virtual machines in your subscription.
*
* @see <a href="https://msdn.microsoft.com/en-us/library/azure/mt163630.aspx">docs</a>
*/
@Path("/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/virtualMachines")
@RequestFilters(OAuthFilter.class)
@QueryParams(keys = "api-version", values = "2015-06-15")
@Consumes(MediaType.APPLICATION_JSON)
public interface VirtualMachineApi {
/**
* The Get Virtual Machine details
*/
@Named("GetVirtualMachine")
@GET
@Path("/{name}")
@Fallback(Fallbacks.NullOnNotFoundOr404.class)
VirtualMachine get(@PathParam("name") String name);
/**
* The Get Virtual Machine details
*/
@Named("GetVirtualMachineInstance")
@GET
@Path("/{name}/instanceView")
@Fallback(Fallbacks.NullOnNotFoundOr404.class)
VirtualMachineInstance getInstanceDetails(@PathParam("name") String name);
/**
* The Create Virtual Machine
*/
@Named("CreateVirtualMachine")
@PUT
@Payload("%7B\"location\":\"{location}\",\"tags\":%7B%7D,\"properties\":{properties}%7D")
@MapBinder(BindToJsonPayload.class)
@Path("/{vmname}")
@QueryParams(keys = "validating", values = "false")
@Produces(MediaType.APPLICATION_JSON)
VirtualMachine create(@PathParam("vmname") String vmname,
@PayloadParam("location") String location,
@PayloadParam("properties") VirtualMachineProperties properties);
/**
* The List Virtual Machines operation
*/
@Named("ListVirtualMachines")
@GET
@SelectJson("value")
@Fallback(Fallbacks.EmptyListOnNotFoundOr404.class)
List<VirtualMachine> list();
/**
* The Delete Virtual Machine operation
*/
@Named("DeleteVirtualMachine")
@DELETE
@Path("/{name}")
@ResponseParser(URIParser.class)
@Fallback(Fallbacks.NullOnNotFoundOr404.class)
URI delete(@PathParam("name") String name);
/**
* The Restart Virtual Machine operation
*/
@Named("RestartVirtualMachine")
@POST
@Path("/{name}/restart")
void restart(@PathParam("name") String name);
/**
* The start Virtual Machine operation
*/
@Named("StartVirtualMachine")
@POST
@Path("/{name}/start")
void start(@PathParam("name") String name);
/**
* The stop Virtual Machine operation
*/
@Named("StopVirtualMachine")
@POST
@Path("/{name}/powerOff")
void stop(@PathParam("name") String name);
}

View File

@ -0,0 +1,139 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jclouds.azurecompute.arm.features;
import com.google.common.collect.ImmutableMap;
import org.jclouds.azurecompute.arm.domain.IdReference;
import org.jclouds.azurecompute.arm.domain.IpConfiguration;
import org.jclouds.azurecompute.arm.domain.IpConfigurationProperties;
import org.jclouds.azurecompute.arm.domain.NetworkInterfaceCard;
import org.jclouds.azurecompute.arm.domain.NetworkInterfaceCardProperties;
import org.jclouds.azurecompute.arm.domain.Subnet;
import org.jclouds.azurecompute.arm.domain.VirtualNetwork;
import org.jclouds.azurecompute.arm.internal.BaseAzureComputeApiLiveTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
@Test(groups = "live", singleThreaded = true)
public class NetworkInterfaceCardApiLiveTest extends BaseAzureComputeApiLiveTest {
private String resourcegroup;
private String subnetID;
@BeforeClass
@Override
public void setup() {
super.setup();
resourcegroup = getResourceGroupName();
//Subnets belong to a virtual network so that needs to be created first
VirtualNetwork vn = getOrCreateVirtualNetwork(VIRTUAL_NETWORK_NAME);
assertNotNull(vn);
//Subnet needs to be up & running before NIC can be created
Subnet subnet = getOrCreateSubnet(DEFAULT_SUBNET_NAME, VIRTUAL_NETWORK_NAME);
assertNotNull(subnet);
assertNotNull(subnet.id());
subnetID = subnet.id();
}
@Test(groups = "live")
public void deleteNetworkInterfaceCardResourceDoesNotExist() {
final NetworkInterfaceCardApi nicApi = api.getNetworkInterfaceCardApi(resourcegroup);
boolean status = nicApi.delete(NETWORKINTERFACECARD_NAME);
assertFalse(status);
}
@Test(groups = "live", dependsOnMethods = "deleteNetworkInterfaceCardResourceDoesNotExist")
public void createNetworkInterfaceCard() {
final NetworkInterfaceCardApi nicApi = api.getNetworkInterfaceCardApi(resourcegroup);
//Create properties object
//Create properties object
final NetworkInterfaceCardProperties networkInterfaceCardProperties =
NetworkInterfaceCardProperties.builder().ipConfigurations(
Arrays.asList(IpConfiguration.builder()
.name("myipconfig")
.properties(IpConfigurationProperties.builder()
.privateIPAllocationMethod("Dynamic")
.subnet(IdReference.create(subnetID)).build()
).build()
)).build();
final Map<String, String> tags = ImmutableMap.of("jclouds", "livetest");
NetworkInterfaceCard nic = nicApi.createOrUpdate(NETWORKINTERFACECARD_NAME, LOCATION, networkInterfaceCardProperties, tags);
assertEquals(nic.name(), NETWORKINTERFACECARD_NAME);
assertEquals(nic.location(), LOCATION);
assertTrue(nic.properties().ipConfigurations().size() > 0);
assertEquals(nic.properties().ipConfigurations().get(0).name(), "myipconfig");
assertEquals(nic.properties().ipConfigurations().get(0).properties().privateIPAllocationMethod(), "Dynamic");
assertEquals(nic.properties().ipConfigurations().get(0).properties().subnet().id(), subnetID);
assertEquals(nic.tags().get("jclouds"), "livetest");
}
@Test(groups = "live", dependsOnMethods = "createNetworkInterfaceCard")
public void getNetworkInterfaceCard() {
final NetworkInterfaceCardApi nicApi = api.getNetworkInterfaceCardApi(resourcegroup);
NetworkInterfaceCard nic = nicApi.get(NETWORKINTERFACECARD_NAME);
assertEquals(nic.name(), NETWORKINTERFACECARD_NAME);
assertEquals(nic.location(), LOCATION);
assertTrue(nic.properties().ipConfigurations().size() > 0);
assertEquals(nic.properties().ipConfigurations().get(0).name(), "myipconfig");
assertEquals(nic.properties().ipConfigurations().get(0).properties().privateIPAllocationMethod(), "Dynamic");
assertEquals(nic.properties().ipConfigurations().get(0).properties().subnet().id(), subnetID);
}
@Test(groups = "live", dependsOnMethods = "createNetworkInterfaceCard")
public void listNetworkInterfaceCards() {
final NetworkInterfaceCardApi nicApi = api.getNetworkInterfaceCardApi(resourcegroup);
List<NetworkInterfaceCard> nicList = nicApi.list();
assertTrue(nicList.contains(nicApi.get(NETWORKINTERFACECARD_NAME)));
}
@Test(groups = "live", dependsOnMethods = {"listNetworkInterfaceCards", "getNetworkInterfaceCard"}, alwaysRun = true)
public void deleteNetworkInterfaceCard() {
final NetworkInterfaceCardApi nicApi = api.getNetworkInterfaceCardApi(resourcegroup);
boolean status = nicApi.delete(NETWORKINTERFACECARD_NAME);
assertTrue(status);
}
}

View File

@ -0,0 +1,150 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jclouds.azurecompute.arm.features;
import com.google.common.collect.ImmutableMap;
import com.squareup.okhttp.mockwebserver.MockResponse;
import org.jclouds.azurecompute.arm.domain.IdReference;
import org.jclouds.azurecompute.arm.domain.IpConfiguration;
import org.jclouds.azurecompute.arm.domain.IpConfigurationProperties;
import org.jclouds.azurecompute.arm.domain.NetworkInterfaceCard;
import org.jclouds.azurecompute.arm.domain.NetworkInterfaceCardProperties;
import org.jclouds.azurecompute.arm.internal.BaseAzureComputeApiMockTest;
import org.testng.annotations.Test;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
@Test(groups = "unit", testName = "NetworkInterfaceCardApiMockTest", singleThreaded = true)
public class NetworkInterfaceCardApiMockTest extends BaseAzureComputeApiMockTest {
private final String subscriptionid = "SUBSCRIPTIONID";
private final String resourcegroup = "myresourcegroup";
private final String apiVersion = "api-version=2015-06-15";
private final String location = "northeurope";
private final String nicName = "myNic";
public void getNetworkInterfaceCard() throws InterruptedException {
server.enqueue(jsonResponse("/getnetworkinterfacecard.json"));
final NetworkInterfaceCardApi nicApi = api.getNetworkInterfaceCardApi(resourcegroup);
NetworkInterfaceCard nic = nicApi.get(nicName);
String path = String.format("/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Network/networkInterfaces/%s?%s", subscriptionid, resourcegroup, nicName, apiVersion);
assertSent(server, "GET", path);
assertNotNull(nic);
assertEquals(nic.name(), nicName);
assertEquals(nic.properties().ipConfigurations().get(0).name(), "myip1");
assertEquals(nic.tags().get("mycustomtag"), "foobar");
}
public void getNetworkInterfaceCardEmpty() throws Exception {
server.enqueue(new MockResponse().setResponseCode(404));
final NetworkInterfaceCardApi nicApi = api.getNetworkInterfaceCardApi(resourcegroup);
assertNull(nicApi.get(nicName));
assertSent(server, "GET", "/subscriptions/SUBSCRIPTIONID/resourcegroups/myresourcegroup/providers/Microsoft.Network/networkInterfaces/myNic?api-version=2015-06-15");
}
public void listNetworkInterfaceCards() throws InterruptedException {
server.enqueue(jsonResponse("/listnetworkinterfaces.json"));
final NetworkInterfaceCardApi nicApi = api.getNetworkInterfaceCardApi(resourcegroup);
List<NetworkInterfaceCard> nicList = nicApi.list();
String path = String.format("/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Network/networkInterfaces?%s", subscriptionid, resourcegroup, apiVersion);
assertSent(server, "GET", path);
assertTrue(nicList.size() == 2);
assertTrue(nicList.get(0).properties().ipConfigurations().size() > 0);
assertEquals(nicList.get(0).properties().ipConfigurations().get(0).properties().privateIPAllocationMethod(), "Dynamic");
assertTrue(nicList.get(1).properties().ipConfigurations().size() > 0);
assertEquals(nicList.get(1).properties().ipConfigurations().get(0).properties().privateIPAllocationMethod(), "Static");
}
public void listNetworkInterfaceCardsEmpty() throws Exception {
server.enqueue(new MockResponse().setResponseCode(404));
final NetworkInterfaceCardApi nicApi = api.getNetworkInterfaceCardApi(resourcegroup);
assertTrue(nicApi.list().isEmpty());
String path = String.format("/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Network/networkInterfaces?%s", subscriptionid, resourcegroup, apiVersion);
assertSent(server, "GET", path);
}
public void createNetworkInterfaceCard() throws InterruptedException {
server.enqueue(jsonResponse("/createnetworkinterfacecard.json").setStatus("HTTP/1.1 201 Created"));
final NetworkInterfaceCardApi nicApi = api.getNetworkInterfaceCardApi(resourcegroup);
final String SubnetID = "/subscriptions/" + subscriptionid + "/resourceGroups/azurearmtesting/providers/Microsoft.Network/virtualNetworks/myvirtualnetwork/subnets/mysubnet";
//Create properties object
final NetworkInterfaceCardProperties networkInterfaceCardProperties =
NetworkInterfaceCardProperties.create(null, null, null,
Arrays.asList(IpConfiguration.create("myipconfig", null, null, null,
IpConfigurationProperties.create(null, null, "Dynamic", IdReference.create(SubnetID), null))
)
);
final Map<String, String> tags = ImmutableMap.of("mycustomtag", "foobar");
NetworkInterfaceCard nic = nicApi.createOrUpdate(nicName, location, networkInterfaceCardProperties, tags);
String path = String.format("/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Network/networkInterfaces/%s?%s", subscriptionid, resourcegroup, nicName, apiVersion);
String json = String.format("{ \"location\":\"%s\", \"tags\": { \"mycustomtag\": \"foobar\" }, \"properties\":{ \"ipConfigurations\":[ { \"name\":\"%s\", \"properties\":{ \"subnet\":{ \"id\": \"%s\" }, \"privateIPAllocationMethod\":\"%s\" } } ] } }", location, "myipconfig", SubnetID, "Dynamic");
assertSent(server, "PUT", path, json);
assertEquals(nic.tags().get("mycustomtag"), "foobar");
}
public void deleteNetworkInterfaceCard() throws InterruptedException {
server.enqueue(response202());
final NetworkInterfaceCardApi nicApi = api.getNetworkInterfaceCardApi(resourcegroup);
boolean status = nicApi.delete(nicName);
assertTrue(status);
String path = String.format("/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Network/networkInterfaces/%s?%s", subscriptionid, resourcegroup, nicName, apiVersion);
assertSent(server, "DELETE", path);
}
public void deleteNetworkInterfaceCardResourceDoesNotExist() throws InterruptedException {
server.enqueue(response204());
final NetworkInterfaceCardApi nicApi = api.getNetworkInterfaceCardApi(resourcegroup);
boolean status = nicApi.delete(nicName);
assertFalse(status);
String path = String.format("/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Network/networkInterfaces/%s?%s", subscriptionid, resourcegroup, nicName, apiVersion);
assertSent(server, "DELETE", path);
}
}

View File

@ -0,0 +1,129 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jclouds.azurecompute.arm.features;
import com.google.common.collect.ImmutableMap;
import org.jclouds.azurecompute.arm.domain.PublicIPAddress;
import org.jclouds.azurecompute.arm.domain.PublicIPAddressProperties;
import org.jclouds.azurecompute.arm.internal.BaseAzureComputeApiLiveTest;
import org.jclouds.util.Predicates2;
import com.google.common.base.Predicate;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import java.util.List;
import java.util.Map;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertNull;
@Test(groups = "live", singleThreaded = true)
public class PublicIPAddressApiLiveTest extends BaseAzureComputeApiLiveTest {
private final String publicIpAddressName = "myipaddress";
private final String subscriptionid = getSubscriptionId();
private String resourcegroup;
@BeforeClass
@Override
public void setup() {
super.setup();
resourcegroup = getResourceGroupName();
}
@Test(groups = "live")
public void deletePublicIPAddressResourceDoesNotExist() {
final PublicIPAddressApi ipApi = api.getPublicIPAddressApi(resourcegroup);
boolean status = ipApi.delete(publicIpAddressName);
assertFalse(status);
}
@Test(groups = "live", dependsOnMethods = "deletePublicIPAddressResourceDoesNotExist")
public void createPublicIPAddress() {
final PublicIPAddressApi ipApi = api.getPublicIPAddressApi(resourcegroup);
final Map<String, String> tags = ImmutableMap.of("testkey", "testvalue");
PublicIPAddressProperties properties =
PublicIPAddressProperties.builder()
.publicIPAllocationMethod("Static")
.idleTimeoutInMinutes(4)
.build();
PublicIPAddress ip = ipApi.createOrUpdate(publicIpAddressName, LOCATION, tags, properties);
assertNotNull(ip);
assertEquals(ip.name(), publicIpAddressName);
assertEquals(ip.location(), LOCATION);
assertEquals(ip.id(), String.format("/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/publicIPAddresses/%s", subscriptionid, resourcegroup, publicIpAddressName));
assertEquals(ip.tags().get("testkey"), "testvalue");
assertNotNull(ip.properties());
assertEquals(ip.properties().provisioningState(), "Updating");
assertNull(ip.properties().ipAddress()); // as we don't get IP address until Succeeded state
assertEquals(ip.properties().publicIPAllocationMethod(), "Static");
assertEquals(ip.properties().idleTimeoutInMinutes().intValue(), 4);
}
@Test(groups = "live", dependsOnMethods = "createPublicIPAddress")
public void getPublicIPAddress() {
final PublicIPAddressApi ipApi = api.getPublicIPAddressApi(resourcegroup);
//Poll until resource is ready to be used
boolean jobDone = Predicates2.retry(new Predicate<String>() {
@Override public boolean apply(String name) {
return ipApi.get(name).properties().provisioningState().equals("Succeeded");
}
}, 10 * 1000).apply(publicIpAddressName);
assertTrue(jobDone, "get operation did not complete in the configured timeout");
PublicIPAddress ip = ipApi.get(publicIpAddressName);
assertNotNull(ip);
assertEquals(ip.name(), publicIpAddressName);
assertEquals(ip.location(), LOCATION);
assertEquals(ip.id(), String.format("/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/publicIPAddresses/%s", subscriptionid, resourcegroup, publicIpAddressName));
assertEquals(ip.tags().get("testkey"), "testvalue");
assertNotNull(ip.properties());
assertEquals(ip.properties().provisioningState(), "Succeeded");
assertNotNull(ip.properties().ipAddress()); // by this time we should have IP address already
assertEquals(ip.properties().publicIPAllocationMethod(), "Static");
assertEquals(ip.properties().idleTimeoutInMinutes().intValue(), 4);
}
@Test(groups = "live", dependsOnMethods = "createPublicIPAddress")
public void listPublicIPAddresses() {
final PublicIPAddressApi ipApi = api.getPublicIPAddressApi(resourcegroup);
List<PublicIPAddress> ipList = ipApi.list();
assertTrue(ipList.size() > 0);
}
@Test(groups = "live", dependsOnMethods = {"listPublicIPAddresses", "getPublicIPAddress"}, alwaysRun = true)
public void deletePublicIPAddress() {
final PublicIPAddressApi ipApi = api.getPublicIPAddressApi(resourcegroup);
boolean status = ipApi.delete(publicIpAddressName);
assertTrue(status);
}
}

View File

@ -0,0 +1,179 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jclouds.azurecompute.arm.features;
import com.google.common.collect.ImmutableMap;
import com.squareup.okhttp.mockwebserver.MockResponse;
import org.jclouds.azurecompute.arm.domain.DnsSettings;
import org.jclouds.azurecompute.arm.domain.PublicIPAddress;
import org.jclouds.azurecompute.arm.domain.PublicIPAddressProperties;
import org.jclouds.azurecompute.arm.internal.BaseAzureComputeApiMockTest;
import org.testng.annotations.Test;
import java.util.List;
import java.util.Map;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertNull;
@Test(groups = "unit", testName = "NetworkInterfaceCardApiMockTest", singleThreaded = true)
public class PublicIPAddressApiMockTest extends BaseAzureComputeApiMockTest {
private final String subscriptionid = "SUBSCRIPTIONID";
private final String resourcegroup = "myresourcegroup";
private final String apiVersion = "api-version=2015-06-15";
private final String location = "northeurope";
private final String publicIpName = "mypublicaddress";
public void getPublicIPAddressInfo() throws InterruptedException {
server.enqueue(jsonResponse("/PublicIPAddressGetInfo.json"));
final PublicIPAddressApi ipApi = api.getPublicIPAddressApi(resourcegroup);
PublicIPAddress ip = ipApi.get(publicIpName);
String path = String.format("/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Network/publicIPAddresses/%s?%s", subscriptionid, resourcegroup, publicIpName, apiVersion);
assertSent(server, "GET", path);
assertNotNull(ip);
assertEquals(ip.name(), "mypublicaddress");
assertEquals(ip.location(), "northeurope");
assertEquals(ip.id(), "/subscriptions/fakeb2f5-4710-4e93-bdf4-419edbde2178/resourceGroups/myresourcegroup/providers/Microsoft.Network/publicIPAddresses/mypublicaddress");
assertEquals(ip.tags().get("testkey"), "testvalue");
assertNotNull(ip.properties());
assertEquals(ip.properties().provisioningState(), "Succeeded");
assertEquals(ip.properties().ipAddress(), "12.123.12.123");
assertEquals(ip.properties().publicIPAllocationMethod(), "Static");
assertEquals(ip.properties().idleTimeoutInMinutes().intValue(), 4);
assertNotNull(ip.properties().dnsSettings());
assertEquals(ip.properties().dnsSettings().domainNameLabel(), "foobar");
assertEquals(ip.properties().dnsSettings().fqdn(), "foobar.northeurope.cloudapp.azure.com");
assertNotNull(ip.properties().ipConfiguration());
assertEquals(ip.properties().ipConfiguration().id(), "/subscriptions/fakeb2f5-4710-4e93-bdf4-419edbde2178/resourceGroups/myresourcegroup/providers/Microsoft.Network/networkInterfaces/myNic/ipConfigurations/myip1");
}
public void getPublicIPAddressInfoEmpty() throws Exception {
server.enqueue(new MockResponse().setResponseCode(404));
final PublicIPAddressApi ipApi = api.getPublicIPAddressApi(resourcegroup);
PublicIPAddress ip = ipApi.get(publicIpName);
String path = String.format("/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Network/publicIPAddresses/%s?%s", subscriptionid, resourcegroup, publicIpName, apiVersion);
assertSent(server, "GET", path);
assertNull(ip);
}
public void listPublicIPAddresses() throws InterruptedException {
server.enqueue(jsonResponse("/PublicIPAddressList.json"));
final PublicIPAddressApi ipApi = api.getPublicIPAddressApi(resourcegroup);
List<PublicIPAddress> ipList = ipApi.list();
String path = String.format("/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Network/publicIPAddresses?%s", subscriptionid, resourcegroup, apiVersion);
assertSent(server, "GET", path);
assertEquals(ipList.size(), 4);
}
public void listPublicIPAddressesEmpty() throws InterruptedException {
server.enqueue(new MockResponse().setResponseCode(404));
final PublicIPAddressApi ipApi = api.getPublicIPAddressApi(resourcegroup);
List<PublicIPAddress> ipList = ipApi.list();
String path = String.format("/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Network/publicIPAddresses?%s", subscriptionid, resourcegroup, apiVersion);
assertSent(server, "GET", path);
assertEquals(ipList.size(), 0);
}
public void createPublicIPAddress() throws InterruptedException {
server.enqueue(jsonResponse("/PublicIPAddressCreate.json").setStatus("HTTP/1.1 201 Created"));
final PublicIPAddressApi ipApi = api.getPublicIPAddressApi(resourcegroup);
final Map<String, String> tags = ImmutableMap.of("testkey", "testvalue");
PublicIPAddressProperties properties = PublicIPAddressProperties.create(null, null, "Static", 4, null,
DnsSettings.create("foobar", "foobar.northeurope.cloudapp.azure.com", null));
PublicIPAddress ip = ipApi.createOrUpdate(publicIpName, location, tags, properties);
String path = String.format("/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Network/publicIPAddresses/%s?%s", subscriptionid, resourcegroup, publicIpName, apiVersion);
String json = String.format("{ \"location\": \"%s\", \"tags\": { \"testkey\": \"testvalue\" }, \"properties\": { \"publicIPAllocationMethod\": \"Static\", \"idleTimeoutInMinutes\": 4, \"dnsSettings\": { \"domainNameLabel\": \"foobar\", \"fqdn\": \"foobar.northeurope.cloudapp.azure.com\" } } }", location);
assertSent(server, "PUT", path, json);
assertNotNull(ip);
assertEquals(ip.name(), "mypublicaddress");
assertEquals(ip.location(), "northeurope");
assertEquals(ip.id(), "/subscriptions/fakeb2f5-4710-4e93-bdf4-419edbde2178/resourceGroups/myresourcegroup/providers/Microsoft.Network/publicIPAddresses/mypublicaddress");
assertEquals(ip.tags().get("testkey"), "testvalue");
assertNotNull(ip.properties());
assertEquals(ip.properties().provisioningState(), "Updating");
assertNull(ip.properties().ipAddress()); // as we don't get IP address until Succeeded state
assertEquals(ip.properties().publicIPAllocationMethod(), "Static");
assertEquals(ip.properties().idleTimeoutInMinutes().intValue(), 4);
assertNotNull(ip.properties().dnsSettings());
assertEquals(ip.properties().dnsSettings().domainNameLabel(), "foobar");
assertEquals(ip.properties().dnsSettings().fqdn(), "foobar.northeurope.cloudapp.azure.com");
}
@Test(expectedExceptions = IllegalArgumentException.class)
public void createPublicIPAddressDnsRecordInUse() throws IllegalArgumentException, InterruptedException {
server.enqueue(jsonResponse("/PublicIPAddressCreateDnsRecordInUse.json").setStatus("HTTP/1.1 400 Bad Request"));
final PublicIPAddressApi ipApi = api.getPublicIPAddressApi(resourcegroup);
final Map<String, String> tags = ImmutableMap.of("testkey", "testvalue");
PublicIPAddressProperties properties = PublicIPAddressProperties.create(null, null, "Static", 4, null,
DnsSettings.create("foobar", "foobar.northeurope.cloudapp.azure.com", null));
PublicIPAddress ip = ipApi.createOrUpdate(publicIpName, location, tags, properties);
}
public void deletePublicIPAddress() throws InterruptedException {
server.enqueue(response202());
final PublicIPAddressApi ipApi = api.getPublicIPAddressApi(resourcegroup);
boolean status = ipApi.delete(publicIpName);
String path = String.format("/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Network/publicIPAddresses/%s?%s", subscriptionid, resourcegroup, publicIpName, apiVersion);
assertSent(server, "DELETE", path);
assertTrue(status);
}
public void deletePublicIPAddressResourceDoesNotExist() throws InterruptedException {
server.enqueue(response204());
final PublicIPAddressApi ipApi = api.getPublicIPAddressApi(resourcegroup);
boolean status = ipApi.delete(publicIpName);
String path = String.format("/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Network/publicIPAddresses/%s?%s", subscriptionid, resourcegroup, publicIpName, apiVersion);
assertSent(server, "DELETE", path);
assertFalse(status);
}
}

View File

@ -0,0 +1,245 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jclouds.azurecompute.arm.features;
import com.google.common.base.Predicate;
import org.jclouds.azurecompute.arm.domain.DataDisk;
import org.jclouds.azurecompute.arm.domain.DiagnosticsProfile;
import org.jclouds.azurecompute.arm.domain.HardwareProfile;
import org.jclouds.azurecompute.arm.domain.IdReference;
import org.jclouds.azurecompute.arm.domain.ImageReference;
import org.jclouds.azurecompute.arm.domain.NetworkInterfaceCard;
import org.jclouds.azurecompute.arm.domain.NetworkProfile;
import org.jclouds.azurecompute.arm.domain.OSDisk;
import org.jclouds.azurecompute.arm.domain.OSProfile;
import org.jclouds.azurecompute.arm.domain.StorageProfile;
import org.jclouds.azurecompute.arm.domain.StorageService;
import org.jclouds.azurecompute.arm.domain.VHD;
import org.jclouds.azurecompute.arm.domain.VirtualMachine;
import org.jclouds.azurecompute.arm.domain.VirtualMachineInstance;
import org.jclouds.azurecompute.arm.domain.VirtualMachineProperties;
import org.jclouds.azurecompute.arm.functions.ParseJobStatus;
import org.jclouds.azurecompute.arm.internal.BaseAzureComputeApiLiveTest;
import org.jclouds.util.Predicates2;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import static org.testng.Assert.assertNotNull;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
import static org.testng.Assert.assertTrue;
@Test(groups = "live", testName = "VirtualMachineApiLiveTest")
public class VirtualMachineApiLiveTest extends BaseAzureComputeApiLiveTest {
private String subscriptionid = getSubscriptionId();
private String vmName = null;
private String nicName = null;
@BeforeClass
public void Setup() {
NetworkInterfaceCard nic = getOrCreateNetworkInterfaceCard(NETWORKINTERFACECARD_NAME);
assertNotNull(nic);
nicName = nic.name();
}
private String getName() {
if (vmName == null) {
vmName = String.format("%3.24s",
System.getProperty("user.name") + RAND + this.getClass().getSimpleName()).toLowerCase().substring(0, 15);
}
return vmName;
}
@Test
public void testCreate(){
StorageAccountApi storageApi = api.getStorageAccountApi(getResourceGroupName());
StorageService storageAccount = storageApi.get(getStorageServiceName());
String blob = storageAccount.storageServiceProperties().primaryEndpoints().get("blob");
VirtualMachine vm = api().create(getName(), LOCATION, getProperties(blob, nicName));
assertTrue(!vm.name().isEmpty());
//Poll until resource is ready to be used
boolean jobDone = Predicates2.retry(new Predicate<String>() {
@Override public boolean apply(String name) {
return !api().get(name).properties().provisioningState().equals("Creating");
}
}, 60 * 20 * 1000).apply(getName());
assertTrue(jobDone, "create operation did not complete in the configured timeout");
String status = api().get(vmName).properties().provisioningState();
// Cannot be creating anymore. Should be succeeded or running but not failed.
assertTrue(!status.equals("Creating"));
assertTrue(!status.equals("Failed"));
}
@Test(dependsOnMethods = "testCreate")
public void testGet() {
VirtualMachine vm = api().get(getName());
assertTrue(!vm.name().isEmpty());
}
@Test(dependsOnMethods = "testCreate")
public void testGetInstanceView() {
VirtualMachineInstance vmi = api().getInstanceDetails(getName());
assertTrue(!vmi.statuses().isEmpty());
}
@Test(dependsOnMethods = "testStart")
public void testStop() {
api().stop(getName());
//Poll until resource is ready to be used
boolean jobDone = Predicates2.retry(new Predicate<String>() {
@Override public boolean apply(String name) {
String status = "";
List<VirtualMachineInstance.VirtualMachineStatus> statuses = api().getInstanceDetails(name).statuses();
for (int c = 0; c < statuses.size(); c++) {
if (statuses.get(c).code().substring(0, 10).equals("PowerState")) {
status = statuses.get(c).displayStatus();
break;
}
}
return status.equals("VM stopped");
}
}, 60 * 4 * 1000).apply(getName());
assertTrue(jobDone, "stop operation did not complete in the configured timeout");
}
@Test(dependsOnMethods = "testGet")
public void testStart() {
api().start(getName());
//Poll until resource is ready to be used
boolean jobDone = Predicates2.retry(new Predicate<String>() {
@Override public boolean apply(String name) {
String status = "";
List<VirtualMachineInstance.VirtualMachineStatus> statuses = api().getInstanceDetails(name).statuses();
for (int c = 0; c < statuses.size(); c++) {
if (statuses.get(c).code().substring(0, 10).equals("PowerState")) {
status = statuses.get(c).displayStatus();
break;
}
}
return status.equals("VM running");
}
}, 60 * 4 * 1000).apply(getName());
assertTrue(jobDone, "start operation did not complete in the configured timeout");
}
@Test(dependsOnMethods = "testStop")
public void testRestart() {
api().start(getName());
//Poll until resource is ready to be used
boolean jobDone = Predicates2.retry(new Predicate<String>() {
@Override public boolean apply(String name) {
String status = "";
List<VirtualMachineInstance.VirtualMachineStatus> statuses = api().getInstanceDetails(name).statuses();
for (int c = 0; c < statuses.size(); c++) {
if (statuses.get(c).code().substring(0, 10).equals("PowerState")) {
status = statuses.get(c).displayStatus();
break;
}
}
return status.equals("VM running");
}
}, 60 * 4 * 1000).apply(getName());
assertTrue(jobDone, "start operation did not complete in the configured timeout");
api().restart(getName());
//Poll until resource is ready to be used
jobDone = Predicates2.retry(new Predicate<String>() {
@Override public boolean apply(String name) {
String status = "";
List<VirtualMachineInstance.VirtualMachineStatus> statuses = api().getInstanceDetails(name).statuses();
for (int c = 0; c < statuses.size(); c++) {
if (statuses.get(c).code().substring(0, 10).equals("PowerState")) {
status = statuses.get(c).displayStatus();
break;
}
}
return status.equals("VM running");
}
}, 60 * 4 * 1000).apply(getName());
assertTrue(jobDone, "restart operation did not complete in the configured timeout");
}
@Test(dependsOnMethods = "testCreate")
public void testList() {
List<VirtualMachine> list = api().list();
VirtualMachine vm = api().get(getName());
assertTrue(list.contains(vm));
}
@Test(dependsOnMethods = {"testRestart", "testList", "testGet"}, alwaysRun = true)
public void testDelete() throws Exception {
URI uri = api().delete(getName());
if (uri != null) {
assertTrue(uri.toString().contains("api-version"));
boolean jobDone = Predicates2.retry(new Predicate<URI>() {
@Override
public boolean apply(URI uri) {
return ParseJobStatus.JobStatus.DONE == api.getJobApi().jobStatus(uri);
}
}, 60 * 8 * 1000 /* 2 minutes timeout */).apply(uri);
assertTrue(jobDone, "delete operation did not complete in the configured timeout");
}
}
private VirtualMachineApi api() {
return api.getVirtualMachineApi(getResourceGroupName());
}
private VirtualMachineProperties getProperties(String blob, String nic) {
HardwareProfile hwProf = HardwareProfile.create("Standard_D1");
ImageReference imgRef = ImageReference.create("MicrosoftWindowsServerEssentials",
"WindowsServerEssentials", "WindowsServerEssentials", "latest");
VHD vhd = VHD.create(blob + "vhds/" + getName() + ".vhd");
VHD vhd2 = VHD.create(blob + "vhds/" + getName() + "data.vhd");
DataDisk dataDisk = DataDisk.create(getName() + "data", "100", 0, vhd2, "Empty");
OSDisk osDisk = OSDisk.create(null, getName(), vhd, "ReadWrite", "FromImage");
StorageProfile storageProfile = StorageProfile.create(imgRef, osDisk, null);
OSProfile.WindowsConfiguration windowsConfig = OSProfile.WindowsConfiguration.create(false, null, null, true,
null);
OSProfile osProfile = OSProfile.create(getName(), "azureuser", "RFe3&432dg", null, null, windowsConfig);
IdReference networkInterface =
IdReference.create("/subscriptions/" + subscriptionid +
"/resourceGroups/" + getResourceGroupName() + "/providers/Microsoft.Network/networkInterfaces/"
+ nic);
List<IdReference> networkInterfaces =
new ArrayList<IdReference>();
networkInterfaces.add(networkInterface);
NetworkProfile networkProfile = NetworkProfile.create(networkInterfaces);
DiagnosticsProfile.BootDiagnostics bootDiagnostics =
DiagnosticsProfile.BootDiagnostics.create(true, blob);
DiagnosticsProfile diagnosticsProfile = DiagnosticsProfile.create(bootDiagnostics);
VirtualMachineProperties properties = VirtualMachineProperties.create(null,
null, null, hwProf, storageProfile, osProfile, networkProfile, diagnosticsProfile, "Creating");
return properties;
}
}

View File

@ -0,0 +1,249 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jclouds.azurecompute.arm.features;
import com.google.common.collect.ImmutableList;
import com.squareup.okhttp.mockwebserver.MockResponse;
import org.jclouds.azurecompute.arm.domain.HardwareProfile;
import org.jclouds.azurecompute.arm.domain.IdReference;
import org.jclouds.azurecompute.arm.domain.ImageReference;
import org.jclouds.azurecompute.arm.domain.VirtualMachine;
import org.jclouds.azurecompute.arm.domain.VHD;
import org.jclouds.azurecompute.arm.domain.OSDisk;
import org.jclouds.azurecompute.arm.domain.OSProfile;
import org.jclouds.azurecompute.arm.domain.DiagnosticsProfile;
import org.jclouds.azurecompute.arm.domain.NetworkProfile;
import org.jclouds.azurecompute.arm.domain.StorageProfile;
import org.jclouds.azurecompute.arm.domain.DataDisk;
import org.jclouds.azurecompute.arm.domain.VirtualMachineInstance;
import org.jclouds.azurecompute.arm.domain.VirtualMachineProperties;
import org.jclouds.azurecompute.arm.internal.BaseAzureComputeApiMockTest;
import org.testng.annotations.Test;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
import java.util.Date;
import java.text.SimpleDateFormat;
import java.text.DateFormat;
import static com.google.common.collect.Iterables.isEmpty;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
@Test(groups = "unit", testName = "VirtualMachineApiMockTest", singleThreaded = true)
public class VirtualMachineApiMockTest extends BaseAzureComputeApiMockTest {
public void testGet() throws Exception {
server.enqueue(jsonResponse("/virtualmachine.json"));
final VirtualMachineApi vmAPI = api.getVirtualMachineApi("groupname");
assertEquals(vmAPI.get("windowsmachine"), getVM());
assertSent(server, "GET", "/subscriptions/SUBSCRIPTIONID/resourceGroups/groupname/providers/Microsoft.Compute" +
"/virtualMachines/windowsmachine?api-version=2015-06-15");
}
public void testGetEmpty() throws Exception {
server.enqueue(new MockResponse().setResponseCode(404));
final VirtualMachineApi vmAPI = api.getVirtualMachineApi("groupname");
assertNull(vmAPI.get("windowsmachine"));
assertSent(server, "GET", "/subscriptions/SUBSCRIPTIONID/resourceGroups/groupname/providers/Microsoft.Compute" +
"/virtualMachines/windowsmachine?api-version=2015-06-15");
}
public void testGetInstanceDetails() throws Exception {
server.enqueue(jsonResponse("/virtualmachineInstance.json"));
final VirtualMachineApi vmAPI = api.getVirtualMachineApi("groupname");
VirtualMachineInstance actual = vmAPI.getInstanceDetails("windowsmachine");
VirtualMachineInstance expected = getVMInstance();
assertEquals(actual.statuses().get(0).code(), expected.statuses().get(0).code());
assertEquals(actual.statuses().get(0).displayStatus(), expected.statuses().get(0).displayStatus());
assertEquals(actual.statuses().get(0).level(), expected.statuses().get(0).level());
assertEquals(actual.statuses().get(0).time().toString(), expected.statuses().get(0).time().toString());
assertSent(server, "GET", "/subscriptions/SUBSCRIPTIONID/resourceGroups/groupname/providers/Microsoft.Compute" +
"/virtualMachines/windowsmachine/instanceView?api-version=2015-06-15");
}
public void testGetInstanceDetailsEmpty() throws Exception {
server.enqueue(new MockResponse().setResponseCode(404));
final VirtualMachineApi vmAPI = api.getVirtualMachineApi("groupname");
assertNull(vmAPI.getInstanceDetails("windowsmachine"));
assertSent(server, "GET", "/subscriptions/SUBSCRIPTIONID/resourceGroups/groupname/providers/Microsoft.Compute" +
"/virtualMachines/windowsmachine/instanceView?api-version=2015-06-15");
}
public void testList() throws Exception {
server.enqueue(jsonResponse("/virtualmachines.json"));
final VirtualMachineApi vmAPI = api.getVirtualMachineApi("groupname");
assertEquals(vmAPI.list(), getVMList());
assertSent(server, "GET", "/subscriptions/SUBSCRIPTIONID/resourceGroups/groupname/providers/Microsoft.Compute" +
"/virtualMachines?api-version=2015-06-15");
}
public void testListEmpty() throws Exception {
server.enqueue(new MockResponse().setResponseCode(404));
final VirtualMachineApi vmAPI = api.getVirtualMachineApi("groupname");
assertTrue(isEmpty(vmAPI.list()));
assertSent(server, "GET", "/subscriptions/SUBSCRIPTIONID/resourceGroups/groupname/providers/Microsoft.Compute" +
"/virtualMachines?api-version=2015-06-15");
}
public void testCreate() throws Exception {
server.enqueue(jsonResponse("/createvirtualmachineresponse.json"));
final VirtualMachineApi vmAPI = api.getVirtualMachineApi("groupname");
VirtualMachine vm = vmAPI.create("windowsmachine", "westus", getProperties());
assertEquals(vm, getVM());
assertSent(server, "PUT", "/subscriptions/SUBSCRIPTIONID/resourceGroups/groupname/providers/Microsoft.Compute" +
"/virtualMachines/windowsmachine?api-version=2015-06-15&validating=false",
"{\"location\":\"westus\",\"properties\":" +
"{\"vmId\":\"27ee085b-d707-xxxx-yyyy-2370e2eb1cc1\"," +
"\"hardwareProfile\":{\"vmSize\":\"Standard_D1\"}," +
"\"storageProfile\":{\"imageReference\":{\"publisher\":\"publisher\",\"offer\":\"offer\",\"sku\":\"sku\",\"version\":\"ver\"}," +
"\"osDisk\":{\"osType\":\"Windows\",\"name\":\"windowsmachine\"," +
"\"vhd\":{\"uri\":\"https://groupname2760.blob.core.windows.net/vhds/windowsmachine201624102936.vhd\"},\"caching\":\"ReadWrite\",\"createOption\":\"FromImage\"},\"dataDisks\":[]}," +
"\"osProfile\":{\"computerName\":\"windowsmachine\",\"adminUsername\":\"azureuser\",\"windowsConfiguration\":{\"provisionVMAgent\":false,\"enableAutomaticUpdates\":true}}," +
"\"networkProfile\":{\"networkInterfaces\":[{\"id\":\"/subscriptions/SUBSCRIPTIONID/resourceGroups/groupname/providers/Microsoft.Network/networkInterfaces/windowsmachine167\"}]}," +
"\"diagnosticsProfile\":{\"bootDiagnostics\":{\"enabled\":true,\"storageUri\":\"https://groupname2760.blob.core.windows.net/\"}},\"provisioningState\":\"Creating\"}}");
}
public void testDeleteReturns404() throws Exception {
server.enqueue(response404());
final VirtualMachineApi vmAPI = api.getVirtualMachineApi("groupname");
URI uri = vmAPI.delete("windowsmachine");
assertEquals(server.getRequestCount(), 1);
assertNull(uri);
assertSent(server, "DELETE", "/subscriptions/SUBSCRIPTIONID/resourceGroups/groupname/providers/Microsoft.Compute" +
"/virtualMachines/windowsmachine?api-version=2015-06-15");
}
public void testDelete() throws Exception {
server.enqueue(response202WithHeader());
final VirtualMachineApi vmAPI = api.getVirtualMachineApi("groupname");
URI uri = vmAPI.delete("windowsmachine");
assertEquals(server.getRequestCount(), 1);
assertNotNull(uri);
assertSent(server, "DELETE", "/subscriptions/SUBSCRIPTIONID/resourceGroups/groupname/providers/Microsoft.Compute" +
"/virtualMachines/windowsmachine?api-version=2015-06-15");
}
public void testStart() throws Exception {
server.enqueue(new MockResponse().setResponseCode(204));
final VirtualMachineApi vmAPI = api.getVirtualMachineApi("groupname");
vmAPI.start("windowsmachine");
assertSent(server, "POST", "/subscriptions/SUBSCRIPTIONID/resourceGroups/groupname/providers/Microsoft.Compute" +
"/virtualMachines/windowsmachine/start?api-version=2015-06-15");
}
public void testRestart() throws Exception {
server.enqueue(new MockResponse().setResponseCode(204));
final VirtualMachineApi vmAPI = api.getVirtualMachineApi("groupname");
vmAPI.restart("windowsmachine");
assertSent(server, "POST", "/subscriptions/SUBSCRIPTIONID/resourceGroups/groupname/providers/Microsoft.Compute" +
"/virtualMachines/windowsmachine/restart?api-version=2015-06-15");
}
public void testStop() throws Exception {
server.enqueue(new MockResponse().setResponseCode(204));
final VirtualMachineApi vmAPI = api.getVirtualMachineApi("groupname");
vmAPI.stop("windowsmachine");
assertSent(server, "POST", "/subscriptions/SUBSCRIPTIONID/resourceGroups/groupname/providers/Microsoft.Compute" +
"/virtualMachines/windowsmachine/powerOff?api-version=2015-06-15");
}
private VirtualMachineProperties getProperties() {
HardwareProfile hwProf = HardwareProfile.create("Standard_D1");
ImageReference imgRef = ImageReference.create("publisher", "offer", "sku", "ver");
VHD vhd = VHD.create("https://groupname2760.blob.core.windows.net/vhds/windowsmachine201624102936.vhd");
List<DataDisk> dataDisks = new ArrayList<DataDisk>();
OSDisk osDisk = OSDisk.create("Windows", "windowsmachine", vhd, "ReadWrite", "FromImage");
StorageProfile storageProfile = StorageProfile.create(imgRef, osDisk, dataDisks);
OSProfile.WindowsConfiguration windowsConfig = OSProfile.WindowsConfiguration.create(false, null, null, true,
null);
OSProfile osProfile = OSProfile.create("windowsmachine", "azureuser", null, null, null, windowsConfig);
IdReference networkInterface =
IdReference.create("/subscriptions/SUBSCRIPTIONID" +
"/resourceGroups/groupname/providers/Microsoft.Network/networkInterfaces/" +
"windowsmachine167");
List<IdReference> networkInterfaces = new ArrayList<IdReference>();
networkInterfaces.add(networkInterface);
NetworkProfile networkProfile = NetworkProfile.create(networkInterfaces);
DiagnosticsProfile.BootDiagnostics bootDiagnostics = DiagnosticsProfile.BootDiagnostics.create(true,
"https://groupname2760.blob.core.windows.net/");
DiagnosticsProfile diagnosticsProfile = DiagnosticsProfile.create(bootDiagnostics);
VirtualMachineProperties properties = VirtualMachineProperties.create("27ee085b-d707-xxxx-yyyy-2370e2eb1cc1",
null, null, hwProf, storageProfile, osProfile, networkProfile, diagnosticsProfile, "Creating");
return properties;
}
private VirtualMachine getVM() {
VirtualMachineProperties properties = getProperties();
VirtualMachine machine = VirtualMachine.create("/subscriptions/SUBSCRIPTIONID/" + "" +
"resourceGroups/groupname/providers/Microsoft.Compute/virtualMachines/windowsmachine", "windowsmachine",
"Microsoft.Compute/virtualMachines", "westus", null, properties);
return machine;
}
private VirtualMachineInstance getVMInstance() {
List<VirtualMachineInstance.VirtualMachineStatus> statuses = new ArrayList<VirtualMachineInstance.VirtualMachineStatus>();
String testDate = "Wed May 04 01:38:52 PDT 2016";
DateFormat formatter = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy");
Date date = null;
try {
date = formatter.parse(testDate);
} catch (Exception e) {
e.printStackTrace();
}
VirtualMachineInstance.VirtualMachineStatus vmStatus =
VirtualMachineInstance.VirtualMachineStatus.create("ProvisioningState/succeeded", "Info", "Provisioning succeeded", date);
statuses.add(vmStatus);
VirtualMachineInstance.VirtualMachineStatus vmStatus1 =
VirtualMachineInstance.VirtualMachineStatus.create("PowerState/running", "Info", "VM running", null);
statuses.add(vmStatus1);
VirtualMachineInstance machineInstance =
VirtualMachineInstance.create(null, null, ImmutableList.copyOf(statuses));
return machineInstance;
}
private List<VirtualMachine> getVMList() {
VirtualMachineProperties properties = getProperties();
VirtualMachine machine = VirtualMachine.create("/subscriptions/SUBSCRIPTIONID/" + "" +
"resourceGroups/groupname/providers/Microsoft.Compute/virtualMachines/windowsmachine",
"windowsmachine", "Microsoft.Compute/virtualMachines", "westus", null, properties);
List<VirtualMachine> list = new ArrayList<VirtualMachine>();
list.add(machine);
return list;
}
}

View File

@ -22,9 +22,9 @@ import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.OPERATI
import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.OPERATION_TIMEOUT;
import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.TCP_RULE_FORMAT;
import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.TCP_RULE_REGEXP;
import java.util.Properties;
import java.util.Random;
import org.jclouds.apis.BaseApiLiveTest;
import org.jclouds.azurecompute.arm.AzureComputeApi;
import org.jclouds.azurecompute.arm.AzureComputeProviderMetadata;

View File

@ -20,11 +20,17 @@ import static org.testng.Assert.assertTrue;
import com.google.common.base.Predicate;
import com.google.common.collect.ImmutableMap;
import org.jclouds.azurecompute.arm.domain.IdReference;
import org.jclouds.azurecompute.arm.domain.IpConfiguration;
import org.jclouds.azurecompute.arm.domain.IpConfigurationProperties;
import org.jclouds.azurecompute.arm.domain.NetworkInterfaceCard;
import org.jclouds.azurecompute.arm.domain.NetworkInterfaceCardProperties;
import org.jclouds.azurecompute.arm.domain.ResourceGroup;
import org.jclouds.azurecompute.arm.domain.StorageService;
import org.jclouds.azurecompute.arm.domain.Subnet;
import org.jclouds.azurecompute.arm.domain.VirtualNetwork;
import org.jclouds.azurecompute.arm.features.NetworkInterfaceCardApi;
import org.jclouds.azurecompute.arm.features.StorageAccountApi;
import org.jclouds.azurecompute.arm.features.SubnetApi;
import org.jclouds.azurecompute.arm.features.VirtualNetworkApi;
@ -36,6 +42,7 @@ import org.testng.annotations.BeforeClass;
import java.net.URI;
import java.util.Arrays;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
@ -50,13 +57,15 @@ public class BaseAzureComputeApiLiveTest extends AbstractAzureComputeApiLiveTest
public static final String DEFAULT_VIRTUALNETWORK_ADDRESS_PREFIX = "10.2.0.0/16";
public static final String NETWORKINTERFACECARD_NAME = "jcloudsNic";
private String resourceGroupName = null;
protected StorageService storageService;
private String storageServiceName = null;
protected String getStorageServiceName() {
if (storageServiceName == null) {
storageServiceName = String.format("%3.24s",
@ -74,6 +83,17 @@ public class BaseAzureComputeApiLiveTest extends AbstractAzureComputeApiLiveTest
return endpoint;
}
protected String getSubscriptionId() {
String subscriptionid = null;
String endpoint = null;
endpoint = getEndpoint();
if (endpoint != null) {
subscriptionid = endpoint.substring(endpoint.lastIndexOf("/") + 1);
}
assertNotNull(subscriptionid);
return subscriptionid;
}
protected String getResourceGroupName() {
if (resourceGroupName == null) {
resourceGroupName = String.format("%3.24s",
@ -99,7 +119,6 @@ public class BaseAzureComputeApiLiveTest extends AbstractAzureComputeApiLiveTest
@Override
public void setup() {
super.setup();
storageService = getOrCreateStorageService(getStorageServiceName());
}
@ -169,4 +188,29 @@ public class BaseAzureComputeApiLiveTest extends AbstractAzureComputeApiLiveTest
return subnet;
}
protected NetworkInterfaceCard getOrCreateNetworkInterfaceCard(final String networkInterfaceCardName){
NetworkInterfaceCardApi nicApi = api.getNetworkInterfaceCardApi(getResourceGroupName());
NetworkInterfaceCard nic = nicApi.get(networkInterfaceCardName);
if (nic != null){
return nic;
}
VirtualNetwork vn = getOrCreateVirtualNetwork(VIRTUAL_NETWORK_NAME);
Subnet subnet = getOrCreateSubnet(DEFAULT_SUBNET_NAME, VIRTUAL_NETWORK_NAME);
//Create properties object
final NetworkInterfaceCardProperties networkInterfaceCardProperties =
NetworkInterfaceCardProperties.builder()
.ipConfigurations(Arrays.asList(IpConfiguration.create("myipconfig", null, null, null,
IpConfigurationProperties.create(null, null, "Dynamic", IdReference.create(subnet.id()), null))
)).build();
final Map<String, String> tags = ImmutableMap.of("jclouds", "livetest");
nic = nicApi.createOrUpdate(NETWORKINTERFACECARD_NAME, LOCATION, networkInterfaceCardProperties, tags);
return nic;
}
}

View File

@ -0,0 +1,20 @@
{
"name": "mypublicaddress",
"id": "/subscriptions/fakeb2f5-4710-4e93-bdf4-419edbde2178/resourceGroups/myresourcegroup/providers/Microsoft.Network/publicIPAddresses/mypublicaddress",
"etag": "W/\"f0bdaf62-456b-4338-8f65-05417b1a55e9\"",
"type": "Microsoft.Network/publicIPAddresses",
"location": "northeurope",
"tags": {
"testkey": "testvalue"
},
"properties": {
"provisioningState": "Updating",
"resourceGuid": "ebe3f160-2484-447a-8980-c587b214b16f",
"publicIPAllocationMethod": "Static",
"idleTimeoutInMinutes": 4,
"dnsSettings": {
"domainNameLabel": "foobar",
"fqdn": "foobar.northeurope.cloudapp.azure.com"
}
}
}

View File

@ -0,0 +1,7 @@
{
"error": {
"code": "DnsRecordInUse",
"message": "DNS record foobar.northeurope.cloudapp.azure.com is already used by another public IP.",
"details": []
}
}

View File

@ -0,0 +1,24 @@
{
"name": "mypublicaddress",
"id": "/subscriptions/fakeb2f5-4710-4e93-bdf4-419edbde2178/resourceGroups/myresourcegroup/providers/Microsoft.Network/publicIPAddresses/mypublicaddress",
"etag": "W/\"0b020646-202f-4ac6-b1a7-f9645db7c371\"",
"type": "Microsoft.Network/publicIPAddresses",
"location": "northeurope",
"tags": {
"testkey": "testvalue"
},
"properties": {
"provisioningState": "Succeeded",
"resourceGuid": "eb0da01e-2a30-4e84-b7a4-0ce9dde019f5",
"ipAddress": "12.123.12.123",
"publicIPAllocationMethod": "Static",
"idleTimeoutInMinutes": 4,
"dnsSettings": {
"domainNameLabel": "foobar",
"fqdn": "foobar.northeurope.cloudapp.azure.com"
},
"ipConfiguration": {
"id": "/subscriptions/fakeb2f5-4710-4e93-bdf4-419edbde2178/resourceGroups/myresourcegroup/providers/Microsoft.Network/networkInterfaces/myNic/ipConfigurations/myip1"
}
}
}

View File

@ -0,0 +1,80 @@
{
"value": [
{
"name": "my2ndpublicaddress",
"id": "/subscriptions/fakeb2f5-4710-4e93-bdf4-419edbde2178/resourceGroups/myresourcegroup/providers/Microsoft.Network/publicIPAddresses/my2ndpublicaddress",
"etag": "W/\"b83fa879-46ee-48a9-8120-26572449788f\"",
"type": "Microsoft.Network/publicIPAddresses",
"location": "northeurope",
"tags": {
"testkey": "testvalue"
},
"properties": {
"provisioningState": "Succeeded",
"resourceGuid": "ebe3f160-2484-447a-8980-c587b214b16f",
"publicIPAllocationMethod": "Dynamic",
"idleTimeoutInMinutes": 4,
"dnsSettings": {
"domainNameLabel": "foobar123",
"fqdn": "foobar123.northeurope.cloudapp.azure.com"
}
}
},
{
"name": "my3rdpublicaddress",
"id": "/subscriptions/fakeb2f5-4710-4e93-bdf4-419edbde2178/resourceGroups/myresourcegroup/providers/Microsoft.Network/publicIPAddresses/my3rdpublicaddress",
"etag": "W/\"17d2cf9a-7aa8-4c53-a5b8-ebc2ccb7bf93\"",
"type": "Microsoft.Network/publicIPAddresses",
"location": "northeurope",
"tags": {
"testkey": "testvalue"
},
"properties": {
"provisioningState": "Succeeded",
"resourceGuid": "e1107240-79c5-4829-ba16-f7a00c2763df",
"ipAddress": "12.12.123.123",
"publicIPAllocationMethod": "Static",
"idleTimeoutInMinutes": 4
}
},
{
"name": "my4thpublicaddress",
"id": "/subscriptions/fakeb2f5-4710-4e93-bdf4-419edbde2178/resourceGroups/myresourcegroup/providers/Microsoft.Network/publicIPAddresses/my4thpublicaddress",
"etag": "W/\"c32275e9-e1fc-465a-a5de-728c1359e123\"",
"type": "Microsoft.Network/publicIPAddresses",
"location": "northeurope",
"tags": {
"testkey": "testvalue"
},
"properties": {
"provisioningState": "Succeeded",
"resourceGuid": "dbde9a83-8c1a-43f4-8d81-0fa469703e8a",
"ipAddress": "12.12.123.124",
"publicIPAllocationMethod": "Static",
"idleTimeoutInMinutes": 4
}
},
{
"name": "mypublicaddress",
"id": "/subscriptions/fakeb2f5-4710-4e93-bdf4-419edbde2178/resourceGroups/myresourcegroup/providers/Microsoft.Network/publicIPAddresses/mypublicaddress",
"etag": "W/\"0b020646-202f-4ac6-b1a7-f9645db7c371\"",
"type": "Microsoft.Network/publicIPAddresses",
"location": "northeurope",
"tags": {},
"properties": {
"provisioningState": "Succeeded",
"resourceGuid": "eb0da01e-2a30-4e84-b7a4-0ce9dde019f5",
"ipAddress": "12.123.12.125",
"publicIPAllocationMethod": "Static",
"idleTimeoutInMinutes": 4,
"dnsSettings": {
"domainNameLabel": "foobar",
"fqdn": "foobar.northeurope.cloudapp.azure.com"
},
"ipConfiguration": {
"id": "/subscriptions/fakeb2f5-4710-4e93-bdf4-419edbde2178/resourceGroups/myresourcegroup/providers/Microsoft.Network/networkInterfaces/myNic/ipConfigurations/myip1"
}
}
}
]
}

View File

@ -0,0 +1,35 @@
{
"name": "myNic",
"id": "/subscriptions/12345678-2749-4e68-9dcf-123456789abc/resourceGroups/azurearmtesting/providers/Microsoft.Network/networkInterfaces/myNic",
"etag": "W/\"6b51f6e7-232b-4289-b740-04a996929f5e\"",
"type": "Microsoft.Network/networkInterfaces",
"location": "northeurope",
"tags": {
"mycustomtag": "foobar"
},
"properties": {
"provisioningState": "Succeeded",
"resourceGuid": "f3465472-536f-49e7-9e9c-fa91b971a618",
"ipConfigurations": [
{
"name": "myip1",
"id": "/subscriptions/12345678-2749-4e68-9dcf-123456789abc/resourceGroups/azurearmtesting/providers/Microsoft.Network/networkInterfaces/myNic/ipConfigurations/myip1",
"etag": "W/\"6b51f6e7-232b-4289-b740-04a996929f5e\"",
"properties": {
"provisioningState": "Succeeded",
"privateIPAddress": "10.2.0.4",
"privateIPAllocationMethod": "Dynamic",
"subnet": {
"id": "/subscriptions/12345678-2749-4e68-9dcf-123456789abc/resourceGroups/azurearmtesting/providers/Microsoft.Network/virtualNetworks/myvirtualnetwork/subnets/mysubnet"
},
"primary": true
}
}
],
"dnsSettings": {
"dnsServers": [],
"appliedDnsServers": []
},
"enableIPForwarding": false
}
}

View File

@ -0,0 +1,47 @@
{
"properties": {
"vmId": "27ee085b-d707-xxxx-yyyy-2370e2eb1cc1",
"hardwareProfile": {
"vmSize": "Standard_D1"
},
"storageProfile": {
"imageReference": {
"publisher": "publisher",
"offer": "offer",
"sku": "sku",
"version": "ver"
},
"osDisk": {
"osType": "Windows",
"name": "windowsmachine",
"createOption": "FromImage",
"vhd": {
"uri": "https://groupname2760.blob.core.windows.net/vhds/windowsmachine201624102936.vhd"
},
"caching": "ReadWrite"
},
"dataDisks": []
},
"osProfile": {
"computerName": "windowsmachine",
"adminUsername": "azureuser",
"windowsConfiguration": {
"provisionVMAgent": false,
"enableAutomaticUpdates": true
},
"secrets": []
},
"networkProfile": {"networkInterfaces":[{"id":"/subscriptions/SUBSCRIPTIONID/resourceGroups/groupname/providers/Microsoft.Network/networkInterfaces/windowsmachine167"}]},
"diagnosticsProfile": {
"bootDiagnostics": {
"enabled": true,
"storageUri": "https://groupname2760.blob.core.windows.net/"
}
},
"provisioningState": "Creating"
},
"id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/groupname/providers/Microsoft.Compute/virtualMachines/windowsmachine",
"name": "windowsmachine",
"type": "Microsoft.Compute/virtualMachines",
"location": "westus"
}

View File

@ -0,0 +1,35 @@
{
"name": "myNic",
"id": "/subscriptions/12345678-2749-4e68-9dcf-123456789abc/resourceGroups/azurearmtesting/providers/Microsoft.Network/networkInterfaces/myNic",
"etag": "W/\"3dff0c55-a7a7-434f-837b-0cad946b755f\"",
"type": "Microsoft.Network/networkInterfaces",
"location": "northeurope",
"tags": {
"mycustomtag": "foobar"
},
"properties": {
"provisioningState": "Succeeded",
"resourceGuid": "f3465472-536f-49e7-9e9c-fa91b971a618",
"ipConfigurations": [
{
"name": "myip1",
"id": "/subscriptions/12345678-2749-4e68-9dcf-123456789abc/resourceGroups/azurearmtesting/providers/Microsoft.Network/networkInterfaces/myNic/ipConfigurations/myip1",
"etag": "W/\"3dff0c55-a7a7-434f-837b-0cad946b755f\"",
"properties": {
"provisioningState": "Succeeded",
"privateIPAddress": "10.2.0.4",
"privateIPAllocationMethod": "Dynamic",
"subnet": {
"id": "/subscriptions/12345678-2749-4e68-9dcf-123456789abc/resourceGroups/azurearmtesting/providers/Microsoft.Network/virtualNetworks/myvirtualnetwork/subnets/mysubnet"
},
"primary": true
}
}
],
"dnsSettings": {
"dnsServers": [],
"appliedDnsServers": []
},
"enableIPForwarding": false
}
}

View File

@ -0,0 +1,68 @@
{
"value": [
{
"name": "AnotherNIC",
"id": "/subscriptions/12345678-2749-4e68-9dcf-123456789abc/resourceGroups/azurearmtesting/providers/Microsoft.Network/networkInterfaces/AnotherNIC",
"etag": "W/\"e4ed4253-64b6-4184-bfaa-554f470d20c5\"",
"type": "Microsoft.Network/networkInterfaces",
"location": "northeurope",
"properties": {
"provisioningState": "Succeeded",
"resourceGuid": "7fcf6704-21c5-4983-bd9f-017e0873f22f",
"ipConfigurations": [
{
"name": "ipconfig1",
"id": "/subscriptions/12345678-2749-4e68-9dcf-123456789abc/resourceGroups/azurearmtesting/providers/Microsoft.Network/networkInterfaces/AnotherNIC/ipConfigurations/ipconfig1",
"etag": "W/\"e4ed4253-64b6-4184-bfaa-554f470d20c5\"",
"properties": {
"provisioningState": "Succeeded",
"privateIPAddress": "10.2.1.4",
"privateIPAllocationMethod": "Dynamic",
"subnet": {
"id": "/subscriptions/12345678-2749-4e68-9dcf-123456789abc/resourceGroups/armlivetesting/providers/Microsoft.Network/virtualNetworks/jclouds-virtual-network-live-test/subnets/anothersubnet"
},
"primary": true
}
}
],
"dnsSettings": {
"dnsServers": [],
"appliedDnsServers": []
},
"enableIPForwarding": false
}
},
{
"name": "MyNic",
"id": "/subscriptions/12345678-2749-4e68-9dcf-123456789abc/resourceGroups/azurearmtesting/providers/Microsoft.Network/networkInterfaces/MyNic",
"etag": "W/\"a37d25ff-3f62-4ee2-a111-f355beb5ff69\"",
"type": "Microsoft.Network/networkInterfaces",
"location": "northeurope",
"properties": {
"provisioningState": "Succeeded",
"resourceGuid": "35908409-a081-4411-86a9-51f9ea99321f",
"ipConfigurations": [
{
"name": "ipconfig1",
"id": "/subscriptions/12345678-2749-4e68-9dcf-123456789abc/resourceGroups/azurearmtesting/providers/Microsoft.Network/networkInterfaces/MyNic/ipConfigurations/ipconfig1",
"etag": "W/\"a37d25ff-3f62-4ee2-a111-f355beb5ff69\"",
"properties": {
"provisioningState": "Succeeded",
"privateIPAddress": "10.2.0.100",
"privateIPAllocationMethod": "Static",
"subnet": {
"id": "/subscriptions/12345678-2749-4e68-9dcf-123456789abc/resourceGroups/armlivetesting/providers/Microsoft.Network/virtualNetworks/jclouds-virtual-network-live-test/subnets/default"
},
"primary": true
}
}
],
"dnsSettings": {
"dnsServers": [],
"appliedDnsServers": []
},
"enableIPForwarding": false
}
}
]
}

View File

@ -12,7 +12,6 @@
"id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/test2",
"name": "test2",
"location": "eastus",
"tags": {},
"properties": {
"provisioningState": "Succeeded"
}

View File

@ -0,0 +1,47 @@
{
"properties": {
"vmId": "27ee085b-d707-xxxx-yyyy-2370e2eb1cc1",
"hardwareProfile": {
"vmSize": "Standard_D1"
},
"storageProfile": {
"imageReference": {
"publisher": "publisher",
"offer": "offer",
"sku": "sku",
"version": "ver"
},
"osDisk": {
"osType": "Windows",
"name": "windowsmachine",
"createOption": "FromImage",
"vhd": {
"uri": "https://groupname2760.blob.core.windows.net/vhds/windowsmachine201624102936.vhd"
},
"caching": "ReadWrite"
},
"dataDisks": []
},
"osProfile": {
"computerName": "windowsmachine",
"adminUsername": "azureuser",
"windowsConfiguration": {
"provisionVMAgent": false,
"enableAutomaticUpdates": true
},
"secrets": []
},
"networkProfile": {"networkInterfaces":[{"id":"/subscriptions/SUBSCRIPTIONID/resourceGroups/groupname/providers/Microsoft.Network/networkInterfaces/windowsmachine167"}]},
"diagnosticsProfile": {
"bootDiagnostics": {
"enabled": true,
"storageUri": "https://groupname2760.blob.core.windows.net/"
}
},
"provisioningState": "Creating"
},
"id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/groupname/providers/Microsoft.Compute/virtualMachines/windowsmachine",
"name": "windowsmachine",
"type": "Microsoft.Compute/virtualMachines",
"location": "westus"
}

View File

@ -0,0 +1,40 @@
{
"vmAgent": {
"vmAgentVersion": "2.7.1198.766",
"statuses": [
{
"code": "ProvisioningState/succeeded",
"level": "Info",
"displayStatus": "Ready",
"message": "GuestAgent is running and accepting new configurations.",
"time": "2016-05-04T08:42:15+00:00"
}
]
},
"disks": [
{
"name": "windowsmachine",
"statuses": [
{
"code": "ProvisioningState/succeeded",
"level": "Info",
"displayStatus": "Provisioning succeeded",
"time": "2016-05-04T08:31:45.2525129+00:00"
}
]
}
],
"statuses": [
{
"code": "ProvisioningState/succeeded",
"level": "Info",
"displayStatus": "Provisioning succeeded",
"time": "2016-05-04T08:38:52.4310433+00:00"
},
{
"code": "PowerState/running",
"level": "Info",
"displayStatus": "VM running"
}
]
}

View File

@ -0,0 +1,57 @@
{
"value": [
{
"properties": {
"vmId": "27ee085b-d707-xxxx-yyyy-2370e2eb1cc1",
"hardwareProfile": {
"vmSize": "Standard_D1"
},
"storageProfile": {
"imageReference": {
"publisher": "publisher",
"offer": "offer",
"sku": "sku",
"version": "ver"
},
"osDisk": {
"osType": "Windows",
"name": "windowsmachine",
"createOption": "FromImage",
"vhd": {
"uri": "https://groupname2760.blob.core.windows.net/vhds/windowsmachine201624102936.vhd"
},
"caching": "ReadWrite"
},
"dataDisks": []
},
"osProfile": {
"computerName": "windowsmachine",
"adminUsername": "azureuser",
"windowsConfiguration": {
"provisionVMAgent": false,
"enableAutomaticUpdates": true
},
"secrets": []
},
"networkProfile": {
"networkInterfaces": [
{
"id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/groupname/providers/Microsoft.Network/networkInterfaces/windowsmachine167"
}
]
},
"diagnosticsProfile": {
"bootDiagnostics": {
"enabled": true,
"storageUri": "https://groupname2760.blob.core.windows.net/"
}
},
"provisioningState": "Creating"
},
"id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/groupname/providers/Microsoft.Compute/virtualMachines/windowsmachine",
"name": "windowsmachine",
"type": "Microsoft.Compute/virtualMachines",
"location": "westus"
}
]
}