diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/GroupableResource.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/GroupableResource.java index 2049a7538139e..be337f64e8e91 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/GroupableResource.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/GroupableResource.java @@ -8,6 +8,7 @@ import com.microsoft.azure.management.apigeneration.Fluent; import com.microsoft.azure.management.resources.ResourceGroup; +import com.microsoft.azure.management.resources.fluentcore.arm.Region; import com.microsoft.azure.management.resources.fluentcore.model.Creatable; /** @@ -23,10 +24,11 @@ public interface GroupableResource extends Resource { /** * Grouping of all the definition stages. */ - interface DefinitionStages { /** * A resource definition allowing a resource group to be selected. + *

+ * Region of the groupable resource will be used for new resource group * * @param the next stage of the resource definition */ @@ -36,11 +38,25 @@ interface WithGroup extends } /** - * A resource definition allowing a new resource group to be created. + * A resource definition allowing a resource group to be selected. + *

+ * Region has to be specified explicitly to create a new resource group * * @param the next stage of the resource definition */ - interface WithNewResourceGroup { + interface WithGroupAndRegion extends + WithExistingResourceGroup, + WithNewResourceGroupWithRegion { + } + + /** + * A resource definition allowing a new resource group to be created in the same + * region as groupable resource. + * + * @param the next stage of the resource definition + */ + interface WithNewResourceGroup extends + WithCreatableResourceGroup { /** * Creates a new resource group to put the resource in. *

@@ -58,7 +74,45 @@ interface WithNewResourceGroup { * @return the next stage of the resource definition */ T withNewResourceGroup(); + } + + /** + * A resource definition allowing a new resource group to be created in a different + * region . + * + * @param the next stage of the resource definition + */ + interface WithNewResourceGroupWithRegion extends + WithCreatableResourceGroup { + /** + * Creates a new resource group to put the resource in. + *

+ * The group will be created in the same location as the resource. + * + * @param name the name of the new group + * @param region the region where resource group needs to be created + * @return the next stage of the resource definition + */ + T withNewResourceGroup(String name, Region region); + /** + * Creates a new resource group to put the resource in. + *

+ * The group will be created in the same location as the resource. + * The group's name is automatically derived from the resource's name. + * + * @param region the region where resource group needs to be created + * @return the next stage of the resource definition + */ + T withNewResourceGroup(Region region); + } + + /** + * A resource definition allowing a new creatable resource group to be specified. + * + * @param the next stage of the resource definition + */ + interface WithCreatableResourceGroup { /** * Creates a new resource group to put the resource in, based on the definition specified. * @param groupDefinition a creatable definition for a new resource group diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/implementation/GroupableResourceImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/implementation/GroupableResourceImpl.java index daa5fb6332fd8..ddf2388b6ee23 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/implementation/GroupableResourceImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/implementation/GroupableResourceImpl.java @@ -7,6 +7,7 @@ package com.microsoft.azure.management.resources.fluentcore.arm.models.implementation; import com.microsoft.azure.management.resources.ResourceGroup; +import com.microsoft.azure.management.resources.fluentcore.arm.Region; import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils; import com.microsoft.azure.management.resources.fluentcore.arm.implementation.ManagerBase; import com.microsoft.azure.management.resources.fluentcore.arm.models.GroupableResource; @@ -82,6 +83,20 @@ public final FluentModelImplT withNewResourceGroup(String groupName) { this.myManager.resourceManager().resourceGroups().define(groupName).withRegion(this.regionName())); } + /** + * Creates a new resource group to put the resource in. + *

+ * The group will be created in the same location as the resource. + * + * @param groupName the name of the new group + * @param region the region where resource group needs to be created + * @return the next stage of the resource definition + */ + public final FluentModelImplT withNewResourceGroup(String groupName, Region region) { + return this.withNewResourceGroup( + this.myManager.resourceManager().resourceGroups().define(groupName).withRegion(region)); + } + /** * Creates a new resource group to put the resource in. *

@@ -93,6 +108,19 @@ public final FluentModelImplT withNewResourceGroup() { return this.withNewResourceGroup(this.name() + "group"); } + /** + * Creates a new resource group to put the resource in. + *

+ * The group will be created in the same location as the resource. + * The group's name is automatically derived from the resource's name. + * + * @param region the region where resource group needs to be created + * @return the next stage of the resource definition + */ + public final FluentModelImplT withNewResourceGroup(Region region) { + return this.withNewResourceGroup(this.name() + "group", region); + } + /** * Creates a new resource group to put the resource in, based on the definition specified. * @param creatable a creatable definition for a new resource group diff --git a/azure-mgmt-trafficmanager/pom.xml b/azure-mgmt-trafficmanager/pom.xml new file mode 100644 index 0000000000000..44335d5458d40 --- /dev/null +++ b/azure-mgmt-trafficmanager/pom.xml @@ -0,0 +1,136 @@ + + + 4.0.0 + + com.microsoft.azure + azure-parent + 1.0.0-beta4-SNAPSHOT + ../pom.xml + + + azure-mgmt-trafficmanager + jar + + Microsoft Azure SDK for Traffic Manager Management + This package contains Microsoft Azure Traffic Manager Management SDK. + https://github.com/Azure/azure-sdk-for-java + + + + The MIT License (MIT) + http://opensource.org/licenses/MIT + repo + + + + + scm:git:https://github.com/Azure/azure-sdk-for-java + scm:git:git@github.com:Azure/azure-sdk-for-java.git + HEAD + + + + UTF-8 + + + + + + microsoft + Microsoft + + + + + + com.microsoft.azure + azure-client-runtime + 1.0.0-beta3 + + + com.microsoft.azure + azure-mgmt-resources + 1.0.0-beta4-SNAPSHOT + + + junit + junit + test + + + com.microsoft.azure + azure-client-authentication + 1.0.0-beta3 + test + + + com.microsoft.azure + azure-mgmt-storage + 1.0.0-beta4-SNAPSHOT + + + com.microsoft.azure + api-annotations + 0.0.1 + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + + true + true + + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.1 + + 1.7 + 1.7 + + + com.microsoft.azure.management.apigeneration.LangDefinitionProcessor + + true + true + + true + true + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.8 + + *.implementation.*;*.utils.*;com.microsoft.schemas._2003._10.serialization;*.blob.core.search + /** +
* Copyright (c) Microsoft Corporation. All rights reserved. +
* Licensed under the MIT License. See License.txt in the project root for +
* license information. +
*/]]>
+
+
+ +
+
+
diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/CheckProfileDnsNameAvailabilityResult.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/CheckProfileDnsNameAvailabilityResult.java new file mode 100644 index 0000000000000..3fd6ca0818b06 --- /dev/null +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/CheckProfileDnsNameAvailabilityResult.java @@ -0,0 +1,46 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ +package com.microsoft.azure.management.trafficmanager; + +import com.microsoft.azure.management.trafficmanager.implementation.TrafficManagerNameAvailabilityInner; + +/** + * The {@link com.microsoft.azure.management.trafficmanager.TrafficManagerProfiles#checkDnsNameAvailability} action result. + */ +public class CheckProfileDnsNameAvailabilityResult { + private TrafficManagerNameAvailabilityInner inner; + + /** + * Creates an instance of CheckProfileDnsNameAvailabilityResult. + * + * @param inner the inner object + */ + public CheckProfileDnsNameAvailabilityResult(TrafficManagerNameAvailabilityInner inner) { + this.inner = inner; + } + + /** + * @return true if the DNS name is available to use, false if the name has already been taken + * or invalid and cannot be used. + */ + public boolean isAvailable() { + return inner.nameAvailable(); + } + + /** + * @return the reason that the DNS name could not be used + */ + public ProfileDnsNameUnavailableReason reason() { + return new ProfileDnsNameUnavailableReason(inner.reason()); + } + + /** + * @return an error message explaining the reason value in more detail + */ + public String message() { + return inner.message(); + } +} diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/DnsConfig.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/DnsConfig.java new file mode 100644 index 0000000000000..d77a9d5789fec --- /dev/null +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/DnsConfig.java @@ -0,0 +1,98 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.trafficmanager; + + +/** + * Class containing DNS settings in a Traffic Manager profile. + */ +public class DnsConfig { + /** + * Gets or sets the relative DNS name provided by this Traffic Manager + * profile. This value is combined with the DNS domain name used by + * Azure Traffic Manager to form the fully-qualified domain name (FQDN) + * of the profile. + */ + private String relativeName; + + /** + * Gets or sets the fully-qualified domain name (FQDN) of the Traffic + * Manager profile. This is formed from the concatenation of the + * RelativeName with the DNS domain used by Azure Traffic Manager. + */ + private String fqdn; + + /** + * Gets or sets the DNS Ttime-To-Live (TTL), in seconds. This informs the + * local DNS resolvers and DNS clients how long to cache DNS responses + * provided by this Traffic Manager profile. + */ + private Long ttl; + + /** + * Get the relativeName value. + * + * @return the relativeName value + */ + public String relativeName() { + return this.relativeName; + } + + /** + * Set the relativeName value. + * + * @param relativeName the relativeName value to set + * @return the DnsConfig object itself. + */ + public DnsConfig withRelativeName(String relativeName) { + this.relativeName = relativeName; + return this; + } + + /** + * Get the fqdn value. + * + * @return the fqdn value + */ + public String fqdn() { + return this.fqdn; + } + + /** + * Set the fqdn value. + * + * @param fqdn the fqdn value to set + * @return the DnsConfig object itself. + */ + public DnsConfig withFqdn(String fqdn) { + this.fqdn = fqdn; + return this; + } + + /** + * Get the ttl value. + * + * @return the ttl value + */ + public Long ttl() { + return this.ttl; + } + + /** + * Set the ttl value. + * + * @param ttl the ttl value to set + * @return the DnsConfig object itself. + */ + public DnsConfig withTtl(Long ttl) { + this.ttl = ttl; + return this; + } + +} diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/EndpointMonitorStatus.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/EndpointMonitorStatus.java new file mode 100644 index 0000000000000..416d4c309df07 --- /dev/null +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/EndpointMonitorStatus.java @@ -0,0 +1,67 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ +package com.microsoft.azure.management.trafficmanager; + +/** + * Traffic manager profile endpoint monitor statuses. + */ +public class EndpointMonitorStatus { + /** Static value Inactive for EndpointMonitorStatus. */ + public static final EndpointMonitorStatus INACTIVE = new EndpointMonitorStatus("Inactive"); + + /** Static value Disabled for EndpointMonitorStatus. */ + public static final EndpointMonitorStatus DISABLED = new EndpointMonitorStatus("Disabled"); + + /** Static value Online for EndpointMonitorStatus. */ + public static final EndpointMonitorStatus ONLINE = new EndpointMonitorStatus("Online"); + + /** Static value Degraded for EndpointMonitorStatus. */ + public static final EndpointMonitorStatus DEGRADED = new EndpointMonitorStatus("Degraded"); + + /** Static value CheckingEndpoint for EndpointMonitorStatus. */ + public static final EndpointMonitorStatus CHECKING_ENDPOINT = new EndpointMonitorStatus("CheckingEndpoint"); + + /** Static value Stopped for EndpointMonitorStatus. */ + public static final EndpointMonitorStatus STOPPED = new EndpointMonitorStatus("Stopped"); + + private String value; + + /** + * Creates EndpointMonitorStatus. + * + * @param value the status + */ + public EndpointMonitorStatus(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @Override + public int hashCode() { + return this.value.hashCode(); + } + + @Override + public boolean equals(Object obj) { + String value = this.toString(); + if (!(obj instanceof EndpointMonitorStatus)) { + return false; + } + if (obj == this) { + return true; + } + EndpointMonitorStatus rhs = (EndpointMonitorStatus) obj; + if (value == null) { + return rhs.value == null; + } else { + return value.equals(rhs.value); + } + } +} diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/EndpointType.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/EndpointType.java new file mode 100644 index 0000000000000..4aa0f709a5e25 --- /dev/null +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/EndpointType.java @@ -0,0 +1,63 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ +package com.microsoft.azure.management.trafficmanager; + +/** + * Possible endpoint types supported in a Traffic manager profile. + */ +public enum EndpointType { + /** + * Enum value Microsoft.Network/trafficManagerProfiles/azureEndpoints. + */ + AZURE("Microsoft.Network/trafficManagerProfiles/azureEndpoints"), + + /** + * Enum value Microsoft.Network/trafficManagerProfiles/externalEndpoints. + */ + EXTERNAL("Microsoft.Network/trafficManagerProfiles/externalEndpoints"), + + /** + * Enum value Microsoft.Network/trafficManagerProfiles/nestedEndpoints. + */ + NESTED_PROFILE("Microsoft.Network/trafficManagerProfiles/nestedEndpoints"); + + private String value; + + EndpointType(String value) { + this.value = value; + } + + /** + * Parses a string value to a TrafficRoutingMethod instance. + * + * @param value the string value to parse. + * @return the parsed TrafficRoutingMethod object, or null if unable to parse. + */ + public static EndpointType fromValue(String value) { + EndpointType[] items = EndpointType.values(); + for (EndpointType item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + @Override + public String toString() { + return this.value; + } + + /** + * @return the local name of the endpoint type + */ + public String localName() { + if (this.value != null) { + return this.value.substring(this.value.lastIndexOf('/') + 1); + } + return null; + } +} diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/MonitorConfig.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/MonitorConfig.java new file mode 100644 index 0000000000000..d043abc9269ff --- /dev/null +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/MonitorConfig.java @@ -0,0 +1,119 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.trafficmanager; + + +/** + * Class containing endpoint monitoring settings in a Traffic Manager profile. + */ +public class MonitorConfig { + /** + * Gets or sets the profile-level monitoring status of the Traffic Manager + * profile. + */ + private String profileMonitorStatus; + + /** + * Gets or sets the protocol (HTTP or HTTPS) used to probe for endpoint + * health. + */ + private String protocol; + + /** + * Gets or sets the TCP port used to probe for endpoint health. + */ + private Long port; + + /** + * Gets or sets the path relative to the endpoint domain name used to + * probe for endpoint health. + */ + private String path; + + /** + * Get the profileMonitorStatus value. + * + * @return the profileMonitorStatus value + */ + public String profileMonitorStatus() { + return this.profileMonitorStatus; + } + + /** + * Set the profileMonitorStatus value. + * + * @param profileMonitorStatus the profileMonitorStatus value to set + * @return the MonitorConfig object itself. + */ + public MonitorConfig withProfileMonitorStatus(String profileMonitorStatus) { + this.profileMonitorStatus = profileMonitorStatus; + return this; + } + + /** + * Get the protocol value. + * + * @return the protocol value + */ + public String protocol() { + return this.protocol; + } + + /** + * Set the protocol value. + * + * @param protocol the protocol value to set + * @return the MonitorConfig object itself. + */ + public MonitorConfig withProtocol(String protocol) { + this.protocol = protocol; + return this; + } + + /** + * Get the port value. + * + * @return the port value + */ + public Long port() { + return this.port; + } + + /** + * Set the port value. + * + * @param port the port value to set + * @return the MonitorConfig object itself. + */ + public MonitorConfig withPort(Long port) { + this.port = port; + return this; + } + + /** + * Get the path value. + * + * @return the path value + */ + public String path() { + return this.path; + } + + /** + * Set the path value. + * + * @param path the path value to set + * @return the MonitorConfig object itself. + */ + public MonitorConfig withPath(String path) { + this.path = path; + return this; + } + +} diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/ProfileDnsNameUnavailableReason.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/ProfileDnsNameUnavailableReason.java new file mode 100644 index 0000000000000..3486e439fc6e7 --- /dev/null +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/ProfileDnsNameUnavailableReason.java @@ -0,0 +1,55 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ +package com.microsoft.azure.management.trafficmanager; + +/** + * The reason for unavailability of traffic manager profile DNS name. + */ +public class ProfileDnsNameUnavailableReason { + /** Static value Invalid for ProfileDnsNameUnavailableReason. */ + public static final ProfileDnsNameUnavailableReason INVALID = new ProfileDnsNameUnavailableReason("Invalid"); + + /** Static value AlreadyExists for ProfileDnsNameUnavailableReason. */ + public static final ProfileDnsNameUnavailableReason ALREADYEXISTS = new ProfileDnsNameUnavailableReason("AlreadyExists"); + + private String value; + + /** + * Creates ProfileDnsNameUnavailableReason. + * + * @param value the reason + */ + public ProfileDnsNameUnavailableReason(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @Override + public int hashCode() { + return this.value.hashCode(); + } + + @Override + public boolean equals(Object obj) { + String value = this.toString(); + if (!(obj instanceof ProfileDnsNameUnavailableReason)) { + return false; + } + if (obj == this) { + return true; + } + ProfileDnsNameUnavailableReason rhs = (ProfileDnsNameUnavailableReason) obj; + if (value == null) { + return rhs.value == null; + } else { + return value.equals(rhs.value); + } + } +} diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/ProfileMonitorStatus.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/ProfileMonitorStatus.java new file mode 100644 index 0000000000000..7d4163280255a --- /dev/null +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/ProfileMonitorStatus.java @@ -0,0 +1,64 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ +package com.microsoft.azure.management.trafficmanager; + +/** + * Traffic manager profile statuses. + */ +public class ProfileMonitorStatus { + /** Static value Inactive for ProfileMonitorStatus. */ + public static final ProfileMonitorStatus INACTIVE = new ProfileMonitorStatus("Inactive"); + + /** Static value Disabled for ProfileMonitorStatus. */ + public static final ProfileMonitorStatus DISABLED = new ProfileMonitorStatus("Disabled"); + + /** Static value Online for ProfileMonitorStatus. */ + public static final ProfileMonitorStatus ONLINE = new ProfileMonitorStatus("Online"); + + /** Static value Degraded for ProfileMonitorStatus. */ + public static final ProfileMonitorStatus DEGRADED = new ProfileMonitorStatus("Degraded"); + + /** Static value CheckingEndpoint for ProfileMonitorStatus. */ + public static final ProfileMonitorStatus CHECKING_ENDPOINT = new ProfileMonitorStatus("CheckingEndpoint"); + + private String value; + + /** + * Creates ProfileMonitorStatus. + * + * @param value the status + */ + public ProfileMonitorStatus(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @Override + public int hashCode() { + return this.value.hashCode(); + } + + @Override + public boolean equals(Object obj) { + String value = this.toString(); + if (!(obj instanceof ProfileMonitorStatus)) { + return false; + } + if (obj == this) { + return true; + } + ProfileMonitorStatus rhs = (ProfileMonitorStatus) obj; + if (value == null) { + return rhs.value == null; + } else { + return value.equals(rhs.value); + } + } +} diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TargetAzureResourceType.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TargetAzureResourceType.java new file mode 100644 index 0000000000000..68f3046dc1b35 --- /dev/null +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TargetAzureResourceType.java @@ -0,0 +1,59 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ +package com.microsoft.azure.management.trafficmanager; + +/** + * Target Azure resource types supported for an Azure endpoint in a traffic manager profile. + */ +public class TargetAzureResourceType { + /** Static value Microsoft.Network/publicIPAddresses for TargetAzureResourceType. */ + public static final TargetAzureResourceType PUBLICIP = new TargetAzureResourceType("Microsoft.Network", "publicIPAddresses"); + + /** Static value Microsoft.Web/sites for TargetAzureResourceType. */ + public static final TargetAzureResourceType WEBAPP = new TargetAzureResourceType("Microsoft.Web", "sites"); + + /** Static value Microsoft.ClassicCompute/domainNames for TargetAzureResourceType. */ + public static final TargetAzureResourceType CLOUDSERVICE = new TargetAzureResourceType("Microsoft.ClassicCompute", "domainNames"); + + private String value; + + /** + * Creates TargetAzureResourceType. + * + * @param resourceProviderName the resource provider name + * @param resourceType the resource type + */ + public TargetAzureResourceType(String resourceProviderName, String resourceType) { + this.value = resourceProviderName + "/" + resourceType; + } + + @Override + public String toString() { + return this.value; + } + + @Override + public int hashCode() { + return this.value.hashCode(); + } + + @Override + public boolean equals(Object obj) { + String value = this.toString(); + if (!(obj instanceof TargetAzureResourceType)) { + return false; + } + if (obj == this) { + return true; + } + TargetAzureResourceType rhs = (TargetAzureResourceType) obj; + if (value == null) { + return rhs.value == null; + } else { + return value.equals(rhs.value); + } + } +} diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerAzureEndpoint.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerAzureEndpoint.java new file mode 100644 index 0000000000000..2a94e6df6f04c --- /dev/null +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerAzureEndpoint.java @@ -0,0 +1,21 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ +package com.microsoft.azure.management.trafficmanager; + +/** + * An immutable client-side representation of an Azure traffic manager profile Azure endpoint. + */ +public interface TrafficManagerAzureEndpoint extends TrafficManagerEndpoint { + /** + * @return the resource id of the target Azure resource. + */ + String targetAzureResourceId(); + + /** + * @return the type of the target Azure resource. + */ + TargetAzureResourceType targetResourceType(); +} diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerEndpoint.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerEndpoint.java new file mode 100644 index 0000000000000..c6da223646d4d --- /dev/null +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerEndpoint.java @@ -0,0 +1,612 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ +package com.microsoft.azure.management.trafficmanager; + +import com.microsoft.azure.management.apigeneration.Fluent; +import com.microsoft.azure.management.resources.fluentcore.arm.Region; +import com.microsoft.azure.management.resources.fluentcore.arm.models.ExternalChildResource; +import com.microsoft.azure.management.resources.fluentcore.model.Attachable; +import com.microsoft.azure.management.resources.fluentcore.model.Settable; +import com.microsoft.azure.management.resources.fluentcore.model.Wrapper; +import com.microsoft.azure.management.trafficmanager.implementation.EndpointInner; + +/** + * An immutable client-side representation of an Azure traffic manager profile endpoint. + */ +@Fluent +public interface TrafficManagerEndpoint extends + ExternalChildResource, + Wrapper { + /** + * @return the endpoint type + */ + EndpointType endpointType(); + + /** + * @return the monitor status of the endpoint + */ + EndpointMonitorStatus monitorStatus(); + + /** + * @return true if the endpoint is enabled, false otherwise + */ + boolean isEnabled(); + + /** + * @return the weight of the endpoint which is used when traffic manager profile is configured with + * Weighted traffic-routing method + */ + int routingWeight(); + + /** + * @return the priority of the endpoint which is used when traffic manager profile is configured with + * Priority traffic-routing method + */ + int routingPriority(); + + /** + * The entirety of a traffic manager profile endpoint definition as a part of parent definition. + * + * @param the return type of the final {@link Attachable#attach()} + */ + interface Definition extends + DefinitionStages.AzureTargetEndpointBlank, + DefinitionStages.ExternalTargetEndpointBlank, + DefinitionStages.NestedProfileTargetEndpointBlank, + DefinitionStages.WithAzureResource, + DefinitionStages.WithFqdn, + DefinitionStages.WithSourceTrafficRegion, + DefinitionStages.WithSourceTrafficRegionThenThreshold, + DefinitionStages.WithEndpointThreshold, + DefinitionStages.WithAttach { + } + + /** + * Grouping of traffic manager profile endpoint definition stages as a part of parent traffic manager + * profile definition. + */ + interface DefinitionStages { + /** + * The first stage of a traffic manager profile Azure endpoint definition. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface AzureTargetEndpointBlank extends WithAzureResource { + } + + /** + * The first stage of a traffic manager profile external endpoint definition. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface ExternalTargetEndpointBlank extends WithFqdn { + } + + /** + * The first stage of a traffic manager profile nested profile endpoint definition. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface NestedProfileTargetEndpointBlank extends WithNestedProfile { + } + + /** + * The stage of the traffic manager profile Azure endpoint definition allowing to specify the ID + * of the target Azure resource. + * + * @param the return type of {@link UpdateDefinitionStages.WithAttach#attach()} + */ + interface WithAzureResource { + /** + * Specifies the resource ID of an Azure resource. + *

+ * supported Azure resources are cloud service, web app or public ip + * + * @param resourceId the Azure resource id + * @return the next stage of the definition + */ + WithAttach toResourceId(String resourceId); + } + + /** + * The stage of the traffic manager profile external endpoint definition allowing to specify + * the FQDN. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface WithFqdn { + /** + * Specifies the FQDN of an external endpoint. + * + * @param externalFqdn the external FQDN + * @return the next stage of the endpoint definition + */ + WithSourceTrafficRegion toFqdn(String externalFqdn); + } + + /** + * The stage of the traffic manager endpoint definition allowing to specify the location of the external + * endpoint. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface WithSourceTrafficRegion { + /** + * Specifies the location of the endpoint that will be used when the parent profile is configured with + * Performance routing method {@link TrafficRoutingMethod#PERFORMANCE}. + * + * @param region the location + * @return the next stage of the endpoint definition + */ + WithAttach fromRegion(Region region); + } + + /** + * The stage of the traffic manager nested profile endpoint definition allowing to specify the profile. + * + * @param the return type of {@link UpdateDefinitionStages.WithAttach#attach()} + */ + interface WithNestedProfile { + /** + * Specifies a nested traffic manager profile for the endpoint. + * + * @param profile the nested traffic manager profile + * @return the next stage of the definition + */ + WithSourceTrafficRegionThenThreshold toProfile(TrafficManagerProfile profile); + } + + /** + * The stage of the traffic manager endpoint definition allowing to specify the location of the nested + * profile endpoint. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface WithSourceTrafficRegionThenThreshold { + /** + * Specifies the location of the endpoint that will be used when the parent profile is configured with + * Performance routing method {@link TrafficRoutingMethod#PERFORMANCE}. + * + * @param region the location + * @return the next stage of the endpoint definition + */ + WithEndpointThreshold fromRegion(Region region); + } + + /** + * The stage of the nested traffic manager profile endpoint definition allowing to specify the minimum + * endpoints to be online in the nested profile to consider it as not degraded. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface WithEndpointThreshold extends WithAttach { + /** + * Specifies the minimum number of endpoints to be online for the nested profile to be considered healthy. + * + * @param count the number of endpoints + * @return the next stage of the endpoint definition + */ + WithAttach withMinimumEndpointsToEnableTraffic(int count); + } + + /** + * The stage of the traffic manager endpoint definition allowing to specify the endpoint weight. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface WithRoutingWeight { + /** + * Specifies the weight for the endpoint that will be used when the parent profile is configured with + * Weighted routing method {@link TrafficRoutingMethod#WEIGHTED}. + * + * @param weight the endpoint weight + * @return the next stage of the endpoint definition + */ + WithAttach withRoutingWeight(int weight); + } + + /** + * The stage of the traffic manager endpoint definition allowing to specify the endpoint priority. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface WithRoutingPriority { + /** + * Specifies the priority for the endpoint that will be used when the parent profile is configured with + * Priority routing method {@link TrafficRoutingMethod#PRIORITY}. + * + * @param priority the endpoint priority + * @return the next stage of the endpoint definition + */ + WithAttach withRoutingPriority(int priority); + } + + /** + * The stage of the traffic manager endpoint definition allowing to disable the endpoint. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface WithTrafficDisabled { + /** + * Specifies that this endpoint should be excluded from receiving traffic. + * + * @return the next stage of the endpoint definition + */ + WithAttach withTrafficDisabled(); + } + + /** The final stage of the traffic manager profile endpoint definition. + *

+ * At this stage, any remaining optional settings can be specified, or the traffic manager profile endpoint + * definition can be attached to the parent traffic manager profile definition using {@link TrafficManagerEndpoint.DefinitionStages.WithAttach#attach()}. + * @param the return type of {@link TrafficManagerEndpoint.DefinitionStages.WithAttach#attach()} + */ + interface WithAttach extends + Attachable.InDefinition, + DefinitionStages.WithRoutingWeight, + DefinitionStages.WithRoutingPriority, + DefinitionStages.WithTrafficDisabled { + } + } + + /** + * The entirety of a traffic manager profile endpoint definition as a part of parent update. + * + * @param the return type of the final {@link Attachable#attach()} + */ + interface UpdateDefinition extends + UpdateDefinitionStages.AzureTargetEndpointBlank, + UpdateDefinitionStages.ExternalTargetEndpointBlank, + UpdateDefinitionStages.NestedProfileTargetEndpointBlank, + UpdateDefinitionStages.WithAzureResource, + UpdateDefinitionStages.WithFqdn, + UpdateDefinitionStages.WithSourceTrafficRegion, + UpdateDefinitionStages.WithSourceTrafficRegionThenThreshold, + UpdateDefinitionStages.WithEndpointThreshold, + UpdateDefinitionStages.WithAttach { + } + + /** + * Grouping of traffic manager profile endpoint definition stages as a part of parent traffic manager + * profile update. + */ + interface UpdateDefinitionStages { + /** + * The first stage of a traffic manager profile Azure endpoint definition. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface AzureTargetEndpointBlank extends WithAzureResource { + } + + /** + * The first stage of a traffic manager profile external endpoint definition. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface ExternalTargetEndpointBlank extends WithFqdn { + } + + /** + * The first stage of a traffic manager profile nested profile endpoint definition. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface NestedProfileTargetEndpointBlank extends WithNestedProfile { + } + + /** + * The stage of the traffic manager profile Azure endpoint definition allowing to specify the ID + * of the target Azure resource. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface WithAzureResource { + /** + * Specifies the resource ID of an Azure resource. + *

+ * supported Azure resources are cloud service, web app or public ip + * + * @param resourceId the Azure resource id + * @return the next stage of the definition + */ + WithAttach toResourceId(String resourceId); + } + + /** + * The stage of the traffic manager profile external endpoint definition allowing to specify + * the FQDN. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface WithFqdn { + /** + * Specifies the FQDN of an external endpoint. + * + * @param externalFqdn the external FQDN + * @return the next stage of the endpoint definition + */ + WithSourceTrafficRegion toFqdn(String externalFqdn); + } + + /** + * The stage of the traffic manager endpoint definition allowing to specify the location of the external + * endpoint. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface WithSourceTrafficRegion { + /** + * Specifies the location of the endpoint that will be used when the parent profile is configured with + * Performance routing method {@link TrafficRoutingMethod#PERFORMANCE}. + * + * @param region the location + * @return the next stage of the endpoint definition + */ + WithAttach fromRegion(Region region); + } + + /** + * The stage of the traffic manager nested profile endpoint definition allowing to specify the profile. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface WithNestedProfile { + /** + * Specifies a nested traffic manager profile for the endpoint. + * + * @param profile the nested traffic manager profile + * @return the next stage of the definition + */ + WithSourceTrafficRegionThenThreshold toProfile(TrafficManagerProfile profile); + } + + /** + * The stage of the traffic manager endpoint definition allowing to specify the location of the nested + * endpoint. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface WithSourceTrafficRegionThenThreshold { + /** + * Specifies the location of the endpoint that will be used when the parent profile is configured with + * Performance routing method {@link TrafficRoutingMethod#PERFORMANCE}. + * + * @param region the location + * @return the next stage of the endpoint definition + */ + WithEndpointThreshold fromRegion(Region region); + } + + /** + * The stage of the nested traffic manager profile endpoint definition allowing to specify the minimum + * endpoints to be online in the nested profile to consider it as not degraded. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface WithEndpointThreshold extends WithAttach { + /** + * Specifies the minimum number of endpoints to be online for the nested profile to be considered healthy. + * + * @param count the number of endpoints + * @return the next stage of the endpoint definition + */ + WithAttach withMinimumEndpointsToEnableTraffic(int count); + } + + /** + * The stage of the traffic manager endpoint definition allowing to specify the endpoint weight. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface WithRoutingWeight { + /** + * Specifies the weight for the endpoint that will be used when the weight-based routing method + * {@link TrafficRoutingMethod#WEIGHTED} is enabled on the profile. + * + * @param weight the endpoint weight + * @return the next stage of the definition + */ + WithAttach withRoutingWeight(int weight); + } + + /** + * The stage of the traffic manager endpoint definition allowing to specify the endpoint priority. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface WithRoutingPriority { + /** + * Specifies the weight for the endpoint that will be used when priority-based routing method + * is {@link TrafficRoutingMethod#PRIORITY} enabled on the profile. + * + * @param priority + * @return the next stage of the definition + */ + WithAttach withRoutingPriority(int priority); + } + + /** + * The stage of the traffic manager endpoint definition allowing to disable the endpoint. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface WithTrafficDisabled { + /** + * Specifies that this endpoint should be excluded from receiving traffic. + * + * @return the next stage of the definition + */ + WithAttach withTrafficDisabled(); + } + + /** The final stage of the traffic manager profile endpoint definition. + *

+ * At this stage, any remaining optional settings can be specified, or the traffic manager profile endpoint + * definition can be attached to the parent traffic manager profile update using {@link TrafficManagerEndpoint.DefinitionStages.WithAttach#attach()}. + * @param the return type of {@link TrafficManagerEndpoint.DefinitionStages.WithAttach#attach()} + */ + interface WithAttach extends + Attachable.InUpdate, + UpdateDefinitionStages.WithRoutingWeight, + UpdateDefinitionStages.WithRoutingPriority, + UpdateDefinitionStages.WithTrafficDisabled { + } + } + + /** + * The entirety of an Azure endpoint update as a part of parent traffic manager profile profile update. + */ + interface UpdateAzureEndpoint extends + UpdateStages.WithAzureResource, + Update { + } + + /** + * The entirety of an external endpoint update as a part of parent traffic manager profile profile update. + */ + interface UpdateExternalEndpoint extends + UpdateStages.WithFqdn, + UpdateStages.WithSourceTrafficRegion, + Update { + } + + /** + * The entirety of a nested profile endpoint update as a part of parent traffic manager profile profile update. + */ + interface UpdateNestedProfileEndpoint extends + UpdateStages.WithNestedProfileConfig, + UpdateStages.WithSourceTrafficRegion, + Update { + } + + /** + * the set of configurations that can be updated for all endpoint irrespective of their type (Azure, external, nested profile). + */ + interface Update extends + Settable, + UpdateStages.WithRoutingWeight, + UpdateStages.WithRoutingPriority, + UpdateStages.WithTrafficDisabledOrEnabled { + } + + /** + * Grouping of traffic manager profile endpoint update stages. + */ + interface UpdateStages { + /** + * The stage of an Azure endpoint update allowing to specify the target Azure resource. + */ + interface WithAzureResource { + /** + * Specifies the resource ID of an Azure resource. + *

+ * supported Azure resources are cloud service, web app or public ip + * + * @param resourceId the Azure resource id + * @return the next stage of the update + */ + Update toResourceId(String resourceId); + } + + /** + * The stage of an external endpoint update allowing to specify the FQDN. + */ + interface WithFqdn { + /** + * Specifies the FQDN of an external endpoint that is not hosted in Azure. + * + * @param externalFqdn the external FQDN + * @return the next stage of the endpoint update + */ + UpdateExternalEndpoint toFqdn(String externalFqdn); + } + + /** + * The stage of an nested profile endpoint update allowing to specify profile and + * minimum child endpoint. + */ + interface WithNestedProfileConfig { + /** + * Specifies a nested traffic manager profile for the endpoint. + * + * @param nestedProfile the nested traffic manager profile + * @return the next stage of the update + */ + UpdateNestedProfileEndpoint toProfile(TrafficManagerProfile nestedProfile); + + /** + * Specifies the minimum number of endpoints to be online for the nested profile to be considered healthy. + * + * @param count number of endpoints + * @return the next stage of the endpoint update + */ + UpdateNestedProfileEndpoint withMinimumEndpointsToEnableTraffic(int count); + } + + /** + * The stage of the traffic manager endpoint update allowing to specify the location of the external + * or nested profile endpoints. + */ + interface WithSourceTrafficRegion { + /** + * Specifies the region of the endpoint that will be used when the performance-based routing method + * {@link TrafficRoutingMethod#PERFORMANCE} is enabled on the profile. + * + * @param location the location + * @return the next stage of the endpoint update + */ + Update fromRegion(Region location); + } + + /** + * The stage of the traffic manager profile endpoint update allowing to specify the endpoint weight. + */ + interface WithRoutingWeight { + /** + * Specifies the weight for the endpoint that will be used when the weight-based routing method + * {@link TrafficRoutingMethod#WEIGHTED} is enabled on the profile. + * + * @param weight the endpoint weight + * @return the next stage of the update + */ + Update withRoutingWeight(int weight); + } + + /** + * The stage of the traffic manager profile endpoint update allowing to specify the endpoint priority. + */ + interface WithRoutingPriority { + /** + * Specifies the weight for the endpoint that will be used when priority-based routing method + * is {@link TrafficRoutingMethod#PRIORITY} enabled on the profile. + * + * @param priority the endpoint priority + * @return the next stage of the update + */ + Update withRoutingPriority(int priority); + } + + /** + * The stage of the traffic manager profile endpoint update allowing to enable or disable it. + */ + interface WithTrafficDisabledOrEnabled { + /** + * Specifies that the endpoint should be excluded from receiving traffic. + * + * @return the next stage of the update + */ + Update withTrafficDisabled(); + + /** + * Specifies that the endpoint should receive the traffic. + * + * @return the next stage of the update + */ + Update withTrafficEnabled(); + } + } +} diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerExternalEndpoint.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerExternalEndpoint.java new file mode 100644 index 0000000000000..0a782c7dba422 --- /dev/null +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerExternalEndpoint.java @@ -0,0 +1,23 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ +package com.microsoft.azure.management.trafficmanager; + +import com.microsoft.azure.management.resources.fluentcore.arm.Region; + +/** + * An immutable client-side representation of an Azure traffic manager profile external endpoint. + */ +public interface TrafficManagerExternalEndpoint extends TrafficManagerEndpoint { + /** + * @return the fully qualified DNS name of the external endpoint + */ + String fqdn(); + + /** + * @return the location of the traffic that the endpoint handles + */ + Region sourceTrafficLocation(); +} diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerNestedProfileEndpoint.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerNestedProfileEndpoint.java new file mode 100644 index 0000000000000..9701c66d7ebce --- /dev/null +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerNestedProfileEndpoint.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ +package com.microsoft.azure.management.trafficmanager; + +import com.microsoft.azure.management.resources.fluentcore.arm.Region; + +/** + * An immutable client-side representation of an Azure traffic manager profile nested profile endpoint. + */ +public interface TrafficManagerNestedProfileEndpoint extends TrafficManagerEndpoint { + /** + * @return the nested traffic manager profile resource id + */ + String nestedProfileId(); + + /** + * @return the number of child endpoints to be online to consider nested profile as healthy + */ + int minimumChildEndpointCount(); + + /** + * @return the location of the traffic that the endpoint handles + */ + Region sourceTrafficLocation(); +} diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerProfile.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerProfile.java new file mode 100644 index 0000000000000..991d2e72e3ded --- /dev/null +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerProfile.java @@ -0,0 +1,471 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ +package com.microsoft.azure.management.trafficmanager; + +import com.microsoft.azure.management.apigeneration.Fluent; +import com.microsoft.azure.management.resources.fluentcore.arm.models.GroupableResource; +import com.microsoft.azure.management.resources.fluentcore.arm.models.Resource; +import com.microsoft.azure.management.resources.fluentcore.model.Appliable; +import com.microsoft.azure.management.resources.fluentcore.model.Creatable; +import com.microsoft.azure.management.resources.fluentcore.model.Refreshable; +import com.microsoft.azure.management.resources.fluentcore.model.Updatable; +import com.microsoft.azure.management.resources.fluentcore.model.Wrapper; +import com.microsoft.azure.management.trafficmanager.implementation.ProfileInner; + +import java.util.Map; + +/** + * An immutable client-side representation of an Azure traffic manager profile. + */ +@Fluent +public interface TrafficManagerProfile extends + GroupableResource, + Refreshable, + Wrapper, + Updatable { + /** + * @return the relative DNS name of the traffic manager profile + */ + String dnsLabel(); + + /** + * @return fully qualified domain name (FQDN) of the traffic manager profile. + */ + String fqdn(); + + /** + * @return the DNS Time-To-Live (TTL), in seconds + */ + int timeToLive(); + + /** + * @return true if the traffic manager profile is enabled, false if enabled + */ + boolean isEnabled(); + + /** + * @return the routing method used to route traffic to traffic manager profile endpoints + */ + TrafficRoutingMethod trafficRoutingMethod(); + + /** + * @return profile monitor status which is combination of the endpoint monitor status values for all endpoints in + * the profile, and the configured profile status + */ + ProfileMonitorStatus monitorStatus(); + + /** + * @return the port that is monitored to check the health of traffic manager profile endpoints + */ + int monitoringPort(); + + /** + * @return the path that is monitored to check the health of traffic manager profile endpoints + */ + String monitoringPath(); + + /** + * + * @return external endpoints in the traffic manager profile, indexed by the name + */ + Map externalEndpoints(); + + /** + * + * @return Azure endpoints in the traffic manager profile, indexed by the name + */ + Map azureEndpoints(); + + /** + * + * @return nested traffic manager profile endpoints in this traffic manager profile, indexed by the name + */ + Map nestedProfileEndpoints(); + + /** + * The entirety of the traffic manager profile definition. + */ + interface Definition extends + DefinitionStages.Blank, + DefinitionStages.WithLeafDomainLabel, + DefinitionStages.WithTrafficRoutingMethod, + DefinitionStages.WithCreate { + } + + /** + * Grouping of traffic manager profile definition stages. + */ + interface DefinitionStages { + /** + * The stage of the traffic manager profile definition allowing to specify the resource group. + */ + interface Blank extends GroupableResource.DefinitionStages.WithGroupAndRegion { + } + + /** + * The stage of the traffic manager profile definition allowing to specify the relative DNS name. + */ + interface WithLeafDomainLabel { + /** + * Specify the relative DNS name of the profile. + *

+ * The fully qualified domain name (FQDN) + * will be constructed automatically by appending the rest of the domain to this label. + * + * @param dnsLabel the relative DNS name of the profile + * @return the next stage of the traffic manager profile definition + */ + WithTrafficRoutingMethod withLeafDomainLabel(String dnsLabel); + } + + /** + * The stage of the traffic manager profile definition allowing to specify the traffic routing method + * for the profile. + */ + interface WithTrafficRoutingMethod { + /** + * Specify that end user traffic should be routed to the endpoint based on its priority + * i.e. use the endpoint with highest priority and if it is not available fallback to next highest + * priority endpoint. + * + * @return the next stage of the traffic manager profile definition + */ + WithEndpoint withPriorityBasedRouting(); + + /** + * Specify that end user traffic should be distributed to the endpoints based on the weight assigned + * to the endpoint. + * + * @return the next stage of the traffic manager profile definition + */ + WithEndpoint withWeightBasedRouting(); + + /** + * Specify that end user traffic should be routed based on the geographic location of the endpoint + * close to user. + * + * @return the next stage of the traffic manager profile definition + */ + WithEndpoint withPerformanceBasedRouting(); + + /** + * Specify the traffic routing method for the profile. + * + * @param routingMethod the traffic routing method for the profile + * @return the next stage of the traffic manager profile definition + */ + WithEndpoint withTrafficRoutingMethod(TrafficRoutingMethod routingMethod); + } + + /** + * The stage of the traffic manager profile definition allowing to specify endpoint. + */ + interface WithEndpoint { + /** + * Specifies definition of an Azure endpoint to be attached to the traffic manager profile. + * + * @param name the name for the endpoint + * @return the stage representing configuration for the endpoint + */ + TrafficManagerEndpoint.DefinitionStages.AzureTargetEndpointBlank defineAzureTargetEndpoint(String name); + + /** + * Specifies definition of an external endpoint to be attached to the traffic manager profile. + * + * @param name the name for the endpoint + * @return the stage representing configuration for the endpoint + */ + TrafficManagerEndpoint.DefinitionStages.ExternalTargetEndpointBlank defineExternalTargetEndpoint(String name); + + /** + * Specifies definition of an nested profile endpoint to be attached to the traffic manager profile. + * + * @param name the name for the endpoint + * @return the stage representing configuration for the endpoint + */ + TrafficManagerEndpoint.DefinitionStages.NestedProfileTargetEndpointBlank defineNestedTargetEndpoint(String name); + } + + /** + * The stage of the traffic manager profile definition allowing to specify the endpoint monitoring configuration. + */ + interface WithMonitoringConfiguration { + /** + * Specify to use HTTP monitoring for the endpoints that checks for HTTP 200 response from the path '/' + * at regular intervals, using port 80. + * + * @return the next stage of the traffic manager profile definition + */ + WithCreate withHttpMonitoring(); + + /** + * Specify to use HTTPS monitoring for the endpoints that checks for HTTPS 200 response from the path '/' + * at regular intervals, using port 443. + * + * @return the next stage of the traffic manager profile definition + */ + WithCreate withHttpsMonitoring(); + + /** + * Specify the HTTP monitoring for the endpoints that checks for HTTP 200 response from the specified + * path at regular intervals, using the specified port. + * + * @param port the monitoring port + * @param path the monitoring path + * @return the next stage of the traffic manager profile definition + */ + WithCreate withHttpMonitoring(int port, String path); + + /** + * Specify the HTTPS monitoring for the endpoints that checks for HTTPS 200 response from the specified + * path at regular intervals, using the specified port. + * + * @param port the monitoring port + * @param path the monitoring path + * @return the next stage of the traffic manager profile definition + */ + WithCreate withHttpsMonitoring(int port, String path); + } + + /** + * The stage of the traffic manager profile definition allowing to specify the DNS TTL. + */ + interface WithTtl { + /** + * Specify the DNS TTL in seconds. + * + * @param ttlInSeconds DNS TTL in seconds + * @return the next stage of the traffic manager profile definition + */ + WithCreate withTimeToLive(int ttlInSeconds); + } + + /** + * The stage of the traffic manager profile definition allowing to disable the profile. + */ + interface WithProfileStatus { + /** + * Specify that the profile needs to be disabled. + *

+ * Disabling the profile will disables traffic to all endpoints in the profile + * + * @return the next stage of the traffic manager profile definition + */ + WithCreate withProfileStatusDisabled(); + } + + /** + * The stage of the definition which contains all the minimum required inputs for the resource to be created + * (via {@link WithCreate#create()}), but also allows for any other optional settings to be specified. + */ + interface WithCreate extends + Creatable, + Resource.DefinitionWithTags, + DefinitionStages.WithMonitoringConfiguration, + DefinitionStages.WithTtl, + DefinitionStages.WithProfileStatus, + DefinitionStages.WithEndpoint { + } + } + + /** + * Grouping of traffic manager update stages. + */ + interface UpdateStages { + /** + * The stage of the traffic manager profile update allowing to specify the traffic routing method + * for the profile. + */ + interface WithTrafficRoutingMethod { + /** + * Specify that end user traffic should be routed to the endpoint based on its priority + * i.e. use the endpoint with highest priority and if it is not available fallback to next highest + * priority endpoint. + * + * @return the next stage of the traffic manager profile update + */ + Update withPriorityBasedRouting(); + + /** + * Specify that end user traffic should be distributed to the endpoints based on the weight assigned + * to the endpoint. + * + * @return the next stage of the traffic manager profile update + */ + Update withWeightBasedRouting(); + + /** + * Specify that end user traffic should be routed based on the geographic location of the endpoint + * close to user. + * + * @return the next stage of the traffic manager profile update + */ + Update withPerformanceBasedRouting(); + + /** + * Specify the traffic routing method for the profile. + * + * @param routingMethod the traffic routing method for the profile + * @return the next stage of the traffic manager profile update + */ + Update withTrafficRoutingMethod(TrafficRoutingMethod routingMethod); + } + + /** + * The stage of the traffic manager profile update allowing to specify the endpoint monitoring configuration. + */ + interface WithMonitoringConfiguration { + /** + * Specify to use HTTP monitoring for the endpoints that checks for HTTP 200 response from the path '/' + * at regular intervals, using port 80. + * + * @return the next stage of the traffic manager profile update + */ + Update withHttpMonitoring(); + + /** + * Specify to use HTTPS monitoring for the endpoints that checks for HTTPS 200 response from the path '/' + * at regular intervals, using port 443. + * + * @return the next stage of the traffic manager profile update + */ + Update withHttpsMonitoring(); + + /** + * Specify the HTTP monitoring for the endpoints that checks for HTTP 200 response from the specified + * path at regular intervals, using the specified port. + * + * @param port the monitoring port + * @param path the monitoring path + * @return the next stage of the traffic manager profile update + */ + Update withHttpMonitoring(int port, String path); + + /** + * Specify the HTTPS monitoring for the endpoints that checks for HTTPS 200 response from the specified + * path at regular intervals, using the specified port. + * + * @param port the monitoring port + * @param path the monitoring path + * @return the next stage of the traffic manager profile update + */ + Update withHttpsMonitoring(int port, String path); + } + + /** + * The stage of the traffic manager profile update allowing to specify endpoints. + */ + interface WithEndpoint { + /** + * Specifies definition of an Azure endpoint to be attached to the traffic manager profile. + * + * @param name the name for the endpoint + * @return the stage representing configuration for the endpoint + */ + TrafficManagerEndpoint.UpdateDefinitionStages.AzureTargetEndpointBlank defineAzureTargetEndpoint(String name); + + /** + * Specifies definition of an external endpoint to be attached to the traffic manager profile. + * + * @param name the name for the endpoint + * @return the stage representing configuration for the endpoint + */ + TrafficManagerEndpoint.UpdateDefinitionStages.ExternalTargetEndpointBlank defineExternalTargetEndpoint(String name); + + /** + * Specifies definition of an nested profile endpoint to be attached to the traffic manager profile. + * + * @param name the name for the endpoint + * @return the stage representing configuration for the endpoint + */ + TrafficManagerEndpoint.UpdateDefinitionStages.NestedProfileTargetEndpointBlank defineNestedTargetEndpoint(String name); + + /** + * Begins the description of an update of an existing Azure endpoint in this profile. + * + * @param name the name of the Azure endpoint + * @return the stage representing updating configuration for the Azure endpoint + */ + TrafficManagerEndpoint.UpdateAzureEndpoint updateAzureTargetEndpoint(String name); + + /** + * Begins the description of an update of an existing external endpoint in this profile. + * + * @param name the name of the external endpoint + * @return the stage representing updating configuration for the external endpoint + */ + TrafficManagerEndpoint.UpdateExternalEndpoint updateExternalTargetEndpoint(String name); + + /** + * Begins the description of an update of an existing nested traffic manager profile endpoint + * in this profile. + * + * @param name the name of the nested profile endpoint + * @return the stage representing updating configuration for the nested traffic manager profile endpoint + */ + TrafficManagerEndpoint.UpdateNestedProfileEndpoint updateNestedProfileTargetEndpoint(String name); + + /** + * Removes an endpoint in the profile. + * + * @param name the name of the endpoint + * @return the next stage of the traffic manager profile update + */ + Update withoutEndpoint(String name); + } + + /** + * The stage of the traffic manager profile update allowing to specify the DNS TTL. + */ + interface WithTtl { + /** + * Specify the DNS TTL in seconds. + * + * @param ttlInSeconds DNS TTL in seconds + * @return the next stage of the traffic manager profile update + */ + Update withTimeToLive(int ttlInSeconds); + } + + /** + * The stage of the traffic manager profile update allowing to disable or enable the profile. + */ + interface WithProfileStatus { + /** + * Specify that the profile needs to be disabled. + *

+ * Disabling the profile will disables traffic to all endpoints in the profile + * + * @return the next stage of the traffic manager profile update + */ + Update withProfileStatusDisabled(); + + /** + * Specify that the profile needs to be enabled. + *

+ * Enabling the profile will enables traffic to all endpoints in the profile + * + * @return the next stage of the traffic manager profile update + */ + Update withProfileStatusEnabled(); + } + } + + /** + * The template for an update operation, containing all the settings that can be modified. + *

+ * Call {@link Update#apply()} to apply the changes to the resource in Azure. + */ + interface Update extends + Appliable, + UpdateStages.WithTrafficRoutingMethod, + UpdateStages.WithMonitoringConfiguration, + UpdateStages.WithEndpoint, + UpdateStages.WithTtl, + UpdateStages.WithProfileStatus, + Resource.UpdateWithTags { + } +} diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerProfiles.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerProfiles.java new file mode 100644 index 0000000000000..3e53d21a96b6a --- /dev/null +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerProfiles.java @@ -0,0 +1,39 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ +package com.microsoft.azure.management.trafficmanager; + +import com.microsoft.azure.management.apigeneration.Fluent; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsDeletingByGroup; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingByGroup; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingById; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsListingByGroup; +import com.microsoft.azure.management.resources.fluentcore.collection.SupportsBatchCreation; +import com.microsoft.azure.management.resources.fluentcore.collection.SupportsCreating; +import com.microsoft.azure.management.resources.fluentcore.collection.SupportsDeleting; +import com.microsoft.azure.management.resources.fluentcore.collection.SupportsListing; + +/** + * Entry point to traffic manager profile management API in Azure. + */ +@Fluent() +public interface TrafficManagerProfiles extends + SupportsCreating, + SupportsListing, + SupportsListingByGroup, + SupportsGettingByGroup, + SupportsGettingById, + SupportsDeleting, + SupportsDeletingByGroup, + SupportsBatchCreation { + + /** + * Checks that the DNS name is valid for traffic manager profile and is not in use. + * + * @param dnsNameLabel the DNS name to check + * @return whether the DNS is available to be used for a traffic manager profile and other info if not + */ + CheckProfileDnsNameAvailabilityResult checkDnsNameAvailability(String dnsNameLabel); +} \ No newline at end of file diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficRoutingMethod.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficRoutingMethod.java new file mode 100644 index 0000000000000..f1ec8939c0377 --- /dev/null +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficRoutingMethod.java @@ -0,0 +1,53 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ +package com.microsoft.azure.management.trafficmanager; + +/** + * Possible routing methods supported by Traffic manager profile. + */ +public enum TrafficRoutingMethod { + /** + * Enum value Performance. + */ + PERFORMANCE("Performance"), + + /** + * Enum value Weighted. + */ + WEIGHTED("Weighted"), + + /** + * Enum value Priority. + */ + PRIORITY("Priority"); + + private String value; + + TrafficRoutingMethod(String value) { + this.value = value; + } + + /** + * Parses a string value to a TrafficRoutingMethod instance. + * + * @param value the string value to parse. + * @return the parsed TrafficRoutingMethod object, or null if unable to parse. + */ + public static TrafficRoutingMethod fromValue(String value) { + TrafficRoutingMethod[] items = TrafficRoutingMethod.values(); + for (TrafficRoutingMethod item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + @Override + public String toString() { + return this.value; + } +} diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/CheckTrafficManagerRelativeDnsNameAvailabilityParametersInner.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/CheckTrafficManagerRelativeDnsNameAvailabilityParametersInner.java new file mode 100644 index 0000000000000..fb5ca2acf6874 --- /dev/null +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/CheckTrafficManagerRelativeDnsNameAvailabilityParametersInner.java @@ -0,0 +1,66 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.trafficmanager.implementation; + + +/** + * Parameters supplied to check Traffic Manager name operation. + */ +public class CheckTrafficManagerRelativeDnsNameAvailabilityParametersInner { + /** + * Gets or sets the name of the resource. + */ + private String name; + + /** + * Gets or sets the type of the resource. + */ + private String type; + + /** + * Get the name value. + * + * @return the name value + */ + public String name() { + return this.name; + } + + /** + * Set the name value. + * + * @param name the name value to set + * @return the CheckTrafficManagerRelativeDnsNameAvailabilityParametersInner object itself. + */ + public CheckTrafficManagerRelativeDnsNameAvailabilityParametersInner withName(String name) { + this.name = name; + return this; + } + + /** + * Get the type value. + * + * @return the type value + */ + public String type() { + return this.type; + } + + /** + * Set the type value. + * + * @param type the type value to set + * @return the CheckTrafficManagerRelativeDnsNameAvailabilityParametersInner object itself. + */ + public CheckTrafficManagerRelativeDnsNameAvailabilityParametersInner withType(String type) { + this.type = type; + return this; + } + +} diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/EndpointInner.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/EndpointInner.java new file mode 100644 index 0000000000000..4e25796ca44ca --- /dev/null +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/EndpointInner.java @@ -0,0 +1,315 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.trafficmanager.implementation; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.microsoft.rest.serializer.JsonFlatten; + +/** + * Class representing a Traffic Manager endpoint. + */ +@JsonFlatten +public class EndpointInner { + /** + * Gets or sets the ID of the Traffic Manager endpoint. + */ + private String id; + + /** + * Gets or sets the name of the Traffic Manager endpoint. + */ + private String name; + + /** + * Gets or sets the endpoint type of the Traffic Manager endpoint. + */ + private String type; + + /** + * Gets or sets the Azure Resource URI of the of the endpoint. Not + * applicable to endpoints of type 'ExternalEndpoints'. + */ + @JsonProperty(value = "properties.targetResourceId") + private String targetResourceId; + + /** + * Gets or sets the fully-qualified DNS name of the endpoint. Traffic + * Manager returns this value in DNS responses to direct traffic to this + * endpoint. + */ + @JsonProperty(value = "properties.target") + private String target; + + /** + * Gets or sets the status of the endpoint.. If the endpoint is Enabled, + * it is probed for endpoint health and is included in the traffic + * routing method. Possible values are 'Enabled' and 'Disabled'. + */ + @JsonProperty(value = "properties.endpointStatus") + private String endpointStatus; + + /** + * Gets or sets the weight of this endpoint when using the 'Weighted' + * traffic routing method. Possible values are from 1 to 1000. + */ + @JsonProperty(value = "properties.weight") + private Long weight; + + /** + * Gets or sets the priority of this endpoint when using the ‘Priority’ + * traffic routing method. Possible values are from 1 to 1000, lower + * values represent higher priority. This is an optional parameter. If + * specified, it must be specified on all endpoints, and no two endpoints + * can share the same priority value. + */ + @JsonProperty(value = "properties.priority") + private Long priority; + + /** + * Specifies the location of the external or nested endpoints when using + * the ‘Performance’ traffic routing method. + */ + @JsonProperty(value = "properties.endpointLocation") + private String endpointLocation; + + /** + * Gets or sets the monitoring status of the endpoint. + */ + @JsonProperty(value = "properties.endpointMonitorStatus") + private String endpointMonitorStatus; + + /** + * Gets or sets the minimum number of endpoints that must be available in + * the child profile in order for the parent profile to be considered + * available. Only applicable to endpoint of type 'NestedEndpoints'. + */ + @JsonProperty(value = "properties.minChildEndpoints") + private Long minChildEndpoints; + + /** + * Get the id value. + * + * @return the id value + */ + public String id() { + return this.id; + } + + /** + * Set the id value. + * + * @param id the id value to set + * @return the EndpointInner object itself. + */ + public EndpointInner withId(String id) { + this.id = id; + return this; + } + + /** + * Get the name value. + * + * @return the name value + */ + public String name() { + return this.name; + } + + /** + * Set the name value. + * + * @param name the name value to set + * @return the EndpointInner object itself. + */ + public EndpointInner withName(String name) { + this.name = name; + return this; + } + + /** + * Get the type value. + * + * @return the type value + */ + public String type() { + return this.type; + } + + /** + * Set the type value. + * + * @param type the type value to set + * @return the EndpointInner object itself. + */ + public EndpointInner withType(String type) { + this.type = type; + return this; + } + + /** + * Get the targetResourceId value. + * + * @return the targetResourceId value + */ + public String targetResourceId() { + return this.targetResourceId; + } + + /** + * Set the targetResourceId value. + * + * @param targetResourceId the targetResourceId value to set + * @return the EndpointInner object itself. + */ + public EndpointInner withTargetResourceId(String targetResourceId) { + this.targetResourceId = targetResourceId; + return this; + } + + /** + * Get the target value. + * + * @return the target value + */ + public String target() { + return this.target; + } + + /** + * Set the target value. + * + * @param target the target value to set + * @return the EndpointInner object itself. + */ + public EndpointInner withTarget(String target) { + this.target = target; + return this; + } + + /** + * Get the endpointStatus value. + * + * @return the endpointStatus value + */ + public String endpointStatus() { + return this.endpointStatus; + } + + /** + * Set the endpointStatus value. + * + * @param endpointStatus the endpointStatus value to set + * @return the EndpointInner object itself. + */ + public EndpointInner withEndpointStatus(String endpointStatus) { + this.endpointStatus = endpointStatus; + return this; + } + + /** + * Get the weight value. + * + * @return the weight value + */ + public Long weight() { + return this.weight; + } + + /** + * Set the weight value. + * + * @param weight the weight value to set + * @return the EndpointInner object itself. + */ + public EndpointInner withWeight(Long weight) { + this.weight = weight; + return this; + } + + /** + * Get the priority value. + * + * @return the priority value + */ + public Long priority() { + return this.priority; + } + + /** + * Set the priority value. + * + * @param priority the priority value to set + * @return the EndpointInner object itself. + */ + public EndpointInner withPriority(Long priority) { + this.priority = priority; + return this; + } + + /** + * Get the endpointLocation value. + * + * @return the endpointLocation value + */ + public String endpointLocation() { + return this.endpointLocation; + } + + /** + * Set the endpointLocation value. + * + * @param endpointLocation the endpointLocation value to set + * @return the EndpointInner object itself. + */ + public EndpointInner withEndpointLocation(String endpointLocation) { + this.endpointLocation = endpointLocation; + return this; + } + + /** + * Get the endpointMonitorStatus value. + * + * @return the endpointMonitorStatus value + */ + public String endpointMonitorStatus() { + return this.endpointMonitorStatus; + } + + /** + * Set the endpointMonitorStatus value. + * + * @param endpointMonitorStatus the endpointMonitorStatus value to set + * @return the EndpointInner object itself. + */ + public EndpointInner withEndpointMonitorStatus(String endpointMonitorStatus) { + this.endpointMonitorStatus = endpointMonitorStatus; + return this; + } + + /** + * Get the minChildEndpoints value. + * + * @return the minChildEndpoints value + */ + public Long minChildEndpoints() { + return this.minChildEndpoints; + } + + /** + * Set the minChildEndpoints value. + * + * @param minChildEndpoints the minChildEndpoints value to set + * @return the EndpointInner object itself. + */ + public EndpointInner withMinChildEndpoints(Long minChildEndpoints) { + this.minChildEndpoints = minChildEndpoints; + return this; + } + +} diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/EndpointsInner.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/EndpointsInner.java new file mode 100644 index 0000000000000..1d34b471ebfac --- /dev/null +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/EndpointsInner.java @@ -0,0 +1,470 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.trafficmanager.implementation; + +import retrofit2.Retrofit; +import com.google.common.reflect.TypeToken; +import com.microsoft.azure.AzureServiceResponseBuilder; +import com.microsoft.azure.CloudException; +import com.microsoft.rest.ServiceCall; +import com.microsoft.rest.ServiceCallback; +import com.microsoft.rest.ServiceResponse; +import com.microsoft.rest.Validator; +import java.io.IOException; +import okhttp3.ResponseBody; +import retrofit2.http.Body; +import retrofit2.http.GET; +import retrofit2.http.Header; +import retrofit2.http.Headers; +import retrofit2.http.HTTP; +import retrofit2.http.PATCH; +import retrofit2.http.Path; +import retrofit2.http.PUT; +import retrofit2.http.Query; +import retrofit2.Response; +import rx.functions.Func1; +import rx.Observable; + +/** + * An instance of this class provides access to all the operations defined + * in Endpoints. + */ +public final class EndpointsInner { + /** The Retrofit service to perform REST calls. */ + private EndpointsService service; + /** The service client containing this operation class. */ + private TrafficManagerManagementClientImpl client; + + /** + * Initializes an instance of EndpointsInner. + * + * @param retrofit the Retrofit instance built from a Retrofit Builder. + * @param client the instance of the service client containing this operation class. + */ + public EndpointsInner(Retrofit retrofit, TrafficManagerManagementClientImpl client) { + this.service = retrofit.create(EndpointsService.class); + this.client = client; + } + + /** + * The interface defining all the services for Endpoints to be + * used by Retrofit to perform actually REST calls. + */ + interface EndpointsService { + @Headers("Content-Type: application/json; charset=utf-8") + @PATCH("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/{endpointType}/{endpointName}") + Observable> update(@Path("resourceGroupName") String resourceGroupName, @Path("profileName") String profileName, @Path("endpointType") String endpointType, @Path("endpointName") String endpointName, @Path("subscriptionId") String subscriptionId, @Body EndpointInner parameters, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @GET("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/{endpointType}/{endpointName}") + Observable> get(@Path("resourceGroupName") String resourceGroupName, @Path("profileName") String profileName, @Path("endpointType") String endpointType, @Path("endpointName") String endpointName, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @PUT("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/{endpointType}/{endpointName}") + Observable> createOrUpdate(@Path("resourceGroupName") String resourceGroupName, @Path("profileName") String profileName, @Path("endpointType") String endpointType, @Path("endpointName") String endpointName, @Path("subscriptionId") String subscriptionId, @Body EndpointInner parameters, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @HTTP(path = "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/{endpointType}/{endpointName}", method = "DELETE", hasBody = true) + Observable> delete(@Path("resourceGroupName") String resourceGroupName, @Path("profileName") String profileName, @Path("endpointType") String endpointType, @Path("endpointName") String endpointName, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + } + + /** + * Update a Traffic Manager endpoint. + * + * @param resourceGroupName The name of the resource group containing the Traffic Manager endpoint to be updated. + * @param profileName The name of the Traffic Manager profile. + * @param endpointType The type of the Traffic Manager endpoint to be updated. + * @param endpointName The name of the Traffic Manager endpoint to be updated. + * @param parameters The Traffic Manager endpoint parameters supplied to the Update operation. + * @return the EndpointInner object if successful. + */ + public EndpointInner update(String resourceGroupName, String profileName, String endpointType, String endpointName, EndpointInner parameters) { + return updateWithServiceResponseAsync(resourceGroupName, profileName, endpointType, endpointName, parameters).toBlocking().single().getBody(); + } + + /** + * Update a Traffic Manager endpoint. + * + * @param resourceGroupName The name of the resource group containing the Traffic Manager endpoint to be updated. + * @param profileName The name of the Traffic Manager profile. + * @param endpointType The type of the Traffic Manager endpoint to be updated. + * @param endpointName The name of the Traffic Manager endpoint to be updated. + * @param parameters The Traffic Manager endpoint parameters supplied to the Update operation. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @return the {@link ServiceCall} object + */ + public ServiceCall updateAsync(String resourceGroupName, String profileName, String endpointType, String endpointName, EndpointInner parameters, final ServiceCallback serviceCallback) { + return ServiceCall.create(updateWithServiceResponseAsync(resourceGroupName, profileName, endpointType, endpointName, parameters), serviceCallback); + } + + /** + * Update a Traffic Manager endpoint. + * + * @param resourceGroupName The name of the resource group containing the Traffic Manager endpoint to be updated. + * @param profileName The name of the Traffic Manager profile. + * @param endpointType The type of the Traffic Manager endpoint to be updated. + * @param endpointName The name of the Traffic Manager endpoint to be updated. + * @param parameters The Traffic Manager endpoint parameters supplied to the Update operation. + * @return the observable to the EndpointInner object + */ + public Observable updateAsync(String resourceGroupName, String profileName, String endpointType, String endpointName, EndpointInner parameters) { + return updateWithServiceResponseAsync(resourceGroupName, profileName, endpointType, endpointName, parameters).map(new Func1, EndpointInner>() { + @Override + public EndpointInner call(ServiceResponse response) { + return response.getBody(); + } + }); + } + + /** + * Update a Traffic Manager endpoint. + * + * @param resourceGroupName The name of the resource group containing the Traffic Manager endpoint to be updated. + * @param profileName The name of the Traffic Manager profile. + * @param endpointType The type of the Traffic Manager endpoint to be updated. + * @param endpointName The name of the Traffic Manager endpoint to be updated. + * @param parameters The Traffic Manager endpoint parameters supplied to the Update operation. + * @return the observable to the EndpointInner object + */ + public Observable> updateWithServiceResponseAsync(String resourceGroupName, String profileName, String endpointType, String endpointName, EndpointInner parameters) { + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (profileName == null) { + throw new IllegalArgumentException("Parameter profileName is required and cannot be null."); + } + if (endpointType == null) { + throw new IllegalArgumentException("Parameter endpointType is required and cannot be null."); + } + if (endpointName == null) { + throw new IllegalArgumentException("Parameter endpointName is required and cannot be null."); + } + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (parameters == null) { + throw new IllegalArgumentException("Parameter parameters is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + Validator.validate(parameters); + return service.update(resourceGroupName, profileName, endpointType, endpointName, this.client.subscriptionId(), parameters, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = updateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse updateDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.client.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + + /** + * Gets a Traffic Manager endpoint. + * + * @param resourceGroupName The name of the resource group containing the Traffic Manager endpoint. + * @param profileName The name of the Traffic Manager profile. + * @param endpointType The type of the Traffic Manager endpoint. + * @param endpointName The name of the Traffic Manager endpoint. + * @return the EndpointInner object if successful. + */ + public EndpointInner get(String resourceGroupName, String profileName, String endpointType, String endpointName) { + return getWithServiceResponseAsync(resourceGroupName, profileName, endpointType, endpointName).toBlocking().single().getBody(); + } + + /** + * Gets a Traffic Manager endpoint. + * + * @param resourceGroupName The name of the resource group containing the Traffic Manager endpoint. + * @param profileName The name of the Traffic Manager profile. + * @param endpointType The type of the Traffic Manager endpoint. + * @param endpointName The name of the Traffic Manager endpoint. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @return the {@link ServiceCall} object + */ + public ServiceCall getAsync(String resourceGroupName, String profileName, String endpointType, String endpointName, final ServiceCallback serviceCallback) { + return ServiceCall.create(getWithServiceResponseAsync(resourceGroupName, profileName, endpointType, endpointName), serviceCallback); + } + + /** + * Gets a Traffic Manager endpoint. + * + * @param resourceGroupName The name of the resource group containing the Traffic Manager endpoint. + * @param profileName The name of the Traffic Manager profile. + * @param endpointType The type of the Traffic Manager endpoint. + * @param endpointName The name of the Traffic Manager endpoint. + * @return the observable to the EndpointInner object + */ + public Observable getAsync(String resourceGroupName, String profileName, String endpointType, String endpointName) { + return getWithServiceResponseAsync(resourceGroupName, profileName, endpointType, endpointName).map(new Func1, EndpointInner>() { + @Override + public EndpointInner call(ServiceResponse response) { + return response.getBody(); + } + }); + } + + /** + * Gets a Traffic Manager endpoint. + * + * @param resourceGroupName The name of the resource group containing the Traffic Manager endpoint. + * @param profileName The name of the Traffic Manager profile. + * @param endpointType The type of the Traffic Manager endpoint. + * @param endpointName The name of the Traffic Manager endpoint. + * @return the observable to the EndpointInner object + */ + public Observable> getWithServiceResponseAsync(String resourceGroupName, String profileName, String endpointType, String endpointName) { + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (profileName == null) { + throw new IllegalArgumentException("Parameter profileName is required and cannot be null."); + } + if (endpointType == null) { + throw new IllegalArgumentException("Parameter endpointType is required and cannot be null."); + } + if (endpointName == null) { + throw new IllegalArgumentException("Parameter endpointName is required and cannot be null."); + } + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + return service.get(resourceGroupName, profileName, endpointType, endpointName, this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse getDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.client.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + + /** + * Create or update a Traffic Manager endpoint. + * + * @param resourceGroupName The name of the resource group containing the Traffic Manager endpoint to be created or updated. + * @param profileName The name of the Traffic Manager profile. + * @param endpointType The type of the Traffic Manager endpoint to be created or updated. + * @param endpointName The name of the Traffic Manager endpoint to be created or updated. + * @param parameters The Traffic Manager endpoint parameters supplied to the CreateOrUpdate operation. + * @return the EndpointInner object if successful. + */ + public EndpointInner createOrUpdate(String resourceGroupName, String profileName, String endpointType, String endpointName, EndpointInner parameters) { + return createOrUpdateWithServiceResponseAsync(resourceGroupName, profileName, endpointType, endpointName, parameters).toBlocking().single().getBody(); + } + + /** + * Create or update a Traffic Manager endpoint. + * + * @param resourceGroupName The name of the resource group containing the Traffic Manager endpoint to be created or updated. + * @param profileName The name of the Traffic Manager profile. + * @param endpointType The type of the Traffic Manager endpoint to be created or updated. + * @param endpointName The name of the Traffic Manager endpoint to be created or updated. + * @param parameters The Traffic Manager endpoint parameters supplied to the CreateOrUpdate operation. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @return the {@link ServiceCall} object + */ + public ServiceCall createOrUpdateAsync(String resourceGroupName, String profileName, String endpointType, String endpointName, EndpointInner parameters, final ServiceCallback serviceCallback) { + return ServiceCall.create(createOrUpdateWithServiceResponseAsync(resourceGroupName, profileName, endpointType, endpointName, parameters), serviceCallback); + } + + /** + * Create or update a Traffic Manager endpoint. + * + * @param resourceGroupName The name of the resource group containing the Traffic Manager endpoint to be created or updated. + * @param profileName The name of the Traffic Manager profile. + * @param endpointType The type of the Traffic Manager endpoint to be created or updated. + * @param endpointName The name of the Traffic Manager endpoint to be created or updated. + * @param parameters The Traffic Manager endpoint parameters supplied to the CreateOrUpdate operation. + * @return the observable to the EndpointInner object + */ + public Observable createOrUpdateAsync(String resourceGroupName, String profileName, String endpointType, String endpointName, EndpointInner parameters) { + return createOrUpdateWithServiceResponseAsync(resourceGroupName, profileName, endpointType, endpointName, parameters).map(new Func1, EndpointInner>() { + @Override + public EndpointInner call(ServiceResponse response) { + return response.getBody(); + } + }); + } + + /** + * Create or update a Traffic Manager endpoint. + * + * @param resourceGroupName The name of the resource group containing the Traffic Manager endpoint to be created or updated. + * @param profileName The name of the Traffic Manager profile. + * @param endpointType The type of the Traffic Manager endpoint to be created or updated. + * @param endpointName The name of the Traffic Manager endpoint to be created or updated. + * @param parameters The Traffic Manager endpoint parameters supplied to the CreateOrUpdate operation. + * @return the observable to the EndpointInner object + */ + public Observable> createOrUpdateWithServiceResponseAsync(String resourceGroupName, String profileName, String endpointType, String endpointName, EndpointInner parameters) { + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (profileName == null) { + throw new IllegalArgumentException("Parameter profileName is required and cannot be null."); + } + if (endpointType == null) { + throw new IllegalArgumentException("Parameter endpointType is required and cannot be null."); + } + if (endpointName == null) { + throw new IllegalArgumentException("Parameter endpointName is required and cannot be null."); + } + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (parameters == null) { + throw new IllegalArgumentException("Parameter parameters is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + Validator.validate(parameters); + return service.createOrUpdate(resourceGroupName, profileName, endpointType, endpointName, this.client.subscriptionId(), parameters, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = createOrUpdateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse createOrUpdateDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.client.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) + .register(201, new TypeToken() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + + /** + * Deletes a Traffic Manager endpoint. + * + * @param resourceGroupName The name of the resource group containing the Traffic Manager endpoint to be deleted. + * @param profileName The name of the Traffic Manager profile. + * @param endpointType The type of the Traffic Manager endpoint to be deleted. + * @param endpointName The name of the Traffic Manager endpoint to be deleted. + */ + public void delete(String resourceGroupName, String profileName, String endpointType, String endpointName) { + deleteWithServiceResponseAsync(resourceGroupName, profileName, endpointType, endpointName).toBlocking().single().getBody(); + } + + /** + * Deletes a Traffic Manager endpoint. + * + * @param resourceGroupName The name of the resource group containing the Traffic Manager endpoint to be deleted. + * @param profileName The name of the Traffic Manager profile. + * @param endpointType The type of the Traffic Manager endpoint to be deleted. + * @param endpointName The name of the Traffic Manager endpoint to be deleted. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @return the {@link ServiceCall} object + */ + public ServiceCall deleteAsync(String resourceGroupName, String profileName, String endpointType, String endpointName, final ServiceCallback serviceCallback) { + return ServiceCall.create(deleteWithServiceResponseAsync(resourceGroupName, profileName, endpointType, endpointName), serviceCallback); + } + + /** + * Deletes a Traffic Manager endpoint. + * + * @param resourceGroupName The name of the resource group containing the Traffic Manager endpoint to be deleted. + * @param profileName The name of the Traffic Manager profile. + * @param endpointType The type of the Traffic Manager endpoint to be deleted. + * @param endpointName The name of the Traffic Manager endpoint to be deleted. + * @return the {@link ServiceResponse} object if successful. + */ + public Observable deleteAsync(String resourceGroupName, String profileName, String endpointType, String endpointName) { + return deleteWithServiceResponseAsync(resourceGroupName, profileName, endpointType, endpointName).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.getBody(); + } + }); + } + + /** + * Deletes a Traffic Manager endpoint. + * + * @param resourceGroupName The name of the resource group containing the Traffic Manager endpoint to be deleted. + * @param profileName The name of the Traffic Manager profile. + * @param endpointType The type of the Traffic Manager endpoint to be deleted. + * @param endpointName The name of the Traffic Manager endpoint to be deleted. + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> deleteWithServiceResponseAsync(String resourceGroupName, String profileName, String endpointType, String endpointName) { + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (profileName == null) { + throw new IllegalArgumentException("Parameter profileName is required and cannot be null."); + } + if (endpointType == null) { + throw new IllegalArgumentException("Parameter endpointType is required and cannot be null."); + } + if (endpointName == null) { + throw new IllegalArgumentException("Parameter endpointName is required and cannot be null."); + } + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + return service.delete(resourceGroupName, profileName, endpointType, endpointName, this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = deleteDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse deleteDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.client.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) + .register(204, new TypeToken() { }.getType()) + .build(response); + } + +} diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/PageImpl.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/PageImpl.java new file mode 100644 index 0000000000000..a7b26586d8396 --- /dev/null +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/PageImpl.java @@ -0,0 +1,75 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.trafficmanager.implementation; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.microsoft.azure.Page; +import java.util.List; + +/** + * An instance of this class defines a page of Azure resources and a link to + * get the next page of resources, if any. + * + * @param type of Azure resource + */ +public class PageImpl implements Page { + /** + * The link to the next page. + */ + @JsonProperty("") + private String nextPageLink; + + /** + * The list of items. + */ + @JsonProperty("value") + private List items; + + /** + * Gets the link to the next page. + * + * @return the link to the next page. + */ + @Override + public String getNextPageLink() { + return this.nextPageLink; + } + + /** + * Gets the list of items. + * + * @return the list of items in {@link List}. + */ + @Override + public List getItems() { + return items; + } + + /** + * Sets the link to the next page. + * + * @param nextPageLink the link to the next page. + * @return this Page object itself. + */ + public PageImpl setNextPageLink(String nextPageLink) { + this.nextPageLink = nextPageLink; + return this; + } + + /** + * Sets the list of items. + * + * @param items the list of items in {@link List}. + * @return this Page object itself. + */ + public PageImpl setItems(List items) { + this.items = items; + return this; + } +} diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/ProfileInner.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/ProfileInner.java new file mode 100644 index 0000000000000..1aa419ce77a1c --- /dev/null +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/ProfileInner.java @@ -0,0 +1,156 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.trafficmanager.implementation; + +import com.microsoft.azure.management.trafficmanager.DnsConfig; +import com.microsoft.azure.management.trafficmanager.MonitorConfig; +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.microsoft.rest.serializer.JsonFlatten; +import com.microsoft.azure.Resource; + +/** + * Class representing a Traffic Manager profile. + */ +@JsonFlatten +public class ProfileInner extends Resource { + /** + * Gets or sets the status of the Traffic Manager profile. Possible + * values are 'Enabled' and 'Disabled'. + */ + @JsonProperty(value = "properties.profileStatus") + private String profileStatus; + + /** + * Gets or sets the traffic routing method of the Traffic Manager profile. + * Possible values are 'Performance', 'Weighted', or 'Priority'. + */ + @JsonProperty(value = "properties.trafficRoutingMethod") + private String trafficRoutingMethod; + + /** + * Gets or sets the DNS settings of the Traffic Manager profile. + */ + @JsonProperty(value = "properties.dnsConfig") + private DnsConfig dnsConfig; + + /** + * Gets or sets the endpoint monitoring settings of the Traffic Manager + * profile. + */ + @JsonProperty(value = "properties.monitorConfig") + private MonitorConfig monitorConfig; + + /** + * Gets or sets the list of endpoints in the Traffic Manager profile. + */ + @JsonProperty(value = "properties.endpoints") + private List endpoints; + + /** + * Get the profileStatus value. + * + * @return the profileStatus value + */ + public String profileStatus() { + return this.profileStatus; + } + + /** + * Set the profileStatus value. + * + * @param profileStatus the profileStatus value to set + * @return the ProfileInner object itself. + */ + public ProfileInner withProfileStatus(String profileStatus) { + this.profileStatus = profileStatus; + return this; + } + + /** + * Get the trafficRoutingMethod value. + * + * @return the trafficRoutingMethod value + */ + public String trafficRoutingMethod() { + return this.trafficRoutingMethod; + } + + /** + * Set the trafficRoutingMethod value. + * + * @param trafficRoutingMethod the trafficRoutingMethod value to set + * @return the ProfileInner object itself. + */ + public ProfileInner withTrafficRoutingMethod(String trafficRoutingMethod) { + this.trafficRoutingMethod = trafficRoutingMethod; + return this; + } + + /** + * Get the dnsConfig value. + * + * @return the dnsConfig value + */ + public DnsConfig dnsConfig() { + return this.dnsConfig; + } + + /** + * Set the dnsConfig value. + * + * @param dnsConfig the dnsConfig value to set + * @return the ProfileInner object itself. + */ + public ProfileInner withDnsConfig(DnsConfig dnsConfig) { + this.dnsConfig = dnsConfig; + return this; + } + + /** + * Get the monitorConfig value. + * + * @return the monitorConfig value + */ + public MonitorConfig monitorConfig() { + return this.monitorConfig; + } + + /** + * Set the monitorConfig value. + * + * @param monitorConfig the monitorConfig value to set + * @return the ProfileInner object itself. + */ + public ProfileInner withMonitorConfig(MonitorConfig monitorConfig) { + this.monitorConfig = monitorConfig; + return this; + } + + /** + * Get the endpoints value. + * + * @return the endpoints value + */ + public List endpoints() { + return this.endpoints; + } + + /** + * Set the endpoints value. + * + * @param endpoints the endpoints value to set + * @return the ProfileInner object itself. + */ + public ProfileInner withEndpoints(List endpoints) { + this.endpoints = endpoints; + return this; + } + +} diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/ProfilesInner.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/ProfilesInner.java new file mode 100644 index 0000000000000..65e89d8026acc --- /dev/null +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/ProfilesInner.java @@ -0,0 +1,643 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.trafficmanager.implementation; + +import retrofit2.Retrofit; +import com.google.common.reflect.TypeToken; +import com.microsoft.azure.AzureServiceResponseBuilder; +import com.microsoft.azure.CloudException; +import com.microsoft.rest.ServiceCall; +import com.microsoft.rest.ServiceCallback; +import com.microsoft.rest.ServiceResponse; +import com.microsoft.rest.Validator; +import java.io.IOException; +import java.util.List; +import okhttp3.ResponseBody; +import retrofit2.http.Body; +import retrofit2.http.GET; +import retrofit2.http.Header; +import retrofit2.http.Headers; +import retrofit2.http.HTTP; +import retrofit2.http.PATCH; +import retrofit2.http.Path; +import retrofit2.http.POST; +import retrofit2.http.PUT; +import retrofit2.http.Query; +import retrofit2.Response; +import rx.functions.Func1; +import rx.Observable; + +/** + * An instance of this class provides access to all the operations defined + * in Profiles. + */ +public final class ProfilesInner { + /** The Retrofit service to perform REST calls. */ + private ProfilesService service; + /** The service client containing this operation class. */ + private TrafficManagerManagementClientImpl client; + + /** + * Initializes an instance of ProfilesInner. + * + * @param retrofit the Retrofit instance built from a Retrofit Builder. + * @param client the instance of the service client containing this operation class. + */ + public ProfilesInner(Retrofit retrofit, TrafficManagerManagementClientImpl client) { + this.service = retrofit.create(ProfilesService.class); + this.client = client; + } + + /** + * The interface defining all the services for Profiles to be + * used by Retrofit to perform actually REST calls. + */ + interface ProfilesService { + @Headers("Content-Type: application/json; charset=utf-8") + @POST("providers/Microsoft.Network/checkTrafficManagerNameAvailability") + Observable> checkTrafficManagerRelativeDnsNameAvailability(@Path("subscriptionId") String subscriptionId, @Body CheckTrafficManagerRelativeDnsNameAvailabilityParametersInner parameters, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @GET("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles") + Observable> listAllInResourceGroup(@Path("resourceGroupName") String resourceGroupName, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @GET("subscriptions/{subscriptionId}/providers/Microsoft.Network/trafficmanagerprofiles") + Observable> listAll(@Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @GET("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}") + Observable> get(@Path("resourceGroupName") String resourceGroupName, @Path("profileName") String profileName, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @PUT("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}") + Observable> createOrUpdate(@Path("resourceGroupName") String resourceGroupName, @Path("profileName") String profileName, @Path("subscriptionId") String subscriptionId, @Body ProfileInner parameters, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @HTTP(path = "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}", method = "DELETE", hasBody = true) + Observable> delete(@Path("resourceGroupName") String resourceGroupName, @Path("profileName") String profileName, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @PATCH("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}") + Observable> update(@Path("resourceGroupName") String resourceGroupName, @Path("profileName") String profileName, @Path("subscriptionId") String subscriptionId, @Body ProfileInner parameters, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + } + + /** + * Checks the availability of a Traffic Manager Relative DNS name. + * + * @param parameters The Traffic Manager name parameters supplied to the CheckTrafficManagerNameAvailability operation. + * @return the TrafficManagerNameAvailabilityInner object if successful. + */ + public TrafficManagerNameAvailabilityInner checkTrafficManagerRelativeDnsNameAvailability(CheckTrafficManagerRelativeDnsNameAvailabilityParametersInner parameters) { + return checkTrafficManagerRelativeDnsNameAvailabilityWithServiceResponseAsync(parameters).toBlocking().single().getBody(); + } + + /** + * Checks the availability of a Traffic Manager Relative DNS name. + * + * @param parameters The Traffic Manager name parameters supplied to the CheckTrafficManagerNameAvailability operation. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @return the {@link ServiceCall} object + */ + public ServiceCall checkTrafficManagerRelativeDnsNameAvailabilityAsync(CheckTrafficManagerRelativeDnsNameAvailabilityParametersInner parameters, final ServiceCallback serviceCallback) { + return ServiceCall.create(checkTrafficManagerRelativeDnsNameAvailabilityWithServiceResponseAsync(parameters), serviceCallback); + } + + /** + * Checks the availability of a Traffic Manager Relative DNS name. + * + * @param parameters The Traffic Manager name parameters supplied to the CheckTrafficManagerNameAvailability operation. + * @return the observable to the TrafficManagerNameAvailabilityInner object + */ + public Observable checkTrafficManagerRelativeDnsNameAvailabilityAsync(CheckTrafficManagerRelativeDnsNameAvailabilityParametersInner parameters) { + return checkTrafficManagerRelativeDnsNameAvailabilityWithServiceResponseAsync(parameters).map(new Func1, TrafficManagerNameAvailabilityInner>() { + @Override + public TrafficManagerNameAvailabilityInner call(ServiceResponse response) { + return response.getBody(); + } + }); + } + + /** + * Checks the availability of a Traffic Manager Relative DNS name. + * + * @param parameters The Traffic Manager name parameters supplied to the CheckTrafficManagerNameAvailability operation. + * @return the observable to the TrafficManagerNameAvailabilityInner object + */ + public Observable> checkTrafficManagerRelativeDnsNameAvailabilityWithServiceResponseAsync(CheckTrafficManagerRelativeDnsNameAvailabilityParametersInner parameters) { + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (parameters == null) { + throw new IllegalArgumentException("Parameter parameters is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + Validator.validate(parameters); + return service.checkTrafficManagerRelativeDnsNameAvailability(this.client.subscriptionId(), parameters, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = checkTrafficManagerRelativeDnsNameAvailabilityDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse checkTrafficManagerRelativeDnsNameAvailabilityDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.client.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + + /** + * Lists all Traffic Manager profiles within a resource group. + * + * @param resourceGroupName The name of the resource group containing the Traffic Manager profiles to be listed. + * @return the List<ProfileInner> object if successful. + */ + public List listAllInResourceGroup(String resourceGroupName) { + return listAllInResourceGroupWithServiceResponseAsync(resourceGroupName).toBlocking().single().getBody(); + } + + /** + * Lists all Traffic Manager profiles within a resource group. + * + * @param resourceGroupName The name of the resource group containing the Traffic Manager profiles to be listed. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @return the {@link ServiceCall} object + */ + public ServiceCall> listAllInResourceGroupAsync(String resourceGroupName, final ServiceCallback> serviceCallback) { + return ServiceCall.create(listAllInResourceGroupWithServiceResponseAsync(resourceGroupName), serviceCallback); + } + + /** + * Lists all Traffic Manager profiles within a resource group. + * + * @param resourceGroupName The name of the resource group containing the Traffic Manager profiles to be listed. + * @return the observable to the List<ProfileInner> object + */ + public Observable> listAllInResourceGroupAsync(String resourceGroupName) { + return listAllInResourceGroupWithServiceResponseAsync(resourceGroupName).map(new Func1>, List>() { + @Override + public List call(ServiceResponse> response) { + return response.getBody(); + } + }); + } + + /** + * Lists all Traffic Manager profiles within a resource group. + * + * @param resourceGroupName The name of the resource group containing the Traffic Manager profiles to be listed. + * @return the observable to the List<ProfileInner> object + */ + public Observable>> listAllInResourceGroupWithServiceResponseAsync(String resourceGroupName) { + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + return service.listAllInResourceGroup(resourceGroupName, this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listAllInResourceGroupDelegate(response); + ServiceResponse> clientResponse = new ServiceResponse>(result.getBody().getItems(), result.getResponse()); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listAllInResourceGroupDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder, CloudException>(this.client.mapperAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + + /** + * Lists all Traffic Manager profiles within a subscription. + * + * @return the List<ProfileInner> object if successful. + */ + public List listAll() { + return listAllWithServiceResponseAsync().toBlocking().single().getBody(); + } + + /** + * Lists all Traffic Manager profiles within a subscription. + * + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @return the {@link ServiceCall} object + */ + public ServiceCall> listAllAsync(final ServiceCallback> serviceCallback) { + return ServiceCall.create(listAllWithServiceResponseAsync(), serviceCallback); + } + + /** + * Lists all Traffic Manager profiles within a subscription. + * + * @return the observable to the List<ProfileInner> object + */ + public Observable> listAllAsync() { + return listAllWithServiceResponseAsync().map(new Func1>, List>() { + @Override + public List call(ServiceResponse> response) { + return response.getBody(); + } + }); + } + + /** + * Lists all Traffic Manager profiles within a subscription. + * + * @return the observable to the List<ProfileInner> object + */ + public Observable>> listAllWithServiceResponseAsync() { + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + return service.listAll(this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listAllDelegate(response); + ServiceResponse> clientResponse = new ServiceResponse>(result.getBody().getItems(), result.getResponse()); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listAllDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder, CloudException>(this.client.mapperAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + + /** + * Gets a Traffic Manager profile. + * + * @param resourceGroupName The name of the resource group containing the Traffic Manager profile. + * @param profileName The name of the Traffic Manager profile. + * @return the ProfileInner object if successful. + */ + public ProfileInner get(String resourceGroupName, String profileName) { + return getWithServiceResponseAsync(resourceGroupName, profileName).toBlocking().single().getBody(); + } + + /** + * Gets a Traffic Manager profile. + * + * @param resourceGroupName The name of the resource group containing the Traffic Manager profile. + * @param profileName The name of the Traffic Manager profile. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @return the {@link ServiceCall} object + */ + public ServiceCall getAsync(String resourceGroupName, String profileName, final ServiceCallback serviceCallback) { + return ServiceCall.create(getWithServiceResponseAsync(resourceGroupName, profileName), serviceCallback); + } + + /** + * Gets a Traffic Manager profile. + * + * @param resourceGroupName The name of the resource group containing the Traffic Manager profile. + * @param profileName The name of the Traffic Manager profile. + * @return the observable to the ProfileInner object + */ + public Observable getAsync(String resourceGroupName, String profileName) { + return getWithServiceResponseAsync(resourceGroupName, profileName).map(new Func1, ProfileInner>() { + @Override + public ProfileInner call(ServiceResponse response) { + return response.getBody(); + } + }); + } + + /** + * Gets a Traffic Manager profile. + * + * @param resourceGroupName The name of the resource group containing the Traffic Manager profile. + * @param profileName The name of the Traffic Manager profile. + * @return the observable to the ProfileInner object + */ + public Observable> getWithServiceResponseAsync(String resourceGroupName, String profileName) { + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (profileName == null) { + throw new IllegalArgumentException("Parameter profileName is required and cannot be null."); + } + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + return service.get(resourceGroupName, profileName, this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse getDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.client.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + + /** + * Create or update a Traffic Manager profile. + * + * @param resourceGroupName The name of the resource group containing the Traffic Manager profile. + * @param profileName The name of the Traffic Manager profile. + * @param parameters The Traffic Manager profile parameters supplied to the CreateOrUpdate operation. + * @return the ProfileInner object if successful. + */ + public ProfileInner createOrUpdate(String resourceGroupName, String profileName, ProfileInner parameters) { + return createOrUpdateWithServiceResponseAsync(resourceGroupName, profileName, parameters).toBlocking().single().getBody(); + } + + /** + * Create or update a Traffic Manager profile. + * + * @param resourceGroupName The name of the resource group containing the Traffic Manager profile. + * @param profileName The name of the Traffic Manager profile. + * @param parameters The Traffic Manager profile parameters supplied to the CreateOrUpdate operation. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @return the {@link ServiceCall} object + */ + public ServiceCall createOrUpdateAsync(String resourceGroupName, String profileName, ProfileInner parameters, final ServiceCallback serviceCallback) { + return ServiceCall.create(createOrUpdateWithServiceResponseAsync(resourceGroupName, profileName, parameters), serviceCallback); + } + + /** + * Create or update a Traffic Manager profile. + * + * @param resourceGroupName The name of the resource group containing the Traffic Manager profile. + * @param profileName The name of the Traffic Manager profile. + * @param parameters The Traffic Manager profile parameters supplied to the CreateOrUpdate operation. + * @return the observable to the ProfileInner object + */ + public Observable createOrUpdateAsync(String resourceGroupName, String profileName, ProfileInner parameters) { + return createOrUpdateWithServiceResponseAsync(resourceGroupName, profileName, parameters).map(new Func1, ProfileInner>() { + @Override + public ProfileInner call(ServiceResponse response) { + return response.getBody(); + } + }); + } + + /** + * Create or update a Traffic Manager profile. + * + * @param resourceGroupName The name of the resource group containing the Traffic Manager profile. + * @param profileName The name of the Traffic Manager profile. + * @param parameters The Traffic Manager profile parameters supplied to the CreateOrUpdate operation. + * @return the observable to the ProfileInner object + */ + public Observable> createOrUpdateWithServiceResponseAsync(String resourceGroupName, String profileName, ProfileInner parameters) { + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (profileName == null) { + throw new IllegalArgumentException("Parameter profileName is required and cannot be null."); + } + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (parameters == null) { + throw new IllegalArgumentException("Parameter parameters is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + Validator.validate(parameters); + return service.createOrUpdate(resourceGroupName, profileName, this.client.subscriptionId(), parameters, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = createOrUpdateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse createOrUpdateDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.client.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) + .register(201, new TypeToken() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + + /** + * Deletes a Traffic Manager profile. + * + * @param resourceGroupName The name of the resource group containing the Traffic Manager profile to be deleted. + * @param profileName The name of the Traffic Manager profile to be deleted. + */ + public void delete(String resourceGroupName, String profileName) { + deleteWithServiceResponseAsync(resourceGroupName, profileName).toBlocking().single().getBody(); + } + + /** + * Deletes a Traffic Manager profile. + * + * @param resourceGroupName The name of the resource group containing the Traffic Manager profile to be deleted. + * @param profileName The name of the Traffic Manager profile to be deleted. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @return the {@link ServiceCall} object + */ + public ServiceCall deleteAsync(String resourceGroupName, String profileName, final ServiceCallback serviceCallback) { + return ServiceCall.create(deleteWithServiceResponseAsync(resourceGroupName, profileName), serviceCallback); + } + + /** + * Deletes a Traffic Manager profile. + * + * @param resourceGroupName The name of the resource group containing the Traffic Manager profile to be deleted. + * @param profileName The name of the Traffic Manager profile to be deleted. + * @return the {@link ServiceResponse} object if successful. + */ + public Observable deleteAsync(String resourceGroupName, String profileName) { + return deleteWithServiceResponseAsync(resourceGroupName, profileName).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.getBody(); + } + }); + } + + /** + * Deletes a Traffic Manager profile. + * + * @param resourceGroupName The name of the resource group containing the Traffic Manager profile to be deleted. + * @param profileName The name of the Traffic Manager profile to be deleted. + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> deleteWithServiceResponseAsync(String resourceGroupName, String profileName) { + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (profileName == null) { + throw new IllegalArgumentException("Parameter profileName is required and cannot be null."); + } + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + return service.delete(resourceGroupName, profileName, this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = deleteDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse deleteDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.client.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) + .register(204, new TypeToken() { }.getType()) + .build(response); + } + + /** + * Update a Traffic Manager profile. + * + * @param resourceGroupName The name of the resource group containing the Traffic Manager profile. + * @param profileName The name of the Traffic Manager profile. + * @param parameters The Traffic Manager profile parameters supplied to the Update operation. + * @return the ProfileInner object if successful. + */ + public ProfileInner update(String resourceGroupName, String profileName, ProfileInner parameters) { + return updateWithServiceResponseAsync(resourceGroupName, profileName, parameters).toBlocking().single().getBody(); + } + + /** + * Update a Traffic Manager profile. + * + * @param resourceGroupName The name of the resource group containing the Traffic Manager profile. + * @param profileName The name of the Traffic Manager profile. + * @param parameters The Traffic Manager profile parameters supplied to the Update operation. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @return the {@link ServiceCall} object + */ + public ServiceCall updateAsync(String resourceGroupName, String profileName, ProfileInner parameters, final ServiceCallback serviceCallback) { + return ServiceCall.create(updateWithServiceResponseAsync(resourceGroupName, profileName, parameters), serviceCallback); + } + + /** + * Update a Traffic Manager profile. + * + * @param resourceGroupName The name of the resource group containing the Traffic Manager profile. + * @param profileName The name of the Traffic Manager profile. + * @param parameters The Traffic Manager profile parameters supplied to the Update operation. + * @return the observable to the ProfileInner object + */ + public Observable updateAsync(String resourceGroupName, String profileName, ProfileInner parameters) { + return updateWithServiceResponseAsync(resourceGroupName, profileName, parameters).map(new Func1, ProfileInner>() { + @Override + public ProfileInner call(ServiceResponse response) { + return response.getBody(); + } + }); + } + + /** + * Update a Traffic Manager profile. + * + * @param resourceGroupName The name of the resource group containing the Traffic Manager profile. + * @param profileName The name of the Traffic Manager profile. + * @param parameters The Traffic Manager profile parameters supplied to the Update operation. + * @return the observable to the ProfileInner object + */ + public Observable> updateWithServiceResponseAsync(String resourceGroupName, String profileName, ProfileInner parameters) { + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (profileName == null) { + throw new IllegalArgumentException("Parameter profileName is required and cannot be null."); + } + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (parameters == null) { + throw new IllegalArgumentException("Parameter parameters is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + Validator.validate(parameters); + return service.update(resourceGroupName, profileName, this.client.subscriptionId(), parameters, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = updateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse updateDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.client.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + +} diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManager.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManager.java new file mode 100644 index 0000000000000..928376027a2e4 --- /dev/null +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManager.java @@ -0,0 +1,99 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ +package com.microsoft.azure.management.trafficmanager.implementation; + +import com.microsoft.azure.RestClient; +import com.microsoft.azure.credentials.AzureTokenCredentials; +import com.microsoft.azure.management.resources.fluentcore.arm.AzureConfigurable; +import com.microsoft.azure.management.resources.fluentcore.arm.implementation.AzureConfigurableImpl; +import com.microsoft.azure.management.resources.fluentcore.arm.implementation.Manager; +import com.microsoft.azure.management.trafficmanager.TrafficManagerProfiles; + +/** + * Entry point to Azure traffic manager management. + */ +public final class TrafficManager extends Manager { + // Collections + private TrafficManagerProfiles profiles; + + /** + * Get a Configurable instance that can be used to create {@link TrafficManager} + * with optional configuration. + * + * @return the instance allowing configurations + */ + public static Configurable configure() { + return new TrafficManager.ConfigurableImpl(); + } + + /** + * Creates an instance of TrafficManager that exposes traffic manager management API entry points. + * + * @param credentials the credentials to use + * @param subscriptionId the subscription UUID + * @return the TrafficManager + */ + public static TrafficManager authenticate(AzureTokenCredentials credentials, String subscriptionId) { + return new TrafficManager(credentials.getEnvironment().newRestClientBuilder() + .withCredentials(credentials) + .build(), subscriptionId); + } + + /** + * Creates an instance of TrafficManager that exposes traffic manager management API entry points. + * + * @param restClient the RestClient to be used for API calls. + * @param subscriptionId the subscription UUID + * @return the TrafficManager + */ + public static TrafficManager authenticate(RestClient restClient, String subscriptionId) { + return new TrafficManager(restClient, subscriptionId); + } + + /** + * The interface allowing configurations to be set. + */ + public interface Configurable extends AzureConfigurable { + /** + * Creates an instance of TrafficManager that exposes traffic manager management API entry points. + * + * @param credentials the credentials to use + * @param subscriptionId the subscription UUID + * @return the interface exposing traffic manager management API entry points that work across subscriptions + */ + TrafficManager authenticate(AzureTokenCredentials credentials, String subscriptionId); + } + + /** + * The implementation for Configurable interface. + */ + private static class ConfigurableImpl + extends AzureConfigurableImpl + implements Configurable { + + public TrafficManager authenticate(AzureTokenCredentials credentials, String subscriptionId) { + return TrafficManager.authenticate(buildRestClient(credentials), subscriptionId); + } + } + + private TrafficManager(RestClient restClient, String subscriptionId) { + super(restClient, + subscriptionId, + new TrafficManagerManagementClientImpl(restClient).withSubscriptionId(subscriptionId)); + } + + /** + * @return entry point to traffic manager profile management + */ + public TrafficManagerProfiles profiles() { + if (this.profiles == null) { + this.profiles = new TrafficManagerProfilesImpl( + super.innerManagementClient, + this); + } + return this.profiles; + } +} diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerAzureEndpointImpl.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerAzureEndpointImpl.java new file mode 100644 index 0000000000000..69e371531f33b --- /dev/null +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerAzureEndpointImpl.java @@ -0,0 +1,34 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ +package com.microsoft.azure.management.trafficmanager.implementation; + +import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils; +import com.microsoft.azure.management.trafficmanager.TrafficManagerAzureEndpoint; +import com.microsoft.azure.management.trafficmanager.TargetAzureResourceType; + +/** + * Implementation for {@link TrafficManagerAzureEndpoint}. + */ +class TrafficManagerAzureEndpointImpl extends TrafficManagerEndpointImpl + implements TrafficManagerAzureEndpoint { + TrafficManagerAzureEndpointImpl(String name, + TrafficManagerProfileImpl parent, + EndpointInner inner, + EndpointsInner client) { + super(name, parent, inner, client); + } + + @Override + public String targetAzureResourceId() { + return inner().targetResourceId(); + } + + @Override + public TargetAzureResourceType targetResourceType() { + return new TargetAzureResourceType(ResourceUtils.resourceProviderFromResourceId(targetAzureResourceId()), + ResourceUtils.resourceTypeFromResourceId(targetAzureResourceId())); + } +} diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerEndpointImpl.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerEndpointImpl.java new file mode 100644 index 0000000000000..b786db08d9688 --- /dev/null +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerEndpointImpl.java @@ -0,0 +1,175 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ +package com.microsoft.azure.management.trafficmanager.implementation; + +import com.microsoft.azure.management.resources.fluentcore.arm.Region; +import com.microsoft.azure.management.resources.fluentcore.arm.models.implementation.ExternalChildResourceImpl; +import com.microsoft.azure.management.trafficmanager.TrafficManagerEndpoint; +import com.microsoft.azure.management.trafficmanager.EndpointMonitorStatus; +import com.microsoft.azure.management.trafficmanager.TrafficManagerProfile; +import com.microsoft.azure.management.trafficmanager.EndpointType; +import rx.Observable; +import rx.functions.Func1; + +/** + * Implementation for {@link TrafficManagerEndpoint}. + */ +class TrafficManagerEndpointImpl extends ExternalChildResourceImpl + implements TrafficManagerEndpoint, + TrafficManagerEndpoint.Definition, + TrafficManagerEndpoint.UpdateDefinition, + TrafficManagerEndpoint.UpdateAzureEndpoint, + TrafficManagerEndpoint.UpdateExternalEndpoint, + TrafficManagerEndpoint.UpdateNestedProfileEndpoint { + private final EndpointsInner client; + private final String endpointStatusDisabled = "Disabled"; + private final String endpointStatusEnabled = "Enabled"; + + TrafficManagerEndpointImpl(String name, + TrafficManagerProfileImpl parent, + EndpointInner inner, + EndpointsInner client) { + super(name, parent, inner); + this.client = client; + } + + @Override + public String id() { + return this.inner().id(); + } + + @Override + public EndpointType endpointType() { + return EndpointType.fromValue(this.inner().type()); + } + + @Override + public EndpointMonitorStatus monitorStatus() { + return new EndpointMonitorStatus(this.inner().endpointMonitorStatus()); + } + + @Override + public boolean isEnabled() { + return this.inner().endpointStatus().equalsIgnoreCase(this.endpointStatusEnabled); + } + + @Override + public int routingWeight() { + return this.inner().weight().intValue(); + } + + @Override + public int routingPriority() { + return this.inner().priority().intValue(); + } + + @Override + public TrafficManagerEndpointImpl toResourceId(String resourceId) { + this.inner().withTargetResourceId(resourceId); + return this; + } + + @Override + public TrafficManagerEndpointImpl toFqdn(String externalFqdn) { + this.inner().withTarget(externalFqdn); + return this; + } + + @Override + public TrafficManagerEndpointImpl toProfile(TrafficManagerProfile nestedProfile) { + this.inner().withTargetResourceId(nestedProfile.id()); + this.inner().withMinChildEndpoints(new Long(1)); + return this; + } + + public TrafficManagerEndpointImpl fromRegion(Region location) { + this.inner().withEndpointLocation(location.toString()); + return this; + } + + @Override + public TrafficManagerEndpointImpl withMinimumEndpointsToEnableTraffic(int count) { + this.inner().withMinChildEndpoints(new Long(count)); + return this; + } + + @Override + public TrafficManagerEndpointImpl withRoutingPriority(int priority) { + this.inner().withPriority(new Long(priority)); + return this; + } + + @Override + public TrafficManagerEndpointImpl withTrafficDisabled() { + this.inner().withEndpointStatus(this.endpointStatusDisabled); + return this; + } + + @Override + public TrafficManagerEndpointImpl withTrafficEnabled() { + this.inner().withEndpointStatus(this.endpointStatusEnabled); + return this; + } + + @Override + public TrafficManagerEndpointImpl withRoutingWeight(int weight) { + this.inner().withWeight(new Long(weight)); + return this; + } + + @Override + public Observable createAsync() { + final TrafficManagerEndpointImpl self = this; + return this.client.createOrUpdateAsync(this.parent().resourceGroupName(), + this.parent().name(), + this.endpointType().localName(), + this.name(), + this.inner()) + .map(new Func1() { + @Override + public TrafficManagerEndpoint call(EndpointInner inner) { + self.setInner(inner); + return self; + } + }); + } + + @Override + public Observable updateAsync() { + return createAsync(); + } + + @Override + public Observable deleteAsync() { + return this.client.deleteAsync(this.parent().resourceGroupName(), + this.parent().name(), + this.endpointType().localName(), + this.name()).map(new Func1() { + @Override + public Void call(Void result) { + return result; + } + }); + } + + @Override + public TrafficManagerProfileImpl attach() { + return this.parent().withEndpoint(this); + } + + @Override + public TrafficManagerEndpointImpl refresh() { + EndpointInner inner = this.client.get(this.parent().resourceGroupName(), + this.parent().name(), + this.endpointType().toString(), + this.name()); + this.setInner(inner); + return this; + } +} diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerEndpointsImpl.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerEndpointsImpl.java new file mode 100644 index 0000000000000..842479fd1e0b1 --- /dev/null +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerEndpointsImpl.java @@ -0,0 +1,218 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ +package com.microsoft.azure.management.trafficmanager.implementation; + +import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.ExternalChildResourcesImpl; +import com.microsoft.azure.management.trafficmanager.TrafficManagerAzureEndpoint; +import com.microsoft.azure.management.trafficmanager.TrafficManagerEndpoint; +import com.microsoft.azure.management.trafficmanager.EndpointType; +import com.microsoft.azure.management.trafficmanager.TrafficManagerExternalEndpoint; +import com.microsoft.azure.management.trafficmanager.TrafficManagerNestedProfileEndpoint; +import com.microsoft.azure.management.trafficmanager.TrafficManagerProfile; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * Represents an endpoint collection associated with a traffic manager profile. + */ +class TrafficManagerEndpointsImpl extends + ExternalChildResourcesImpl { + private final EndpointsInner client; + + /** + * Creates new EndpointsImpl. + * + * @param client the client to perform REST calls on endpoints + * @param parent the parent traffic manager profile of the endpoints + */ + TrafficManagerEndpointsImpl(EndpointsInner client, TrafficManagerProfileImpl parent) { + super(parent, "Endpoint"); + this.client = client; + this.initializeCollection(); + } + + /** + * @return the azure endpoints as a map indexed by name. + */ + Map azureEndpointsAsMap() { + Map result = new HashMap<>(); + for (Map.Entry entry : this.collection().entrySet()) { + TrafficManagerEndpointImpl endpoint = entry.getValue(); + if (endpoint.endpointType() == EndpointType.AZURE) { + TrafficManagerAzureEndpoint azureEndpoint = new TrafficManagerAzureEndpointImpl(entry.getKey(), + this.parent(), + endpoint.inner(), + this.client); + result.put(entry.getKey(), azureEndpoint); + } + } + return Collections.unmodifiableMap(result); + } + + /** + * @return the external endpoints as a map indexed by name. + */ + Map externalEndpointsAsMap() { + Map result = new HashMap<>(); + for (Map.Entry entry : this.collection().entrySet()) { + TrafficManagerEndpointImpl endpoint = entry.getValue(); + if (endpoint.endpointType() == EndpointType.EXTERNAL) { + TrafficManagerExternalEndpoint externalEndpoint = new TrafficManagerExternalEndpointImpl(entry.getKey(), + this.parent(), + endpoint.inner(), + this.client); + result.put(entry.getKey(), externalEndpoint); + } + } + return Collections.unmodifiableMap(result); + } + + /** + * @return the nested profile endpoints as a map indexed by name. + */ + Map nestedProfileEndpointsAsMap() { + Map result = new HashMap<>(); + for (Map.Entry entry : this.collection().entrySet()) { + TrafficManagerEndpointImpl endpoint = entry.getValue(); + if (endpoint.endpointType() == EndpointType.NESTED_PROFILE) { + TrafficManagerNestedProfileEndpoint nestedProfileEndpoint = new TrafficManagerNestedProfileEndpointImpl(entry.getKey(), + this.parent(), + endpoint.inner(), + this.client); + result.put(entry.getKey(), nestedProfileEndpoint); + } + } + return Collections.unmodifiableMap(result); + } + + /** + * Starts an Azure endpoint definition chain. + * + * @param name the name of the endpoint to be added + * @return the endpoint + */ + public TrafficManagerEndpointImpl defineAzureTargetEndpoint(String name) { + TrafficManagerEndpointImpl endpoint = this.prepareDefine(name); + endpoint.inner().withType(EndpointType.AZURE.toString()); + return endpoint; + } + + /** + * Starts an external endpoint definition chain. + * + * @param name the name of the endpoint to be added + * @return the endpoint + */ + public TrafficManagerEndpointImpl defineExteralTargetEndpoint(String name) { + TrafficManagerEndpointImpl endpoint = this.prepareDefine(name); + endpoint.inner().withType(EndpointType.EXTERNAL.toString()); + return endpoint; + } + + /** + * Starts an nested profile endpoint definition chain. + * + * @param name the name of the endpoint to be added + * @return the endpoint + */ + public TrafficManagerEndpointImpl defineNestedProfileTargetEndpoint(String name) { + TrafficManagerEndpointImpl endpoint = this.prepareDefine(name); + endpoint.inner().withType(EndpointType.NESTED_PROFILE.toString()); + return endpoint; + } + + /** + * Starts an azure endpoint update chain. + * + * @param name the name of the endpoint to be updated + * @return the endpoint + */ + public TrafficManagerEndpointImpl updateAzureEndpoint(String name) { + TrafficManagerEndpointImpl endpoint = this.prepareUpdate(name); + if (endpoint.endpointType() != EndpointType.AZURE) { + throw new IllegalArgumentException("An azure endpoint with name " + name + " not found in the profile"); + } + return endpoint; + } + + /** + * Starts an external endpoint update chain. + * + * @param name the name of the endpoint to be updated + * @return the endpoint + */ + public TrafficManagerEndpointImpl updateExternalEndpoint(String name) { + TrafficManagerEndpointImpl endpoint = this.prepareUpdate(name); + if (endpoint.endpointType() != EndpointType.EXTERNAL) { + throw new IllegalArgumentException("An external endpoint with name " + name + " not found in the profile"); + } + return endpoint; + } + + /** + * Starts a nested profile endpoint update chain. + * + * @param name the name of the endpoint to be updated + * @return the endpoint + */ + public TrafficManagerEndpointImpl updateNestedProfileEndpoint(String name) { + TrafficManagerEndpointImpl endpoint = this.prepareUpdate(name); + if (endpoint.endpointType() != EndpointType.NESTED_PROFILE) { + throw new IllegalArgumentException("A nested profile endpoint with name " + name + " not found in the profile"); + } + return endpoint; + } + /** + * Mark the endpoint with given name as to be removed. + * + * @param name the name of the endpoint to be removed + */ + public void remove(String name) { + this.prepareRemove(name); + } + + /** + * Adds the endpoint to the collection. + * + * @param endpoint the endpoint + */ + public void addEndpoint(TrafficManagerEndpointImpl endpoint) { + this.addChildResource(endpoint); + } + + @Override + protected List listChildResources() { + List childResources = new ArrayList<>(); + if (parent().inner().endpoints() != null) { + for (EndpointInner inner : parent().inner().endpoints()) { + childResources.add(new TrafficManagerEndpointImpl(inner.name(), + this.parent(), + inner, + this.client)); + } + } + return childResources; + } + + @Override + protected TrafficManagerEndpointImpl newChildResource(String name) { + TrafficManagerEndpointImpl endpoint = new TrafficManagerEndpointImpl(name, + this.parent(), + new EndpointInner().withName(name), + this.client); + return endpoint + .withRoutingWeight(1) + .withTrafficEnabled(); + } +} diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerExternalEndpointImpl.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerExternalEndpointImpl.java new file mode 100644 index 0000000000000..0c29228a37673 --- /dev/null +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerExternalEndpointImpl.java @@ -0,0 +1,36 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ +package com.microsoft.azure.management.trafficmanager.implementation; + +import com.microsoft.azure.management.resources.fluentcore.arm.Region; +import com.microsoft.azure.management.trafficmanager.TrafficManagerExternalEndpoint; + +/** + * Implementation for {@link TrafficManagerExternalEndpoint}. + */ +class TrafficManagerExternalEndpointImpl extends TrafficManagerEndpointImpl + implements TrafficManagerExternalEndpoint { + TrafficManagerExternalEndpointImpl(String name, + TrafficManagerProfileImpl parent, + EndpointInner inner, + EndpointsInner client) { + super(name, parent, inner, client); + } + + @Override + public String fqdn() { + return inner().target(); + } + + @Override + public Region sourceTrafficLocation() { + Region location = Region.fromLabel((inner().endpointLocation())); + if (location == null) { + return Region.fromName((inner().endpointLocation())); + } + return location; + } +} diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerManagementClientImpl.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerManagementClientImpl.java new file mode 100644 index 0000000000000..9541fdcdde7c8 --- /dev/null +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerManagementClientImpl.java @@ -0,0 +1,214 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.trafficmanager.implementation; + +import com.microsoft.azure.AzureClient; +import com.microsoft.azure.AzureServiceClient; +import com.microsoft.azure.RestClient; +import com.microsoft.rest.credentials.ServiceClientCredentials; + +/** + * Initializes a new instance of the TrafficManagerManagementClientImpl class. + */ +public final class TrafficManagerManagementClientImpl extends AzureServiceClient { + /** the {@link AzureClient} used for long running operations. */ + private AzureClient azureClient; + + /** + * Gets the {@link AzureClient} used for long running operations. + * @return the azure client; + */ + public AzureClient getAzureClient() { + return this.azureClient; + } + + /** Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. */ + private String subscriptionId; + + /** + * Gets Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + * + * @return the subscriptionId value. + */ + public String subscriptionId() { + return this.subscriptionId; + } + + /** + * Sets Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + * + * @param subscriptionId the subscriptionId value. + * @return the service client itself + */ + public TrafficManagerManagementClientImpl withSubscriptionId(String subscriptionId) { + this.subscriptionId = subscriptionId; + return this; + } + + /** Client Api Version. */ + private String apiVersion; + + /** + * Gets Client Api Version. + * + * @return the apiVersion value. + */ + public String apiVersion() { + return this.apiVersion; + } + + /** Gets or sets the preferred language for the response. */ + private String acceptLanguage; + + /** + * Gets Gets or sets the preferred language for the response. + * + * @return the acceptLanguage value. + */ + public String acceptLanguage() { + return this.acceptLanguage; + } + + /** + * Sets Gets or sets the preferred language for the response. + * + * @param acceptLanguage the acceptLanguage value. + * @return the service client itself + */ + public TrafficManagerManagementClientImpl withAcceptLanguage(String acceptLanguage) { + this.acceptLanguage = acceptLanguage; + return this; + } + + /** Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30. */ + private int longRunningOperationRetryTimeout; + + /** + * Gets Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30. + * + * @return the longRunningOperationRetryTimeout value. + */ + public int longRunningOperationRetryTimeout() { + return this.longRunningOperationRetryTimeout; + } + + /** + * Sets Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30. + * + * @param longRunningOperationRetryTimeout the longRunningOperationRetryTimeout value. + * @return the service client itself + */ + public TrafficManagerManagementClientImpl withLongRunningOperationRetryTimeout(int longRunningOperationRetryTimeout) { + this.longRunningOperationRetryTimeout = longRunningOperationRetryTimeout; + return this; + } + + /** When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. */ + private boolean generateClientRequestId; + + /** + * Gets When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. + * + * @return the generateClientRequestId value. + */ + public boolean generateClientRequestId() { + return this.generateClientRequestId; + } + + /** + * Sets When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. + * + * @param generateClientRequestId the generateClientRequestId value. + * @return the service client itself + */ + public TrafficManagerManagementClientImpl withGenerateClientRequestId(boolean generateClientRequestId) { + this.generateClientRequestId = generateClientRequestId; + return this; + } + + /** + * The EndpointsInner object to access its operations. + */ + private EndpointsInner endpoints; + + /** + * Gets the EndpointsInner object to access its operations. + * @return the EndpointsInner object. + */ + public EndpointsInner endpoints() { + return this.endpoints; + } + + /** + * The ProfilesInner object to access its operations. + */ + private ProfilesInner profiles; + + /** + * Gets the ProfilesInner object to access its operations. + * @return the ProfilesInner object. + */ + public ProfilesInner profiles() { + return this.profiles; + } + + /** + * Initializes an instance of TrafficManagerManagementClient client. + * + * @param credentials the management credentials for Azure + */ + public TrafficManagerManagementClientImpl(ServiceClientCredentials credentials) { + this("https://management.azure.com", credentials); + } + + /** + * Initializes an instance of TrafficManagerManagementClient client. + * + * @param baseUrl the base URL of the host + * @param credentials the management credentials for Azure + */ + public TrafficManagerManagementClientImpl(String baseUrl, ServiceClientCredentials credentials) { + this(new RestClient.Builder() + .withBaseUrl(baseUrl) + .withCredentials(credentials) + .build()); + } + + /** + * Initializes an instance of TrafficManagerManagementClient client. + * + * @param restClient the REST client to connect to Azure. + */ + public TrafficManagerManagementClientImpl(RestClient restClient) { + super(restClient); + initialize(); + } + + protected void initialize() { + this.apiVersion = "2015-11-01"; + this.acceptLanguage = "en-US"; + this.longRunningOperationRetryTimeout = 30; + this.generateClientRequestId = true; + this.endpoints = new EndpointsInner(restClient().retrofit(), this); + this.profiles = new ProfilesInner(restClient().retrofit(), this); + this.azureClient = new AzureClient(this); + } + + /** + * Gets the User-Agent header for the client. + * + * @return the user agent string. + */ + @Override + public String userAgent() { + return String.format("Azure-SDK-For-Java/%s (%s)", + getClass().getPackage().getImplementationVersion(), + "TrafficManagerManagementClient, 2015-11-01"); + } +} diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerNameAvailabilityInner.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerNameAvailabilityInner.java new file mode 100644 index 0000000000000..a6abb730aa414 --- /dev/null +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerNameAvailabilityInner.java @@ -0,0 +1,142 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.trafficmanager.implementation; + + +/** + * Class representing a Traffic Manager Name Availability response. + */ +public class TrafficManagerNameAvailabilityInner { + /** + * The relative name. + */ + private String name; + + /** + * Traffic Manager profile resource type. + */ + private String type; + + /** + * Describes whether the relative name is available or not. + */ + private Boolean nameAvailable; + + /** + * The reason why the name is not available, when applicable. + */ + private String reason; + + /** + * Descriptive message that explains why the name is not available, when + * applicable. + */ + private String message; + + /** + * Get the name value. + * + * @return the name value + */ + public String name() { + return this.name; + } + + /** + * Set the name value. + * + * @param name the name value to set + * @return the TrafficManagerNameAvailabilityInner object itself. + */ + public TrafficManagerNameAvailabilityInner withName(String name) { + this.name = name; + return this; + } + + /** + * Get the type value. + * + * @return the type value + */ + public String type() { + return this.type; + } + + /** + * Set the type value. + * + * @param type the type value to set + * @return the TrafficManagerNameAvailabilityInner object itself. + */ + public TrafficManagerNameAvailabilityInner withType(String type) { + this.type = type; + return this; + } + + /** + * Get the nameAvailable value. + * + * @return the nameAvailable value + */ + public Boolean nameAvailable() { + return this.nameAvailable; + } + + /** + * Set the nameAvailable value. + * + * @param nameAvailable the nameAvailable value to set + * @return the TrafficManagerNameAvailabilityInner object itself. + */ + public TrafficManagerNameAvailabilityInner withNameAvailable(Boolean nameAvailable) { + this.nameAvailable = nameAvailable; + return this; + } + + /** + * Get the reason value. + * + * @return the reason value + */ + public String reason() { + return this.reason; + } + + /** + * Set the reason value. + * + * @param reason the reason value to set + * @return the TrafficManagerNameAvailabilityInner object itself. + */ + public TrafficManagerNameAvailabilityInner withReason(String reason) { + this.reason = reason; + return this; + } + + /** + * Get the message value. + * + * @return the message value + */ + public String message() { + return this.message; + } + + /** + * Set the message value. + * + * @param message the message value to set + * @return the TrafficManagerNameAvailabilityInner object itself. + */ + public TrafficManagerNameAvailabilityInner withMessage(String message) { + this.message = message; + return this; + } + +} diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerNestedProfileEndpointImpl.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerNestedProfileEndpointImpl.java new file mode 100644 index 0000000000000..e959fb8c7f303 --- /dev/null +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerNestedProfileEndpointImpl.java @@ -0,0 +1,44 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ +package com.microsoft.azure.management.trafficmanager.implementation; + +import com.microsoft.azure.management.resources.fluentcore.arm.Region; +import com.microsoft.azure.management.trafficmanager.TrafficManagerNestedProfileEndpoint; + +/** + * Implementation for {@link TrafficManagerNestedProfileEndpoint}. + */ +class TrafficManagerNestedProfileEndpointImpl extends TrafficManagerEndpointImpl + implements TrafficManagerNestedProfileEndpoint { + TrafficManagerNestedProfileEndpointImpl(String name, + TrafficManagerProfileImpl parent, + EndpointInner inner, + EndpointsInner client) { + super(name, parent, inner, client); + } + + @Override + public String nestedProfileId() { + return inner().targetResourceId(); + } + + @Override + public int minimumChildEndpointCount() { + if (inner().minChildEndpoints() == null) { + return 0; + } + return inner().minChildEndpoints().intValue(); + } + + @Override + public Region sourceTrafficLocation() { + Region location = Region.fromLabel((inner().endpointLocation())); + if (location == null) { + return Region.fromName((inner().endpointLocation())); + } + return location; + } +} diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerProfileImpl.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerProfileImpl.java new file mode 100644 index 0000000000000..3a4c571d86c58 --- /dev/null +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerProfileImpl.java @@ -0,0 +1,278 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ +package com.microsoft.azure.management.trafficmanager.implementation; + +import com.microsoft.azure.management.resources.fluentcore.arm.models.implementation.GroupableResourceImpl; +import com.microsoft.azure.management.trafficmanager.TrafficManagerAzureEndpoint; +import com.microsoft.azure.management.trafficmanager.TrafficManagerExternalEndpoint; +import com.microsoft.azure.management.trafficmanager.TrafficManagerNestedProfileEndpoint; +import com.microsoft.azure.management.trafficmanager.TrafficManagerProfile; +import com.microsoft.azure.management.trafficmanager.ProfileMonitorStatus; +import com.microsoft.azure.management.trafficmanager.TrafficRoutingMethod; +import rx.Observable; +import rx.functions.Func1; + +import java.util.List; +import java.util.Map; + +/** + * Implementation for {@link TrafficManagerProfile}. + */ +class TrafficManagerProfileImpl + extends GroupableResourceImpl< + TrafficManagerProfile, + ProfileInner, + TrafficManagerProfileImpl, + TrafficManager> + implements + TrafficManagerProfile, + TrafficManagerProfile.Definition, + TrafficManagerProfile.Update { + private final ProfilesInner innerCollection; + private final EndpointsInner endpointsClient; + private final String profileStatusDisabled = "Disabled"; + private final String profileStatusEnabled = "Enabled"; + private TrafficManagerEndpointsImpl endpoints; + + TrafficManagerProfileImpl(String name, + final ProfileInner innerModel, + final ProfilesInner innerCollection, + final EndpointsInner endpointsClient, + final TrafficManager trafficManager) { + super(name, innerModel, trafficManager); + this.innerCollection = innerCollection; + this.endpointsClient = endpointsClient; + this.endpoints = new TrafficManagerEndpointsImpl(endpointsClient, this); + } + + @Override + public String dnsLabel() { + return this.inner().dnsConfig().relativeName(); + } + + @Override + public String fqdn() { + return this.inner().dnsConfig().fqdn(); + } + + @Override + public int timeToLive() { + return this.inner().dnsConfig().ttl().intValue(); + } + + @Override + public boolean isEnabled() { + return this.inner().profileStatus().equalsIgnoreCase(this.profileStatusEnabled); + } + + @Override + public TrafficRoutingMethod trafficRoutingMethod() { + return TrafficRoutingMethod.fromValue(this.inner().trafficRoutingMethod()); + } + + @Override + public ProfileMonitorStatus monitorStatus() { + return new ProfileMonitorStatus(this.inner().monitorConfig().profileMonitorStatus()); + } + + @Override + public int monitoringPort() { + return this.inner().monitorConfig().port().intValue(); + } + + @Override + public String monitoringPath() { + return this.inner().monitorConfig().path(); + } + + // TODO Expose monitoring protocol + + @Override + public Map externalEndpoints() { + return this.endpoints.externalEndpointsAsMap(); + } + + @Override + public Map azureEndpoints() { + return this.endpoints.azureEndpointsAsMap(); + } + + @Override + public Map nestedProfileEndpoints() { + return this.endpoints.nestedProfileEndpointsAsMap(); + } + + @Override + public TrafficManagerProfile refresh() { + ProfileInner inner = this.innerCollection.get(this.resourceGroupName(), this.name()); + this.setInner(inner); + this.endpoints.refresh(); + return this; + } + + @Override + public TrafficManagerProfileImpl withLeafDomainLabel(String dnsLabel) { + this.inner().dnsConfig().withRelativeName(dnsLabel); + return this; + } + + @Override + public TrafficManagerProfileImpl withPriorityBasedRouting() { + this.withTrafficRoutingMethod(TrafficRoutingMethod.PRIORITY); + return this; + } + + @Override + public TrafficManagerProfileImpl withWeightBasedRouting() { + this.withTrafficRoutingMethod(TrafficRoutingMethod.WEIGHTED); + return this; + } + + @Override + public TrafficManagerProfileImpl withPerformanceBasedRouting() { + this.withTrafficRoutingMethod(TrafficRoutingMethod.PERFORMANCE); + return this; + } + + @Override + public TrafficManagerProfileImpl withTrafficRoutingMethod(TrafficRoutingMethod routingMethod) { + this.inner().withTrafficRoutingMethod(routingMethod.toString()); + return this; + } + + @Override + public TrafficManagerEndpointImpl defineAzureTargetEndpoint(String name) { + return this.endpoints.defineAzureTargetEndpoint(name); + } + + @Override + public TrafficManagerEndpointImpl defineExternalTargetEndpoint(String name) { + return this.endpoints.defineExteralTargetEndpoint(name); + } + + @Override + public TrafficManagerEndpointImpl defineNestedTargetEndpoint(String name) { + return this.endpoints.defineNestedProfileTargetEndpoint(name); + } + + @Override + public TrafficManagerEndpointImpl updateAzureTargetEndpoint(String name) { + return this.endpoints.updateAzureEndpoint(name); + } + + @Override + public TrafficManagerEndpointImpl updateExternalTargetEndpoint(String name) { + return this.endpoints.updateExternalEndpoint(name); + } + + @Override + public TrafficManagerEndpointImpl updateNestedProfileTargetEndpoint(String name) { + return this.endpoints.updateNestedProfileEndpoint(name); + } + + @Override + public TrafficManagerProfileImpl withoutEndpoint(String name) { + this.endpoints.remove(name); + return this; + } + + @Override + public TrafficManagerProfileImpl withHttpMonitoring() { + return this.withHttpMonitoring(80, "/"); + } + + @Override + public TrafficManagerProfileImpl withHttpsMonitoring() { + return this.withHttpsMonitoring(443, "/"); + } + + @Override + public TrafficManagerProfileImpl withHttpMonitoring(int port, String path) { + this.inner().monitorConfig() + .withPort(new Long(port)) + .withPath(path) + .withProtocol("http"); + return this; + } + + @Override + public TrafficManagerProfileImpl withHttpsMonitoring(int port, String path) { + this.inner().monitorConfig() + .withPort(new Long(port)) + .withPath(path) + .withProtocol("https"); + return this; + } + + @Override + public TrafficManagerProfileImpl withProfileStatusDisabled() { + this.inner().withProfileStatus(this.profileStatusDisabled); + return this; + } + + @Override + public TrafficManagerProfileImpl withProfileStatusEnabled() { + this.inner().withProfileStatus(this.profileStatusEnabled); + return this; + } + + @Override + public TrafficManagerProfileImpl withTimeToLive(int ttlInSeconds) { + this.inner().dnsConfig().withTtl(new Long(ttlInSeconds)); + return this; + } + + @Override + public Observable createResourceAsync() { + final TrafficManagerProfileImpl self = this; + return innerCollection.createOrUpdateAsync(resourceGroupName(), name(), inner()) + .map(new Func1() { + @Override + public TrafficManagerProfile call(ProfileInner profileInner) { + self.setInner(profileInner); + return self; + } + }).flatMap(new Func1>() { + @Override + public Observable call(TrafficManagerProfile profile) { + return self.endpoints.commitAndGetAllAsync() + .map(new Func1, TrafficManagerProfile>() { + @Override + public TrafficManagerProfile call(List endpoints) { + return self; + } + }); + } + }); + } + + @Override + public Observable updateResourceAsync() { + final TrafficManagerProfileImpl self = this; + // In update we first commit the endpoints then update profile, the reason is through portal and direct API + // call one can create endpoints without properties those are not applicable for the profile's current routing + // method. We cannot update the routing method of the profile until existing endpoints contains the properties + // required for the new routing method. + return self.endpoints.commitAndGetAllAsync() + .flatMap(new Func1, Observable>() { + public Observable call(List endpoints) { + return innerCollection.createOrUpdateAsync(resourceGroupName(), name(), inner()) + .map(new Func1() { + @Override + public TrafficManagerProfile call(ProfileInner profileInner) { + self.setInner(profileInner); + return self; + } + }); + } + }); + } + + TrafficManagerProfileImpl withEndpoint(TrafficManagerEndpointImpl endpoint) { + this.endpoints.addEndpoint(endpoint); + return this; + } +} diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerProfilesImpl.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerProfilesImpl.java new file mode 100644 index 0000000000000..4bf38a5ff63a2 --- /dev/null +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerProfilesImpl.java @@ -0,0 +1,105 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ +package com.microsoft.azure.management.trafficmanager.implementation; + +import com.microsoft.azure.PagedList; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.GroupableResourcesImpl; +import com.microsoft.azure.management.trafficmanager.CheckProfileDnsNameAvailabilityResult; +import com.microsoft.azure.management.trafficmanager.DnsConfig; +import com.microsoft.azure.management.trafficmanager.MonitorConfig; +import com.microsoft.azure.management.trafficmanager.TrafficManagerProfile; +import com.microsoft.azure.management.trafficmanager.TrafficManagerProfiles; +import rx.Observable; + +import java.util.ArrayList; + +/** + * Implementation for {@link TrafficManagerProfiles}. + */ +class TrafficManagerProfilesImpl extends GroupableResourcesImpl< + TrafficManagerProfile, + TrafficManagerProfileImpl, + ProfileInner, + ProfilesInner, + TrafficManager> + implements TrafficManagerProfiles { + private final EndpointsInner endpointsClient; + + TrafficManagerProfilesImpl( + final TrafficManagerManagementClientImpl trafficManagementClient, + final TrafficManager trafficManager) { + super(trafficManagementClient.profiles(), trafficManager); + this.endpointsClient = trafficManagementClient.endpoints(); + } + + @Override + public CheckProfileDnsNameAvailabilityResult checkDnsNameAvailability(String dnsNameLabel) { + CheckTrafficManagerRelativeDnsNameAvailabilityParametersInner parameter = + new CheckTrafficManagerRelativeDnsNameAvailabilityParametersInner() + .withName(dnsNameLabel) + .withType("Microsoft.Network/trafficManagerProfiles"); + return new CheckProfileDnsNameAvailabilityResult(this + .innerCollection + .checkTrafficManagerRelativeDnsNameAvailability(parameter)); + } + + @Override + public PagedList list() { + return wrapList(this.innerCollection.listAll()); + } + + @Override + public PagedList listByGroup(String groupName) { + return wrapList(this.innerCollection.listAllInResourceGroup(groupName)); + } + + @Override + public TrafficManagerProfile getByGroup(String groupName, String name) { + return wrapModel(this.innerCollection.get(groupName, name)); + } + + @Override + public Observable deleteAsync(String groupName, String name) { + return this.innerCollection.deleteAsync(groupName, name); + } + + @Override + protected TrafficManagerProfileImpl wrapModel(String name) { + return new TrafficManagerProfileImpl(name, + new ProfileInner(), + this.innerCollection, + this.endpointsClient, + this.myManager); + } + + @Override + protected TrafficManagerProfileImpl wrapModel(ProfileInner inner) { + return new TrafficManagerProfileImpl(inner.name(), + inner, + this.innerCollection, + this.endpointsClient, + this.myManager); + } + + @Override + public TrafficManagerProfileImpl define(String name) { + return setDefaults(wrapModel(name)); + } + + private TrafficManagerProfileImpl setDefaults(TrafficManagerProfileImpl profile) { + // MonitorConfig is required + profile.inner().withMonitorConfig(new MonitorConfig()); + profile.withHttpMonitoring(); // Default to Http monitoring + // DnsConfig is required + profile.inner().withDnsConfig(new DnsConfig()); + profile.withTimeToLive(300); + // TM location must be 'global' irrespective of region of the resource group it resides. + profile.inner().withLocation("global"); + // Endpoints are external child resource still initializing it avoid null checks in the model impl. + profile.inner().withEndpoints(new ArrayList()); + return profile; + } +} diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/package-info.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/package-info.java new file mode 100644 index 0000000000000..47b1e63b276de --- /dev/null +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/package-info.java @@ -0,0 +1,10 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** + * This package contains the implementation classes for TrafficManagerManagementClient. + */ +package com.microsoft.azure.management.trafficmanager.implementation; diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/package-info.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/package-info.java new file mode 100644 index 0000000000000..3347e61452c01 --- /dev/null +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/package-info.java @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** + * This package contains the classes for TrafficManagerManagementClient. + * The TrafficManager Management Client. + */ +package com.microsoft.azure.management.trafficmanager; \ No newline at end of file diff --git a/azure/pom.xml b/azure/pom.xml index 994ff7b32880b..3e79458c29236 100644 --- a/azure/pom.xml +++ b/azure/pom.xml @@ -89,6 +89,11 @@ azure-mgmt-batch 1.0.0-beta4-SNAPSHOT + + com.microsoft.azure + azure-mgmt-trafficmanager + 1.0.0-beta4-SNAPSHOT + junit junit diff --git a/azure/src/main/java/com/microsoft/azure/management/Azure.java b/azure/src/main/java/com/microsoft/azure/management/Azure.java index 6103447abd52b..4914fa6910dfe 100644 --- a/azure/src/main/java/com/microsoft/azure/management/Azure.java +++ b/azure/src/main/java/com/microsoft/azure/management/Azure.java @@ -42,6 +42,8 @@ import com.microsoft.azure.management.storage.StorageAccounts; import com.microsoft.azure.management.storage.Usages; import com.microsoft.azure.management.storage.implementation.StorageManager; +import com.microsoft.azure.management.trafficmanager.TrafficManagerProfiles; +import com.microsoft.azure.management.trafficmanager.implementation.TrafficManager; import java.io.File; import java.io.IOException; @@ -56,6 +58,7 @@ public final class Azure { private final NetworkManager networkManager; private final KeyVaultManager keyVaultManager; private final BatchManager batchManager; + private final TrafficManager trafficManager; private final String subscriptionId; /** @@ -258,6 +261,7 @@ private Azure(RestClient restClient, String subscriptionId, String tenantId) { this.networkManager = NetworkManager.authenticate(restClient, subscriptionId); this.keyVaultManager = KeyVaultManager.authenticate(restClient, tenantId, subscriptionId); this.batchManager = BatchManager.authenticate(restClient, subscriptionId); + this.trafficManager = TrafficManager.authenticate(restClient, subscriptionId); this.subscriptionId = subscriptionId; } @@ -401,4 +405,10 @@ public BatchAccounts batchAccounts() { return batchManager.batchAccounts(); } + /** + * @return entry point to managing traffic manager profiles. + */ + public TrafficManagerProfiles trafficManagerProfiles() { + return trafficManager.profiles(); + } } diff --git a/azure/src/test/java/com/microsoft/azure/management/AzureTests.java b/azure/src/test/java/com/microsoft/azure/management/AzureTests.java index d32a174e41519..01eaa86f72da2 100644 --- a/azure/src/test/java/com/microsoft/azure/management/AzureTests.java +++ b/azure/src/test/java/com/microsoft/azure/management/AzureTests.java @@ -71,7 +71,7 @@ public static void main(String[] args) throws IOException, CloudException { public void setup() throws Exception { // Authenticate based on credentials instance Azure.Authenticated azureAuthed = Azure.configure() - .withLogLevel(Level.NONE) + .withLogLevel(Level.BODY) .withUserAgent("AzureTests") .authenticate(CREDENTIALS); @@ -314,4 +314,10 @@ public void createStorageAccount() throws Exception { public void testBatchAccount() throws Exception { new TestBatch().runTest(azure.batchAccounts(), azure.resourceGroups()); } + + @Test + public void testTrafficManager() throws Exception { + new TestTrafficManager(azure.resourceGroups(), azure.publicIpAddresses()) + .runTest(azure.trafficManagerProfiles(), azure.resourceGroups()); + } } diff --git a/azure/src/test/java/com/microsoft/azure/management/TestTrafficManager.java b/azure/src/test/java/com/microsoft/azure/management/TestTrafficManager.java new file mode 100644 index 0000000000000..2addd76f404cc --- /dev/null +++ b/azure/src/test/java/com/microsoft/azure/management/TestTrafficManager.java @@ -0,0 +1,325 @@ +package com.microsoft.azure.management; + +import com.microsoft.azure.management.network.PublicIpAddress; +import com.microsoft.azure.management.network.PublicIpAddresses; +import com.microsoft.azure.management.resources.ResourceGroup; +import com.microsoft.azure.management.resources.ResourceGroups; +import com.microsoft.azure.management.resources.fluentcore.arm.Region; +import com.microsoft.azure.management.resources.fluentcore.utils.ResourceNamer; +import com.microsoft.azure.management.trafficmanager.EndpointType; +import com.microsoft.azure.management.trafficmanager.TargetAzureResourceType; +import com.microsoft.azure.management.trafficmanager.TrafficManagerAzureEndpoint; +import com.microsoft.azure.management.trafficmanager.TrafficManagerExternalEndpoint; +import com.microsoft.azure.management.trafficmanager.TrafficManagerNestedProfileEndpoint; +import com.microsoft.azure.management.trafficmanager.TrafficManagerProfile; +import com.microsoft.azure.management.trafficmanager.TrafficManagerProfiles; +import org.junit.Assert; + +import java.util.Map; + +/** + * Test of virtual network management. + */ +public class TestTrafficManager extends TestTemplate { + + private final PublicIpAddresses publicIpAddresses; + private final ResourceGroups resourceGroups; + + private final String externalEndpointName21 = "external-ep-1"; + private final String externalEndpointName22 = "external-ep-2"; + private final String externalEndpointName23 = "external-ep-3"; + + private final String externalFqdn21 = "www.azure.microsoft.com"; + private final String externalFqdn22 = "www.bing.com"; + private final String externalFqdn23 = "www.github.com"; + + private final String azureEndpointName = "azure-ep-1"; + private final String nestedProfileEndpointName = "nested-profile-ep-1"; + + public TestTrafficManager(ResourceGroups resourceGroups, PublicIpAddresses publicIpAddresses) { + this.resourceGroups = resourceGroups; + this.publicIpAddresses = publicIpAddresses; + } + + @Override + public TrafficManagerProfile createResource(TrafficManagerProfiles profiles) throws Exception { + final Region region = Region.US_EAST; + final String groupName = "rg" + this.testId; + + final String pipName = "pip" + this.testId; + final String pipDnsLabel = ResourceNamer.randomResourceName("contoso", 15); + + final String tmProfileName = "tm" + this.testId; + final String nestedTmProfileName = "nested" + tmProfileName; + + final String tmProfileDnsLabel = ResourceNamer.randomResourceName("tmdns", 15); + final String nestedTmProfileDnsLabel = "nested" + tmProfileDnsLabel; + + ResourceGroup.DefinitionStages.WithCreate rgCreatable = resourceGroups.define(groupName) + .withRegion(region); + + // Creates a TM profile that will be used as a nested profile endpoint in parent TM profile + // + TrafficManagerProfile nestedProfile = profiles.define(nestedTmProfileName) + .withNewResourceGroup(rgCreatable) + .withLeafDomainLabel(nestedTmProfileDnsLabel) + .withPriorityBasedRouting() + .defineExternalTargetEndpoint("external-ep-1") + .toFqdn("www.gitbook.com") + .fromRegion(Region.INDIA_CENTRAL) + .attach() + .withHttpsMonitoring() + .withTimeToLive(500) + .create(); + + Assert.assertTrue(nestedProfile.isEnabled()); + Assert.assertNotNull(nestedProfile.monitorStatus()); + Assert.assertEquals(nestedProfile.monitoringPort(), 443); + Assert.assertEquals(nestedProfile.monitoringPath(), "/"); + Assert.assertEquals(nestedProfile.azureEndpoints().size(), 0); + Assert.assertEquals(nestedProfile.nestedProfileEndpoints().size(), 0); + Assert.assertEquals(nestedProfile.externalEndpoints().size(), 1); + Assert.assertEquals(nestedProfile.fqdn(), nestedTmProfileDnsLabel + ".trafficmanager.net"); + Assert.assertEquals(nestedProfile.timeToLive(), 500); + + // Creates a public ip to be used as an Azure endpoint + // + PublicIpAddress publicIpAddress = this.publicIpAddresses.define(pipName) + .withRegion(region) + .withNewResourceGroup(rgCreatable) + .withLeafDomainLabel(pipDnsLabel) + .create(); + + Assert.assertNotNull(publicIpAddress.fqdn()); + // Creates a TM profile + // + + TrafficManagerProfile profile = profiles.define(tmProfileName) + .withNewResourceGroup(rgCreatable) + .withLeafDomainLabel(tmProfileDnsLabel) + .withWeightBasedRouting() + .defineExternalTargetEndpoint(externalEndpointName21) + .toFqdn(externalFqdn21) + .fromRegion(Region.US_EAST) + .withRoutingPriority(1) + .withRoutingWeight(1) + .attach() + .defineExternalTargetEndpoint(externalEndpointName22) + .toFqdn(externalFqdn22) + .fromRegion(Region.US_EAST2) + .withRoutingPriority(2) + .withRoutingWeight(1) + .withTrafficDisabled() + .attach() + .defineAzureTargetEndpoint(azureEndpointName) + .toResourceId(publicIpAddress.id()) + .withRoutingPriority(3) + .attach() + .defineNestedTargetEndpoint(nestedProfileEndpointName) + .toProfile(nestedProfile) + .fromRegion(Region.INDIA_CENTRAL) + .withMinimumEndpointsToEnableTraffic(1) + .withRoutingPriority(4) + .attach() + .withHttpMonitoring() + .create(); + + Assert.assertTrue(profile.isEnabled()); + Assert.assertNotNull(profile.monitorStatus()); + Assert.assertEquals(profile.monitoringPort(), 80); + Assert.assertEquals(profile.monitoringPath(), "/"); + Assert.assertEquals(profile.azureEndpoints().size(), 1); + Assert.assertEquals(profile.nestedProfileEndpoints().size(), 1); + Assert.assertEquals(profile.externalEndpoints().size(), 2); + Assert.assertEquals(profile.fqdn(), tmProfileDnsLabel + ".trafficmanager.net"); + Assert.assertEquals(profile.timeToLive(), 300); // Default + + profile = profile.refresh(); + Assert.assertEquals(profile.azureEndpoints().size(), 1); + Assert.assertEquals(profile.nestedProfileEndpoints().size(), 1); + Assert.assertEquals(profile.externalEndpoints().size(), 2); + + int c = 0; + for (TrafficManagerExternalEndpoint endpoint : profile.externalEndpoints().values()) { + Assert.assertEquals(endpoint.endpointType(), EndpointType.EXTERNAL); + if (endpoint.name().equalsIgnoreCase(externalEndpointName21)) { + Assert.assertEquals(endpoint.routingPriority(), 1); + Assert.assertEquals(endpoint.fqdn(), externalFqdn21); + Assert.assertNotNull(endpoint.monitorStatus()); + Assert.assertEquals(endpoint.sourceTrafficLocation(), Region.US_EAST); + c++; + } else if (endpoint.name().equalsIgnoreCase(externalEndpointName22)) { + Assert.assertEquals(endpoint.routingPriority(), 2); + Assert.assertEquals(endpoint.fqdn(), externalFqdn22); + Assert.assertNotNull(endpoint.monitorStatus()); + Assert.assertEquals(endpoint.sourceTrafficLocation(), Region.US_EAST2); + c++; + } + } + Assert.assertEquals(c, 2); + + c = 0; + for (TrafficManagerAzureEndpoint endpoint : profile.azureEndpoints().values()) { + Assert.assertEquals(endpoint.endpointType(), EndpointType.AZURE); + if (endpoint.name().equalsIgnoreCase(azureEndpointName)) { + Assert.assertEquals(endpoint.routingPriority(), 3); + Assert.assertNotNull(endpoint.monitorStatus()); + Assert.assertEquals(endpoint.targetAzureResourceId(), publicIpAddress.id()); + Assert.assertEquals(endpoint.targetResourceType(), TargetAzureResourceType.PUBLICIP); + c++; + } + } + Assert.assertEquals(c, 1); + + c = 0; + for (TrafficManagerNestedProfileEndpoint endpoint : profile.nestedProfileEndpoints().values()) { + Assert.assertEquals(endpoint.endpointType(), EndpointType.NESTED_PROFILE); + if (endpoint.name().equalsIgnoreCase(nestedProfileEndpointName)) { + Assert.assertEquals(endpoint.routingPriority(), 4); + Assert.assertNotNull(endpoint.monitorStatus()); + Assert.assertEquals(endpoint.minimumChildEndpointCount(), 1); + Assert.assertEquals(endpoint.nestedProfileId(), nestedProfile.id()); + Assert.assertEquals(endpoint.sourceTrafficLocation(), Region.INDIA_CENTRAL); + c++; + } + } + Assert.assertEquals(c, 1); + return profile; + } + + @Override + public TrafficManagerProfile updateResource(TrafficManagerProfile profile) throws Exception { + // Remove an endpoint, update two endpoints and add new one + // + profile.update() + .withTimeToLive(600) + .withHttpMonitoring(8080, "/") + .withPerformanceBasedRouting() + .withoutEndpoint(externalEndpointName21) + .updateAzureTargetEndpoint(azureEndpointName) + .withRoutingPriority(5) + .withRoutingWeight(2) + .parent() + .updateNestedProfileTargetEndpoint(nestedProfileEndpointName) + .withTrafficDisabled() + .parent() + .defineExternalTargetEndpoint(externalEndpointName23) + .toFqdn(externalFqdn23) + .fromRegion(Region.US_CENTRAL) + .withRoutingPriority(6) + .attach() + .apply(); + + Assert.assertEquals(profile.monitoringPort(), 8080); + Assert.assertEquals(profile.monitoringPath(), "/"); + Assert.assertEquals(profile.azureEndpoints().size(), 1); + Assert.assertEquals(profile.nestedProfileEndpoints().size(), 1); + Assert.assertEquals(profile.externalEndpoints().size(), 2); + Assert.assertEquals(profile.timeToLive(), 600); + + int c = 0; + for (TrafficManagerExternalEndpoint endpoint : profile.externalEndpoints().values()) { + Assert.assertEquals(endpoint.endpointType(), EndpointType.EXTERNAL); + if (endpoint.name().equalsIgnoreCase(externalEndpointName22)) { + Assert.assertEquals(endpoint.routingPriority(), 2); + Assert.assertEquals(endpoint.fqdn(), externalFqdn22); + Assert.assertEquals(endpoint.sourceTrafficLocation(), Region.US_EAST2); + Assert.assertNotNull(endpoint.monitorStatus()); + c++; + } else if (endpoint.name().equalsIgnoreCase(externalEndpointName23)) { + Assert.assertEquals(endpoint.routingPriority(), 6); + Assert.assertEquals(endpoint.fqdn(), externalFqdn23); + Assert.assertNotNull(endpoint.monitorStatus()); + Assert.assertEquals(endpoint.sourceTrafficLocation(), Region.US_CENTRAL); + c++; + } else { + c++; + } + } + Assert.assertEquals(c, 2); + + c = 0; + for (TrafficManagerAzureEndpoint endpoint : profile.azureEndpoints().values()) { + Assert.assertEquals(endpoint.endpointType(), EndpointType.AZURE); + if (endpoint.name().equalsIgnoreCase(azureEndpointName)) { + Assert.assertEquals(endpoint.routingPriority(), 5); + Assert.assertEquals(endpoint.routingWeight(), 2); + Assert.assertEquals(endpoint.targetResourceType(), TargetAzureResourceType.PUBLICIP); + c++; + } + } + Assert.assertEquals(c, 1); + return profile; + } + + @Override + public void print(TrafficManagerProfile profile) { + StringBuilder info = new StringBuilder(); + info.append("Traffic Manager Profile: ").append(profile.id()) + .append("\n\tName: ").append(profile.name()) + .append("\n\tResource group: ").append(profile.resourceGroupName()) + .append("\n\tRegion: ").append(profile.regionName()) + .append("\n\tTags: ").append(profile.tags()) + .append("\n\tDNSLabel: ").append(profile.dnsLabel()) + .append("\n\tFQDN: ").append(profile.fqdn()) + .append("\n\tTTL: ").append(profile.timeToLive()) + .append("\n\tEnabled: ").append(profile.isEnabled()) + .append("\n\tRoutingMethod: ").append(profile.trafficRoutingMethod()) + .append("\n\tMonitor status: ").append(profile.monitorStatus()) + .append("\n\tMonitoring port: ").append(profile.monitoringPort()) + .append("\n\tMonitoring path: ").append(profile.monitoringPath()); + + Map azureEndpoints = profile.azureEndpoints(); + if (!azureEndpoints.isEmpty()) { + info.append("\n\tAzure endpoints:"); + int idx = 1; + for (TrafficManagerAzureEndpoint endpoint : azureEndpoints.values()) { + info.append("\n\t\tAzure endpoint: #").append(idx++) + .append("\n\t\t\tId: ").append(endpoint.id()) + .append("\n\t\t\tType: ").append(endpoint.endpointType()) + .append("\n\t\t\tTarget resourceId: ").append(endpoint.targetAzureResourceId()) + .append("\n\t\t\tTarget resourceType: ").append(endpoint.targetResourceType()) + .append("\n\t\t\tMonitor status: ").append(endpoint.monitorStatus()) + .append("\n\t\t\tEnabled: ").append(endpoint.isEnabled()) + .append("\n\t\t\tRouting priority: ").append(endpoint.routingPriority()) + .append("\n\t\t\tRouting weight: ").append(endpoint.routingWeight()); + } + } + + Map externalEndpoints = profile.externalEndpoints(); + if (!externalEndpoints.isEmpty()) { + info.append("\n\tExternal endpoints:"); + int idx = 1; + for (TrafficManagerExternalEndpoint endpoint : externalEndpoints.values()) { + info.append("\n\t\tExternal endpoint: #").append(idx++) + .append("\n\t\t\tId: ").append(endpoint.id()) + .append("\n\t\t\tType: ").append(endpoint.endpointType()) + .append("\n\t\t\tFQDN: ").append(endpoint.fqdn()) + .append("\n\t\t\tSource Traffic Location: ").append(endpoint.sourceTrafficLocation()) + .append("\n\t\t\tMonitor status: ").append(endpoint.monitorStatus()) + .append("\n\t\t\tEnabled: ").append(endpoint.isEnabled()) + .append("\n\t\t\tRouting priority: ").append(endpoint.routingPriority()) + .append("\n\t\t\tRouting weight: ").append(endpoint.routingWeight()); + } + } + + Map nestedProfileEndpoints = profile.nestedProfileEndpoints(); + if (!nestedProfileEndpoints.isEmpty()) { + info.append("\n\tNested profile endpoints:"); + int idx = 1; + for (TrafficManagerNestedProfileEndpoint endpoint : nestedProfileEndpoints.values()) { + info.append("\n\t\tNested profile endpoint: #").append(idx++) + .append("\n\t\t\tId: ").append(endpoint.id()) + .append("\n\t\t\tType: ").append(endpoint.endpointType()) + .append("\n\t\t\tNested profileId: ").append(endpoint.nestedProfileId()) + .append("\n\t\t\tMinimum child threshold: ").append(endpoint.minimumChildEndpointCount()) + .append("\n\t\t\tSource Traffic Location: ").append(endpoint.sourceTrafficLocation()) + .append("\n\t\t\tMonitor status: ").append(endpoint.monitorStatus()) + .append("\n\t\t\tEnabled: ").append(endpoint.isEnabled()) + .append("\n\t\t\tRouting priority: ").append(endpoint.routingPriority()) + .append("\n\t\t\tRouting weight: ").append(endpoint.routingWeight()); + } + } + System.out.println(info.toString()); + } +} diff --git a/gulpfile.js b/gulpfile.js index 8f04908786960..6dd79e1d76158 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -74,6 +74,12 @@ var mappings = { 'package': 'com.microsoft.azure.management.search', 'args': '-FT 1' }, + 'trafficmanager': { + 'dir': 'azure-mgmt-trafficmanager', + 'source': 'arm-trafficmanager/2015-11-01/swagger/trafficmanager.json', + 'package': 'com.microsoft.azure.management.trafficmanager', + 'args': '-FT 1' + }, 'datalake.store.account': { 'dir': 'azure-mgmt-datalake-store', 'source': 'arm-datalake-store/account/2015-10-01-preview/swagger/account.json', diff --git a/pom.xml b/pom.xml index 1c0fa5bd03a4e..d241f4aec9947 100644 --- a/pom.xml +++ b/pom.xml @@ -316,6 +316,7 @@ ./azure-mgmt-redis ./azure-mgmt-search ./azure-mgmt-batch + ./azure-mgmt-trafficmanager ./azure-mgmt-sql