From 7b5bd17413cd7fb569197b28b446bc270d5c9ed5 Mon Sep 17 00:00:00 2001 From: Jianghao Lu Date: Fri, 14 Oct 2016 17:41:05 -0700 Subject: [PATCH 1/7] Add supporting by tag interface --- .../arm/collection/SupportsListingByTag.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/SupportsListingByTag.java diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/SupportsListingByTag.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/SupportsListingByTag.java new file mode 100644 index 0000000000000..a521e0f7900b6 --- /dev/null +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/SupportsListingByTag.java @@ -0,0 +1,30 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ + +package com.microsoft.azure.management.resources.fluentcore.arm.collection; + +import com.microsoft.azure.PagedList; +import com.microsoft.azure.management.apigeneration.LangDefinition; +import com.microsoft.azure.management.apigeneration.LangDefinition.MethodConversion; +import com.microsoft.azure.management.resources.fluentcore.arm.Region; + +/** + * Provides access to listing Azure resources of a specific type based on their tag. + *

+ * (Note: this interface is not intended to be implemented by user code) + * + * @param the fluent type of the resource + */ +@LangDefinition(ContainerName = "CollectionActions", MethodConversionType = MethodConversion.OnlyMethod) +public interface SupportsListingByTag { + /** + * Lists all the resources of the specified type in the specified tag. + * + * @param tag the tag value + * @return list of resources + */ + PagedList listByTag(String resourceGroupName, String tag); +} From c3b800b865065e851fa1c9b50b4bd64171a4bd5c Mon Sep 17 00:00:00 2001 From: Jianghao Lu Date: Fri, 14 Oct 2016 17:41:33 -0700 Subject: [PATCH 2/7] Add helper to extract relative path --- .../resources/fluentcore/arm/ResourceUtils.java | 4 ++++ .../management/resources/ResourceUtilsTests.java | 15 +++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/ResourceUtils.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/ResourceUtils.java index 164f7346fb1cb..37705a5372d93 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/ResourceUtils.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/ResourceUtils.java @@ -52,6 +52,10 @@ public static String parentResourcePathFromResourceId(String id) { return id.replace("/" + resourceTypeFromResourceId(id) + "/" + nameFromResourceId(id), ""); } + public static String relativePathFromResourceId(String id) { + return id.split("/providers/" + resourceProviderFromResourceId(id) + "/")[1]; + } + /** * Extract information from a resource ID string with the resource type * as the identifier. diff --git a/azure-mgmt-resources/src/test/java/com/microsoft/azure/management/resources/ResourceUtilsTests.java b/azure-mgmt-resources/src/test/java/com/microsoft/azure/management/resources/ResourceUtilsTests.java index b4d58028dc122..8ab9bfc2547a4 100644 --- a/azure-mgmt-resources/src/test/java/com/microsoft/azure/management/resources/ResourceUtilsTests.java +++ b/azure-mgmt-resources/src/test/java/com/microsoft/azure/management/resources/ResourceUtilsTests.java @@ -7,7 +7,18 @@ public class ResourceUtilsTests { @Test public void canExtractGroupFromId() throws Exception { - Assert.assertEquals("foo", ResourceUtils.groupFromResourceId("subscriptions/123/resourceGroups/foo/Microsoft.Bar/bars/bar1")); - Assert.assertEquals("foo", ResourceUtils.groupFromResourceId("subscriptions/123/resourcegroups/foo/Microsoft.Bar/bars/bar1")); + Assert.assertEquals("foo", ResourceUtils.groupFromResourceId("subscriptions/123/resourceGroups/foo/providers/Microsoft.Bar/bars/bar1")); + Assert.assertEquals("foo", ResourceUtils.groupFromResourceId("subscriptions/123/resourcegroups/foo/providers/Microsoft.Bar/bars/bar1")); + } + + @Test + public void canExtractParentPathFromId() throws Exception { + Assert.assertEquals("subscriptions/123/resourceGroups/foo/providers/Microsoft.Bar/bars/bar1", ResourceUtils.parentResourcePathFromResourceId("subscriptions/123/resourceGroups/foo/providers/Microsoft.Bar/bars/bar1/bazs/baz1")); + Assert.assertEquals("subscriptions/123/resourceGroups/foo/providers/Microsoft.Bar", ResourceUtils.parentResourcePathFromResourceId("subscriptions/123/resourceGroups/foo/providers/Microsoft.Bar/bars/bar1")); + } + + @Test + public void canExtractRelativePathFromid() throws Exception { + Assert.assertEquals("bars/bar1", ResourceUtils.relativePathFromResourceId("subscriptions/123/resourceGroups/foo/providers/Microsoft.Bar/bars/bar1")); } } From 6a7843b5549fb4d831ded359002357e247834e61 Mon Sep 17 00:00:00 2001 From: Jianghao Lu Date: Fri, 14 Oct 2016 17:52:55 -0700 Subject: [PATCH 3/7] Fix generic resource create --- .../management/resources/GenericResource.java | 3 +- .../resources/GenericResources.java | 2 + .../azure/management/resources/Providers.java | 9 +++ .../fluentcore/arm/ResourceUtils.java | 7 ++- .../arm/collection/SupportsListingByTag.java | 5 +- .../implementation/GenericResourceImpl.java | 58 ++++++++++++++----- .../implementation/GenericResourcesImpl.java | 11 ++++ .../implementation/ProvidersImpl.java | 13 +++++ .../resources/ResourceUtilsTests.java | 3 + 9 files changed, 94 insertions(+), 17 deletions(-) diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/GenericResource.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/GenericResource.java index 1084d61ada6a5..91b0585cc09da 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/GenericResource.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/GenericResource.java @@ -23,7 +23,7 @@ public interface GenericResource extends GroupableResource, Refreshable, - Updatable, + Updatable, Wrapper { /** * @return the namespace of the resource provider @@ -251,6 +251,7 @@ interface WithApiVersion { */ interface Update extends Appliable, + UpdateStages.WithApiVersion, UpdateStages.WithPlan, UpdateStages.WithParentResource, UpdateStages.WithProperties, diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/GenericResources.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/GenericResources.java index f1e09b7da15a5..451ebfaa740e6 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/GenericResources.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/GenericResources.java @@ -9,6 +9,7 @@ import com.microsoft.azure.management.apigeneration.Fluent; 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.arm.collection.SupportsListingByTag; import com.microsoft.azure.management.resources.fluentcore.collection.SupportsCreating; import java.util.List; @@ -19,6 +20,7 @@ @Fluent public interface GenericResources extends SupportsListingByGroup, + SupportsListingByTag, SupportsGettingById, SupportsCreating { /** diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/Providers.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/Providers.java index 8f4f105ec932d..193075df9d0b4 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/Providers.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/Providers.java @@ -10,6 +10,7 @@ import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingByName; import com.microsoft.azure.management.resources.fluentcore.collection.SupportsListing; import com.microsoft.rest.ServiceResponse; +import rx.Observable; /** * Entry point to providers management API. @@ -33,4 +34,12 @@ public interface Providers extends * @return the ProviderInner object wrapped in {@link ServiceResponse} if successful */ Provider register(String resourceProviderNamespace); + + /** + * Gets the information about a provider from Azure based on the provider name. + * + * @param name the name of the provider + * @return an observable of the immutable representation of the Provider + */ + Observable getByNameAsync(String name); } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/ResourceUtils.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/ResourceUtils.java index 37705a5372d93..5c127f8b2d545 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/ResourceUtils.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/ResourceUtils.java @@ -53,7 +53,12 @@ public static String parentResourcePathFromResourceId(String id) { } public static String relativePathFromResourceId(String id) { - return id.split("/providers/" + resourceProviderFromResourceId(id) + "/")[1]; + String[] paths = id.split("/providers/" + resourceProviderFromResourceId(id) + "/", 2); + if (paths.length == 1) { + return ""; + } else { + return paths[1]; + } } /** diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/SupportsListingByTag.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/SupportsListingByTag.java index a521e0f7900b6..a5ca5d92a44a1 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/SupportsListingByTag.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/SupportsListingByTag.java @@ -23,8 +23,9 @@ public interface SupportsListingByTag { /** * Lists all the resources of the specified type in the specified tag. * - * @param tag the tag value + * @param tagName tag's name as the key + * @param tagValue tag's value * @return list of resources */ - PagedList listByTag(String resourceGroupName, String tag); + PagedList listByTag(String resourceGroupName, String tagName, String tagValue); } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/GenericResourceImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/GenericResourceImpl.java index fd82e163887c2..9963d69febbda 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/GenericResourceImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/GenericResourceImpl.java @@ -8,8 +8,14 @@ import com.microsoft.azure.management.resources.GenericResource; import com.microsoft.azure.management.resources.Plan; +import com.microsoft.azure.management.resources.Provider; +import com.microsoft.azure.management.resources.ProviderResourceType; +import com.microsoft.azure.management.resources.Providers; +import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils; import com.microsoft.azure.management.resources.fluentcore.arm.models.implementation.GroupableResourceImpl; import rx.Observable; +import rx.exceptions.Exceptions; +import rx.functions.Func1; import rx.schedulers.Schedulers; /** @@ -26,7 +32,8 @@ final class GenericResourceImpl GenericResource.Definition, GenericResource.UpdateStages.WithApiVersion, GenericResource.Update { - private final ResourcesInner client; + private final ResourcesInner resourceClient; + private final Providers providersClient; private String resourceProviderNamespace; private String parentResourceId; private String resourceType; @@ -34,11 +41,13 @@ final class GenericResourceImpl GenericResourceImpl(String key, GenericResourceInner innerModel, - ResourcesInner client, + ResourcesInner innerCollection, + Providers providerClient, final ResourceManagementClientImpl serviceClient, final ResourceManager resourceManager) { super(key, innerModel, resourceManager); - this.client = client; + this.resourceClient = innerCollection; + this.providersClient = providerClient; } @Override @@ -119,15 +128,38 @@ public GenericResourceImpl withApiVersion(String apiVersion) { // CreateUpdateTaskGroup.ResourceCreator implementation @Override public Observable createResourceAsync() { - return client.createOrUpdateAsync( - resourceGroupName(), - resourceProviderNamespace, - parentResourceId, - resourceType, - name(), - apiVersion, - inner()) - .subscribeOn(Schedulers.io()) - .map(innerToFluentMap(this)); + final GenericResourceImpl self = this; + Observable observable = Observable.just(apiVersion); + if (apiVersion == null) { + observable = providersClient.getByNameAsync(resourceProviderNamespace) + .map(new Func1() { + @Override + public String call(Provider provider) { + for (ProviderResourceType type : provider.resourceTypes()) { + if (resourceType().equals(type.resourceType())) { + return type.apiVersions().get(0); + } + } + throw Exceptions.propagate(new UnsupportedOperationException("Resource provider " + resourceProviderNamespace + " doesn't have a default api version, please specify one.")); + } + }); + } + return observable + .flatMap(new Func1>() { + @Override + public Observable call(String api) { + return resourceClient.createOrUpdateAsync( + resourceGroupName(), + resourceProviderNamespace, + ResourceUtils.relativePathFromResourceId(parentResourceId), + resourceType, + name(), + api, + inner()) + .subscribeOn(Schedulers.io()) + .map(innerToFluentMap(self)); + } + }); + } } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/GenericResourcesImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/GenericResourcesImpl.java index 115c63fc4d00e..a648cce3aae0a 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/GenericResourcesImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/GenericResourcesImpl.java @@ -41,12 +41,20 @@ public PagedList listByGroup(String groupName) { return wrapList(this.serviceClient.resourceGroups().listResources(groupName)); } + @Override + public PagedList listByTag(String resourceGroupName, String tagName, String tagValue) { + return wrapList(this.serviceClient.resourceGroups().listResources( + resourceGroupName, + String.format("%s eq '%s'", tagName, tagValue), null, null)); + } + @Override public GenericResource.DefinitionStages.Blank define(String name) { return new GenericResourceImpl( name, new GenericResourceInner(), this.innerCollection, + this.myManager.providers(), serviceClient, super.myManager); } @@ -114,6 +122,7 @@ public GenericResource get( resourceName, inner, this.innerCollection, + this.myManager.providers(), serviceClient, this.myManager); @@ -143,6 +152,7 @@ protected GenericResourceImpl wrapModel(String id) { id, new GenericResourceInner(), this.innerCollection, + this.myManager.providers(), this.serviceClient, this.myManager) .withExistingResourceGroup(ResourceUtils.groupFromResourceId(id)) @@ -157,6 +167,7 @@ protected GenericResourceImpl wrapModel(GenericResourceInner inner) { inner.id(), inner, this.innerCollection, + this.myManager.providers(), this.serviceClient, this.myManager) .withExistingResourceGroup(ResourceUtils.groupFromResourceId(inner.id())) diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/ProvidersImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/ProvidersImpl.java index 9c637ea502dd1..43fbbbab6cc20 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/ProvidersImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/ProvidersImpl.java @@ -10,6 +10,8 @@ import com.microsoft.azure.management.resources.Provider; import com.microsoft.azure.management.resources.Providers; import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.ReadableWrappersImpl; +import rx.Observable; +import rx.functions.Func1; /** * The implementation for {@link Providers}. @@ -38,6 +40,17 @@ public Provider register(String resourceProviderNamespace) { return wrapModel(client.register(resourceProviderNamespace)); } + @Override + public Observable getByNameAsync(String name) { + return client.getAsync(name) + .map(new Func1() { + @Override + public Provider call(ProviderInner providerInner) { + return wrapModel(providerInner); + } + }); + } + @Override public Provider getByName(String resourceProviderNamespace) { return wrapModel(client.get(resourceProviderNamespace)); diff --git a/azure-mgmt-resources/src/test/java/com/microsoft/azure/management/resources/ResourceUtilsTests.java b/azure-mgmt-resources/src/test/java/com/microsoft/azure/management/resources/ResourceUtilsTests.java index 8ab9bfc2547a4..116f6591c920b 100644 --- a/azure-mgmt-resources/src/test/java/com/microsoft/azure/management/resources/ResourceUtilsTests.java +++ b/azure-mgmt-resources/src/test/java/com/microsoft/azure/management/resources/ResourceUtilsTests.java @@ -20,5 +20,8 @@ public void canExtractParentPathFromId() throws Exception { @Test public void canExtractRelativePathFromid() throws Exception { Assert.assertEquals("bars/bar1", ResourceUtils.relativePathFromResourceId("subscriptions/123/resourceGroups/foo/providers/Microsoft.Bar/bars/bar1")); + Assert.assertEquals("", ResourceUtils.relativePathFromResourceId(ResourceUtils.parentResourcePathFromResourceId("subscriptions/123/resourceGroups/foo/providers/Microsoft.Bar/bars/bar1"))); + Assert.assertEquals("bars/bar1/providers/provider1", ResourceUtils.relativePathFromResourceId("subscriptions/123/resourceGroups/foo/providers/Microsoft.Bar/bars/bar1/providers/provider1")); + Assert.assertEquals("providers/provider1/bars/bar1", ResourceUtils.relativePathFromResourceId("subscriptions/123/resourceGroups/foo/providers/Microsoft.Bar/providers/provider1/bars/bar1")); } } From 66887068f2ba3394a895fd56330ce271ea2b7471 Mon Sep 17 00:00:00 2001 From: Jianghao Lu Date: Mon, 17 Oct 2016 12:06:52 -0700 Subject: [PATCH 4/7] Add list with tags sample --- .../DeployUsingARMTemplateWithTags.java | 135 ++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100644 azure-samples/src/main/java/com/microsoft/azure/management/resources/samples/DeployUsingARMTemplateWithTags.java diff --git a/azure-samples/src/main/java/com/microsoft/azure/management/resources/samples/DeployUsingARMTemplateWithTags.java b/azure-samples/src/main/java/com/microsoft/azure/management/resources/samples/DeployUsingARMTemplateWithTags.java new file mode 100644 index 0000000000000..dad7984d1a8f1 --- /dev/null +++ b/azure-samples/src/main/java/com/microsoft/azure/management/resources/samples/DeployUsingARMTemplateWithTags.java @@ -0,0 +1,135 @@ +/** + * + * 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.resources.samples; + +import com.microsoft.azure.management.Azure; +import com.microsoft.azure.management.resources.Deployment; +import com.microsoft.azure.management.resources.DeploymentMode; +import com.microsoft.azure.management.resources.DeploymentOperation; +import com.microsoft.azure.management.resources.GenericResource; +import com.microsoft.azure.management.resources.fluentcore.arm.Region; +import com.microsoft.azure.management.resources.fluentcore.utils.ResourceNamer; +import okhttp3.logging.HttpLoggingInterceptor; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +/** + * Azure Resource sample for deploying resources using an ARM template. + */ + +public final class DeployUsingARMTemplateWithTags { + + /** + * Main entry point. + * + * @param args the parameters + */ + public static void main(String[] args) { + try { + final String rgName = ResourceNamer.randomResourceName("rgRSAT", 24); + final String deploymentName = ResourceNamer.randomResourceName("dpRSAT", 24); + + try { + + + //================================================================= + // Authenticate + + final File credFile = new File(System.getenv("AZURE_AUTH_LOCATION")); + + Azure azure = Azure.configure() + .withLogLevel(HttpLoggingInterceptor.Level.HEADERS) + .authenticate(credFile) + .withDefaultSubscription(); + + try { + String templateLink = "https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/101-vm-multiple-data-disk/azuredeploy.json"; + String parameterJson = "{\"adminUsername\":{\"value\":\"azureUser\"},\"adminPassword\":{\"value\":\"StrongPass!123\"},\"dnsLabelPrefix\":{\"value\":\"uniqueazure58889\"},\"vmSize\":{\"value\":\"Standard_D2\"},\"sizeOfEachDataDiskInGB\":{\"value\":\"100\"}}"; + + + //============================================================= + // Create resource group. + + System.out.println("Creating a resource group with name: " + rgName); + + azure.resourceGroups().define(rgName) + .withRegion(Region.US_WEST) + .create(); + + System.out.println("Created a resource group with name: " + rgName); + + + //============================================================= + // Create a deployment for an Azure App Service via an ARM + // template. + + System.out.println("Starting a deployment for an Azure VM with multiple data disks: " + deploymentName); + + Deployment deployment = azure.deployments().define(deploymentName) + .withExistingResourceGroup(rgName) + .withTemplateLink(templateLink, "1.0.0.0") + .withParameters(parameterJson) + .withMode(DeploymentMode.INCREMENTAL) + .create(); + + System.out.println("Started a deployment for an Azure VM with multiple data disks: " + deploymentName); + + List operations = deployment.deploymentOperations().list(); + List genericResources = new ArrayList<>(); + + // Getting created resources + for (DeploymentOperation operation : operations) { + if (operation.targetResource() != null) { + genericResources.add(azure.genericResources().getById(operation.targetResource().id())); + } + } + + System.out.println("Resource created during deployment: " + deploymentName); + for (GenericResource genericResource : genericResources) { + System.out.println(genericResource.resourceProviderNamespace() + "/" + genericResource.resourceType() + ": " + genericResource.name()); + // Tag resource + genericResource.update() + .withTag("label", "deploy1") + .apply(); + } + + genericResources = azure.genericResources().listByTag(rgName, "label", "deploy1"); + System.out.println("Tagged resources for deployment: " + deploymentName); + for (GenericResource genericResource : genericResources) { + System.out.println(genericResource.resourceProviderNamespace() + "/" + genericResource.resourceType() + ": " + genericResource.name()); + } + + } catch (Exception f) { + + System.out.println(f.getMessage()); + f.printStackTrace(); + + } finally { + + try { + System.out.println("Deleting Resource Group: " + rgName); + azure.resourceGroups().delete(rgName); + System.out.println("Deleted Resource Group: " + rgName); + } catch (NullPointerException npe) { + System.out.println("Did not create any resources in Azure. No clean up is necessary"); + } catch (Exception g) { + g.printStackTrace(); + } + + } + } catch (Exception e) { + System.out.println(e.getMessage()); + e.printStackTrace(); + } + } catch (Exception e) { + System.err.println(e.getMessage()); + } + } +} From bc8fc4ff96094b065c77f6325b6d6c53afaefed0 Mon Sep 17 00:00:00 2001 From: Jianghao Lu Date: Mon, 17 Oct 2016 19:57:54 -0700 Subject: [PATCH 5/7] Some fixes --- .../resources/GenericResources.java | 2 + .../arm/collection/SupportsListingByTag.java | 3 +- .../implementation/GenericResourcesImpl.java | 17 ++++++- .../DeployUsingARMTemplateWithTags.java | 51 ++++++++++++++++--- 4 files changed, 61 insertions(+), 12 deletions(-) diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/GenericResources.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/GenericResources.java index 451ebfaa740e6..7222e0337bd8c 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/GenericResources.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/GenericResources.java @@ -11,6 +11,7 @@ import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsListingByGroup; import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsListingByTag; import com.microsoft.azure.management.resources.fluentcore.collection.SupportsCreating; +import com.microsoft.azure.management.resources.fluentcore.collection.SupportsListing; import java.util.List; @@ -19,6 +20,7 @@ */ @Fluent public interface GenericResources extends + SupportsListing, SupportsListingByGroup, SupportsListingByTag, SupportsGettingById, diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/SupportsListingByTag.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/SupportsListingByTag.java index a5ca5d92a44a1..24a22be800432 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/SupportsListingByTag.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/SupportsListingByTag.java @@ -9,7 +9,6 @@ import com.microsoft.azure.PagedList; import com.microsoft.azure.management.apigeneration.LangDefinition; import com.microsoft.azure.management.apigeneration.LangDefinition.MethodConversion; -import com.microsoft.azure.management.resources.fluentcore.arm.Region; /** * Provides access to listing Azure resources of a specific type based on their tag. @@ -21,7 +20,7 @@ @LangDefinition(ContainerName = "CollectionActions", MethodConversionType = MethodConversion.OnlyMethod) public interface SupportsListingByTag { /** - * Lists all the resources of the specified type in the specified tag. + * Lists all the resources with the specified tag. * * @param tagName tag's name as the key * @param tagValue tag's value diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/GenericResourcesImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/GenericResourcesImpl.java index a648cce3aae0a..a545875e06d9b 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/GenericResourcesImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/GenericResourcesImpl.java @@ -36,6 +36,11 @@ final class GenericResourcesImpl this.serviceClient = serviceClient; } + @Override + public PagedList list() { + return wrapList(this.serviceClient.resources().list()); + } + @Override public PagedList listByGroup(String groupName) { return wrapList(this.serviceClient.resourceGroups().listResources(groupName)); @@ -43,9 +48,17 @@ public PagedList listByGroup(String groupName) { @Override public PagedList listByTag(String resourceGroupName, String tagName, String tagValue) { + if (tagName == null) { + throw new IllegalArgumentException("tagName == null"); + } + String odataFilter = ""; + if (tagValue == null) { + odataFilter = String.format("tagname eq %s", tagName); + } else { + odataFilter = String.format("tagname eq %s and tagvalue eq %s", tagName, tagValue); + } return wrapList(this.serviceClient.resourceGroups().listResources( - resourceGroupName, - String.format("%s eq '%s'", tagName, tagValue), null, null)); + resourceGroupName, odataFilter, null, null)); } @Override diff --git a/azure-samples/src/main/java/com/microsoft/azure/management/resources/samples/DeployUsingARMTemplateWithTags.java b/azure-samples/src/main/java/com/microsoft/azure/management/resources/samples/DeployUsingARMTemplateWithTags.java index dad7984d1a8f1..a1f8846d438f9 100644 --- a/azure-samples/src/main/java/com/microsoft/azure/management/resources/samples/DeployUsingARMTemplateWithTags.java +++ b/azure-samples/src/main/java/com/microsoft/azure/management/resources/samples/DeployUsingARMTemplateWithTags.java @@ -7,6 +7,10 @@ package com.microsoft.azure.management.resources.samples; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ObjectNode; import com.microsoft.azure.management.Azure; import com.microsoft.azure.management.resources.Deployment; import com.microsoft.azure.management.resources.DeploymentMode; @@ -17,6 +21,8 @@ import okhttp3.logging.HttpLoggingInterceptor; import java.io.File; +import java.io.IOException; +import java.io.InputStream; import java.util.ArrayList; import java.util.List; @@ -50,9 +56,7 @@ public static void main(String[] args) { .withDefaultSubscription(); try { - String templateLink = "https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/101-vm-multiple-data-disk/azuredeploy.json"; - String parameterJson = "{\"adminUsername\":{\"value\":\"azureUser\"},\"adminPassword\":{\"value\":\"StrongPass!123\"},\"dnsLabelPrefix\":{\"value\":\"uniqueazure58889\"},\"vmSize\":{\"value\":\"Standard_D2\"},\"sizeOfEachDataDiskInGB\":{\"value\":\"100\"}}"; - + String templateJson = getTemplate(); //============================================================= // Create resource group. @@ -60,7 +64,7 @@ public static void main(String[] args) { System.out.println("Creating a resource group with name: " + rgName); azure.resourceGroups().define(rgName) - .withRegion(Region.US_WEST) + .withRegion(Region.GERMANY_CENTRAL) .create(); System.out.println("Created a resource group with name: " + rgName); @@ -70,16 +74,16 @@ public static void main(String[] args) { // Create a deployment for an Azure App Service via an ARM // template. - System.out.println("Starting a deployment for an Azure VM with multiple data disks: " + deploymentName); + System.out.println("Starting a deployment for an Azure App Service: " + deploymentName); Deployment deployment = azure.deployments().define(deploymentName) .withExistingResourceGroup(rgName) - .withTemplateLink(templateLink, "1.0.0.0") - .withParameters(parameterJson) + .withTemplate(templateJson) + .withParameters("{}") .withMode(DeploymentMode.INCREMENTAL) .create(); - System.out.println("Started a deployment for an Azure VM with multiple data disks: " + deploymentName); + System.out.println("Starting a deployment for an Azure App Service: " + deploymentName); List operations = deployment.deploymentOperations().list(); List genericResources = new ArrayList<>(); @@ -132,4 +136,35 @@ public static void main(String[] args) { System.err.println(e.getMessage()); } } + + private static String getTemplate() throws IllegalAccessException, JsonProcessingException, IOException { + final String hostingPlanName = ResourceNamer.randomResourceName("hpRSAT", 24); + final String webappName = ResourceNamer.randomResourceName("wnRSAT", 24); + final InputStream embeddedTemplate; + embeddedTemplate = DeployUsingARMTemplate.class.getResourceAsStream("/templateValue.json"); + + final ObjectMapper mapper = new ObjectMapper(); + final JsonNode tmp = mapper.readTree(embeddedTemplate); + + validateAndAddFieldValue("string", hostingPlanName, "hostingPlanName", null, tmp); + validateAndAddFieldValue("string", webappName, "webSiteName", null, tmp); + validateAndAddFieldValue("string", "F1", "skuName", null, tmp); + validateAndAddFieldValue("int", "1", "skuCapacity", null, tmp); + + return tmp.toString(); + } + + private static void validateAndAddFieldValue(String type, String fieldValue, String fieldName, String errorMessage, + JsonNode tmp) throws IllegalAccessException { + // Add count variable for loop.... + final ObjectMapper mapper = new ObjectMapper(); + final ObjectNode parameter = mapper.createObjectNode(); + parameter.put("type", type); + if (type == "int") { + parameter.put("defaultValue", Integer.parseInt(fieldValue)); + } else { + parameter.put("defaultValue", fieldValue); + } + ObjectNode.class.cast(tmp.get("parameters")).replace(fieldName, parameter); + } } From e890e9f0ac64702c49eca546946448d5192f5377 Mon Sep 17 00:00:00 2001 From: Jianghao Lu Date: Mon, 17 Oct 2016 20:37:33 -0700 Subject: [PATCH 6/7] Regenerate with 2016-09-01 resource swagger --- .../management/resources/AliasPathType.java | 2 +- .../azure/management/resources/AliasType.java | 2 +- .../DeploymentOperationProperties.java | 97 +-- .../DeploymentPropertiesExtended.java | 37 +- .../ResourceManagementErrorWithDetails.java | 50 +- .../management/resources/SpendingLimit.java | 56 ++ .../management/resources/Subscription.java | 2 +- .../resources/SubscriptionPolicies.java | 38 +- .../resources/SubscriptionState.java | 62 ++ .../DeploymentExportResultInner.java | 2 +- .../DeploymentOperationInner.java | 25 +- .../implementation/DeploymentsInner.java | 15 +- .../implementation/GenericResourceImpl.java | 9 +- .../implementation/GenericResourcesImpl.java | 24 +- .../implementation/LocationInner.java | 86 +-- .../implementation/ProviderInner.java | 37 +- .../implementation/ResourceGroupInner.java | 25 + .../ResourceManagementClientImpl.java | 4 +- .../implementation/ResourcesInner.java | 708 +++++++++++++++++- .../SubscriptionClientImpl.java | 4 +- .../implementation/SubscriptionImpl.java | 3 +- .../implementation/SubscriptionInner.java | 96 +-- .../implementation/SubscriptionsInner.java | 20 +- .../TenantIdDescriptionInner.java | 30 +- .../implementation/TenantsInner.java | 20 +- .../DeployUsingARMTemplateWithTags.java | 4 +- gulpfile.js | 4 +- 27 files changed, 995 insertions(+), 467 deletions(-) create mode 100644 azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/SpendingLimit.java create mode 100644 azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/SubscriptionState.java diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/AliasPathType.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/AliasPathType.java index 7329501a6cfeb..32db8ba77b912 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/AliasPathType.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/AliasPathType.java @@ -11,7 +11,7 @@ import java.util.List; /** - * The AliasPathType model. + * The type of the paths for alias. */ public class AliasPathType { /** diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/AliasType.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/AliasType.java index 1e0622f7d0616..15eac681dcdd6 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/AliasType.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/AliasType.java @@ -11,7 +11,7 @@ import java.util.List; /** - * The AliasType model. + * The alias type. */ public class AliasType { /** diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/DeploymentOperationProperties.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/DeploymentOperationProperties.java index ca0fc4ae399c6..d387708df02f5 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/DeploymentOperationProperties.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/DeploymentOperationProperties.java @@ -9,6 +9,7 @@ package com.microsoft.azure.management.resources; import org.joda.time.DateTime; +import com.fasterxml.jackson.annotation.JsonProperty; /** * Deployment operation properties. @@ -17,41 +18,49 @@ public class DeploymentOperationProperties { /** * The state of the provisioning. */ + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) private String provisioningState; /** * The date and time of the operation. */ + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) private DateTime timestamp; /** * Deployment operation service request id. */ + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) private String serviceRequestId; /** * Operation status code. */ + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) private String statusCode; /** * Operation status message. */ + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) private Object statusMessage; /** * The target resource. */ + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) private TargetResource targetResource; /** * The HTTP request message. */ + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) private HttpMessage request; /** * The HTTP response message. */ + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) private HttpMessage response; /** @@ -63,17 +72,6 @@ public String provisioningState() { return this.provisioningState; } - /** - * Set the provisioningState value. - * - * @param provisioningState the provisioningState value to set - * @return the DeploymentOperationProperties object itself. - */ - public DeploymentOperationProperties withProvisioningState(String provisioningState) { - this.provisioningState = provisioningState; - return this; - } - /** * Get the timestamp value. * @@ -83,17 +81,6 @@ public DateTime timestamp() { return this.timestamp; } - /** - * Set the timestamp value. - * - * @param timestamp the timestamp value to set - * @return the DeploymentOperationProperties object itself. - */ - public DeploymentOperationProperties withTimestamp(DateTime timestamp) { - this.timestamp = timestamp; - return this; - } - /** * Get the serviceRequestId value. * @@ -103,17 +90,6 @@ public String serviceRequestId() { return this.serviceRequestId; } - /** - * Set the serviceRequestId value. - * - * @param serviceRequestId the serviceRequestId value to set - * @return the DeploymentOperationProperties object itself. - */ - public DeploymentOperationProperties withServiceRequestId(String serviceRequestId) { - this.serviceRequestId = serviceRequestId; - return this; - } - /** * Get the statusCode value. * @@ -123,17 +99,6 @@ public String statusCode() { return this.statusCode; } - /** - * Set the statusCode value. - * - * @param statusCode the statusCode value to set - * @return the DeploymentOperationProperties object itself. - */ - public DeploymentOperationProperties withStatusCode(String statusCode) { - this.statusCode = statusCode; - return this; - } - /** * Get the statusMessage value. * @@ -143,17 +108,6 @@ public Object statusMessage() { return this.statusMessage; } - /** - * Set the statusMessage value. - * - * @param statusMessage the statusMessage value to set - * @return the DeploymentOperationProperties object itself. - */ - public DeploymentOperationProperties withStatusMessage(Object statusMessage) { - this.statusMessage = statusMessage; - return this; - } - /** * Get the targetResource value. * @@ -163,17 +117,6 @@ public TargetResource targetResource() { return this.targetResource; } - /** - * Set the targetResource value. - * - * @param targetResource the targetResource value to set - * @return the DeploymentOperationProperties object itself. - */ - public DeploymentOperationProperties withTargetResource(TargetResource targetResource) { - this.targetResource = targetResource; - return this; - } - /** * Get the request value. * @@ -183,17 +126,6 @@ public HttpMessage request() { return this.request; } - /** - * Set the request value. - * - * @param request the request value to set - * @return the DeploymentOperationProperties object itself. - */ - public DeploymentOperationProperties withRequest(HttpMessage request) { - this.request = request; - return this; - } - /** * Get the response value. * @@ -203,15 +135,4 @@ public HttpMessage response() { return this.response; } - /** - * Set the response value. - * - * @param response the response value to set - * @return the DeploymentOperationProperties object itself. - */ - public DeploymentOperationProperties withResponse(HttpMessage response) { - this.response = response; - return this; - } - } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/DeploymentPropertiesExtended.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/DeploymentPropertiesExtended.java index daa5aed9cbe2d..f88dbb01ac6c6 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/DeploymentPropertiesExtended.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/DeploymentPropertiesExtended.java @@ -11,6 +11,7 @@ import org.joda.time.DateTime; import java.util.List; import com.microsoft.azure.management.resources.implementation.ProviderInner; +import com.fasterxml.jackson.annotation.JsonProperty; /** * Deployment properties with additional details. @@ -19,16 +20,19 @@ public class DeploymentPropertiesExtended { /** * The state of the provisioning. */ + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) private String provisioningState; /** * The correlation ID of the deployment. */ + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) private String correlationId; /** * The timestamp of the template deployment. */ + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) private DateTime timestamp; /** @@ -87,17 +91,6 @@ public String provisioningState() { return this.provisioningState; } - /** - * Set the provisioningState value. - * - * @param provisioningState the provisioningState value to set - * @return the DeploymentPropertiesExtended object itself. - */ - public DeploymentPropertiesExtended withProvisioningState(String provisioningState) { - this.provisioningState = provisioningState; - return this; - } - /** * Get the correlationId value. * @@ -107,17 +100,6 @@ public String correlationId() { return this.correlationId; } - /** - * Set the correlationId value. - * - * @param correlationId the correlationId value to set - * @return the DeploymentPropertiesExtended object itself. - */ - public DeploymentPropertiesExtended withCorrelationId(String correlationId) { - this.correlationId = correlationId; - return this; - } - /** * Get the timestamp value. * @@ -127,17 +109,6 @@ public DateTime timestamp() { return this.timestamp; } - /** - * Set the timestamp value. - * - * @param timestamp the timestamp value to set - * @return the DeploymentPropertiesExtended object itself. - */ - public DeploymentPropertiesExtended withTimestamp(DateTime timestamp) { - this.timestamp = timestamp; - return this; - } - /** * Get the outputs value. * diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/ResourceManagementErrorWithDetails.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/ResourceManagementErrorWithDetails.java index d24b63a237021..e438287160320 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/ResourceManagementErrorWithDetails.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/ResourceManagementErrorWithDetails.java @@ -18,23 +18,25 @@ public class ResourceManagementErrorWithDetails { /** * The error code returned from the server. */ - @JsonProperty(required = true) + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) private String code; /** * The error message returned from the server. */ - @JsonProperty(required = true) + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) private String message; /** * The target of the error. */ + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) private String target; /** * Validation error. */ + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) private List details; /** @@ -46,17 +48,6 @@ public String code() { return this.code; } - /** - * Set the code value. - * - * @param code the code value to set - * @return the ResourceManagementErrorWithDetails object itself. - */ - public ResourceManagementErrorWithDetails withCode(String code) { - this.code = code; - return this; - } - /** * Get the message value. * @@ -66,17 +57,6 @@ public String message() { return this.message; } - /** - * Set the message value. - * - * @param message the message value to set - * @return the ResourceManagementErrorWithDetails object itself. - */ - public ResourceManagementErrorWithDetails withMessage(String message) { - this.message = message; - return this; - } - /** * Get the target value. * @@ -86,17 +66,6 @@ public String target() { return this.target; } - /** - * Set the target value. - * - * @param target the target value to set - * @return the ResourceManagementErrorWithDetails object itself. - */ - public ResourceManagementErrorWithDetails withTarget(String target) { - this.target = target; - return this; - } - /** * Get the details value. * @@ -106,15 +75,4 @@ public List details() { return this.details; } - /** - * Set the details value. - * - * @param details the details value to set - * @return the ResourceManagementErrorWithDetails object itself. - */ - public ResourceManagementErrorWithDetails withDetails(List details) { - this.details = details; - return this; - } - } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/SpendingLimit.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/SpendingLimit.java new file mode 100644 index 0000000000000..5d673c0f74254 --- /dev/null +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/SpendingLimit.java @@ -0,0 +1,56 @@ +/** + * 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.resources; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Defines values for SpendingLimit. + */ +public enum SpendingLimit { + /** Enum value On. */ + ON("On"), + + /** Enum value Off. */ + OFF("Off"), + + /** Enum value CurrentPeriodOff. */ + CURRENT_PERIOD_OFF("CurrentPeriodOff"); + + /** The actual serialized value for a SpendingLimit instance. */ + private String value; + + SpendingLimit(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a SpendingLimit instance. + * + * @param value the serialized value to parse. + * @return the parsed SpendingLimit object, or null if unable to parse. + */ + @JsonCreator + public static SpendingLimit fromString(String value) { + SpendingLimit[] items = SpendingLimit.values(); + for (SpendingLimit item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/Subscription.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/Subscription.java index 46256482f1976..2f58a592924a4 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/Subscription.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/Subscription.java @@ -33,7 +33,7 @@ public interface Subscription extends /** * @return the state of the subscription. */ - String state(); + SubscriptionState state(); /** * @return the policies defined in the subscription diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/SubscriptionPolicies.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/SubscriptionPolicies.java index 5cb9484e62d73..6a61c301dd101 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/SubscriptionPolicies.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/SubscriptionPolicies.java @@ -8,21 +8,34 @@ package com.microsoft.azure.management.resources; +import com.fasterxml.jackson.annotation.JsonProperty; /** * Subscription policies. */ public class SubscriptionPolicies { /** - * Gets or sets the subscription location placement Id. + * The subscription location placement Id. The Id indicates which regions + * are visible for a subscription. For example, a subscription with a + * location placement Id of Public_2014-09-01 has access to Azure public + * regions. */ + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) private String locationPlacementId; /** - * Gets or sets the subscription quota Id. + * The subscription quota Id. */ + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) private String quotaId; + /** + * The subscription spending limit. Possible values include: 'On', 'Off', + * 'CurrentPeriodOff'. + */ + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) + private SpendingLimit spendingLimit; + /** * Get the locationPlacementId value. * @@ -32,17 +45,6 @@ public String locationPlacementId() { return this.locationPlacementId; } - /** - * Set the locationPlacementId value. - * - * @param locationPlacementId the locationPlacementId value to set - * @return the SubscriptionPolicies object itself. - */ - public SubscriptionPolicies withLocationPlacementId(String locationPlacementId) { - this.locationPlacementId = locationPlacementId; - return this; - } - /** * Get the quotaId value. * @@ -53,14 +55,12 @@ public String quotaId() { } /** - * Set the quotaId value. + * Get the spendingLimit value. * - * @param quotaId the quotaId value to set - * @return the SubscriptionPolicies object itself. + * @return the spendingLimit value */ - public SubscriptionPolicies withQuotaId(String quotaId) { - this.quotaId = quotaId; - return this; + public SpendingLimit spendingLimit() { + return this.spendingLimit; } } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/SubscriptionState.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/SubscriptionState.java new file mode 100644 index 0000000000000..b4c77985ed549 --- /dev/null +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/SubscriptionState.java @@ -0,0 +1,62 @@ +/** + * 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.resources; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Defines values for SubscriptionState. + */ +public enum SubscriptionState { + /** Enum value Enabled. */ + ENABLED("Enabled"), + + /** Enum value Warned. */ + WARNED("Warned"), + + /** Enum value PastDue. */ + PAST_DUE("PastDue"), + + /** Enum value Disabled. */ + DISABLED("Disabled"), + + /** Enum value Deleted. */ + DELETED("Deleted"); + + /** The actual serialized value for a SubscriptionState instance. */ + private String value; + + SubscriptionState(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a SubscriptionState instance. + * + * @param value the serialized value to parse. + * @return the parsed SubscriptionState object, or null if unable to parse. + */ + @JsonCreator + public static SubscriptionState fromString(String value) { + SubscriptionState[] items = SubscriptionState.values(); + for (SubscriptionState item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/DeploymentExportResultInner.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/DeploymentExportResultInner.java index 84e4034b2dc82..6232fdd25e85a 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/DeploymentExportResultInner.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/DeploymentExportResultInner.java @@ -10,7 +10,7 @@ /** - * The DeploymentExportResultInner model. + * The deployment export result. */ public class DeploymentExportResultInner { /** diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/DeploymentOperationInner.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/DeploymentOperationInner.java index e320431986457..bfba6c3dcb796 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/DeploymentOperationInner.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/DeploymentOperationInner.java @@ -9,6 +9,7 @@ package com.microsoft.azure.management.resources.implementation; import com.microsoft.azure.management.resources.DeploymentOperationProperties; +import com.fasterxml.jackson.annotation.JsonProperty; /** * Deployment operation information. @@ -17,11 +18,13 @@ public class DeploymentOperationInner { /** * Full deployment operation id. */ + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) private String id; /** * Deployment operation id. */ + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) private String operationId; /** @@ -38,17 +41,6 @@ public String id() { return this.id; } - /** - * Set the id value. - * - * @param id the id value to set - * @return the DeploymentOperationInner object itself. - */ - public DeploymentOperationInner withId(String id) { - this.id = id; - return this; - } - /** * Get the operationId value. * @@ -58,17 +50,6 @@ public String operationId() { return this.operationId; } - /** - * Set the operationId value. - * - * @param operationId the operationId value to set - * @return the DeploymentOperationInner object itself. - */ - public DeploymentOperationInner withOperationId(String operationId) { - this.operationId = operationId; - return this; - } - /** * Get the properties value. * diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/DeploymentsInner.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/DeploymentsInner.java index 123f7ba6b5a68..cc822d8d5ac49 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/DeploymentsInner.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/DeploymentsInner.java @@ -8,6 +8,7 @@ package com.microsoft.azure.management.resources.implementation; +import retrofit2.Retrofit; import com.google.common.reflect.TypeToken; import com.microsoft.azure.AzureServiceCall; import com.microsoft.azure.AzureServiceResponseBuilder; @@ -19,24 +20,22 @@ 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.Response; -import retrofit2.Retrofit; import retrofit2.http.Body; import retrofit2.http.GET; import retrofit2.http.HEAD; -import retrofit2.http.HTTP; import retrofit2.http.Header; import retrofit2.http.Headers; +import retrofit2.http.HTTP; +import retrofit2.http.Path; import retrofit2.http.POST; import retrofit2.http.PUT; -import retrofit2.http.Path; import retrofit2.http.Query; -import rx.Observable; +import retrofit2.Response; import rx.functions.Func1; - -import java.io.IOException; -import java.util.List; +import rx.Observable; /** * An instance of this class provides access to all the operations defined diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/GenericResourceImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/GenericResourceImpl.java index 9963d69febbda..52233889f039f 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/GenericResourceImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/GenericResourceImpl.java @@ -140,7 +140,8 @@ public String call(Provider provider) { return type.apiVersions().get(0); } } - throw Exceptions.propagate(new UnsupportedOperationException("Resource provider " + resourceProviderNamespace + " doesn't have a default api version, please specify one.")); + // Use the first available one as default + return provider.resourceTypes().get(0).apiVersions().get(0); } }); } @@ -150,10 +151,10 @@ public String call(Provider provider) { public Observable call(String api) { return resourceClient.createOrUpdateAsync( resourceGroupName(), - resourceProviderNamespace, + ResourceUtils.resourceProviderFromResourceId(inner().id()), ResourceUtils.relativePathFromResourceId(parentResourceId), - resourceType, - name(), + ResourceUtils.resourceTypeFromResourceId(inner().id()), + ResourceUtils.nameFromResourceId(inner().id()), api, inner()) .subscribeOn(Schedulers.io()) diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/GenericResourcesImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/GenericResourcesImpl.java index a545875e06d9b..6eb3c3dd1256d 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/GenericResourcesImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/GenericResourcesImpl.java @@ -10,6 +10,8 @@ import com.microsoft.azure.PagedList; import com.microsoft.azure.management.resources.GenericResource; import com.microsoft.azure.management.resources.GenericResources; +import com.microsoft.azure.management.resources.Provider; +import com.microsoft.azure.management.resources.ProviderResourceType; import com.microsoft.azure.management.resources.ResourceGroup; import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils; import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.GroupableResourcesImpl; @@ -51,11 +53,11 @@ public PagedList listByTag(String resourceGroupName, String tag if (tagName == null) { throw new IllegalArgumentException("tagName == null"); } - String odataFilter = ""; + String odataFilter; if (tagValue == null) { - odataFilter = String.format("tagname eq %s", tagName); + odataFilter = String.format("tagname eq '%s'", tagName); } else { - odataFilter = String.format("tagname eq %s and tagvalue eq %s", tagName, tagValue); + odataFilter = String.format("tagname eq '%s' and tagvalue eq '%s'", tagName, tagValue); } return wrapList(this.serviceClient.resourceGroups().listResources( resourceGroupName, odataFilter, null, null)); @@ -85,11 +87,17 @@ public boolean checkExistence(String resourceGroupName, String resourceProviderN @Override public GenericResource getById(String id) { - return this.get( - ResourceUtils.groupFromResourceId(id), - ResourceUtils.resourceProviderFromResourceId(id), - ResourceUtils.resourceTypeFromResourceId(id), - ResourceUtils.nameFromResourceId(id)); + Provider provider = myManager.providers().getByName(ResourceUtils.resourceProviderFromResourceId(id)); + String apiVersion = null; + for (ProviderResourceType type : provider.resourceTypes()) { + if (ResourceUtils.resourceTypeFromResourceId(id).equalsIgnoreCase(type.resourceType())) { + apiVersion = type.apiVersions().get(0); + } + } + if (apiVersion == null) { + apiVersion = provider.resourceTypes().get(0).apiVersions().get(0); + } + return wrapModel(this.innerCollection.getById(id, apiVersion)); } @Override diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/LocationInner.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/LocationInner.java index 1c044bf42a156..238c1b33f9310 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/LocationInner.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/LocationInner.java @@ -8,39 +8,47 @@ package com.microsoft.azure.management.resources.implementation; +import com.fasterxml.jackson.annotation.JsonProperty; /** * Location information. */ public class LocationInner { /** - * Gets or sets the ID of the resource (/subscriptions/SubscriptionId). + * The fully qualified Id of the location. For example, + * /subscriptions/00000000-0000-0000-0000-000000000000/locations/westus. */ + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) private String id; /** - * Gets or sets the subscription Id. + * The subscription Id. */ + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) private String subscriptionId; /** - * Gets or sets the location name. + * The location name. */ + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) private String name; /** - * Gets or sets the display name of the location. + * The display name of the location. */ + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) private String displayName; /** - * Gets or sets the latitude of the location. + * The latitude of the location. */ + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) private String latitude; /** - * Gets or sets the longitude of the location. + * The longitude of the location. */ + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) private String longitude; /** @@ -52,17 +60,6 @@ public String id() { return this.id; } - /** - * Set the id value. - * - * @param id the id value to set - * @return the LocationInner object itself. - */ - public LocationInner withId(String id) { - this.id = id; - return this; - } - /** * Get the subscriptionId value. * @@ -72,17 +69,6 @@ public String subscriptionId() { return this.subscriptionId; } - /** - * Set the subscriptionId value. - * - * @param subscriptionId the subscriptionId value to set - * @return the LocationInner object itself. - */ - public LocationInner withSubscriptionId(String subscriptionId) { - this.subscriptionId = subscriptionId; - return this; - } - /** * Get the name value. * @@ -92,17 +78,6 @@ public String name() { return this.name; } - /** - * Set the name value. - * - * @param name the name value to set - * @return the LocationInner object itself. - */ - public LocationInner withName(String name) { - this.name = name; - return this; - } - /** * Get the displayName value. * @@ -112,17 +87,6 @@ public String displayName() { return this.displayName; } - /** - * Set the displayName value. - * - * @param displayName the displayName value to set - * @return the LocationInner object itself. - */ - public LocationInner withDisplayName(String displayName) { - this.displayName = displayName; - return this; - } - /** * Get the latitude value. * @@ -132,17 +96,6 @@ public String latitude() { return this.latitude; } - /** - * Set the latitude value. - * - * @param latitude the latitude value to set - * @return the LocationInner object itself. - */ - public LocationInner withLatitude(String latitude) { - this.latitude = latitude; - return this; - } - /** * Get the longitude value. * @@ -152,15 +105,4 @@ public String longitude() { return this.longitude; } - /** - * Set the longitude value. - * - * @param longitude the longitude value to set - * @return the LocationInner object itself. - */ - public LocationInner withLongitude(String longitude) { - this.longitude = longitude; - return this; - } - } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/ProviderInner.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/ProviderInner.java index 30167055e1d9b..d5805ac15e318 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/ProviderInner.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/ProviderInner.java @@ -10,6 +10,7 @@ import java.util.List; import com.microsoft.azure.management.resources.ProviderResourceType; +import com.fasterxml.jackson.annotation.JsonProperty; /** * Resource provider information. @@ -18,6 +19,7 @@ public class ProviderInner { /** * The provider id. */ + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) private String id; /** @@ -28,11 +30,13 @@ public class ProviderInner { /** * The registration state of the provider. */ + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) private String registrationState; /** * The collection of provider resource types. */ + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) private List resourceTypes; /** @@ -44,17 +48,6 @@ public String id() { return this.id; } - /** - * Set the id value. - * - * @param id the id value to set - * @return the ProviderInner object itself. - */ - public ProviderInner withId(String id) { - this.id = id; - return this; - } - /** * Get the namespace value. * @@ -84,17 +77,6 @@ public String registrationState() { return this.registrationState; } - /** - * Set the registrationState value. - * - * @param registrationState the registrationState value to set - * @return the ProviderInner object itself. - */ - public ProviderInner withRegistrationState(String registrationState) { - this.registrationState = registrationState; - return this; - } - /** * Get the resourceTypes value. * @@ -104,15 +86,4 @@ public List resourceTypes() { return this.resourceTypes; } - /** - * Set the resourceTypes value. - * - * @param resourceTypes the resourceTypes value to set - * @return the ProviderInner object itself. - */ - public ProviderInner withResourceTypes(List resourceTypes) { - this.resourceTypes = resourceTypes; - return this; - } - } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/ResourceGroupInner.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/ResourceGroupInner.java index 89b95b8f73297..10ac7ec241e57 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/ResourceGroupInner.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/ResourceGroupInner.java @@ -40,6 +40,11 @@ public class ResourceGroupInner { @JsonProperty(required = true) private String location; + /** + * Id of the resource that manages this resource group. + */ + private String managedBy; + /** * The tags attached to the resource group. */ @@ -114,6 +119,26 @@ public ResourceGroupInner withLocation(String location) { return this; } + /** + * Get the managedBy value. + * + * @return the managedBy value + */ + public String managedBy() { + return this.managedBy; + } + + /** + * Set the managedBy value. + * + * @param managedBy the managedBy value to set + * @return the ResourceGroupInner object itself. + */ + public ResourceGroupInner withManagedBy(String managedBy) { + this.managedBy = managedBy; + return this; + } + /** * Get the tags value. * diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/ResourceManagementClientImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/ResourceManagementClientImpl.java index f1209ca644b99..11b0ed51d2d5e 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/ResourceManagementClientImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/ResourceManagementClientImpl.java @@ -243,7 +243,7 @@ public ResourceManagementClientImpl(RestClient restClient) { } protected void initialize() { - this.apiVersion = "2016-02-01"; + this.apiVersion = "2016-09-01"; this.acceptLanguage = "en-US"; this.longRunningOperationRetryTimeout = 30; this.generateClientRequestId = true; @@ -265,6 +265,6 @@ protected void initialize() { public String userAgent() { return String.format("Azure-SDK-For-Java/%s (%s)", getClass().getPackage().getImplementationVersion(), - "ResourceManagementClient, 2016-02-01"); + "ResourceManagementClient, 2016-09-01"); } } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/ResourcesInner.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/ResourcesInner.java index bb2c32959fb31..3ee0f97ba8ff4 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/ResourcesInner.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/ResourcesInner.java @@ -83,14 +83,46 @@ interface ResourcesService { @HTTP(path = "subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", method = "DELETE", hasBody = true) Observable> delete(@Path("resourceGroupName") String resourceGroupName, @Path("resourceProviderNamespace") String resourceProviderNamespace, @Path(value = "parentResourcePath", encoded = true) String parentResourcePath, @Path(value = "resourceType", encoded = true) String resourceType, @Path("resourceName") String resourceName, @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") + @HTTP(path = "subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", method = "DELETE", hasBody = true) + Observable> beginDelete(@Path("resourceGroupName") String resourceGroupName, @Path("resourceProviderNamespace") String resourceProviderNamespace, @Path(value = "parentResourcePath", encoded = true) String parentResourcePath, @Path(value = "resourceType", encoded = true) String resourceType, @Path("resourceName") String resourceName, @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/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") Observable> createOrUpdate(@Path("resourceGroupName") String resourceGroupName, @Path("resourceProviderNamespace") String resourceProviderNamespace, @Path(value = "parentResourcePath", encoded = true) String parentResourcePath, @Path(value = "resourceType", encoded = true) String resourceType, @Path("resourceName") String resourceName, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Body GenericResourceInner parameters, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + @Headers("Content-Type: application/json; charset=utf-8") + @PUT("subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") + Observable> beginCreateOrUpdate(@Path("resourceGroupName") String resourceGroupName, @Path("resourceProviderNamespace") String resourceProviderNamespace, @Path(value = "parentResourcePath", encoded = true) String parentResourcePath, @Path(value = "resourceType", encoded = true) String resourceType, @Path("resourceName") String resourceName, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Body GenericResourceInner parameters, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + @Headers("Content-Type: application/json; charset=utf-8") @GET("subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") Observable> get(@Path("resourceGroupName") String resourceGroupName, @Path("resourceProviderNamespace") String resourceProviderNamespace, @Path(value = "parentResourcePath", encoded = true) String parentResourcePath, @Path(value = "resourceType", encoded = true) String resourceType, @Path("resourceName") String resourceName, @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") + @HEAD("{resourceId}") + Observable> checkExistenceById(@Path(value = "resourceId", encoded = true) String resourceId, @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 = "{resourceId}", method = "DELETE", hasBody = true) + Observable> deleteById(@Path(value = "resourceId", encoded = true) String resourceId, @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 = "{resourceId}", method = "DELETE", hasBody = true) + Observable> beginDeleteById(@Path(value = "resourceId", encoded = true) String resourceId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @PUT("{resourceId}") + Observable> createOrUpdateById(@Path(value = "resourceId", encoded = true) String resourceId, @Query("api-version") String apiVersion, @Body GenericResourceInner parameters, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @PUT("{resourceId}") + Observable> beginCreateOrUpdateById(@Path(value = "resourceId", encoded = true) String resourceId, @Query("api-version") String apiVersion, @Body GenericResourceInner parameters, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @GET("{resourceId}") + Observable> getById(@Path(value = "resourceId", encoded = true) String resourceId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + @Headers("Content-Type: application/json; charset=utf-8") @GET("{nextLink}") Observable> listNext(@Path(value = "nextLink", encoded = true) String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); @@ -459,7 +491,7 @@ private ServiceResponse> listDelegate(Response checkExistenceAsync(String resourceGroupName, String * @param parentResourcePath Resource identity. * @param resourceType Resource identity. * @param resourceName Resource identity. - * @param apiVersion the String value + * @param apiVersion Api version to use. * @return the observable to the boolean object */ public Observable checkExistenceAsync(String resourceGroupName, String resourceProviderNamespace, String parentResourcePath, String resourceType, String resourceName, String apiVersion) { @@ -510,7 +542,7 @@ public Boolean call(ServiceResponse response) { * @param parentResourcePath Resource identity. * @param resourceType Resource identity. * @param resourceName Resource identity. - * @param apiVersion the String value + * @param apiVersion Api version to use. * @return the observable to the boolean object */ public Observable> checkExistenceWithServiceResponseAsync(String resourceGroupName, String resourceProviderNamespace, String parentResourcePath, String resourceType, String resourceName, String apiVersion) { @@ -558,28 +590,28 @@ private ServiceResponse checkExistenceDelegate(Response response) } /** - * Delete resource and all of its resources. + * Deletes a resource. * * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param resourceProviderNamespace Resource identity. * @param parentResourcePath Resource identity. * @param resourceType Resource identity. * @param resourceName Resource identity. - * @param apiVersion the String value + * @param apiVersion Api version to use. */ public void delete(String resourceGroupName, String resourceProviderNamespace, String parentResourcePath, String resourceType, String resourceName, String apiVersion) { - deleteWithServiceResponseAsync(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion).toBlocking().single().getBody(); + deleteWithServiceResponseAsync(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion).toBlocking().last().getBody(); } /** - * Delete resource and all of its resources. + * Deletes a resource. * * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param resourceProviderNamespace Resource identity. * @param parentResourcePath Resource identity. * @param resourceType Resource identity. * @param resourceName Resource identity. - * @param apiVersion the String value + * @param apiVersion Api version to use. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ @@ -588,15 +620,15 @@ public ServiceCall deleteAsync(String resourceGroupName, String resourcePr } /** - * Delete resource and all of its resources. + * Deletes a resource. * * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param resourceProviderNamespace Resource identity. * @param parentResourcePath Resource identity. * @param resourceType Resource identity. * @param resourceName Resource identity. - * @param apiVersion the String value - * @return the {@link ServiceResponse} object if successful. + * @param apiVersion Api version to use. + * @return the observable for the request */ public Observable deleteAsync(String resourceGroupName, String resourceProviderNamespace, String parentResourcePath, String resourceType, String resourceName, String apiVersion) { return deleteWithServiceResponseAsync(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion).map(new Func1, Void>() { @@ -608,15 +640,15 @@ public Void call(ServiceResponse response) { } /** - * Delete resource and all of its resources. + * Deletes a resource. * * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param resourceProviderNamespace Resource identity. * @param parentResourcePath Resource identity. * @param resourceType Resource identity. * @param resourceName Resource identity. - * @param apiVersion the String value - * @return the {@link ServiceResponse} object if successful. + * @param apiVersion Api version to use. + * @return the observable for the request */ public Observable> deleteWithServiceResponseAsync(String resourceGroupName, String resourceProviderNamespace, String parentResourcePath, String resourceType, String resourceName, String apiVersion) { if (resourceGroupName == null) { @@ -640,12 +672,99 @@ public Observable> deleteWithServiceResponseAsync(String r if (apiVersion == null) { throw new IllegalArgumentException("Parameter apiVersion is required and cannot be null."); } - return service.delete(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, this.client.subscriptionId(), apiVersion, this.client.acceptLanguage(), this.client.userAgent()) + Observable> observable = service.delete(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, this.client.subscriptionId(), apiVersion, this.client.acceptLanguage(), this.client.userAgent()); + return client.getAzureClient().getPostOrDeleteResultAsync(observable, new TypeToken() { }.getType()); + } + + /** + * Deletes a resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceProviderNamespace Resource identity. + * @param parentResourcePath Resource identity. + * @param resourceType Resource identity. + * @param resourceName Resource identity. + * @param apiVersion Api version to use. + */ + public void beginDelete(String resourceGroupName, String resourceProviderNamespace, String parentResourcePath, String resourceType, String resourceName, String apiVersion) { + beginDeleteWithServiceResponseAsync(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion).toBlocking().single().getBody(); + } + + /** + * Deletes a resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceProviderNamespace Resource identity. + * @param parentResourcePath Resource identity. + * @param resourceType Resource identity. + * @param resourceName Resource identity. + * @param apiVersion Api version to use. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @return the {@link ServiceCall} object + */ + public ServiceCall beginDeleteAsync(String resourceGroupName, String resourceProviderNamespace, String parentResourcePath, String resourceType, String resourceName, String apiVersion, final ServiceCallback serviceCallback) { + return ServiceCall.create(beginDeleteWithServiceResponseAsync(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion), serviceCallback); + } + + /** + * Deletes a resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceProviderNamespace Resource identity. + * @param parentResourcePath Resource identity. + * @param resourceType Resource identity. + * @param resourceName Resource identity. + * @param apiVersion Api version to use. + * @return the {@link ServiceResponse} object if successful. + */ + public Observable beginDeleteAsync(String resourceGroupName, String resourceProviderNamespace, String parentResourcePath, String resourceType, String resourceName, String apiVersion) { + return beginDeleteWithServiceResponseAsync(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.getBody(); + } + }); + } + + /** + * Deletes a resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceProviderNamespace Resource identity. + * @param parentResourcePath Resource identity. + * @param resourceType Resource identity. + * @param resourceName Resource identity. + * @param apiVersion Api version to use. + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> beginDeleteWithServiceResponseAsync(String resourceGroupName, String resourceProviderNamespace, String parentResourcePath, String resourceType, String resourceName, String apiVersion) { + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (resourceProviderNamespace == null) { + throw new IllegalArgumentException("Parameter resourceProviderNamespace is required and cannot be null."); + } + if (parentResourcePath == null) { + throw new IllegalArgumentException("Parameter parentResourcePath is required and cannot be null."); + } + if (resourceType == null) { + throw new IllegalArgumentException("Parameter resourceType is required and cannot be null."); + } + if (resourceName == null) { + throw new IllegalArgumentException("Parameter resourceName 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 (apiVersion == null) { + throw new IllegalArgumentException("Parameter apiVersion is required and cannot be null."); + } + return service.beginDelete(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, this.client.subscriptionId(), apiVersion, this.client.acceptLanguage(), this.client.userAgent()) .flatMap(new Func1, Observable>>() { @Override public Observable> call(Response response) { try { - ServiceResponse clientResponse = deleteDelegate(response); + ServiceResponse clientResponse = beginDeleteDelegate(response); return Observable.just(clientResponse); } catch (Throwable t) { return Observable.error(t); @@ -654,7 +773,7 @@ public Observable> call(Response response) { }); } - private ServiceResponse deleteDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + private ServiceResponse beginDeleteDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { return new AzureServiceResponseBuilder(this.client.mapperAdapter()) .register(200, new TypeToken() { }.getType()) .register(204, new TypeToken() { }.getType()) @@ -670,12 +789,12 @@ private ServiceResponse deleteDelegate(Response response) th * @param parentResourcePath Resource identity. * @param resourceType Resource identity. * @param resourceName Resource identity. - * @param apiVersion the String value + * @param apiVersion Api version to use. * @param parameters Create or update resource parameters. * @return the GenericResourceInner object if successful. */ public GenericResourceInner createOrUpdate(String resourceGroupName, String resourceProviderNamespace, String parentResourcePath, String resourceType, String resourceName, String apiVersion, GenericResourceInner parameters) { - return createOrUpdateWithServiceResponseAsync(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, parameters).toBlocking().single().getBody(); + return createOrUpdateWithServiceResponseAsync(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, parameters).toBlocking().last().getBody(); } /** @@ -686,7 +805,7 @@ public GenericResourceInner createOrUpdate(String resourceGroupName, String reso * @param parentResourcePath Resource identity. * @param resourceType Resource identity. * @param resourceName Resource identity. - * @param apiVersion the String value + * @param apiVersion Api version to use. * @param parameters Create or update resource parameters. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object @@ -703,9 +822,9 @@ public ServiceCall createOrUpdateAsync(String resourceGrou * @param parentResourcePath Resource identity. * @param resourceType Resource identity. * @param resourceName Resource identity. - * @param apiVersion the String value + * @param apiVersion Api version to use. * @param parameters Create or update resource parameters. - * @return the observable to the GenericResourceInner object + * @return the observable for the request */ public Observable createOrUpdateAsync(String resourceGroupName, String resourceProviderNamespace, String parentResourcePath, String resourceType, String resourceName, String apiVersion, GenericResourceInner parameters) { return createOrUpdateWithServiceResponseAsync(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, parameters).map(new Func1, GenericResourceInner>() { @@ -724,9 +843,9 @@ public GenericResourceInner call(ServiceResponse response) * @param parentResourcePath Resource identity. * @param resourceType Resource identity. * @param resourceName Resource identity. - * @param apiVersion the String value + * @param apiVersion Api version to use. * @param parameters Create or update resource parameters. - * @return the observable to the GenericResourceInner object + * @return the observable for the request */ public Observable> createOrUpdateWithServiceResponseAsync(String resourceGroupName, String resourceProviderNamespace, String parentResourcePath, String resourceType, String resourceName, String apiVersion, GenericResourceInner parameters) { if (resourceGroupName == null) { @@ -754,12 +873,108 @@ public Observable> createOrUpdateWithServi throw new IllegalArgumentException("Parameter parameters is required and cannot be null."); } Validator.validate(parameters); - return service.createOrUpdate(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, this.client.subscriptionId(), apiVersion, parameters, this.client.acceptLanguage(), this.client.userAgent()) + Observable> observable = service.createOrUpdate(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, this.client.subscriptionId(), apiVersion, parameters, this.client.acceptLanguage(), this.client.userAgent()); + return client.getAzureClient().getPutOrPatchResultAsync(observable, new TypeToken() { }.getType()); + } + + /** + * Create a resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceProviderNamespace Resource identity. + * @param parentResourcePath Resource identity. + * @param resourceType Resource identity. + * @param resourceName Resource identity. + * @param apiVersion Api version to use. + * @param parameters Create or update resource parameters. + * @return the GenericResourceInner object if successful. + */ + public GenericResourceInner beginCreateOrUpdate(String resourceGroupName, String resourceProviderNamespace, String parentResourcePath, String resourceType, String resourceName, String apiVersion, GenericResourceInner parameters) { + return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, parameters).toBlocking().single().getBody(); + } + + /** + * Create a resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceProviderNamespace Resource identity. + * @param parentResourcePath Resource identity. + * @param resourceType Resource identity. + * @param resourceName Resource identity. + * @param apiVersion Api version to use. + * @param parameters Create or update resource parameters. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @return the {@link ServiceCall} object + */ + public ServiceCall beginCreateOrUpdateAsync(String resourceGroupName, String resourceProviderNamespace, String parentResourcePath, String resourceType, String resourceName, String apiVersion, GenericResourceInner parameters, final ServiceCallback serviceCallback) { + return ServiceCall.create(beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, parameters), serviceCallback); + } + + /** + * Create a resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceProviderNamespace Resource identity. + * @param parentResourcePath Resource identity. + * @param resourceType Resource identity. + * @param resourceName Resource identity. + * @param apiVersion Api version to use. + * @param parameters Create or update resource parameters. + * @return the observable to the GenericResourceInner object + */ + public Observable beginCreateOrUpdateAsync(String resourceGroupName, String resourceProviderNamespace, String parentResourcePath, String resourceType, String resourceName, String apiVersion, GenericResourceInner parameters) { + return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, parameters).map(new Func1, GenericResourceInner>() { + @Override + public GenericResourceInner call(ServiceResponse response) { + return response.getBody(); + } + }); + } + + /** + * Create a resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceProviderNamespace Resource identity. + * @param parentResourcePath Resource identity. + * @param resourceType Resource identity. + * @param resourceName Resource identity. + * @param apiVersion Api version to use. + * @param parameters Create or update resource parameters. + * @return the observable to the GenericResourceInner object + */ + public Observable> beginCreateOrUpdateWithServiceResponseAsync(String resourceGroupName, String resourceProviderNamespace, String parentResourcePath, String resourceType, String resourceName, String apiVersion, GenericResourceInner parameters) { + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (resourceProviderNamespace == null) { + throw new IllegalArgumentException("Parameter resourceProviderNamespace is required and cannot be null."); + } + if (parentResourcePath == null) { + throw new IllegalArgumentException("Parameter parentResourcePath is required and cannot be null."); + } + if (resourceType == null) { + throw new IllegalArgumentException("Parameter resourceType is required and cannot be null."); + } + if (resourceName == null) { + throw new IllegalArgumentException("Parameter resourceName 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 (apiVersion == null) { + throw new IllegalArgumentException("Parameter apiVersion is required and cannot be null."); + } + if (parameters == null) { + throw new IllegalArgumentException("Parameter parameters is required and cannot be null."); + } + Validator.validate(parameters); + return service.beginCreateOrUpdate(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, this.client.subscriptionId(), apiVersion, parameters, this.client.acceptLanguage(), this.client.userAgent()) .flatMap(new Func1, Observable>>() { @Override public Observable> call(Response response) { try { - ServiceResponse clientResponse = createOrUpdateDelegate(response); + ServiceResponse clientResponse = beginCreateOrUpdateDelegate(response); return Observable.just(clientResponse); } catch (Throwable t) { return Observable.error(t); @@ -768,10 +983,11 @@ public Observable> call(Response createOrUpdateDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + private ServiceResponse beginCreateOrUpdateDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { return new AzureServiceResponseBuilder(this.client.mapperAdapter()) .register(201, new TypeToken() { }.getType()) .register(200, new TypeToken() { }.getType()) + .register(202, new TypeToken() { }.getType()) .registerError(CloudException.class) .build(response); } @@ -784,7 +1000,7 @@ private ServiceResponse createOrUpdateDelegate(Response getAsync(String resourceGroupName, Stri * @param parentResourcePath Resource identity. * @param resourceType Resource identity. * @param resourceName Resource identity. - * @param apiVersion the String value + * @param apiVersion Api version to use. * @return the observable to the GenericResourceInner object */ public Observable getAsync(String resourceGroupName, String resourceProviderNamespace, String parentResourcePath, String resourceType, String resourceName, String apiVersion) { @@ -835,7 +1051,7 @@ public GenericResourceInner call(ServiceResponse response) * @param parentResourcePath Resource identity. * @param resourceType Resource identity. * @param resourceName Resource identity. - * @param apiVersion the String value + * @param apiVersion Api version to use. * @return the observable to the GenericResourceInner object */ public Observable> getWithServiceResponseAsync(String resourceGroupName, String resourceProviderNamespace, String parentResourcePath, String resourceType, String resourceName, String apiVersion) { @@ -881,6 +1097,434 @@ private ServiceResponse getDelegate(Response .build(response); } + /** + * Checks whether resource exists. + * + * @param resourceId The fully qualified Id of the resource, including the resource name and resource type. For example, /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite + * @param apiVersion Api version to use. + * @return the boolean object if successful. + */ + public boolean checkExistenceById(String resourceId, String apiVersion) { + return checkExistenceByIdWithServiceResponseAsync(resourceId, apiVersion).toBlocking().single().getBody(); + } + + /** + * Checks whether resource exists. + * + * @param resourceId The fully qualified Id of the resource, including the resource name and resource type. For example, /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite + * @param apiVersion Api version to use. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @return the {@link ServiceCall} object + */ + public ServiceCall checkExistenceByIdAsync(String resourceId, String apiVersion, final ServiceCallback serviceCallback) { + return ServiceCall.create(checkExistenceByIdWithServiceResponseAsync(resourceId, apiVersion), serviceCallback); + } + + /** + * Checks whether resource exists. + * + * @param resourceId The fully qualified Id of the resource, including the resource name and resource type. For example, /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite + * @param apiVersion Api version to use. + * @return the observable to the boolean object + */ + public Observable checkExistenceByIdAsync(String resourceId, String apiVersion) { + return checkExistenceByIdWithServiceResponseAsync(resourceId, apiVersion).map(new Func1, Boolean>() { + @Override + public Boolean call(ServiceResponse response) { + return response.getBody(); + } + }); + } + + /** + * Checks whether resource exists. + * + * @param resourceId The fully qualified Id of the resource, including the resource name and resource type. For example, /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite + * @param apiVersion Api version to use. + * @return the observable to the boolean object + */ + public Observable> checkExistenceByIdWithServiceResponseAsync(String resourceId, String apiVersion) { + if (resourceId == null) { + throw new IllegalArgumentException("Parameter resourceId is required and cannot be null."); + } + if (apiVersion == null) { + throw new IllegalArgumentException("Parameter apiVersion is required and cannot be null."); + } + return service.checkExistenceById(resourceId, apiVersion, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = checkExistenceByIdDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse checkExistenceByIdDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.client.mapperAdapter()) + .register(204, new TypeToken() { }.getType()) + .register(404, new TypeToken() { }.getType()) + .registerError(CloudException.class) + .buildEmpty(response); + } + + /** + * Deletes a resource. + * + * @param resourceId The fully qualified Id of the resource, including the resource name and resource type. For example, /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite + * @param apiVersion Api version to use. + */ + public void deleteById(String resourceId, String apiVersion) { + deleteByIdWithServiceResponseAsync(resourceId, apiVersion).toBlocking().last().getBody(); + } + + /** + * Deletes a resource. + * + * @param resourceId The fully qualified Id of the resource, including the resource name and resource type. For example, /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite + * @param apiVersion Api version to use. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @return the {@link ServiceCall} object + */ + public ServiceCall deleteByIdAsync(String resourceId, String apiVersion, final ServiceCallback serviceCallback) { + return ServiceCall.create(deleteByIdWithServiceResponseAsync(resourceId, apiVersion), serviceCallback); + } + + /** + * Deletes a resource. + * + * @param resourceId The fully qualified Id of the resource, including the resource name and resource type. For example, /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite + * @param apiVersion Api version to use. + * @return the observable for the request + */ + public Observable deleteByIdAsync(String resourceId, String apiVersion) { + return deleteByIdWithServiceResponseAsync(resourceId, apiVersion).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.getBody(); + } + }); + } + + /** + * Deletes a resource. + * + * @param resourceId The fully qualified Id of the resource, including the resource name and resource type. For example, /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite + * @param apiVersion Api version to use. + * @return the observable for the request + */ + public Observable> deleteByIdWithServiceResponseAsync(String resourceId, String apiVersion) { + if (resourceId == null) { + throw new IllegalArgumentException("Parameter resourceId is required and cannot be null."); + } + if (apiVersion == null) { + throw new IllegalArgumentException("Parameter apiVersion is required and cannot be null."); + } + Observable> observable = service.deleteById(resourceId, apiVersion, this.client.acceptLanguage(), this.client.userAgent()); + return client.getAzureClient().getPostOrDeleteResultAsync(observable, new TypeToken() { }.getType()); + } + + /** + * Deletes a resource. + * + * @param resourceId The fully qualified Id of the resource, including the resource name and resource type. For example, /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite + * @param apiVersion Api version to use. + */ + public void beginDeleteById(String resourceId, String apiVersion) { + beginDeleteByIdWithServiceResponseAsync(resourceId, apiVersion).toBlocking().single().getBody(); + } + + /** + * Deletes a resource. + * + * @param resourceId The fully qualified Id of the resource, including the resource name and resource type. For example, /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite + * @param apiVersion Api version to use. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @return the {@link ServiceCall} object + */ + public ServiceCall beginDeleteByIdAsync(String resourceId, String apiVersion, final ServiceCallback serviceCallback) { + return ServiceCall.create(beginDeleteByIdWithServiceResponseAsync(resourceId, apiVersion), serviceCallback); + } + + /** + * Deletes a resource. + * + * @param resourceId The fully qualified Id of the resource, including the resource name and resource type. For example, /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite + * @param apiVersion Api version to use. + * @return the {@link ServiceResponse} object if successful. + */ + public Observable beginDeleteByIdAsync(String resourceId, String apiVersion) { + return beginDeleteByIdWithServiceResponseAsync(resourceId, apiVersion).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.getBody(); + } + }); + } + + /** + * Deletes a resource. + * + * @param resourceId The fully qualified Id of the resource, including the resource name and resource type. For example, /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite + * @param apiVersion Api version to use. + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> beginDeleteByIdWithServiceResponseAsync(String resourceId, String apiVersion) { + if (resourceId == null) { + throw new IllegalArgumentException("Parameter resourceId is required and cannot be null."); + } + if (apiVersion == null) { + throw new IllegalArgumentException("Parameter apiVersion is required and cannot be null."); + } + return service.beginDeleteById(resourceId, apiVersion, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = beginDeleteByIdDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse beginDeleteByIdDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.client.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) + .register(204, new TypeToken() { }.getType()) + .register(202, new TypeToken() { }.getType()) + .build(response); + } + + /** + * Create a resource. + * + * @param resourceId The fully qualified Id of the resource, including the resource name and resource type. For example, /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite + * @param apiVersion Api version to use. + * @param parameters Create or update resource parameters. + * @return the GenericResourceInner object if successful. + */ + public GenericResourceInner createOrUpdateById(String resourceId, String apiVersion, GenericResourceInner parameters) { + return createOrUpdateByIdWithServiceResponseAsync(resourceId, apiVersion, parameters).toBlocking().last().getBody(); + } + + /** + * Create a resource. + * + * @param resourceId The fully qualified Id of the resource, including the resource name and resource type. For example, /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite + * @param apiVersion Api version to use. + * @param parameters Create or update resource parameters. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @return the {@link ServiceCall} object + */ + public ServiceCall createOrUpdateByIdAsync(String resourceId, String apiVersion, GenericResourceInner parameters, final ServiceCallback serviceCallback) { + return ServiceCall.create(createOrUpdateByIdWithServiceResponseAsync(resourceId, apiVersion, parameters), serviceCallback); + } + + /** + * Create a resource. + * + * @param resourceId The fully qualified Id of the resource, including the resource name and resource type. For example, /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite + * @param apiVersion Api version to use. + * @param parameters Create or update resource parameters. + * @return the observable for the request + */ + public Observable createOrUpdateByIdAsync(String resourceId, String apiVersion, GenericResourceInner parameters) { + return createOrUpdateByIdWithServiceResponseAsync(resourceId, apiVersion, parameters).map(new Func1, GenericResourceInner>() { + @Override + public GenericResourceInner call(ServiceResponse response) { + return response.getBody(); + } + }); + } + + /** + * Create a resource. + * + * @param resourceId The fully qualified Id of the resource, including the resource name and resource type. For example, /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite + * @param apiVersion Api version to use. + * @param parameters Create or update resource parameters. + * @return the observable for the request + */ + public Observable> createOrUpdateByIdWithServiceResponseAsync(String resourceId, String apiVersion, GenericResourceInner parameters) { + if (resourceId == null) { + throw new IllegalArgumentException("Parameter resourceId is required and cannot be null."); + } + if (apiVersion == null) { + throw new IllegalArgumentException("Parameter apiVersion is required and cannot be null."); + } + if (parameters == null) { + throw new IllegalArgumentException("Parameter parameters is required and cannot be null."); + } + Validator.validate(parameters); + Observable> observable = service.createOrUpdateById(resourceId, apiVersion, parameters, this.client.acceptLanguage(), this.client.userAgent()); + return client.getAzureClient().getPutOrPatchResultAsync(observable, new TypeToken() { }.getType()); + } + + /** + * Create a resource. + * + * @param resourceId The fully qualified Id of the resource, including the resource name and resource type. For example, /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite + * @param apiVersion Api version to use. + * @param parameters Create or update resource parameters. + * @return the GenericResourceInner object if successful. + */ + public GenericResourceInner beginCreateOrUpdateById(String resourceId, String apiVersion, GenericResourceInner parameters) { + return beginCreateOrUpdateByIdWithServiceResponseAsync(resourceId, apiVersion, parameters).toBlocking().single().getBody(); + } + + /** + * Create a resource. + * + * @param resourceId The fully qualified Id of the resource, including the resource name and resource type. For example, /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite + * @param apiVersion Api version to use. + * @param parameters Create or update resource parameters. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @return the {@link ServiceCall} object + */ + public ServiceCall beginCreateOrUpdateByIdAsync(String resourceId, String apiVersion, GenericResourceInner parameters, final ServiceCallback serviceCallback) { + return ServiceCall.create(beginCreateOrUpdateByIdWithServiceResponseAsync(resourceId, apiVersion, parameters), serviceCallback); + } + + /** + * Create a resource. + * + * @param resourceId The fully qualified Id of the resource, including the resource name and resource type. For example, /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite + * @param apiVersion Api version to use. + * @param parameters Create or update resource parameters. + * @return the observable to the GenericResourceInner object + */ + public Observable beginCreateOrUpdateByIdAsync(String resourceId, String apiVersion, GenericResourceInner parameters) { + return beginCreateOrUpdateByIdWithServiceResponseAsync(resourceId, apiVersion, parameters).map(new Func1, GenericResourceInner>() { + @Override + public GenericResourceInner call(ServiceResponse response) { + return response.getBody(); + } + }); + } + + /** + * Create a resource. + * + * @param resourceId The fully qualified Id of the resource, including the resource name and resource type. For example, /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite + * @param apiVersion Api version to use. + * @param parameters Create or update resource parameters. + * @return the observable to the GenericResourceInner object + */ + public Observable> beginCreateOrUpdateByIdWithServiceResponseAsync(String resourceId, String apiVersion, GenericResourceInner parameters) { + if (resourceId == null) { + throw new IllegalArgumentException("Parameter resourceId is required and cannot be null."); + } + if (apiVersion == null) { + throw new IllegalArgumentException("Parameter apiVersion is required and cannot be null."); + } + if (parameters == null) { + throw new IllegalArgumentException("Parameter parameters is required and cannot be null."); + } + Validator.validate(parameters); + return service.beginCreateOrUpdateById(resourceId, apiVersion, parameters, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = beginCreateOrUpdateByIdDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse beginCreateOrUpdateByIdDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.client.mapperAdapter()) + .register(201, new TypeToken() { }.getType()) + .register(200, new TypeToken() { }.getType()) + .register(202, new TypeToken() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + + /** + * Gets a resource. + * + * @param resourceId The fully qualified Id of the resource, including the resource name and resource type. For example, /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite + * @param apiVersion Api version to use. + * @return the GenericResourceInner object if successful. + */ + public GenericResourceInner getById(String resourceId, String apiVersion) { + return getByIdWithServiceResponseAsync(resourceId, apiVersion).toBlocking().single().getBody(); + } + + /** + * Gets a resource. + * + * @param resourceId The fully qualified Id of the resource, including the resource name and resource type. For example, /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite + * @param apiVersion Api version to use. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @return the {@link ServiceCall} object + */ + public ServiceCall getByIdAsync(String resourceId, String apiVersion, final ServiceCallback serviceCallback) { + return ServiceCall.create(getByIdWithServiceResponseAsync(resourceId, apiVersion), serviceCallback); + } + + /** + * Gets a resource. + * + * @param resourceId The fully qualified Id of the resource, including the resource name and resource type. For example, /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite + * @param apiVersion Api version to use. + * @return the observable to the GenericResourceInner object + */ + public Observable getByIdAsync(String resourceId, String apiVersion) { + return getByIdWithServiceResponseAsync(resourceId, apiVersion).map(new Func1, GenericResourceInner>() { + @Override + public GenericResourceInner call(ServiceResponse response) { + return response.getBody(); + } + }); + } + + /** + * Gets a resource. + * + * @param resourceId The fully qualified Id of the resource, including the resource name and resource type. For example, /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite + * @param apiVersion Api version to use. + * @return the observable to the GenericResourceInner object + */ + public Observable> getByIdWithServiceResponseAsync(String resourceId, String apiVersion) { + if (resourceId == null) { + throw new IllegalArgumentException("Parameter resourceId is required and cannot be null."); + } + if (apiVersion == null) { + throw new IllegalArgumentException("Parameter apiVersion is required and cannot be null."); + } + return service.getById(resourceId, apiVersion, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getByIdDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse getByIdDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.client.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + /** * Get all of the resources under a subscription. * diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/SubscriptionClientImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/SubscriptionClientImpl.java index 4c94cbe31212e..34484f6184e55 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/SubscriptionClientImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/SubscriptionClientImpl.java @@ -168,7 +168,7 @@ public SubscriptionClientImpl(RestClient restClient) { } protected void initialize() { - this.apiVersion = "2015-11-01"; + this.apiVersion = "2016-06-01"; this.acceptLanguage = "en-US"; this.longRunningOperationRetryTimeout = 30; this.generateClientRequestId = true; @@ -186,6 +186,6 @@ protected void initialize() { public String userAgent() { return String.format("Azure-SDK-For-Java/%s (%s)", getClass().getPackage().getImplementationVersion(), - "SubscriptionClient, 2015-11-01"); + "SubscriptionClient, 2016-06-01"); } } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/SubscriptionImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/SubscriptionImpl.java index 020eb8972d137..61b3d2c9f1dd9 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/SubscriptionImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/SubscriptionImpl.java @@ -11,6 +11,7 @@ import com.microsoft.azure.management.resources.Location; import com.microsoft.azure.management.resources.Subscription; import com.microsoft.azure.management.resources.SubscriptionPolicies; +import com.microsoft.azure.management.resources.SubscriptionState; import com.microsoft.azure.management.resources.fluentcore.model.implementation.IndexableWrapperImpl; import com.microsoft.azure.management.resources.fluentcore.utils.PagedListConverter; @@ -42,7 +43,7 @@ public String displayName() { } @Override - public String state() { + public SubscriptionState state() { return this.inner().state(); } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/SubscriptionInner.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/SubscriptionInner.java index 3df85962e4122..aa2d9017eaa2a 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/SubscriptionInner.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/SubscriptionInner.java @@ -8,37 +8,58 @@ package com.microsoft.azure.management.resources.implementation; +import com.microsoft.azure.management.resources.SubscriptionState; import com.microsoft.azure.management.resources.SubscriptionPolicies; +import com.fasterxml.jackson.annotation.JsonProperty; /** * Subscription information. */ public class SubscriptionInner { /** - * Gets or sets the ID of the resource (/subscriptions/SubscriptionId). + * The fully qualified Id. For example, + * /subscriptions/00000000-0000-0000-0000-000000000000. */ + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) private String id; /** - * Gets or sets the subscription Id. + * The subscription Id. */ + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) private String subscriptionId; /** - * Gets or sets the subscription display name. + * The tenant Id. */ + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) + private String tenantId; + + /** + * The subscription display name. + */ + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) private String displayName; /** - * Gets or sets the subscription state. + * The subscription state. Possible values include: 'Enabled', 'Warned', + * 'PastDue', 'Disabled', 'Deleted'. */ - private String state; + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) + private SubscriptionState state; /** - * Gets or sets the subscription policies. + * The subscription policies. */ private SubscriptionPolicies subscriptionPolicies; + /** + * The authorization source of the request. Valid values are one or more + * combinations of Legacy, RoleBased, Bypassed, Direct and Management. + * For example, 'Legacy, RoleBased'. + */ + private String authorizationSource; + /** * Get the id value. * @@ -48,17 +69,6 @@ public String id() { return this.id; } - /** - * Set the id value. - * - * @param id the id value to set - * @return the SubscriptionInner object itself. - */ - public SubscriptionInner withId(String id) { - this.id = id; - return this; - } - /** * Get the subscriptionId value. * @@ -69,14 +79,12 @@ public String subscriptionId() { } /** - * Set the subscriptionId value. + * Get the tenantId value. * - * @param subscriptionId the subscriptionId value to set - * @return the SubscriptionInner object itself. + * @return the tenantId value */ - public SubscriptionInner withSubscriptionId(String subscriptionId) { - this.subscriptionId = subscriptionId; - return this; + public String tenantId() { + return this.tenantId; } /** @@ -89,53 +97,51 @@ public String displayName() { } /** - * Set the displayName value. + * Get the state value. * - * @param displayName the displayName value to set - * @return the SubscriptionInner object itself. + * @return the state value */ - public SubscriptionInner withDisplayName(String displayName) { - this.displayName = displayName; - return this; + public SubscriptionState state() { + return this.state; } /** - * Get the state value. + * Get the subscriptionPolicies value. * - * @return the state value + * @return the subscriptionPolicies value */ - public String state() { - return this.state; + public SubscriptionPolicies subscriptionPolicies() { + return this.subscriptionPolicies; } /** - * Set the state value. + * Set the subscriptionPolicies value. * - * @param state the state value to set + * @param subscriptionPolicies the subscriptionPolicies value to set * @return the SubscriptionInner object itself. */ - public SubscriptionInner withState(String state) { - this.state = state; + public SubscriptionInner withSubscriptionPolicies(SubscriptionPolicies subscriptionPolicies) { + this.subscriptionPolicies = subscriptionPolicies; return this; } /** - * Get the subscriptionPolicies value. + * Get the authorizationSource value. * - * @return the subscriptionPolicies value + * @return the authorizationSource value */ - public SubscriptionPolicies subscriptionPolicies() { - return this.subscriptionPolicies; + public String authorizationSource() { + return this.authorizationSource; } /** - * Set the subscriptionPolicies value. + * Set the authorizationSource value. * - * @param subscriptionPolicies the subscriptionPolicies value to set + * @param authorizationSource the authorizationSource value to set * @return the SubscriptionInner object itself. */ - public SubscriptionInner withSubscriptionPolicies(SubscriptionPolicies subscriptionPolicies) { - this.subscriptionPolicies = subscriptionPolicies; + public SubscriptionInner withAuthorizationSource(String authorizationSource) { + this.authorizationSource = authorizationSource; return this; } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/SubscriptionsInner.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/SubscriptionsInner.java index 259fa24a190e7..a6a18dbd8061a 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/SubscriptionsInner.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/SubscriptionsInner.java @@ -217,7 +217,7 @@ private ServiceResponse getDelegate(Response re } /** - * Gets a list of the subscriptionIds. + * Gets a list of subscriptions. * * @return the PagedList<SubscriptionInner> object if successful. */ @@ -232,7 +232,7 @@ public Page nextPage(String nextPageLink) { } /** - * Gets a list of the subscriptionIds. + * Gets a list of subscriptions. * * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object @@ -250,7 +250,7 @@ public Observable>> call(String nextPage } /** - * Gets a list of the subscriptionIds. + * Gets a list of subscriptions. * * @return the observable to the PagedList<SubscriptionInner> object */ @@ -265,7 +265,7 @@ public Page call(ServiceResponse> res } /** - * Gets a list of the subscriptionIds. + * Gets a list of subscriptions. * * @return the observable to the PagedList<SubscriptionInner> object */ @@ -284,7 +284,7 @@ public Observable>> call(ServiceResponse } /** - * Gets a list of the subscriptionIds. + * Gets a list of subscriptions. * * @return the PagedList<SubscriptionInner> object wrapped in {@link ServiceResponse} if successful. */ @@ -314,7 +314,7 @@ private ServiceResponse> listDelegate(Response nextPage(String nextPageLink) { } /** - * Gets a list of the subscriptionIds. + * Gets a list of subscriptions. * * @param nextPageLink The NextLink from the previous successful call to List operation. * @param serviceCall the ServiceCall object tracking the Retrofit calls @@ -350,7 +350,7 @@ public Observable>> call(String nextPage } /** - * Gets a list of the subscriptionIds. + * Gets a list of subscriptions. * * @param nextPageLink The NextLink from the previous successful call to List operation. * @return the observable to the PagedList<SubscriptionInner> object @@ -366,7 +366,7 @@ public Page call(ServiceResponse> res } /** - * Gets a list of the subscriptionIds. + * Gets a list of subscriptions. * * @param nextPageLink The NextLink from the previous successful call to List operation. * @return the observable to the PagedList<SubscriptionInner> object @@ -386,7 +386,7 @@ public Observable>> call(ServiceResponse } /** - * Gets a list of the subscriptionIds. + * Gets a list of subscriptions. * ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. * @return the PagedList<SubscriptionInner> object wrapped in {@link ServiceResponse} if successful. diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/TenantIdDescriptionInner.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/TenantIdDescriptionInner.java index e66e1d0472c32..1cf7fcc09cf72 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/TenantIdDescriptionInner.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/TenantIdDescriptionInner.java @@ -8,19 +8,23 @@ package com.microsoft.azure.management.resources.implementation; +import com.fasterxml.jackson.annotation.JsonProperty; /** * Tenant Id information. */ public class TenantIdDescriptionInner { /** - * Gets or sets Id. + * The fully qualified Id. For example, + * /tenants/00000000-0000-0000-0000-000000000000. */ + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) private String id; /** - * Gets or sets tenantId. + * The tenantId. For example, 00000000-0000-0000-0000-000000000000. */ + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) private String tenantId; /** @@ -32,17 +36,6 @@ public String id() { return this.id; } - /** - * Set the id value. - * - * @param id the id value to set - * @return the TenantIdDescriptionInner object itself. - */ - public TenantIdDescriptionInner withId(String id) { - this.id = id; - return this; - } - /** * Get the tenantId value. * @@ -52,15 +45,4 @@ public String tenantId() { return this.tenantId; } - /** - * Set the tenantId value. - * - * @param tenantId the tenantId value to set - * @return the TenantIdDescriptionInner object itself. - */ - public TenantIdDescriptionInner withTenantId(String tenantId) { - this.tenantId = tenantId; - return this; - } - } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/TenantsInner.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/TenantsInner.java index b1f43fac8b23a..1cd7a556fcccc 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/TenantsInner.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/TenantsInner.java @@ -67,7 +67,7 @@ interface TenantsService { } /** - * Gets a list of the tenantIds. + * Gets a list of tenants. * * @return the PagedList<TenantIdDescriptionInner> object if successful. */ @@ -82,7 +82,7 @@ public Page nextPage(String nextPageLink) { } /** - * Gets a list of the tenantIds. + * Gets a list of tenants. * * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object @@ -100,7 +100,7 @@ public Observable>> call(String n } /** - * Gets a list of the tenantIds. + * Gets a list of tenants. * * @return the observable to the PagedList<TenantIdDescriptionInner> object */ @@ -115,7 +115,7 @@ public Page call(ServiceResponse>> call(ServiceR } /** - * Gets a list of the tenantIds. + * Gets a list of tenants. * * @return the PagedList<TenantIdDescriptionInner> object wrapped in {@link ServiceResponse} if successful. */ @@ -164,7 +164,7 @@ private ServiceResponse> listDelegate(Respon } /** - * Gets a list of the tenantIds. + * Gets a list of tenants. * * @param nextPageLink The NextLink from the previous successful call to List operation. * @return the PagedList<TenantIdDescriptionInner> object if successful. @@ -180,7 +180,7 @@ public Page nextPage(String nextPageLink) { } /** - * Gets a list of the tenantIds. + * Gets a list of tenants. * * @param nextPageLink The NextLink from the previous successful call to List operation. * @param serviceCall the ServiceCall object tracking the Retrofit calls @@ -200,7 +200,7 @@ public Observable>> call(String n } /** - * Gets a list of the tenantIds. + * Gets a list of tenants. * * @param nextPageLink The NextLink from the previous successful call to List operation. * @return the observable to the PagedList<TenantIdDescriptionInner> object @@ -216,7 +216,7 @@ public Page call(ServiceResponse>> call(ServiceR } /** - * Gets a list of the tenantIds. + * Gets a list of tenants. * ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. * @return the PagedList<TenantIdDescriptionInner> object wrapped in {@link ServiceResponse} if successful. diff --git a/azure-samples/src/main/java/com/microsoft/azure/management/resources/samples/DeployUsingARMTemplateWithTags.java b/azure-samples/src/main/java/com/microsoft/azure/management/resources/samples/DeployUsingARMTemplateWithTags.java index a1f8846d438f9..11e5c5482681b 100644 --- a/azure-samples/src/main/java/com/microsoft/azure/management/resources/samples/DeployUsingARMTemplateWithTags.java +++ b/azure-samples/src/main/java/com/microsoft/azure/management/resources/samples/DeployUsingARMTemplateWithTags.java @@ -51,7 +51,7 @@ public static void main(String[] args) { final File credFile = new File(System.getenv("AZURE_AUTH_LOCATION")); Azure azure = Azure.configure() - .withLogLevel(HttpLoggingInterceptor.Level.HEADERS) + .withLogLevel(HttpLoggingInterceptor.Level.NONE) .authenticate(credFile) .withDefaultSubscription(); @@ -83,7 +83,7 @@ public static void main(String[] args) { .withMode(DeploymentMode.INCREMENTAL) .create(); - System.out.println("Starting a deployment for an Azure App Service: " + deploymentName); + System.out.println("Finished a deployment for an Azure App Service: " + deploymentName); List operations = deployment.deploymentOperations().list(); List genericResources = new ArrayList<>(); diff --git a/gulpfile.js b/gulpfile.js index ebefbd1b3d7f1..8f04908786960 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -31,12 +31,12 @@ var mappings = { }, 'resources': { 'dir': 'azure-mgmt-resources', - 'source': 'arm-resources/resources/2016-02-01/swagger/resources.json', + 'source': 'arm-resources/resources/2016-09-01/swagger/resources.json', 'package': 'com.microsoft.azure.management.resources' }, 'subscriptions': { 'dir': 'azure-mgmt-resources', - 'source': 'arm-resources/subscriptions/2015-11-01/swagger/subscriptions.json', + 'source': 'arm-resources/subscriptions/2016-06-01/swagger/subscriptions.json', 'package': 'com.microsoft.azure.management.resources' }, 'features': { From eb68cb7ae517bcc3f9399b21e8b54c127594771e Mon Sep 17 00:00:00 2001 From: Jianghao Lu Date: Mon, 17 Oct 2016 20:41:37 -0700 Subject: [PATCH 7/7] javadoc and checkstyles --- .../management/resources/fluentcore/arm/ResourceUtils.java | 7 +++++++ .../fluentcore/arm/collection/SupportsListingByTag.java | 1 + .../resources/implementation/GenericResourceImpl.java | 1 - 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/ResourceUtils.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/ResourceUtils.java index 5c127f8b2d545..96421716ddb56 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/ResourceUtils.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/ResourceUtils.java @@ -52,6 +52,13 @@ public static String parentResourcePathFromResourceId(String id) { return id.replace("/" + resourceTypeFromResourceId(id) + "/" + nameFromResourceId(id), ""); } + /** + * Extract the relative path to the current resource provider. + * E.g. subscriptions/sub1/resourceGroups/rg1/providers/Microsoft.Foo/foos/foo1 will return foos/foo1. + * + * @param id the id of the resource + * @return the relative path + */ public static String relativePathFromResourceId(String id) { String[] paths = id.split("/providers/" + resourceProviderFromResourceId(id) + "/", 2); if (paths.length == 1) { diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/SupportsListingByTag.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/SupportsListingByTag.java index 24a22be800432..684968a9775a3 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/SupportsListingByTag.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/SupportsListingByTag.java @@ -22,6 +22,7 @@ public interface SupportsListingByTag { /** * Lists all the resources with the specified tag. * + * @param resourceGroupName the name of the resource group * @param tagName tag's name as the key * @param tagValue tag's value * @return list of resources diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/GenericResourceImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/GenericResourceImpl.java index 52233889f039f..ab6e474eafcba 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/GenericResourceImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/GenericResourceImpl.java @@ -14,7 +14,6 @@ import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils; import com.microsoft.azure.management.resources.fluentcore.arm.models.implementation.GroupableResourceImpl; import rx.Observable; -import rx.exceptions.Exceptions; import rx.functions.Func1; import rx.schedulers.Schedulers;