http://git-wip-us.apache.org/repos/asf/jclouds/blob/ea5b899d/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/IPSecEncryption.java ---------------------------------------------------------------------- diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/IPSecEncryption.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/IPSecEncryption.java new file mode 100644 index 0000000..a9405c5 --- /dev/null +++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/IPSecEncryption.java @@ -0,0 +1,28 @@ +/* + * 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.vpn; + +import org.jclouds.azurecompute.arm.util.GetEnumValue; + +public enum IPSecEncryption { + + AES128, AES192, AES256, DES, DES3, GCMAES128, GCMAES192, GCMAES256, None, Unrecognized; + + public static IPSecEncryption fromValue(final String text) { + return (IPSecEncryption) GetEnumValue.fromValueOrDefault(text, IPSecEncryption.Unrecognized); + } +}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/ea5b899d/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/IPSecIntegrity.java ---------------------------------------------------------------------- diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/IPSecIntegrity.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/IPSecIntegrity.java new file mode 100644 index 0000000..02dc6ee --- /dev/null +++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/IPSecIntegrity.java @@ -0,0 +1,28 @@ +/* + * 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.vpn; + +import org.jclouds.azurecompute.arm.util.GetEnumValue; + +public enum IPSecIntegrity { + + GCMAES128, GCMAES192, GCMAES256, MD5, SHA1, SHA256, Unrecognized; + + public static IPSecIntegrity fromValue(final String text) { + return (IPSecIntegrity) GetEnumValue.fromValueOrDefault(text, IPSecIntegrity.Unrecognized); + } +} http://git-wip-us.apache.org/repos/asf/jclouds/blob/ea5b899d/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/IPSecPolicy.java ---------------------------------------------------------------------- diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/IPSecPolicy.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/IPSecPolicy.java new file mode 100644 index 0000000..d744fb0 --- /dev/null +++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/IPSecPolicy.java @@ -0,0 +1,77 @@ +/* + * 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.vpn; + +import org.jclouds.azurecompute.arm.domain.AddressSpace; +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.json.SerializedNames; + +import com.google.auto.value.AutoValue; + +@AutoValue +public abstract class IPSecPolicy { + @Nullable public abstract String radiusServerAddress(); + @Nullable public abstract String radiusServerSecret(); + @Nullable public abstract AddressSpace vpnClientAddressPool(); + @Nullable public abstract DHGroup dhGroup(); + @Nullable public abstract IkeEncryption ikeEncryption(); + @Nullable public abstract IkeIntegrity ikeIntegrity(); + @Nullable public abstract IPSecEncryption ipsecEncryption(); + @Nullable public abstract IPSecIntegrity ipsecIntegrity(); + @Nullable public abstract PFSGroup pfsGroup(); + @Nullable public abstract Integer saDataSizeKilobytes(); + @Nullable public abstract Integer saLifeTimeSeconds(); + + IPSecPolicy() { + + } + + @SerializedNames({ "radiusServerAddress", "radiusServerSecret", "vpnClientAddressPool", "dhGroup", "ikeEncryption", + "ikeIntegrity", "ipsecEncryption", "ipsecIntegrity", "pfsGroup", "saDataSizeKilobytes", "saLifeTimeSeconds" }) + public static IPSecPolicy create(String radiusServerAddress, String radiusServerSecret, + AddressSpace vpnClientAddressPool, DHGroup dhGroup, IkeEncryption ikeEncryption, IkeIntegrity ikeIntegrity, + IPSecEncryption ipsecEncryption, IPSecIntegrity ipsecIntegrity, PFSGroup pfsGroup, + Integer saDataSizeKilobytes, Integer saLifeTimeSeconds) { + return builder().radiusServerAddress(radiusServerAddress).radiusServerSecret(radiusServerSecret) + .vpnClientAddressPool(vpnClientAddressPool).dhGroup(dhGroup).ikeEncryption(ikeEncryption) + .ikeIntegrity(ikeIntegrity).ipsecEncryption(ipsecEncryption).ipsecIntegrity(ipsecIntegrity) + .pfsGroup(pfsGroup).saDataSizeKilobytes(saDataSizeKilobytes).saLifeTimeSeconds(saLifeTimeSeconds).build(); + } + + public static Builder builder() { + return new AutoValue_IPSecPolicy.Builder(); + } + + public abstract Builder toBuilder(); + + @AutoValue.Builder + public abstract static class Builder { + public abstract Builder radiusServerAddress(String radiusServerAddress); + public abstract Builder radiusServerSecret(String radiusServerSecret); + public abstract Builder vpnClientAddressPool(AddressSpace vpnClientAddressPool); + public abstract Builder dhGroup(DHGroup dhGroup); + public abstract Builder ikeEncryption(IkeEncryption ikeEncryption); + public abstract Builder ikeIntegrity(IkeIntegrity ikeIntegrity); + public abstract Builder ipsecEncryption(IPSecEncryption ipsecEncryption); + public abstract Builder ipsecIntegrity(IPSecIntegrity ipsecIntegrity); + public abstract Builder pfsGroup(PFSGroup pfsGroup); + public abstract Builder saDataSizeKilobytes(Integer saDataSizeKilobytes); + public abstract Builder saLifeTimeSeconds(Integer saLifeTimeSeconds); + + public abstract IPSecPolicy build(); + } +} http://git-wip-us.apache.org/repos/asf/jclouds/blob/ea5b899d/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/IkeEncryption.java ---------------------------------------------------------------------- diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/IkeEncryption.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/IkeEncryption.java new file mode 100644 index 0000000..0ac8637 --- /dev/null +++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/IkeEncryption.java @@ -0,0 +1,28 @@ +/* + * 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.vpn; + +import org.jclouds.azurecompute.arm.util.GetEnumValue; + +public enum IkeEncryption { + + AES128, AES192, AES256, DES, DES3, GCMAES128, GCMAES256, Unrecognized; + + public static IkeEncryption fromValue(final String text) { + return (IkeEncryption) GetEnumValue.fromValueOrDefault(text, IkeEncryption.Unrecognized); + } +} http://git-wip-us.apache.org/repos/asf/jclouds/blob/ea5b899d/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/IkeIntegrity.java ---------------------------------------------------------------------- diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/IkeIntegrity.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/IkeIntegrity.java new file mode 100644 index 0000000..1697347 --- /dev/null +++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/IkeIntegrity.java @@ -0,0 +1,28 @@ +/* + * 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.vpn; + +import org.jclouds.azurecompute.arm.util.GetEnumValue; + +public enum IkeIntegrity { + + GCMAES128, GCMAES256, MD5, SHA1, SHA256, SHA384, Unrecognized; + + public static IkeIntegrity fromValue(final String text) { + return (IkeIntegrity) GetEnumValue.fromValueOrDefault(text, IkeIntegrity.Unrecognized); + } +} http://git-wip-us.apache.org/repos/asf/jclouds/blob/ea5b899d/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/LocalNetworkGateway.java ---------------------------------------------------------------------- diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/LocalNetworkGateway.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/LocalNetworkGateway.java new file mode 100644 index 0000000..95d8fcd --- /dev/null +++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/LocalNetworkGateway.java @@ -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.vpn; + +import java.util.Map; + +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.json.SerializedNames; + +import com.google.auto.value.AutoValue; +import com.google.common.collect.ImmutableMap; + +@AutoValue +public abstract class LocalNetworkGateway { + + @Nullable public abstract String id(); + public abstract String name(); + public abstract String location(); + @Nullable public abstract String type(); + @Nullable public abstract Map<String, String> tags(); + @Nullable public abstract String etag(); + public abstract LocalNetworkGatewayProperties properties(); + + LocalNetworkGateway() { + + } + + @SerializedNames({ "id", "name", "location", "type", "tags", "etag", "properties" }) + public static LocalNetworkGateway create(String id, String name, String location, String type, + Map<String, String> tags, String etag, LocalNetworkGatewayProperties properties) { + return builder(name, location, properties).id(id).type(type).tags(tags).etag(etag).build(); + } + + public abstract Builder toBuilder(); + + public static Builder builder(String name, String location, LocalNetworkGatewayProperties properties) { + return new AutoValue_LocalNetworkGateway.Builder().name(name).location(location).properties(properties); + } + + @AutoValue.Builder + public abstract static class Builder { + public abstract Builder id(String id); + public abstract Builder name(String name); + public abstract Builder location(String location); + public abstract Builder type(String type); + public abstract Builder tags(Map<String, String> tags); + public abstract Builder etag(String etag); + public abstract Builder properties(LocalNetworkGatewayProperties properties); + + abstract Map<String, String> tags(); + abstract LocalNetworkGateway autoBuild(); + + public LocalNetworkGateway build() { + tags(tags() != null ? ImmutableMap.copyOf(tags()) : null); + return autoBuild(); + } + } +} http://git-wip-us.apache.org/repos/asf/jclouds/blob/ea5b899d/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/LocalNetworkGatewayProperties.java ---------------------------------------------------------------------- diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/LocalNetworkGatewayProperties.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/LocalNetworkGatewayProperties.java new file mode 100644 index 0000000..031dcb9 --- /dev/null +++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/LocalNetworkGatewayProperties.java @@ -0,0 +1,63 @@ +/* + * 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.vpn; + +import org.jclouds.azurecompute.arm.domain.AddressSpace; +import org.jclouds.azurecompute.arm.domain.Provisionable; +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.json.SerializedNames; + +import com.google.auto.value.AutoValue; + +@AutoValue +public abstract class LocalNetworkGatewayProperties implements Provisionable { + + @Nullable public abstract BGPSettings bgpSettings(); + public abstract String gatewayIpAddress(); + @Nullable public abstract AddressSpace localNetworkAddressSpace(); + @Nullable public abstract String provisioningState(); + @Nullable public abstract String resourceGuid(); + + @SerializedNames({ "bgpSettings", "gatewayIpAddress", "localNetworkAddressSpace", "provisioningState", + "resourceGuid" }) + public static LocalNetworkGatewayProperties create(BGPSettings bgpSettings, String gatewayIpAddress, + AddressSpace localNetworkAddressSpace, String provisioningState, String resourceGuid) { + return builder(gatewayIpAddress).bgpSettings(bgpSettings).localNetworkAddressSpace(localNetworkAddressSpace) + .provisioningState(provisioningState).resourceGuid(resourceGuid).build(); + } + + LocalNetworkGatewayProperties() { + + } + + public abstract LocalNetworkGatewayProperties.Builder toBuilder(); + + public static LocalNetworkGatewayProperties.Builder builder(String gatewayIpAddress) { + return new AutoValue_LocalNetworkGatewayProperties.Builder().gatewayIpAddress(gatewayIpAddress); + } + + @AutoValue.Builder + public abstract static class Builder { + public abstract Builder bgpSettings(BGPSettings bgpSettings); + public abstract Builder gatewayIpAddress(String gatewayIpAddress); + public abstract Builder localNetworkAddressSpace(AddressSpace localNetworkAddressSpace); + public abstract Builder provisioningState(String provisioningState); + public abstract Builder resourceGuid(String resourceGuid); + + public abstract LocalNetworkGatewayProperties build(); + } +} http://git-wip-us.apache.org/repos/asf/jclouds/blob/ea5b899d/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/PFSGroup.java ---------------------------------------------------------------------- diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/PFSGroup.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/PFSGroup.java new file mode 100644 index 0000000..5ff43ae --- /dev/null +++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/PFSGroup.java @@ -0,0 +1,28 @@ +/* + * 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.vpn; + +import org.jclouds.azurecompute.arm.util.GetEnumValue; + +public enum PFSGroup { + + ECP256, ECP384, PFS1, PFS14, PFS2, PFS2048, PFS24, PFSMM, None, Unrecognized; + + public static PFSGroup fromValue(final String text) { + return (PFSGroup) GetEnumValue.fromValueOrDefault(text, PFSGroup.Unrecognized); + } +} http://git-wip-us.apache.org/repos/asf/jclouds/blob/ea5b899d/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/SKU.java ---------------------------------------------------------------------- diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/SKU.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/SKU.java new file mode 100644 index 0000000..9ddf18a --- /dev/null +++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/SKU.java @@ -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.vpn; + +import org.jclouds.azurecompute.arm.util.GetEnumValue; +import org.jclouds.json.SerializedNames; + +import com.google.auto.value.AutoValue; + +@AutoValue +public abstract class SKU { + + public static enum SKUName { + Basic, HighPerformance, Standard, UltraPerformance, VpnGw1, VpnGw2, VpnGw3, Unrecognized; + + public static SKUName fromValue(final String text) { + return (SKUName) GetEnumValue.fromValueOrDefault(text, SKUName.Unrecognized); + } + } + + public static enum SKUTier { + Basic, HighPerformance, Standard, UltraPerformance, VpnGw1, VpnGw2, VpnGw3, Unrecognized; + + public static SKUTier fromValue(final String text) { + return (SKUTier) GetEnumValue.fromValueOrDefault(text, SKUTier.Unrecognized); + } + } + + public abstract int capacity(); + public abstract SKUName name(); + public abstract SKUTier tier(); + + SKU() { + + } + + @SerializedNames({ "capacity", "name", "tier" }) + public static SKU create(int capacity, SKUName name, SKUTier tier) { + return new AutoValue_SKU(capacity, name, tier); + } +} http://git-wip-us.apache.org/repos/asf/jclouds/blob/ea5b899d/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/VPNClientConfiguration.java ---------------------------------------------------------------------- diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/VPNClientConfiguration.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/VPNClientConfiguration.java new file mode 100644 index 0000000..14871c0 --- /dev/null +++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/VPNClientConfiguration.java @@ -0,0 +1,89 @@ +/* + * 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.vpn; + +import java.util.List; + +import org.jclouds.azurecompute.arm.domain.AddressSpace; +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.json.SerializedNames; + +import com.google.auto.value.AutoValue; +import com.google.common.collect.ImmutableList; + +@AutoValue +public abstract class VPNClientConfiguration { + @Nullable public abstract String radiusServerAddress(); + @Nullable public abstract String radiusServerSecret(); + @Nullable public abstract AddressSpace vpnClientAddressPool(); + public abstract List<IPSecPolicy> vpnClientIpsecPolicies(); + public abstract List<String> vpnClientProtocols(); + public abstract List<VPNClientRevokedCertificate> vpnClientRevokedCertificates(); + public abstract List<VPNClientRootCertificate> vpnClientRootCertificates(); + + VPNClientConfiguration() { + + } + + @SerializedNames({ "radiusServerAddress", "radiusServerSecret", "vpnClientAddressPool", "vpnClientIpsecPolicies", + "vpnClientProtocols", "vpnClientRevokedCertificates", "vpnClientRootCertificates" }) + public static VPNClientConfiguration create(String radiusServerAddress, String radiusServerSecret, + AddressSpace vpnClientAddressPool, List<IPSecPolicy> vpnClientIpsecPolicies, List<String> vpnClientProtocols, + List<VPNClientRevokedCertificate> vpnClientRevokedCertificates, + List<VPNClientRootCertificate> vpnClientRootCertificates) { + return builder().radiusServerAddress(radiusServerAddress).radiusServerSecret(radiusServerSecret) + .vpnClientAddressPool(vpnClientAddressPool).vpnClientIpsecPolicies(vpnClientIpsecPolicies) + .vpnClientProtocols(vpnClientProtocols).vpnClientRevokedCertificates(vpnClientRevokedCertificates) + .vpnClientRootCertificates(vpnClientRootCertificates).build(); + } + + public static Builder builder() { + return new AutoValue_VPNClientConfiguration.Builder(); + } + + public abstract Builder toBuilder(); + + @AutoValue.Builder + public abstract static class Builder { + public abstract Builder radiusServerAddress(String radiusServerAddress); + public abstract Builder radiusServerSecret(String radiusServerSecret); + public abstract Builder vpnClientAddressPool(AddressSpace vpnClientAddressPool); + public abstract Builder vpnClientIpsecPolicies(List<IPSecPolicy> vpnClientIpsecPolicies); + public abstract Builder vpnClientProtocols(List<String> vpnClientProtocols); + public abstract Builder vpnClientRevokedCertificates(List<VPNClientRevokedCertificate> vpnClientRevokedCertificates); + public abstract Builder vpnClientRootCertificates(List<VPNClientRootCertificate> vpnClientRootCertificates); + + abstract List<IPSecPolicy> vpnClientIpsecPolicies(); + abstract List<String> vpnClientProtocols(); + abstract List<VPNClientRevokedCertificate> vpnClientRevokedCertificates(); + abstract List<VPNClientRootCertificate> vpnClientRootCertificates(); + abstract VPNClientConfiguration autoBuild(); + + public VPNClientConfiguration build() { + vpnClientIpsecPolicies(vpnClientIpsecPolicies() == null ? ImmutableList.<IPSecPolicy> of() : ImmutableList + .copyOf(vpnClientIpsecPolicies())); + vpnClientProtocols(vpnClientProtocols() == null ? ImmutableList.<String> of() : ImmutableList + .copyOf(vpnClientProtocols())); + vpnClientRevokedCertificates(vpnClientRevokedCertificates() == null ? ImmutableList + .<VPNClientRevokedCertificate> of() : ImmutableList.copyOf(vpnClientRevokedCertificates())); + vpnClientRootCertificates(vpnClientRootCertificates() == null ? ImmutableList.<VPNClientRootCertificate> of() + : ImmutableList.copyOf(vpnClientRootCertificates())); + + return autoBuild(); + } + } +} http://git-wip-us.apache.org/repos/asf/jclouds/blob/ea5b899d/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/VPNClientRevokedCertificate.java ---------------------------------------------------------------------- diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/VPNClientRevokedCertificate.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/VPNClientRevokedCertificate.java new file mode 100644 index 0000000..39232cc --- /dev/null +++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/VPNClientRevokedCertificate.java @@ -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.vpn; + +import org.jclouds.azurecompute.arm.domain.Provisionable; +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.json.SerializedNames; + +import com.google.auto.value.AutoValue; + +@AutoValue +public abstract class VPNClientRevokedCertificate { + @Nullable public abstract String id(); + public abstract String name(); + @Nullable public abstract String etag(); + public abstract VPNClientRevokedCertificateProperties properties(); + + VPNClientRevokedCertificate() { + + } + + @SerializedNames({ "id", "name", "etag", "properties" }) + public static VPNClientRevokedCertificate create(String id, String name, String etag, + VPNClientRevokedCertificateProperties properties) { + return new AutoValue_VPNClientRevokedCertificate(id, name, etag, properties); + } + + @AutoValue + public abstract static class VPNClientRevokedCertificateProperties implements Provisionable { + public abstract String provisioningState(); + public abstract String thumbprint(); + + VPNClientRevokedCertificateProperties() { + + } + + @SerializedNames({ "provisioningState", "thumbprint" }) + public static VPNClientRevokedCertificateProperties create(String provisioningState, String thumbprint) { + return new AutoValue_VPNClientRevokedCertificate_VPNClientRevokedCertificateProperties(provisioningState, + thumbprint); + } + } +} http://git-wip-us.apache.org/repos/asf/jclouds/blob/ea5b899d/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/VPNClientRootCertificate.java ---------------------------------------------------------------------- diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/VPNClientRootCertificate.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/VPNClientRootCertificate.java new file mode 100644 index 0000000..0271c32 --- /dev/null +++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/VPNClientRootCertificate.java @@ -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.vpn; + +import org.jclouds.azurecompute.arm.domain.Provisionable; +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.json.SerializedNames; + +import com.google.auto.value.AutoValue; + +@AutoValue +public abstract class VPNClientRootCertificate { + @Nullable public abstract String id(); + public abstract String name(); + @Nullable public abstract String etag(); + public abstract VPNClientRootCertificateProperties properties(); + + VPNClientRootCertificate() { + + } + + @SerializedNames({ "id", "name", "etag", "properties" }) + public static VPNClientRootCertificate create(String id, String name, String etag, + VPNClientRootCertificateProperties properties) { + return new AutoValue_VPNClientRootCertificate(id, name, etag, properties); + } + + @AutoValue + public abstract static class VPNClientRootCertificateProperties implements Provisionable { + public abstract String provisioningState(); + public abstract String publicCertData(); + + VPNClientRootCertificateProperties() { + + } + + @SerializedNames({ "provisioningState", "publicCertData" }) + public static VPNClientRootCertificateProperties create(String provisioningState, String publicCertData) { + return new AutoValue_VPNClientRootCertificate_VPNClientRootCertificateProperties(provisioningState, + publicCertData); + } + } +} http://git-wip-us.apache.org/repos/asf/jclouds/blob/ea5b899d/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/VPNType.java ---------------------------------------------------------------------- diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/VPNType.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/VPNType.java new file mode 100644 index 0000000..d65cacf --- /dev/null +++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/VPNType.java @@ -0,0 +1,27 @@ +/* + * 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.vpn; + +import org.jclouds.azurecompute.arm.util.GetEnumValue; + +public enum VPNType { + PolicyBased, RouteBased, Unrecognized; + + public static VPNType fromValue(final String text) { + return (VPNType) GetEnumValue.fromValueOrDefault(text, VPNType.Unrecognized); + } +} http://git-wip-us.apache.org/repos/asf/jclouds/blob/ea5b899d/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/VirtualNetworkGateway.java ---------------------------------------------------------------------- diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/VirtualNetworkGateway.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/VirtualNetworkGateway.java new file mode 100644 index 0000000..68f9579 --- /dev/null +++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/VirtualNetworkGateway.java @@ -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.vpn; + +import java.util.Map; + +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.json.SerializedNames; + +import com.google.auto.value.AutoValue; +import com.google.common.collect.ImmutableMap; + +@AutoValue +public abstract class VirtualNetworkGateway { + + @Nullable public abstract String id(); + public abstract String name(); + public abstract String location(); + @Nullable public abstract String type(); + @Nullable public abstract Map<String, String> tags(); + @Nullable public abstract String etag(); + public abstract VirtualNetworkGatewayProperties properties(); + + VirtualNetworkGateway() { + + } + + @SerializedNames({ "id", "name", "location", "type", "tags", "etag", "properties" }) + public static VirtualNetworkGateway create(String id, String name, String location, String type, + Map<String, String> tags, String etag, VirtualNetworkGatewayProperties properties) { + return builder(name, location, properties).id(id).type(type).tags(tags).etag(etag).build(); + } + + public abstract Builder toBuilder(); + + public static Builder builder(String name, String location, VirtualNetworkGatewayProperties properties) { + return new AutoValue_VirtualNetworkGateway.Builder().name(name).location(location).properties(properties); + } + + @AutoValue.Builder + public abstract static class Builder { + public abstract Builder id(String id); + public abstract Builder name(String name); + public abstract Builder location(String location); + public abstract Builder type(String type); + public abstract Builder tags(Map<String, String> tags); + public abstract Builder etag(String etag); + public abstract Builder properties(VirtualNetworkGatewayProperties properties); + + abstract Map<String, String> tags(); + abstract VirtualNetworkGateway autoBuild(); + + public VirtualNetworkGateway build() { + tags(tags() != null ? ImmutableMap.copyOf(tags()) : null); + return autoBuild(); + } + } +} http://git-wip-us.apache.org/repos/asf/jclouds/blob/ea5b899d/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/VirtualNetworkGatewayProperties.java ---------------------------------------------------------------------- diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/VirtualNetworkGatewayProperties.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/VirtualNetworkGatewayProperties.java new file mode 100644 index 0000000..1d30f5f --- /dev/null +++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/VirtualNetworkGatewayProperties.java @@ -0,0 +1,144 @@ +/* + * 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.vpn; + +import java.util.List; + +import org.jclouds.azurecompute.arm.domain.IdReference; +import org.jclouds.azurecompute.arm.domain.IpAllocationMethod; +import org.jclouds.azurecompute.arm.domain.Provisionable; +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.json.SerializedNames; + +import com.google.auto.value.AutoValue; +import com.google.common.collect.ImmutableList; + +@AutoValue +public abstract class VirtualNetworkGatewayProperties implements Provisionable { + + @Nullable public abstract Boolean activeActive(); + @Nullable public abstract BGPSettings bgpSettings(); + public abstract boolean enableBGP(); + @Nullable public abstract IdReference gatewayDefaultSite(); + public abstract VirtualNetworkGatewayType gatewayType(); + public abstract List<IpConfiguration> ipConfigurations(); + @Nullable public abstract String provisioningState(); + @Nullable public abstract String resourceGuid(); + public abstract SKU sku(); + @Nullable public abstract VPNClientConfiguration vpnClientConfiguration(); + @Nullable public abstract VPNType vpnType(); + + VirtualNetworkGatewayProperties() { + + } + + @SerializedNames({ "activeActive", "bgpSettings", "enableBgp", "gatewayDefaultSite", "gatewayType", + "ipConfigurations", "provisioningState", "resourceGuid", "sku", "vpnClientConfiguration", "vpnType" }) + public static VirtualNetworkGatewayProperties create(Boolean activeActive, BGPSettings bgpSettings, + boolean enableBGP, IdReference gatewayDefaultSite, VirtualNetworkGatewayType gatewayType, + List<IpConfiguration> ipConfigurations, String provisioningState, String resourceGuid, SKU sku, + VPNClientConfiguration vpnClientConfiguration, VPNType vpnType) { + return builder(enableBGP, gatewayType, sku).activeActive(activeActive).bgpSettings(bgpSettings) + .gatewayDefaultSite(gatewayDefaultSite).ipConfigurations(ipConfigurations) + .provisioningState(provisioningState).resourceGuid(resourceGuid) + .vpnClientConfiguration(vpnClientConfiguration).vpnType(vpnType).build(); + } + + public static Builder builder(boolean enableBGP, VirtualNetworkGatewayType virtualNetworkGatewayType, SKU sku) { + return new AutoValue_VirtualNetworkGatewayProperties.Builder().enableBGP(enableBGP) + .gatewayType(virtualNetworkGatewayType).sku(sku); + } + + public abstract Builder toBuilder(); + + @AutoValue.Builder + public abstract static class Builder { + public abstract Builder activeActive( Boolean activeActive); + public abstract Builder bgpSettings(BGPSettings bgpSettings); + public abstract Builder enableBGP(boolean enableBG); + public abstract Builder gatewayDefaultSite(IdReference gatewayDefaultSite); + public abstract Builder gatewayType(VirtualNetworkGatewayType gatewayType); + public abstract Builder ipConfigurations(List<IpConfiguration> ipConfigurations); + public abstract Builder provisioningState(String provisioningState); + public abstract Builder resourceGuid(String resourceGuid); + public abstract Builder sku(SKU sku); + public abstract Builder vpnClientConfiguration(VPNClientConfiguration vpnClientConfiguration); + public abstract Builder vpnType(VPNType vpnType); + + abstract List<IpConfiguration> ipConfigurations(); + abstract VirtualNetworkGatewayProperties autoBuild(); + + public VirtualNetworkGatewayProperties build() { + ipConfigurations(ipConfigurations() == null ? ImmutableList.<IpConfiguration> of() : ImmutableList + .copyOf(ipConfigurations())); + return autoBuild(); + } + } + + @AutoValue + public abstract static class IpConfiguration { + @Nullable public abstract String id(); + public abstract String name(); + @Nullable public abstract String etag(); + public abstract IpConfigurationProperties properties(); + + IpConfiguration() { + + } + + @SerializedNames({ "id", "name", "etag", "properties" }) + public static IpConfiguration create(String id, String name, String etag, IpConfigurationProperties properties) { + return new AutoValue_VirtualNetworkGatewayProperties_IpConfiguration(id, name, etag, properties); + } + + @AutoValue + public abstract static class IpConfigurationProperties implements Provisionable { + public abstract IpAllocationMethod privateIPAllocationMethod(); + @Nullable public abstract String provisioningState(); + @Nullable public abstract IdReference publicIPAddress(); + @Nullable public abstract IdReference subnet(); + + @SerializedNames({ "privateIPAllocationMethod", "provisioningState", "publicIPAddress", "subnet" }) + public static IpConfigurationProperties create(IpAllocationMethod privateIPAllocationMethod, + String provisioningState, IdReference publicIPAddress, IdReference subnet) { + return builder(privateIPAllocationMethod).provisioningState(provisioningState) + .publicIPAddress(publicIPAddress).subnet(subnet).build(); + } + + IpConfigurationProperties() { + + } + + public static Builder builder(IpAllocationMethod privateIPAllocationMethod) { + return new AutoValue_VirtualNetworkGatewayProperties_IpConfiguration_IpConfigurationProperties.Builder() + .privateIPAllocationMethod(privateIPAllocationMethod); + } + + public abstract Builder toBuilder(); + + @AutoValue.Builder + public abstract static class Builder { + public abstract Builder privateIPAllocationMethod(IpAllocationMethod privateIPAllocationMethod); + public abstract Builder provisioningState(String provisioningState); + public abstract Builder publicIPAddress(IdReference publicIPAddress); + public abstract Builder subnet(IdReference subnet); + + public abstract IpConfigurationProperties build(); + } + } + } +} http://git-wip-us.apache.org/repos/asf/jclouds/blob/ea5b899d/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/VirtualNetworkGatewayType.java ---------------------------------------------------------------------- diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/VirtualNetworkGatewayType.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/VirtualNetworkGatewayType.java new file mode 100644 index 0000000..46ec025 --- /dev/null +++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/VirtualNetworkGatewayType.java @@ -0,0 +1,28 @@ +/* + * 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.vpn; + +import org.jclouds.azurecompute.arm.util.GetEnumValue; + +public enum VirtualNetworkGatewayType { + ExpressRoute, Vpn, Unrecognized; + + public static VirtualNetworkGatewayType fromValue(final String text) { + return (VirtualNetworkGatewayType) GetEnumValue.fromValueOrDefault(text, + VirtualNetworkGatewayType.Unrecognized); + } +} http://git-wip-us.apache.org/repos/asf/jclouds/blob/ea5b899d/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/features/LocalNetworkGatewayApi.java ---------------------------------------------------------------------- diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/features/LocalNetworkGatewayApi.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/features/LocalNetworkGatewayApi.java index a868e40..4d8af39 100644 --- a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/features/LocalNetworkGatewayApi.java +++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/features/LocalNetworkGatewayApi.java @@ -32,8 +32,8 @@ import javax.ws.rs.core.MediaType; import org.jclouds.Fallbacks.EmptyListOnNotFoundOr404; import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.azurecompute.arm.domain.LocalNetworkGateway; -import org.jclouds.azurecompute.arm.domain.LocalNetworkGatewayProperties; +import org.jclouds.azurecompute.arm.domain.vpn.LocalNetworkGateway; +import org.jclouds.azurecompute.arm.domain.vpn.LocalNetworkGatewayProperties; import org.jclouds.azurecompute.arm.filters.ApiVersionFilter; import org.jclouds.azurecompute.arm.functions.URIParser; import org.jclouds.javax.annotation.Nullable; http://git-wip-us.apache.org/repos/asf/jclouds/blob/ea5b899d/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/features/VirtualNetworkGatewayApi.java ---------------------------------------------------------------------- diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/features/VirtualNetworkGatewayApi.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/features/VirtualNetworkGatewayApi.java new file mode 100644 index 0000000..0fb62c3 --- /dev/null +++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/features/VirtualNetworkGatewayApi.java @@ -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.features; + +import java.io.Closeable; +import java.net.URI; +import java.util.List; +import java.util.Map; + +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 org.jclouds.Fallbacks.EmptyListOnNotFoundOr404; +import org.jclouds.Fallbacks.NullOnNotFoundOr404; +import org.jclouds.azurecompute.arm.domain.vpn.VirtualNetworkGateway; +import org.jclouds.azurecompute.arm.domain.vpn.VirtualNetworkGatewayProperties; +import org.jclouds.azurecompute.arm.filters.ApiVersionFilter; +import org.jclouds.azurecompute.arm.functions.URIParser; +import org.jclouds.javax.annotation.Nullable; +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.RequestFilters; +import org.jclouds.rest.annotations.ResponseParser; +import org.jclouds.rest.annotations.SelectJson; +import org.jclouds.rest.binders.BindToJsonPayload; + +@Path("/resourcegroups/{resourcegroup}/providers/Microsoft.Network/virtualNetworkGateways") +@RequestFilters({ OAuthFilter.class, ApiVersionFilter.class }) +@Consumes(MediaType.APPLICATION_JSON) +public interface VirtualNetworkGatewayApi extends Closeable { + + @Named("virtualnetworkgateway:list") + @GET + @SelectJson("value") + @Fallback(EmptyListOnNotFoundOr404.class) + List<VirtualNetworkGateway> list(); + + @Named("virtualnetworkgateway:get") + @Path("/{name}") + @GET + @Fallback(NullOnNotFoundOr404.class) + VirtualNetworkGateway get(@PathParam("name") String name); + + @Named("virtualnetworkgateway:createOrUpdate") + @MapBinder(BindToJsonPayload.class) + @Path("/{name}") + @PUT + VirtualNetworkGateway createOrUpdate(@PathParam("name") String name, @PayloadParam("location") String location, + @Nullable @PayloadParam("tags") Map<String, String> tags, + @PayloadParam("properties") VirtualNetworkGatewayProperties properties); + + @Named("virtualnetworkgateway:delete") + @Path("/{name}") + @DELETE + @ResponseParser(URIParser.class) + @Fallback(NullOnNotFoundOr404.class) + URI delete(@PathParam("name") String name); +} http://git-wip-us.apache.org/repos/asf/jclouds/blob/ea5b899d/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/LocalNetworkGatewayApiLiveTest.java ---------------------------------------------------------------------- diff --git a/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/LocalNetworkGatewayApiLiveTest.java b/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/LocalNetworkGatewayApiLiveTest.java index 301df03..bdf26ee 100644 --- a/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/LocalNetworkGatewayApiLiveTest.java +++ b/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/LocalNetworkGatewayApiLiveTest.java @@ -23,10 +23,10 @@ import static org.testng.Assert.assertTrue; import java.net.URI; -import org.jclouds.azurecompute.arm.domain.LocalNetworkGateway; -import org.jclouds.azurecompute.arm.domain.LocalNetworkGatewayProperties; -import org.jclouds.azurecompute.arm.domain.LocalNetworkGatewayProperties.AddressSpace; +import org.jclouds.azurecompute.arm.domain.AddressSpace; import org.jclouds.azurecompute.arm.domain.Provisionable; +import org.jclouds.azurecompute.arm.domain.vpn.LocalNetworkGateway; +import org.jclouds.azurecompute.arm.domain.vpn.LocalNetworkGatewayProperties; import org.jclouds.azurecompute.arm.internal.BaseAzureComputeApiLiveTest; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -52,7 +52,7 @@ public class LocalNetworkGatewayApiLiveTest extends BaseAzureComputeApiLiveTest @Test public void createLocalNetworkGateway() { AddressSpace localAddresses = AddressSpace.create(ImmutableList.of("192.168.0.0/24")); - LocalNetworkGatewayProperties props = LocalNetworkGatewayProperties.builder().gatewayIpAddress("1.2.3.4") + LocalNetworkGatewayProperties props = LocalNetworkGatewayProperties.builder("1.2.3.4") .localNetworkAddressSpace(localAddresses).build(); LocalNetworkGateway gw = api().createOrUpdate(name, LOCATION, null, props); http://git-wip-us.apache.org/repos/asf/jclouds/blob/ea5b899d/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/LocalNetworkGatewayApiMockTest.java ---------------------------------------------------------------------- diff --git a/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/LocalNetworkGatewayApiMockTest.java b/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/LocalNetworkGatewayApiMockTest.java index 840c872..e7efa71 100644 --- a/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/LocalNetworkGatewayApiMockTest.java +++ b/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/LocalNetworkGatewayApiMockTest.java @@ -25,9 +25,9 @@ import static org.testng.Assert.assertTrue; import java.net.URI; import java.util.List; -import org.jclouds.azurecompute.arm.domain.LocalNetworkGateway; -import org.jclouds.azurecompute.arm.domain.LocalNetworkGatewayProperties; -import org.jclouds.azurecompute.arm.domain.LocalNetworkGatewayProperties.AddressSpace; +import org.jclouds.azurecompute.arm.domain.AddressSpace; +import org.jclouds.azurecompute.arm.domain.vpn.LocalNetworkGateway; +import org.jclouds.azurecompute.arm.domain.vpn.LocalNetworkGatewayProperties; import org.jclouds.azurecompute.arm.internal.BaseAzureComputeApiMockTest; import org.testng.annotations.Test; @@ -46,7 +46,7 @@ public class LocalNetworkGatewayApiMockTest extends BaseAzureComputeApiMockTest LocalNetworkGatewayApi gwapi = api.getLocalNetworkGatewayApi(resourcegroup); AddressSpace localAddresses = AddressSpace.create(ImmutableList.of("192.168.0.0/24")); - LocalNetworkGatewayProperties props = LocalNetworkGatewayProperties.builder().gatewayIpAddress("1.2.3.4") + LocalNetworkGatewayProperties props = LocalNetworkGatewayProperties.builder("1.2.3.4") .localNetworkAddressSpace(localAddresses).build(); LocalNetworkGateway gw = gwapi.createOrUpdate(name, "westeurope", null, props); http://git-wip-us.apache.org/repos/asf/jclouds/blob/ea5b899d/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/NetworkInterfaceCardApiLiveTest.java ---------------------------------------------------------------------- diff --git a/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/NetworkInterfaceCardApiLiveTest.java b/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/NetworkInterfaceCardApiLiveTest.java index d7caab0..0d1e6ca 100644 --- a/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/NetworkInterfaceCardApiLiveTest.java +++ b/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/NetworkInterfaceCardApiLiveTest.java @@ -49,7 +49,6 @@ public class NetworkInterfaceCardApiLiveTest extends BaseAzureComputeApiLiveTest public void setup() { super.setup(); createTestResourceGroup(); - assertNotNull(api.getResourceGroupApi().create(resourceGroupName, LOCATION, ImmutableMap.<String, String>of())); String virtualNetworkName = String.format("vn-%s-%s", this.getClass().getSimpleName().toLowerCase(), System.getProperty("user.name")); nicName = String.format("nic-%s-%s", this.getClass().getSimpleName().toLowerCase(), System.getProperty("user.name")); String subnetName = String.format("s-%s-%s", this.getClass().getSimpleName().toLowerCase(), System.getProperty("user.name")); http://git-wip-us.apache.org/repos/asf/jclouds/blob/ea5b899d/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualNetworkApiLiveTest.java ---------------------------------------------------------------------- diff --git a/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualNetworkApiLiveTest.java b/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualNetworkApiLiveTest.java index c0271d3..5a89b07 100644 --- a/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualNetworkApiLiveTest.java +++ b/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualNetworkApiLiveTest.java @@ -24,6 +24,7 @@ import static org.testng.Assert.assertTrue; import java.util.Arrays; import java.util.List; +import org.jclouds.azurecompute.arm.domain.AddressSpace; import org.jclouds.azurecompute.arm.domain.VirtualNetwork; import org.jclouds.azurecompute.arm.internal.BaseAzureComputeApiLiveTest; import org.testng.annotations.BeforeClass; @@ -53,7 +54,7 @@ public class VirtualNetworkApiLiveTest extends BaseAzureComputeApiLiveTest { final VirtualNetwork.VirtualNetworkProperties virtualNetworkProperties = VirtualNetwork.VirtualNetworkProperties.builder().addressSpace( - VirtualNetwork.AddressSpace.create(Arrays.asList(DEFAULT_VIRTUALNETWORK_ADDRESS_PREFIX))).build(); + AddressSpace.create(Arrays.asList(DEFAULT_VIRTUALNETWORK_ADDRESS_PREFIX))).build(); VirtualNetwork vn = api().createOrUpdate(virtualNetworkName, LOCATION, null, virtualNetworkProperties); http://git-wip-us.apache.org/repos/asf/jclouds/blob/ea5b899d/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualNetworkApiMockTest.java ---------------------------------------------------------------------- diff --git a/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualNetworkApiMockTest.java b/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualNetworkApiMockTest.java index 8ba0406..2cf3a41 100644 --- a/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualNetworkApiMockTest.java +++ b/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualNetworkApiMockTest.java @@ -16,21 +16,19 @@ */ package org.jclouds.azurecompute.arm.features; -import org.jclouds.azurecompute.arm.domain.VirtualNetwork; - -import org.testng.annotations.Test; - -import org.jclouds.azurecompute.arm.internal.BaseAzureComputeApiMockTest; - -import java.util.Arrays; -import java.util.List; - import static com.google.common.collect.Iterables.isEmpty; - import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertTrue; import static org.testng.Assert.assertNull; +import static org.testng.Assert.assertTrue; + +import java.util.Arrays; +import java.util.List; + +import org.jclouds.azurecompute.arm.domain.AddressSpace; +import org.jclouds.azurecompute.arm.domain.VirtualNetwork; +import org.jclouds.azurecompute.arm.internal.BaseAzureComputeApiMockTest; +import org.testng.annotations.Test; @Test(groups = "unit", testName = "VirtualNetworkApiMockTest", singleThreaded = true) public class VirtualNetworkApiMockTest extends BaseAzureComputeApiMockTest { @@ -98,7 +96,7 @@ public class VirtualNetworkApiMockTest extends BaseAzureComputeApiMockTest { final VirtualNetwork.VirtualNetworkProperties virtualNetworkProperties = VirtualNetwork.VirtualNetworkProperties.create(null, null, - VirtualNetwork.AddressSpace.create(Arrays.asList("10.2.0.0/16")), null); + AddressSpace.create(Arrays.asList("10.2.0.0/16")), null); vnApi.createOrUpdate(virtualNetwork, location, null, virtualNetworkProperties); http://git-wip-us.apache.org/repos/asf/jclouds/blob/ea5b899d/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualNetworkGatewayApiLiveTest.java ---------------------------------------------------------------------- diff --git a/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualNetworkGatewayApiLiveTest.java b/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualNetworkGatewayApiLiveTest.java new file mode 100644 index 0000000..4faaf2d --- /dev/null +++ b/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualNetworkGatewayApiLiveTest.java @@ -0,0 +1,132 @@ +/* + * 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 static com.google.common.collect.Iterables.any; +import static java.util.Collections.singletonList; +import static org.jclouds.azurecompute.arm.domain.vpn.VirtualNetworkGatewayType.Vpn; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertTrue; + +import java.net.URI; +import java.util.Collections; + +import org.jclouds.azurecompute.arm.domain.IdReference; +import org.jclouds.azurecompute.arm.domain.IpAllocationMethod; +import org.jclouds.azurecompute.arm.domain.PublicIPAddress; +import org.jclouds.azurecompute.arm.domain.PublicIPAddressProperties; +import org.jclouds.azurecompute.arm.domain.Subnet; +import org.jclouds.azurecompute.arm.domain.VirtualNetwork; +import org.jclouds.azurecompute.arm.domain.vpn.SKU; +import org.jclouds.azurecompute.arm.domain.vpn.SKU.SKUName; +import org.jclouds.azurecompute.arm.domain.vpn.SKU.SKUTier; +import org.jclouds.azurecompute.arm.domain.vpn.VPNType; +import org.jclouds.azurecompute.arm.domain.vpn.VirtualNetworkGateway; +import org.jclouds.azurecompute.arm.domain.vpn.VirtualNetworkGatewayProperties; +import org.jclouds.azurecompute.arm.domain.vpn.VirtualNetworkGatewayProperties.IpConfiguration; +import org.jclouds.azurecompute.arm.domain.vpn.VirtualNetworkGatewayProperties.IpConfiguration.IpConfigurationProperties; +import org.jclouds.azurecompute.arm.internal.BaseAzureComputeApiLiveTest; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import com.google.common.base.Predicate; +import com.google.common.collect.ImmutableMap; + +@Test(groups = "live", testName = "VirtualNetworkGatewayApiLiveTest", singleThreaded = true) +public class VirtualNetworkGatewayApiLiveTest extends BaseAzureComputeApiLiveTest { + + private String name; + private String subnetId; + private PublicIPAddress publicIp; + private Predicate<String> virtualNetworkGatewayAvailable; + + @BeforeClass + @Override + public void setup() { + super.setup(); + createTestResourceGroup(); + name = "jclouds-" + RAND; + virtualNetworkGatewayAvailable = virtualNetworkGatewayStatus.create(resourceGroupName); + + VirtualNetwork vnet = createDefaultVirtualNetwork(resourceGroupName, name + "-net", "10.2.0.0/16", LOCATION); + Subnet subnet = createDefaultSubnet(resourceGroupName, Subnet.GATEWAY_SUBNET_NAME, vnet.name(), "10.2.0.0/23"); + subnetId = subnet.id(); + + PublicIPAddressProperties props = PublicIPAddressProperties.builder() + .publicIPAllocationMethod(IpAllocationMethod.Dynamic.name()).idleTimeoutInMinutes(4).build(); + publicIp = api.getPublicIPAddressApi(resourceGroupName).createOrUpdate(name + "-publicip", LOCATION, + Collections.<String, String> emptyMap(), props); + } + + @Test + public void createVirtualNetworkGateway() { + IpConfigurationProperties ipprops = IpConfigurationProperties.builder(IpAllocationMethod.Dynamic) + .subnet(IdReference.create(subnetId)).publicIPAddress(IdReference.create(publicIp.id())).build(); + IpConfiguration ipconf = IpConfiguration.create(null, name + "-ipconf", null, ipprops); + + VirtualNetworkGatewayProperties props = VirtualNetworkGatewayProperties + .builder(false, Vpn, SKU.create(1, SKUName.Basic, SKUTier.Basic)).vpnType(VPNType.PolicyBased) + .ipConfigurations(singletonList(ipconf)).build(); + + VirtualNetworkGateway gw = api().createOrUpdate(name, LOCATION, null, props); + + assertNotNull(gw); + assertEquals(gw.name(), name); + assertNotNull(gw.properties()); + } + + @Test(dependsOnMethods = "createVirtualNetworkGateway") + public void getVirtualNetworkGateway() { + assertNotNull(api().get(name)); + } + + @Test(dependsOnMethods = "createVirtualNetworkGateway") + public void listVirtualNetworkGateways() { + assertTrue(any(api().list(), new Predicate<VirtualNetworkGateway>() { + @Override + public boolean apply(VirtualNetworkGateway input) { + return name.equals(input.name()); + } + })); + } + + @Test(dependsOnMethods = "createVirtualNetworkGateway") + public void updateVirtualNetworkGateway() { + // Make sure the resource is fully provisioned before modifying it + assertTrue(virtualNetworkGatewayAvailable.apply(name)); + + VirtualNetworkGateway gw = api().get(name); + gw = api().createOrUpdate(name, LOCATION, ImmutableMap.of("foo", "bar"), gw.properties()); + + assertNotNull(gw); + assertTrue(gw.tags().containsKey("foo")); + assertEquals(gw.tags().get("foo"), "bar"); + } + + @Test(dependsOnMethods = { "getVirtualNetworkGateway", "listVirtualNetworkGateways", "updateVirtualNetworkGateway" }, alwaysRun = true) + public void deleteVirtualNetworkGateway() { + // Make sure the resource is fully provisioned before deleting it + assertTrue(virtualNetworkGatewayAvailable.apply(name)); + URI uri = api().delete(name); + assertResourceDeleted(uri); + } + + private VirtualNetworkGatewayApi api() { + return api.getVirtualNetworkGatewayApi(resourceGroupName); + } +} http://git-wip-us.apache.org/repos/asf/jclouds/blob/ea5b899d/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualNetworkGatewayApiMockTest.java ---------------------------------------------------------------------- diff --git a/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualNetworkGatewayApiMockTest.java b/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualNetworkGatewayApiMockTest.java new file mode 100644 index 0000000..1c8096f --- /dev/null +++ b/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualNetworkGatewayApiMockTest.java @@ -0,0 +1,161 @@ +/* + * 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 static com.google.common.collect.Iterables.isEmpty; +import static java.util.Collections.singletonList; +import static org.jclouds.azurecompute.arm.domain.vpn.VirtualNetworkGatewayType.Vpn; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertNull; +import static org.testng.Assert.assertTrue; + +import java.net.URI; +import java.util.List; + +import org.jclouds.azurecompute.arm.domain.IdReference; +import org.jclouds.azurecompute.arm.domain.IpAllocationMethod; +import org.jclouds.azurecompute.arm.domain.vpn.SKU; +import org.jclouds.azurecompute.arm.domain.vpn.SKU.SKUName; +import org.jclouds.azurecompute.arm.domain.vpn.SKU.SKUTier; +import org.jclouds.azurecompute.arm.domain.vpn.VPNType; +import org.jclouds.azurecompute.arm.domain.vpn.VirtualNetworkGateway; +import org.jclouds.azurecompute.arm.domain.vpn.VirtualNetworkGatewayProperties; +import org.jclouds.azurecompute.arm.domain.vpn.VirtualNetworkGatewayProperties.IpConfiguration; +import org.jclouds.azurecompute.arm.domain.vpn.VirtualNetworkGatewayProperties.IpConfiguration.IpConfigurationProperties; +import org.jclouds.azurecompute.arm.domain.vpn.VirtualNetworkGatewayType; +import org.jclouds.azurecompute.arm.internal.BaseAzureComputeApiMockTest; +import org.testng.annotations.Test; + +@Test(groups = "unit", testName = "VirtualNetworkGatewayApiMockTest", singleThreaded = true) +public class VirtualNetworkGatewayApiMockTest extends BaseAzureComputeApiMockTest { + + private final String subscriptionid = "SUBSCRIPTIONID"; + private final String resourcegroup = "myresourcegroup"; + private final String name = "myvirtualgw"; + private final String apiVersion = "api-version=2018-02-01"; + + private static final String SUBNET_ID = "/subscriptions/SUBSCRIPTIONID/resourceGroups/rg-virtualnetworkgatewayapilivetest-nacx/providers/Microsoft.Network/virtualNetworks/myvirtualgw-net/subnets/GatewaySubnet"; + private static final String PUBLIC_IP = "/subscriptions/SUBSCRIPTIONID/resourceGroups/rg-virtualnetworkgatewayapilivetest-nacx/providers/Microsoft.Network/publicIPAddresses/myvirtualgw-publicip"; + + public void createOrUpdateVirtualNetworkGateway() throws InterruptedException { + server.enqueue(jsonResponse("/virtualnetworkgatewaycreate.json").setResponseCode(200)); + VirtualNetworkGatewayApi gwapi = api.getVirtualNetworkGatewayApi(resourcegroup); + + IpConfigurationProperties ipprops = IpConfigurationProperties.builder(IpAllocationMethod.Dynamic) + .subnet(IdReference.create(SUBNET_ID)).publicIPAddress(IdReference.create(PUBLIC_IP)).build(); + IpConfiguration ipconf = IpConfiguration.create(null, name + "-ipconf", null, ipprops); + + VirtualNetworkGatewayProperties props = VirtualNetworkGatewayProperties + .builder(false, Vpn, SKU.create(1, SKUName.Basic, SKUTier.Basic)).vpnType(VPNType.PolicyBased) + .ipConfigurations(singletonList(ipconf)).build(); + + VirtualNetworkGateway gw = gwapi.createOrUpdate(name, "westeurope", null, props); + + String path = String.format( + "/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Network/virtualNetworkGateways/%s?%s", + subscriptionid, resourcegroup, name, apiVersion); + String json = "{\"location\":\"westeurope\",\"properties\":{\"enableBgp\":false,\"gatewayType\":\"Vpn\",\"ipConfigurations\":[{\"name\":\"myvirtualgw-ipconf\",\"properties\":{\"privateIPAllocationMethod\":\"Dynamic\",\"publicIPAddress\":{\"id\":\"/subscriptions/SUBSCRIPTIONID/resourceGroups/rg-virtualnetworkgatewayapilivetest-nacx/providers/Microsoft.Network/publicIPAddresses/myvirtualgw-publicip\"},\"subnet\":{\"id\":\"/subscriptions/SUBSCRIPTIONID/resourceGroups/rg-virtualnetworkgatewayapilivetest-nacx/providers/Microsoft.Network/virtualNetworks/myvirtualgw-net/subnets/GatewaySubnet\"}}}],\"sku\":{\"capacity\":1,\"name\":\"Basic\",\"tier\":\"Basic\"},\"vpnType\":\"PolicyBased\"}}"; + assertSent(server, "PUT", path, json); + + assertEquals(gw.name(), name); + assertNotNull(gw.properties()); + assertEquals(gw.properties().gatewayType(), VirtualNetworkGatewayType.Vpn); + } + + public void getVirtualNetworkGateway() throws InterruptedException { + server.enqueue(jsonResponse("/virtualnetworkgatewayget.json").setResponseCode(200)); + VirtualNetworkGatewayApi gwapi = api.getVirtualNetworkGatewayApi(resourcegroup); + + VirtualNetworkGateway gw = gwapi.get(name); + + String path = String.format( + "/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Network/virtualNetworkGateways/%s?%s", + subscriptionid, resourcegroup, name, apiVersion); + assertSent(server, "GET", path); + + assertEquals(gw.name(), name); + } + + public void getVirtualNetworkGatewayReturns404() throws InterruptedException { + server.enqueue(response404()); + VirtualNetworkGatewayApi gwapi = api.getVirtualNetworkGatewayApi(resourcegroup); + + VirtualNetworkGateway gw = gwapi.get(name); + + String path = String.format( + "/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Network/virtualNetworkGateways/%s?%s", + subscriptionid, resourcegroup, name, apiVersion); + assertSent(server, "GET", path); + + assertNull(gw); + } + + public void listVirtualNetworkGateways() throws InterruptedException { + server.enqueue(jsonResponse("/virtualnetworkgatewaylist.json").setResponseCode(200)); + VirtualNetworkGatewayApi gwapi = api.getVirtualNetworkGatewayApi(resourcegroup); + + List<VirtualNetworkGateway> gws = gwapi.list(); + + String path = String.format( + "/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Network/virtualNetworkGateways?%s", + subscriptionid, resourcegroup, apiVersion); + assertSent(server, "GET", path); + + assertTrue(gws.size() > 0); + } + + public void listVirtualNetworkGatewaysReturns404() throws InterruptedException { + server.enqueue(response404()); + VirtualNetworkGatewayApi gwapi = api.getVirtualNetworkGatewayApi(resourcegroup); + + List<VirtualNetworkGateway> gws = gwapi.list(); + + String path = String.format( + "/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Network/virtualNetworkGateways?%s", + subscriptionid, resourcegroup, apiVersion); + assertSent(server, "GET", path); + + assertTrue(isEmpty(gws)); + } + + public void deleteVirtualNetworkGateway() throws InterruptedException { + server.enqueue(response202WithHeader()); + VirtualNetworkGatewayApi gwapi = api.getVirtualNetworkGatewayApi(resourcegroup); + + URI uri = gwapi.delete(name); + assertNotNull(uri); + + String path = String.format( + "/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Network/virtualNetworkGateways/%s?%s", + subscriptionid, resourcegroup, name, apiVersion); + assertSent(server, "DELETE", path); + } + + public void deleteVirtualNetworkGatewayDoesNotExist() throws InterruptedException { + server.enqueue(response204()); + VirtualNetworkGatewayApi gwapi = api.getVirtualNetworkGatewayApi(resourcegroup); + + URI uri = gwapi.delete(name); + assertNull(uri); + + String path = String.format( + "/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Network/virtualNetworkGateways/%s?%s", + subscriptionid, resourcegroup, name, apiVersion); + assertSent(server, "DELETE", path); + } +} http://git-wip-us.apache.org/repos/asf/jclouds/blob/ea5b899d/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/internal/BaseAzureComputeApiLiveTest.java ---------------------------------------------------------------------- diff --git a/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/internal/BaseAzureComputeApiLiveTest.java b/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/internal/BaseAzureComputeApiLiveTest.java index 78d5425..5833834 100644 --- a/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/internal/BaseAzureComputeApiLiveTest.java +++ b/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/internal/BaseAzureComputeApiLiveTest.java @@ -17,19 +17,19 @@ package org.jclouds.azurecompute.arm.internal; import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_IMAGE_AVAILABLE; -import static org.jclouds.util.Predicates2.retry; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.TIMEOUT_RESOURCE_DELETED; +import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.VAULT_CERTIFICATE_DELETE_STATUS; +import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.VAULT_CERTIFICATE_OPERATION_STATUS; +import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.VAULT_CERTIFICATE_RECOVERABLE_STATUS; import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.VAULT_DELETE_STATUS; -import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.VAULT_SECRET_DELETE_STATUS; -import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.VAULT_SECRET_RECOVERABLE_STATUS; import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.VAULT_KEY_DELETED_STATUS; import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.VAULT_KEY_RECOVERABLE_STATUS; -import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.VAULT_CERTIFICATE_DELETE_STATUS; -import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.VAULT_CERTIFICATE_RECOVERABLE_STATUS; -import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.VAULT_CERTIFICATE_OPERATION_STATUS; +import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.VAULT_SECRET_DELETE_STATUS; +import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.VAULT_SECRET_RECOVERABLE_STATUS; +import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_IMAGE_AVAILABLE; +import static org.jclouds.util.Predicates2.retry; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertTrue; import java.io.IOException; import java.net.URI; @@ -38,21 +38,20 @@ import java.util.List; import java.util.Properties; import java.util.Random; -import com.google.common.base.Charsets; -import com.google.common.base.Throwables; -import com.google.common.io.Resources; import org.jclouds.apis.BaseApiLiveTest; import org.jclouds.azurecompute.arm.AzureComputeApi; -import org.jclouds.azurecompute.arm.config.Tenant; -import org.jclouds.azurecompute.arm.compute.config.AzurePredicatesModule.VaultPredicates.DeletedVaultStatusPredicateFactory; +import org.jclouds.azurecompute.arm.compute.config.AzurePredicatesModule.PublicIpAvailablePredicateFactory; +import org.jclouds.azurecompute.arm.compute.config.AzurePredicatesModule.VaultCertificatePredicates.CertificateOperationStatusPredicateFactory; +import org.jclouds.azurecompute.arm.compute.config.AzurePredicatesModule.VaultCertificatePredicates.DeletedCertificateStatusPredicateFactory; +import org.jclouds.azurecompute.arm.compute.config.AzurePredicatesModule.VaultCertificatePredicates.RecoverableCertificateStatusPredicateFactory; import org.jclouds.azurecompute.arm.compute.config.AzurePredicatesModule.VaultKeyPredicates.DeletedKeyStatusPredicateFactory; import org.jclouds.azurecompute.arm.compute.config.AzurePredicatesModule.VaultKeyPredicates.RecoverableKeyStatusPredicateFactory; +import org.jclouds.azurecompute.arm.compute.config.AzurePredicatesModule.VaultPredicates.DeletedVaultStatusPredicateFactory; import org.jclouds.azurecompute.arm.compute.config.AzurePredicatesModule.VaultSecretPredicates.DeletedSecretStatusPredicateFactory; import org.jclouds.azurecompute.arm.compute.config.AzurePredicatesModule.VaultSecretPredicates.RecoverableSecretStatusPredicateFactory; -import org.jclouds.azurecompute.arm.compute.config.AzurePredicatesModule.VaultCertificatePredicates.CertificateOperationStatusPredicateFactory; -import org.jclouds.azurecompute.arm.compute.config.AzurePredicatesModule.VaultCertificatePredicates.DeletedCertificateStatusPredicateFactory; -import org.jclouds.azurecompute.arm.compute.config.AzurePredicatesModule.VaultCertificatePredicates.RecoverableCertificateStatusPredicateFactory; -import org.jclouds.azurecompute.arm.compute.config.AzurePredicatesModule.PublicIpAvailablePredicateFactory; +import org.jclouds.azurecompute.arm.compute.config.AzurePredicatesModule.VirtualNetworkGatewayAvailablePredicateFactory; +import org.jclouds.azurecompute.arm.config.Tenant; +import org.jclouds.azurecompute.arm.domain.AddressSpace; import org.jclouds.azurecompute.arm.domain.NetworkSecurityGroup; import org.jclouds.azurecompute.arm.domain.NetworkSecurityGroupProperties; import org.jclouds.azurecompute.arm.domain.NetworkSecurityRule; @@ -64,15 +63,18 @@ import org.jclouds.azurecompute.arm.domain.VirtualNetwork; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; +import com.google.common.base.Charsets; import com.google.common.base.Predicate; import com.google.common.base.Supplier; +import com.google.common.base.Throwables; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; -import com.google.inject.name.Names; +import com.google.common.io.Resources; import com.google.inject.Injector; -import com.google.inject.Module; import com.google.inject.Key; +import com.google.inject.Module; import com.google.inject.TypeLiteral; +import com.google.inject.name.Names; public class BaseAzureComputeApiLiveTest extends BaseApiLiveTest<AzureComputeApi> { @@ -84,6 +86,7 @@ public class BaseAzureComputeApiLiveTest extends BaseApiLiveTest<AzureComputeApi protected Predicate<URI> imageAvailablePredicate; protected Predicate<URI> resourceDeleted; protected PublicIpAvailablePredicateFactory publicIpAvailable; + protected VirtualNetworkGatewayAvailablePredicateFactory virtualNetworkGatewayStatus; protected Predicate<Supplier<Provisionable>> resourceAvailable; protected DeletedVaultStatusPredicateFactory deletedVaultStatus; protected DeletedKeyStatusPredicateFactory deletedKeyStatus; @@ -94,7 +97,6 @@ public class BaseAzureComputeApiLiveTest extends BaseApiLiveTest<AzureComputeApi protected RecoverableCertificateStatusPredicateFactory recoverableCertificateStatus; protected CertificateOperationStatusPredicateFactory certificateOperationStatus; - protected String resourceGroupName; protected String vaultResourceGroup; @@ -139,6 +141,7 @@ public class BaseAzureComputeApiLiveTest extends BaseApiLiveTest<AzureComputeApi resourceDeleted = injector.getInstance(Key.get(new TypeLiteral<Predicate<URI>>() { }, Names.named(TIMEOUT_RESOURCE_DELETED))); publicIpAvailable = injector.getInstance(PublicIpAvailablePredicateFactory.class); + virtualNetworkGatewayStatus = injector.getInstance(VirtualNetworkGatewayAvailablePredicateFactory.class); resourceAvailable = injector.getInstance(Key.get(new TypeLiteral<Predicate<Supplier<Provisionable>>>() { })); deletedVaultStatus = injector.getInstance(Key.get(DeletedVaultStatusPredicateFactory.class, Names.named(VAULT_DELETE_STATUS))); @@ -172,7 +175,7 @@ public class BaseAzureComputeApiLiveTest extends BaseApiLiveTest<AzureComputeApi protected VirtualNetwork createDefaultVirtualNetwork(final String resourceGroupName, final String virtualNetworkName, final String virtualnetworkAddressPrefix, final String location) { final VirtualNetwork.VirtualNetworkProperties virtualNetworkProperties = VirtualNetwork.VirtualNetworkProperties.create(null, null, - VirtualNetwork.AddressSpace.create(Arrays.asList(virtualnetworkAddressPrefix)), null); + AddressSpace.create(Arrays.asList(virtualnetworkAddressPrefix)), null); VirtualNetwork virtualNetwork = api.getVirtualNetworkApi(resourceGroupName).createOrUpdate(virtualNetworkName, location, null, virtualNetworkProperties); retry(new Predicate<String>() { @Override
