diff --git a/azure-mgmt-managementgroups/src/main/java/com/microsoft/azure/management/managementgroups/ErrorDetails.java b/azure-mgmt-managementgroups/src/main/java/com/microsoft/azure/management/managementgroups/ErrorDetails.java new file mode 100644 index 00000000000..c3341f493d2 --- /dev/null +++ b/azure-mgmt-managementgroups/src/main/java/com/microsoft/azure/management/managementgroups/ErrorDetails.java @@ -0,0 +1,69 @@ +/** + * 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.managementgroups; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The details of the error. + */ +public class ErrorDetails { + /** + * One of a server-defined set of error codes. + */ + @JsonProperty(value = "code") + private String code; + + /** + * A human-readable representation of the error. + */ + @JsonProperty(value = "message") + private String message; + + /** + * Get the code value. + * + * @return the code value + */ + public String code() { + return this.code; + } + + /** + * Set the code value. + * + * @param code the code value to set + * @return the ErrorDetails object itself. + */ + public ErrorDetails withCode(String code) { + this.code = code; + return this; + } + + /** + * Get the message value. + * + * @return the message value + */ + public String message() { + return this.message; + } + + /** + * Set the message value. + * + * @param message the message value to set + * @return the ErrorDetails object itself. + */ + public ErrorDetails withMessage(String message) { + this.message = message; + return this; + } + +} diff --git a/azure-mgmt-managementgroups/src/main/java/com/microsoft/azure/management/managementgroups/ErrorResponse.java b/azure-mgmt-managementgroups/src/main/java/com/microsoft/azure/management/managementgroups/ErrorResponse.java new file mode 100644 index 00000000000..91af58df21e --- /dev/null +++ b/azure-mgmt-managementgroups/src/main/java/com/microsoft/azure/management/managementgroups/ErrorResponse.java @@ -0,0 +1,43 @@ +/** + * 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.managementgroups; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The error object. + */ +public class ErrorResponse { + /** + * Error. + */ + @JsonProperty(value = "error") + private ErrorDetails error; + + /** + * Get the error value. + * + * @return the error value + */ + public ErrorDetails error() { + return this.error; + } + + /** + * Set the error value. + * + * @param error the error value to set + * @return the ErrorResponse object itself. + */ + public ErrorResponse withError(ErrorDetails error) { + this.error = error; + return this; + } + +} diff --git a/azure-mgmt-managementgroups/src/main/java/com/microsoft/azure/management/managementgroups/ErrorResponseException.java b/azure-mgmt-managementgroups/src/main/java/com/microsoft/azure/management/managementgroups/ErrorResponseException.java new file mode 100644 index 00000000000..7bbbb1bc6f3 --- /dev/null +++ b/azure-mgmt-managementgroups/src/main/java/com/microsoft/azure/management/managementgroups/ErrorResponseException.java @@ -0,0 +1,44 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.managementgroups; + +import com.microsoft.rest.RestException; +import okhttp3.ResponseBody; +import retrofit2.Response; + +/** + * Exception thrown for an invalid response with ErrorResponse information. + */ +public class ErrorResponseException extends RestException { + /** + * Initializes a new instance of the ErrorResponseException class. + * + * @param message the exception message or the response content if a message is not available + * @param response the HTTP response + */ + public ErrorResponseException(final String message, final Response response) { + super(message, response); + } + + /** + * Initializes a new instance of the ErrorResponseException class. + * + * @param message the exception message or the response content if a message is not available + * @param response the HTTP response + * @param body the deserialized response body + */ + public ErrorResponseException(final String message, final Response response, final ErrorResponse body) { + super(message, response, body); + } + + @Override + public ErrorResponse body() { + return (ErrorResponse) super.body(); + } +} diff --git a/azure-mgmt-managementgroups/src/main/java/com/microsoft/azure/management/managementgroups/ManagementGroupChildInfo.java b/azure-mgmt-managementgroups/src/main/java/com/microsoft/azure/management/managementgroups/ManagementGroupChildInfo.java new file mode 100644 index 00000000000..5fb30c8e5f8 --- /dev/null +++ b/azure-mgmt-managementgroups/src/main/java/com/microsoft/azure/management/managementgroups/ManagementGroupChildInfo.java @@ -0,0 +1,125 @@ +/** + * 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.managementgroups; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The child information of a management group. + */ +public class ManagementGroupChildInfo { + /** + * The type of child resource. + * Possible values include: 'ManagementGroup', 'Subscription'. + */ + @JsonProperty(value = "childType") + private String childType; + + /** + * The fully qualified ID for the child resource (management group or + * subscription). For example, + * /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000. + */ + @JsonProperty(value = "childId") + private String childId; + + /** + * The friendly name of the child resource. + */ + @JsonProperty(value = "displayName") + private String displayName; + + /** + * The list of children. + */ + @JsonProperty(value = "children") + private List children; + + /** + * Get the childType value. + * + * @return the childType value + */ + public String childType() { + return this.childType; + } + + /** + * Set the childType value. + * + * @param childType the childType value to set + * @return the ManagementGroupChildInfo object itself. + */ + public ManagementGroupChildInfo withChildType(String childType) { + this.childType = childType; + return this; + } + + /** + * Get the childId value. + * + * @return the childId value + */ + public String childId() { + return this.childId; + } + + /** + * Set the childId value. + * + * @param childId the childId value to set + * @return the ManagementGroupChildInfo object itself. + */ + public ManagementGroupChildInfo withChildId(String childId) { + this.childId = childId; + return this; + } + + /** + * Get the displayName value. + * + * @return the displayName value + */ + public String displayName() { + return this.displayName; + } + + /** + * Set the displayName value. + * + * @param displayName the displayName value to set + * @return the ManagementGroupChildInfo object itself. + */ + public ManagementGroupChildInfo withDisplayName(String displayName) { + this.displayName = displayName; + return this; + } + + /** + * Get the children value. + * + * @return the children value + */ + public List children() { + return this.children; + } + + /** + * Set the children value. + * + * @param children the children value to set + * @return the ManagementGroupChildInfo object itself. + */ + public ManagementGroupChildInfo withChildren(List children) { + this.children = children; + return this; + } + +} diff --git a/azure-mgmt-managementgroups/src/main/java/com/microsoft/azure/management/managementgroups/ManagementGroupDetails.java b/azure-mgmt-managementgroups/src/main/java/com/microsoft/azure/management/managementgroups/ManagementGroupDetails.java new file mode 100644 index 00000000000..2fa32afacac --- /dev/null +++ b/azure-mgmt-managementgroups/src/main/java/com/microsoft/azure/management/managementgroups/ManagementGroupDetails.java @@ -0,0 +1,122 @@ +/** + * 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.managementgroups; + +import org.joda.time.DateTime; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The details of a management group. + */ +public class ManagementGroupDetails { + /** + * The version number of the object. + */ + @JsonProperty(value = "version") + private Double version; + + /** + * The date and time when this object was last updated. + */ + @JsonProperty(value = "updatedTime") + private DateTime updatedTime; + + /** + * The identity of the principal or process that updated the object. + */ + @JsonProperty(value = "updatedBy") + private String updatedBy; + + /** + * Parent. + */ + @JsonProperty(value = "parent") + private ParentGroupInfo parent; + + /** + * Get the version value. + * + * @return the version value + */ + public Double version() { + return this.version; + } + + /** + * Set the version value. + * + * @param version the version value to set + * @return the ManagementGroupDetails object itself. + */ + public ManagementGroupDetails withVersion(Double version) { + this.version = version; + return this; + } + + /** + * Get the updatedTime value. + * + * @return the updatedTime value + */ + public DateTime updatedTime() { + return this.updatedTime; + } + + /** + * Set the updatedTime value. + * + * @param updatedTime the updatedTime value to set + * @return the ManagementGroupDetails object itself. + */ + public ManagementGroupDetails withUpdatedTime(DateTime updatedTime) { + this.updatedTime = updatedTime; + return this; + } + + /** + * Get the updatedBy value. + * + * @return the updatedBy value + */ + public String updatedBy() { + return this.updatedBy; + } + + /** + * Set the updatedBy value. + * + * @param updatedBy the updatedBy value to set + * @return the ManagementGroupDetails object itself. + */ + public ManagementGroupDetails withUpdatedBy(String updatedBy) { + this.updatedBy = updatedBy; + return this; + } + + /** + * Get the parent value. + * + * @return the parent value + */ + public ParentGroupInfo parent() { + return this.parent; + } + + /** + * Set the parent value. + * + * @param parent the parent value to set + * @return the ManagementGroupDetails object itself. + */ + public ManagementGroupDetails withParent(ParentGroupInfo parent) { + this.parent = parent; + return this; + } + +} diff --git a/azure-mgmt-managementgroups/src/main/java/com/microsoft/azure/management/managementgroups/OperationDisplay.java b/azure-mgmt-managementgroups/src/main/java/com/microsoft/azure/management/managementgroups/OperationDisplay.java new file mode 100644 index 00000000000..e02dd0aedea --- /dev/null +++ b/azure-mgmt-managementgroups/src/main/java/com/microsoft/azure/management/managementgroups/OperationDisplay.java @@ -0,0 +1,77 @@ +/** + * 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.managementgroups; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The object that represents the operation. + */ +public class OperationDisplay { + /** + * The name of the provider. + */ + @JsonProperty(value = "provider", access = JsonProperty.Access.WRITE_ONLY) + private String provider; + + /** + * The resource on which the operation is performed. + */ + @JsonProperty(value = "resource", access = JsonProperty.Access.WRITE_ONLY) + private String resource; + + /** + * The operation that can be performed. + */ + @JsonProperty(value = "operation", access = JsonProperty.Access.WRITE_ONLY) + private String operation; + + /** + * Operation description. + */ + @JsonProperty(value = "description", access = JsonProperty.Access.WRITE_ONLY) + private String description; + + /** + * Get the provider value. + * + * @return the provider value + */ + public String provider() { + return this.provider; + } + + /** + * Get the resource value. + * + * @return the resource value + */ + public String resource() { + return this.resource; + } + + /** + * Get the operation value. + * + * @return the operation value + */ + public String operation() { + return this.operation; + } + + /** + * Get the description value. + * + * @return the description value + */ + public String description() { + return this.description; + } + +} diff --git a/azure-mgmt-managementgroups/src/main/java/com/microsoft/azure/management/managementgroups/ParentGroupInfo.java b/azure-mgmt-managementgroups/src/main/java/com/microsoft/azure/management/managementgroups/ParentGroupInfo.java new file mode 100644 index 00000000000..bea62c50d01 --- /dev/null +++ b/azure-mgmt-managementgroups/src/main/java/com/microsoft/azure/management/managementgroups/ParentGroupInfo.java @@ -0,0 +1,70 @@ +/** + * 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.managementgroups; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * (Optional) The ID of the parent management group. + */ +public class ParentGroupInfo { + /** + * The fully qualified ID for the parent management group. For example, + * /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000. + */ + @JsonProperty(value = "parentId") + private String parentId; + + /** + * The friendly name of the parent management group. + */ + @JsonProperty(value = "displayName") + private String displayName; + + /** + * Get the parentId value. + * + * @return the parentId value + */ + public String parentId() { + return this.parentId; + } + + /** + * Set the parentId value. + * + * @param parentId the parentId value to set + * @return the ParentGroupInfo object itself. + */ + public ParentGroupInfo withParentId(String parentId) { + this.parentId = parentId; + return this; + } + + /** + * Get the displayName value. + * + * @return the displayName value + */ + public String displayName() { + return this.displayName; + } + + /** + * Set the displayName value. + * + * @param displayName the displayName value to set + * @return the ParentGroupInfo object itself. + */ + public ParentGroupInfo withDisplayName(String displayName) { + this.displayName = displayName; + return this; + } + +} diff --git a/azure-mgmt-managementgroups/src/main/java/com/microsoft/azure/management/managementgroups/implementation/CreateManagementGroupRequestInner.java b/azure-mgmt-managementgroups/src/main/java/com/microsoft/azure/management/managementgroups/implementation/CreateManagementGroupRequestInner.java new file mode 100644 index 00000000000..52c5051f56a --- /dev/null +++ b/azure-mgmt-managementgroups/src/main/java/com/microsoft/azure/management/managementgroups/implementation/CreateManagementGroupRequestInner.java @@ -0,0 +1,71 @@ +/** + * 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.managementgroups.implementation; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Management group creation parameters. + */ +public class CreateManagementGroupRequestInner { + /** + * The friendly name of the management group. + */ + @JsonProperty(value = "displayName") + private String displayName; + + /** + * (Optional) The fully qualified ID for the parent management group. For + * example, + * /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000. + */ + @JsonProperty(value = "parentId") + private String parentId; + + /** + * Get the displayName value. + * + * @return the displayName value + */ + public String displayName() { + return this.displayName; + } + + /** + * Set the displayName value. + * + * @param displayName the displayName value to set + * @return the CreateManagementGroupRequestInner object itself. + */ + public CreateManagementGroupRequestInner withDisplayName(String displayName) { + this.displayName = displayName; + return this; + } + + /** + * Get the parentId value. + * + * @return the parentId value + */ + public String parentId() { + return this.parentId; + } + + /** + * Set the parentId value. + * + * @param parentId the parentId value to set + * @return the CreateManagementGroupRequestInner object itself. + */ + public CreateManagementGroupRequestInner withParentId(String parentId) { + this.parentId = parentId; + return this; + } + +} diff --git a/azure-mgmt-managementgroups/src/main/java/com/microsoft/azure/management/managementgroups/implementation/ManagementGroupInfoInner.java b/azure-mgmt-managementgroups/src/main/java/com/microsoft/azure/management/managementgroups/implementation/ManagementGroupInfoInner.java new file mode 100644 index 00000000000..e7c24880027 --- /dev/null +++ b/azure-mgmt-managementgroups/src/main/java/com/microsoft/azure/management/managementgroups/implementation/ManagementGroupInfoInner.java @@ -0,0 +1,120 @@ +/** + * 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.managementgroups.implementation; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.microsoft.rest.serializer.JsonFlatten; + +/** + * The management group resource. + */ +@JsonFlatten +public class ManagementGroupInfoInner { + /** + * The fully qualified ID for the management group. For example, + * /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000. + */ + @JsonProperty(value = "id", access = JsonProperty.Access.WRITE_ONLY) + private String id; + + /** + * The type of the resource. For example, + * /providers/Microsoft.Management/managementGroups. + */ + @JsonProperty(value = "type", access = JsonProperty.Access.WRITE_ONLY) + private String type; + + /** + * The name of the management group. For example, + * 00000000-0000-0000-0000-000000000000. + */ + @JsonProperty(value = "name", access = JsonProperty.Access.WRITE_ONLY) + private String name; + + /** + * The AAD Tenant ID associated with the management group. For example, + * 00000000-0000-0000-0000-000000000000. + */ + @JsonProperty(value = "properties.tenantId") + private String tenantId; + + /** + * The friendly name of the management group. + */ + @JsonProperty(value = "properties.displayName") + private String displayName; + + /** + * Get the id value. + * + * @return the id value + */ + public String id() { + return this.id; + } + + /** + * Get the type value. + * + * @return the type value + */ + public String type() { + return this.type; + } + + /** + * Get the name value. + * + * @return the name value + */ + public String name() { + return this.name; + } + + /** + * Get the tenantId value. + * + * @return the tenantId value + */ + public String tenantId() { + return this.tenantId; + } + + /** + * Set the tenantId value. + * + * @param tenantId the tenantId value to set + * @return the ManagementGroupInfoInner object itself. + */ + public ManagementGroupInfoInner withTenantId(String tenantId) { + this.tenantId = tenantId; + return this; + } + + /** + * Get the displayName value. + * + * @return the displayName value + */ + public String displayName() { + return this.displayName; + } + + /** + * Set the displayName value. + * + * @param displayName the displayName value to set + * @return the ManagementGroupInfoInner object itself. + */ + public ManagementGroupInfoInner withDisplayName(String displayName) { + this.displayName = displayName; + return this; + } + +} diff --git a/azure-mgmt-managementgroups/src/main/java/com/microsoft/azure/management/managementgroups/implementation/ManagementGroupInner.java b/azure-mgmt-managementgroups/src/main/java/com/microsoft/azure/management/managementgroups/implementation/ManagementGroupInner.java new file mode 100644 index 00000000000..83de6306622 --- /dev/null +++ b/azure-mgmt-managementgroups/src/main/java/com/microsoft/azure/management/managementgroups/implementation/ManagementGroupInner.java @@ -0,0 +1,175 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.managementgroups.implementation; + +import com.microsoft.azure.management.managementgroups.ManagementGroupDetails; +import java.util.List; +import com.microsoft.azure.management.managementgroups.ManagementGroupChildInfo; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.microsoft.rest.serializer.JsonFlatten; + +/** + * The management group details. + */ +@JsonFlatten +public class ManagementGroupInner { + /** + * The fully qualified ID for the management group. For example, + * /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000. + */ + @JsonProperty(value = "id", access = JsonProperty.Access.WRITE_ONLY) + private String id; + + /** + * The type of the resource. For example, + * /providers/Microsoft.Management/managementGroups. + */ + @JsonProperty(value = "type", access = JsonProperty.Access.WRITE_ONLY) + private String type; + + /** + * The name of the management group. For example, + * 00000000-0000-0000-0000-000000000000. + */ + @JsonProperty(value = "name", access = JsonProperty.Access.WRITE_ONLY) + private String name; + + /** + * The AAD Tenant ID associated with the management group. For example, + * 00000000-0000-0000-0000-000000000000. + */ + @JsonProperty(value = "properties.tenantId") + private String tenantId; + + /** + * The friendly name of the management group. + */ + @JsonProperty(value = "properties.displayName") + private String displayName; + + /** + * Details. + */ + @JsonProperty(value = "properties.details") + private ManagementGroupDetails details; + + /** + * The list of children. + */ + @JsonProperty(value = "properties.children") + private List children; + + /** + * Get the id value. + * + * @return the id value + */ + public String id() { + return this.id; + } + + /** + * Get the type value. + * + * @return the type value + */ + public String type() { + return this.type; + } + + /** + * Get the name value. + * + * @return the name value + */ + public String name() { + return this.name; + } + + /** + * Get the tenantId value. + * + * @return the tenantId value + */ + public String tenantId() { + return this.tenantId; + } + + /** + * Set the tenantId value. + * + * @param tenantId the tenantId value to set + * @return the ManagementGroupInner object itself. + */ + public ManagementGroupInner withTenantId(String tenantId) { + this.tenantId = tenantId; + return this; + } + + /** + * Get the displayName value. + * + * @return the displayName value + */ + public String displayName() { + return this.displayName; + } + + /** + * Set the displayName value. + * + * @param displayName the displayName value to set + * @return the ManagementGroupInner object itself. + */ + public ManagementGroupInner withDisplayName(String displayName) { + this.displayName = displayName; + return this; + } + + /** + * Get the details value. + * + * @return the details value + */ + public ManagementGroupDetails details() { + return this.details; + } + + /** + * Set the details value. + * + * @param details the details value to set + * @return the ManagementGroupInner object itself. + */ + public ManagementGroupInner withDetails(ManagementGroupDetails details) { + this.details = details; + return this; + } + + /** + * Get the children value. + * + * @return the children value + */ + public List children() { + return this.children; + } + + /** + * Set the children value. + * + * @param children the children value to set + * @return the ManagementGroupInner object itself. + */ + public ManagementGroupInner withChildren(List children) { + this.children = children; + return this; + } + +} diff --git a/azure-mgmt-managementgroups/src/main/java/com/microsoft/azure/management/managementgroups/implementation/ManagementGroupSubscriptionsInner.java b/azure-mgmt-managementgroups/src/main/java/com/microsoft/azure/management/managementgroups/implementation/ManagementGroupSubscriptionsInner.java new file mode 100644 index 00000000000..9ace5af0cbb --- /dev/null +++ b/azure-mgmt-managementgroups/src/main/java/com/microsoft/azure/management/managementgroups/implementation/ManagementGroupSubscriptionsInner.java @@ -0,0 +1,390 @@ +/** + * 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.managementgroups.implementation; + +import com.microsoft.azure.management.resources.fluentcore.collection.InnerSupportsDelete; +import retrofit2.Retrofit; +import com.google.common.reflect.TypeToken; +import com.microsoft.azure.management.managementgroups.ErrorResponseException; +import com.microsoft.rest.ServiceCallback; +import com.microsoft.rest.ServiceFuture; +import com.microsoft.rest.ServiceResponse; +import java.io.IOException; +import okhttp3.ResponseBody; +import retrofit2.http.Header; +import retrofit2.http.Headers; +import retrofit2.http.HTTP; +import retrofit2.http.Path; +import retrofit2.http.PUT; +import retrofit2.http.Query; +import retrofit2.Response; +import rx.functions.Func1; +import rx.Observable; + +/** + * An instance of this class provides access to all the operations defined + * in ManagementGroupSubscriptions. + */ +public class ManagementGroupSubscriptionsInner implements InnerSupportsDelete { + /** The Retrofit service to perform REST calls. */ + private ManagementGroupSubscriptionsService service; + /** The service client containing this operation class. */ + private ManagementGroupsAPIImpl client; + + /** + * Initializes an instance of ManagementGroupSubscriptionsInner. + * + * @param retrofit the Retrofit instance built from a Retrofit Builder. + * @param client the instance of the service client containing this operation class. + */ + public ManagementGroupSubscriptionsInner(Retrofit retrofit, ManagementGroupsAPIImpl client) { + this.service = retrofit.create(ManagementGroupSubscriptionsService.class); + this.client = client; + } + + /** + * The interface defining all the services for ManagementGroupSubscriptions to be + * used by Retrofit to perform actually REST calls. + */ + interface ManagementGroupSubscriptionsService { + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.managementgroups.ManagementGroupSubscriptions create" }) + @PUT("providers/Microsoft.Management/managementGroups/{groupId}/subscriptions/{subscriptionId}") + Observable> create(@Path("groupId") String groupId, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("Cache-Control") String cacheControl, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.managementgroups.ManagementGroupSubscriptions delete" }) + @HTTP(path = "providers/Microsoft.Management/managementGroups/{groupId}/subscriptions/{subscriptionId}", method = "DELETE", hasBody = true) + Observable> delete(@Path("groupId") String groupId, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("Cache-Control") String cacheControl, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + } + + /** + * Associates existing subscription with the management group. + * + * @param groupId Management Group ID. + * @param subscriptionId Subscription ID. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void create(String groupId, String subscriptionId) { + createWithServiceResponseAsync(groupId, subscriptionId).toBlocking().single().body(); + } + + /** + * Associates existing subscription with the management group. + * + * @param groupId Management Group ID. + * @param subscriptionId Subscription ID. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture createAsync(String groupId, String subscriptionId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(createWithServiceResponseAsync(groupId, subscriptionId), serviceCallback); + } + + /** + * Associates existing subscription with the management group. + * + * @param groupId Management Group ID. + * @param subscriptionId Subscription ID. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable createAsync(String groupId, String subscriptionId) { + return createWithServiceResponseAsync(groupId, subscriptionId).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Associates existing subscription with the management group. + * + * @param groupId Management Group ID. + * @param subscriptionId Subscription ID. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> createWithServiceResponseAsync(String groupId, String subscriptionId) { + if (groupId == null) { + throw new IllegalArgumentException("Parameter groupId is required and cannot be null."); + } + if (subscriptionId == null) { + throw new IllegalArgumentException("Parameter subscriptionId is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + final String cacheControl = null; + return service.create(groupId, subscriptionId, this.client.apiVersion(), cacheControl, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = createDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * Associates existing subscription with the management group. + * + * @param groupId Management Group ID. + * @param subscriptionId Subscription ID. + * @param cacheControl Indicates that the request shouldn't utilize any caches. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void create(String groupId, String subscriptionId, String cacheControl) { + createWithServiceResponseAsync(groupId, subscriptionId, cacheControl).toBlocking().single().body(); + } + + /** + * Associates existing subscription with the management group. + * + * @param groupId Management Group ID. + * @param subscriptionId Subscription ID. + * @param cacheControl Indicates that the request shouldn't utilize any caches. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture createAsync(String groupId, String subscriptionId, String cacheControl, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(createWithServiceResponseAsync(groupId, subscriptionId, cacheControl), serviceCallback); + } + + /** + * Associates existing subscription with the management group. + * + * @param groupId Management Group ID. + * @param subscriptionId Subscription ID. + * @param cacheControl Indicates that the request shouldn't utilize any caches. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable createAsync(String groupId, String subscriptionId, String cacheControl) { + return createWithServiceResponseAsync(groupId, subscriptionId, cacheControl).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Associates existing subscription with the management group. + * + * @param groupId Management Group ID. + * @param subscriptionId Subscription ID. + * @param cacheControl Indicates that the request shouldn't utilize any caches. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> createWithServiceResponseAsync(String groupId, String subscriptionId, String cacheControl) { + if (groupId == null) { + throw new IllegalArgumentException("Parameter groupId is required and cannot be null."); + } + if (subscriptionId == null) { + throw new IllegalArgumentException("Parameter subscriptionId is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + return service.create(groupId, subscriptionId, this.client.apiVersion(), cacheControl, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = createDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse createDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(204, new TypeToken() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * De-associates subscription from the management group. + * + * @param groupId Management Group ID. + * @param subscriptionId Subscription ID. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void delete(String groupId, String subscriptionId) { + deleteWithServiceResponseAsync(groupId, subscriptionId).toBlocking().single().body(); + } + + /** + * De-associates subscription from the management group. + * + * @param groupId Management Group ID. + * @param subscriptionId Subscription ID. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture deleteAsync(String groupId, String subscriptionId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(deleteWithServiceResponseAsync(groupId, subscriptionId), serviceCallback); + } + + /** + * De-associates subscription from the management group. + * + * @param groupId Management Group ID. + * @param subscriptionId Subscription ID. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable deleteAsync(String groupId, String subscriptionId) { + return deleteWithServiceResponseAsync(groupId, subscriptionId).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * De-associates subscription from the management group. + * + * @param groupId Management Group ID. + * @param subscriptionId Subscription ID. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> deleteWithServiceResponseAsync(String groupId, String subscriptionId) { + if (groupId == null) { + throw new IllegalArgumentException("Parameter groupId is required and cannot be null."); + } + if (subscriptionId == null) { + throw new IllegalArgumentException("Parameter subscriptionId is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + final String cacheControl = null; + return service.delete(groupId, subscriptionId, this.client.apiVersion(), cacheControl, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = deleteDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * De-associates subscription from the management group. + * + * @param groupId Management Group ID. + * @param subscriptionId Subscription ID. + * @param cacheControl Indicates that the request shouldn't utilize any caches. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void delete(String groupId, String subscriptionId, String cacheControl) { + deleteWithServiceResponseAsync(groupId, subscriptionId, cacheControl).toBlocking().single().body(); + } + + /** + * De-associates subscription from the management group. + * + * @param groupId Management Group ID. + * @param subscriptionId Subscription ID. + * @param cacheControl Indicates that the request shouldn't utilize any caches. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture deleteAsync(String groupId, String subscriptionId, String cacheControl, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(deleteWithServiceResponseAsync(groupId, subscriptionId, cacheControl), serviceCallback); + } + + /** + * De-associates subscription from the management group. + * + * @param groupId Management Group ID. + * @param subscriptionId Subscription ID. + * @param cacheControl Indicates that the request shouldn't utilize any caches. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable deleteAsync(String groupId, String subscriptionId, String cacheControl) { + return deleteWithServiceResponseAsync(groupId, subscriptionId, cacheControl).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * De-associates subscription from the management group. + * + * @param groupId Management Group ID. + * @param subscriptionId Subscription ID. + * @param cacheControl Indicates that the request shouldn't utilize any caches. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> deleteWithServiceResponseAsync(String groupId, String subscriptionId, String cacheControl) { + if (groupId == null) { + throw new IllegalArgumentException("Parameter groupId is required and cannot be null."); + } + if (subscriptionId == null) { + throw new IllegalArgumentException("Parameter subscriptionId is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + return service.delete(groupId, subscriptionId, this.client.apiVersion(), cacheControl, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = deleteDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse deleteDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(204, new TypeToken() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + +} diff --git a/azure-mgmt-managementgroups/src/main/java/com/microsoft/azure/management/managementgroups/implementation/ManagementGroupsAPIImpl.java b/azure-mgmt-managementgroups/src/main/java/com/microsoft/azure/management/managementgroups/implementation/ManagementGroupsAPIImpl.java new file mode 100644 index 00000000000..17b031f3bce --- /dev/null +++ b/azure-mgmt-managementgroups/src/main/java/com/microsoft/azure/management/managementgroups/implementation/ManagementGroupsAPIImpl.java @@ -0,0 +1,201 @@ +/** + * 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.managementgroups.implementation; + +import com.microsoft.azure.AzureClient; +import com.microsoft.azure.AzureServiceClient; +import com.microsoft.rest.credentials.ServiceClientCredentials; +import com.microsoft.rest.RestClient; + +/** + * Initializes a new instance of the ManagementGroupsAPIImpl class. + */ +public class ManagementGroupsAPIImpl extends AzureServiceClient { + /** the {@link AzureClient} used for long running operations. */ + private AzureClient azureClient; + + /** + * Gets the {@link AzureClient} used for long running operations. + * @return the azure client; + */ + public AzureClient getAzureClient() { + return this.azureClient; + } + + /** Version of the API to be used with the client request. The current version is 2017-11-01-preview. */ + private String apiVersion; + + /** + * Gets Version of the API to be used with the client request. The current version is 2017-11-01-preview. + * + * @return the apiVersion value. + */ + public String apiVersion() { + return this.apiVersion; + } + + /** Gets or sets the preferred language for the response. */ + private String acceptLanguage; + + /** + * Gets Gets or sets the preferred language for the response. + * + * @return the acceptLanguage value. + */ + public String acceptLanguage() { + return this.acceptLanguage; + } + + /** + * Sets Gets or sets the preferred language for the response. + * + * @param acceptLanguage the acceptLanguage value. + * @return the service client itself + */ + public ManagementGroupsAPIImpl withAcceptLanguage(String acceptLanguage) { + this.acceptLanguage = acceptLanguage; + return this; + } + + /** Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30. */ + private int longRunningOperationRetryTimeout; + + /** + * Gets Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30. + * + * @return the longRunningOperationRetryTimeout value. + */ + public int longRunningOperationRetryTimeout() { + return this.longRunningOperationRetryTimeout; + } + + /** + * Sets Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30. + * + * @param longRunningOperationRetryTimeout the longRunningOperationRetryTimeout value. + * @return the service client itself + */ + public ManagementGroupsAPIImpl withLongRunningOperationRetryTimeout(int longRunningOperationRetryTimeout) { + this.longRunningOperationRetryTimeout = longRunningOperationRetryTimeout; + return this; + } + + /** When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. */ + private boolean generateClientRequestId; + + /** + * Gets When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. + * + * @return the generateClientRequestId value. + */ + public boolean generateClientRequestId() { + return this.generateClientRequestId; + } + + /** + * Sets When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. + * + * @param generateClientRequestId the generateClientRequestId value. + * @return the service client itself + */ + public ManagementGroupsAPIImpl withGenerateClientRequestId(boolean generateClientRequestId) { + this.generateClientRequestId = generateClientRequestId; + return this; + } + + /** + * The ManagementGroupsInner object to access its operations. + */ + private ManagementGroupsInner managementGroups; + + /** + * Gets the ManagementGroupsInner object to access its operations. + * @return the ManagementGroupsInner object. + */ + public ManagementGroupsInner managementGroups() { + return this.managementGroups; + } + + /** + * The ManagementGroupSubscriptionsInner object to access its operations. + */ + private ManagementGroupSubscriptionsInner managementGroupSubscriptions; + + /** + * Gets the ManagementGroupSubscriptionsInner object to access its operations. + * @return the ManagementGroupSubscriptionsInner object. + */ + public ManagementGroupSubscriptionsInner managementGroupSubscriptions() { + return this.managementGroupSubscriptions; + } + + /** + * The OperationsInner object to access its operations. + */ + private OperationsInner operations; + + /** + * Gets the OperationsInner object to access its operations. + * @return the OperationsInner object. + */ + public OperationsInner operations() { + return this.operations; + } + + /** + * Initializes an instance of ManagementGroupsAPI client. + * + * @param credentials the management credentials for Azure + */ + public ManagementGroupsAPIImpl(ServiceClientCredentials credentials) { + this("https://management.azure.com", credentials); + } + + /** + * Initializes an instance of ManagementGroupsAPI client. + * + * @param baseUrl the base URL of the host + * @param credentials the management credentials for Azure + */ + public ManagementGroupsAPIImpl(String baseUrl, ServiceClientCredentials credentials) { + super(baseUrl, credentials); + initialize(); + } + + /** + * Initializes an instance of ManagementGroupsAPI client. + * + * @param restClient the REST client to connect to Azure. + */ + public ManagementGroupsAPIImpl(RestClient restClient) { + super(restClient); + initialize(); + } + + protected void initialize() { + this.apiVersion = "2017-11-01-preview"; + this.acceptLanguage = "en-US"; + this.longRunningOperationRetryTimeout = 30; + this.generateClientRequestId = true; + this.managementGroups = new ManagementGroupsInner(restClient().retrofit(), this); + this.managementGroupSubscriptions = new ManagementGroupSubscriptionsInner(restClient().retrofit(), this); + this.operations = new OperationsInner(restClient().retrofit(), this); + this.azureClient = new AzureClient(this); + } + + /** + * Gets the User-Agent header for the client. + * + * @return the user agent string. + */ + @Override + public String userAgent() { + return String.format("%s (%s, %s)", super.userAgent(), "ManagementGroupsAPI", "2017-11-01-preview"); + } +} diff --git a/azure-mgmt-managementgroups/src/main/java/com/microsoft/azure/management/managementgroups/implementation/ManagementGroupsInner.java b/azure-mgmt-managementgroups/src/main/java/com/microsoft/azure/management/managementgroups/implementation/ManagementGroupsInner.java new file mode 100644 index 00000000000..2041d337428 --- /dev/null +++ b/azure-mgmt-managementgroups/src/main/java/com/microsoft/azure/management/managementgroups/implementation/ManagementGroupsInner.java @@ -0,0 +1,1187 @@ +/** + * 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.managementgroups.implementation; + +import retrofit2.Retrofit; +import com.google.common.reflect.TypeToken; +import com.microsoft.azure.AzureServiceFuture; +import com.microsoft.azure.ListOperationCallback; +import com.microsoft.azure.management.managementgroups.ErrorResponseException; +import com.microsoft.azure.Page; +import com.microsoft.azure.PagedList; +import com.microsoft.rest.ServiceCallback; +import com.microsoft.rest.ServiceFuture; +import com.microsoft.rest.ServiceResponse; +import com.microsoft.rest.Validator; +import java.io.IOException; +import java.util.List; +import okhttp3.ResponseBody; +import retrofit2.http.Body; +import retrofit2.http.GET; +import retrofit2.http.Header; +import retrofit2.http.Headers; +import retrofit2.http.HTTP; +import retrofit2.http.PATCH; +import retrofit2.http.Path; +import retrofit2.http.PUT; +import retrofit2.http.Query; +import retrofit2.http.Url; +import retrofit2.Response; +import rx.functions.Func1; +import rx.Observable; + +/** + * An instance of this class provides access to all the operations defined + * in ManagementGroups. + */ +public class ManagementGroupsInner { + /** The Retrofit service to perform REST calls. */ + private ManagementGroupsService service; + /** The service client containing this operation class. */ + private ManagementGroupsAPIImpl client; + + /** + * Initializes an instance of ManagementGroupsInner. + * + * @param retrofit the Retrofit instance built from a Retrofit Builder. + * @param client the instance of the service client containing this operation class. + */ + public ManagementGroupsInner(Retrofit retrofit, ManagementGroupsAPIImpl client) { + this.service = retrofit.create(ManagementGroupsService.class); + this.client = client; + } + + /** + * The interface defining all the services for ManagementGroups to be + * used by Retrofit to perform actually REST calls. + */ + interface ManagementGroupsService { + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.managementgroups.ManagementGroups list" }) + @GET("providers/Microsoft.Management/managementGroups") + Observable> list(@Query("api-version") String apiVersion, @Header("Cache-Control") String cacheControl, @Query("$skiptoken") String skiptoken, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.managementgroups.ManagementGroups get" }) + @GET("providers/Microsoft.Management/managementGroups/{groupId}") + Observable> get(@Path("groupId") String groupId, @Query("api-version") String apiVersion, @Query("$expand") String expand, @Query("$recurse") Boolean recurse, @Header("Cache-Control") String cacheControl, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.managementgroups.ManagementGroups createOrUpdate" }) + @PUT("providers/Microsoft.Management/managementGroups/{groupId}") + Observable> createOrUpdate(@Path("groupId") String groupId, @Query("api-version") String apiVersion, @Body CreateManagementGroupRequestInner createManagementGroupRequest, @Header("Cache-Control") String cacheControl, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.managementgroups.ManagementGroups update" }) + @PATCH("providers/Microsoft.Management/managementGroups/{groupId}") + Observable> update(@Path("groupId") String groupId, @Query("api-version") String apiVersion, @Body CreateManagementGroupRequestInner createManagementGroupRequest, @Header("Cache-Control") String cacheControl, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.managementgroups.ManagementGroups delete" }) + @HTTP(path = "providers/Microsoft.Management/managementGroups/{groupId}", method = "DELETE", hasBody = true) + Observable> delete(@Path("groupId") String groupId, @Query("api-version") String apiVersion, @Header("Cache-Control") String cacheControl, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.managementgroups.ManagementGroups listNext" }) + @GET + Observable> listNext(@Url String nextUrl, @Header("Cache-Control") String cacheControl, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + } + + /** + * List management groups for the authenticated user. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<ManagementGroupInfoInner> object if successful. + */ + public PagedList list() { + ServiceResponse> response = listSinglePageAsync().toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink, null).toBlocking().single().body(); + } + }; + } + + /** + * List management groups for the authenticated user. + * + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listAsync(final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listSinglePageAsync(), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink, null); + } + }, + serviceCallback); + } + + /** + * List management groups for the authenticated user. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<ManagementGroupInfoInner> object + */ + public Observable> listAsync() { + return listWithServiceResponseAsync() + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * List management groups for the authenticated user. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<ManagementGroupInfoInner> object + */ + public Observable>> listWithServiceResponseAsync() { + return listSinglePageAsync() + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listNextWithServiceResponseAsync(nextPageLink, null)); + } + }); + } + + /** + * List management groups for the authenticated user. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<ManagementGroupInfoInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listSinglePageAsync() { + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + final String cacheControl = null; + final String skiptoken = null; + return service.list(this.client.apiVersion(), cacheControl, skiptoken, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * List management groups for the authenticated user. + * + * @param cacheControl Indicates that the request shouldn't utilize any caches. + * @param skiptoken Page continuation token is only used if a previous operation returned a partial result. + If a previous response contains a nextLink element, the value of the nextLink element will include a token parameter that specifies a starting point to use for subsequent calls. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<ManagementGroupInfoInner> object if successful. + */ + public PagedList list(final String cacheControl, final String skiptoken) { + ServiceResponse> response = listSinglePageAsync(cacheControl, skiptoken).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink, cacheControl).toBlocking().single().body(); + } + }; + } + + /** + * List management groups for the authenticated user. + * + * @param cacheControl Indicates that the request shouldn't utilize any caches. + * @param skiptoken Page continuation token is only used if a previous operation returned a partial result. + If a previous response contains a nextLink element, the value of the nextLink element will include a token parameter that specifies a starting point to use for subsequent calls. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listAsync(final String cacheControl, final String skiptoken, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listSinglePageAsync(cacheControl, skiptoken), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink, cacheControl); + } + }, + serviceCallback); + } + + /** + * List management groups for the authenticated user. + * + * @param cacheControl Indicates that the request shouldn't utilize any caches. + * @param skiptoken Page continuation token is only used if a previous operation returned a partial result. + If a previous response contains a nextLink element, the value of the nextLink element will include a token parameter that specifies a starting point to use for subsequent calls. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<ManagementGroupInfoInner> object + */ + public Observable> listAsync(final String cacheControl, final String skiptoken) { + return listWithServiceResponseAsync(cacheControl, skiptoken) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * List management groups for the authenticated user. + * + * @param cacheControl Indicates that the request shouldn't utilize any caches. + * @param skiptoken Page continuation token is only used if a previous operation returned a partial result. + If a previous response contains a nextLink element, the value of the nextLink element will include a token parameter that specifies a starting point to use for subsequent calls. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<ManagementGroupInfoInner> object + */ + public Observable>> listWithServiceResponseAsync(final String cacheControl, final String skiptoken) { + return listSinglePageAsync(cacheControl, skiptoken) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listNextWithServiceResponseAsync(nextPageLink, cacheControl)); + } + }); + } + + /** + * List management groups for the authenticated user. + * + ServiceResponse> * @param cacheControl Indicates that the request shouldn't utilize any caches. + ServiceResponse> * @param skiptoken Page continuation token is only used if a previous operation returned a partial result. + If a previous response contains a nextLink element, the value of the nextLink element will include a token parameter that specifies a starting point to use for subsequent calls. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<ManagementGroupInfoInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listSinglePageAsync(final String cacheControl, final String skiptoken) { + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + return service.list(this.client.apiVersion(), cacheControl, skiptoken, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorResponseException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Get the details of the management group. + * + * @param groupId Management Group ID. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the ManagementGroupInner object if successful. + */ + public ManagementGroupInner get(String groupId) { + return getWithServiceResponseAsync(groupId).toBlocking().single().body(); + } + + /** + * Get the details of the management group. + * + * @param groupId Management Group ID. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture getAsync(String groupId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(getWithServiceResponseAsync(groupId), serviceCallback); + } + + /** + * Get the details of the management group. + * + * @param groupId Management Group ID. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the ManagementGroupInner object + */ + public Observable getAsync(String groupId) { + return getWithServiceResponseAsync(groupId).map(new Func1, ManagementGroupInner>() { + @Override + public ManagementGroupInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Get the details of the management group. + * + * @param groupId Management Group ID. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the ManagementGroupInner object + */ + public Observable> getWithServiceResponseAsync(String groupId) { + if (groupId == null) { + throw new IllegalArgumentException("Parameter groupId is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + final String expand = null; + final Boolean recurse = null; + final String cacheControl = null; + return service.get(groupId, this.client.apiVersion(), expand, recurse, cacheControl, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * Get the details of the management group. + * + * @param groupId Management Group ID. + * @param expand The $expand=children query string parameter allows clients to request inclusion of children in the response payload. Possible values include: 'children' + * @param recurse The $recurse=true query string parameter allows clients to request inclusion of entire hierarchy in the response payload. + * @param cacheControl Indicates that the request shouldn't utilize any caches. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the ManagementGroupInner object if successful. + */ + public ManagementGroupInner get(String groupId, String expand, Boolean recurse, String cacheControl) { + return getWithServiceResponseAsync(groupId, expand, recurse, cacheControl).toBlocking().single().body(); + } + + /** + * Get the details of the management group. + * + * @param groupId Management Group ID. + * @param expand The $expand=children query string parameter allows clients to request inclusion of children in the response payload. Possible values include: 'children' + * @param recurse The $recurse=true query string parameter allows clients to request inclusion of entire hierarchy in the response payload. + * @param cacheControl Indicates that the request shouldn't utilize any caches. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture getAsync(String groupId, String expand, Boolean recurse, String cacheControl, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(getWithServiceResponseAsync(groupId, expand, recurse, cacheControl), serviceCallback); + } + + /** + * Get the details of the management group. + * + * @param groupId Management Group ID. + * @param expand The $expand=children query string parameter allows clients to request inclusion of children in the response payload. Possible values include: 'children' + * @param recurse The $recurse=true query string parameter allows clients to request inclusion of entire hierarchy in the response payload. + * @param cacheControl Indicates that the request shouldn't utilize any caches. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the ManagementGroupInner object + */ + public Observable getAsync(String groupId, String expand, Boolean recurse, String cacheControl) { + return getWithServiceResponseAsync(groupId, expand, recurse, cacheControl).map(new Func1, ManagementGroupInner>() { + @Override + public ManagementGroupInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Get the details of the management group. + * + * @param groupId Management Group ID. + * @param expand The $expand=children query string parameter allows clients to request inclusion of children in the response payload. Possible values include: 'children' + * @param recurse The $recurse=true query string parameter allows clients to request inclusion of entire hierarchy in the response payload. + * @param cacheControl Indicates that the request shouldn't utilize any caches. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the ManagementGroupInner object + */ + public Observable> getWithServiceResponseAsync(String groupId, String expand, Boolean recurse, String cacheControl) { + if (groupId == null) { + throw new IllegalArgumentException("Parameter groupId is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + return service.get(groupId, this.client.apiVersion(), expand, recurse, cacheControl, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse getDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Create or update a management group. + If a management group is already created and a subsequent create request is issued with different properties, the management group properties will be updated. + * + * @param groupId Management Group ID. + * @param createManagementGroupRequest Management group creation parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the ManagementGroupInner object if successful. + */ + public ManagementGroupInner createOrUpdate(String groupId, CreateManagementGroupRequestInner createManagementGroupRequest) { + return createOrUpdateWithServiceResponseAsync(groupId, createManagementGroupRequest).toBlocking().single().body(); + } + + /** + * Create or update a management group. + If a management group is already created and a subsequent create request is issued with different properties, the management group properties will be updated. + * + * @param groupId Management Group ID. + * @param createManagementGroupRequest Management group creation parameters. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture createOrUpdateAsync(String groupId, CreateManagementGroupRequestInner createManagementGroupRequest, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(createOrUpdateWithServiceResponseAsync(groupId, createManagementGroupRequest), serviceCallback); + } + + /** + * Create or update a management group. + If a management group is already created and a subsequent create request is issued with different properties, the management group properties will be updated. + * + * @param groupId Management Group ID. + * @param createManagementGroupRequest Management group creation parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the ManagementGroupInner object + */ + public Observable createOrUpdateAsync(String groupId, CreateManagementGroupRequestInner createManagementGroupRequest) { + return createOrUpdateWithServiceResponseAsync(groupId, createManagementGroupRequest).map(new Func1, ManagementGroupInner>() { + @Override + public ManagementGroupInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Create or update a management group. + If a management group is already created and a subsequent create request is issued with different properties, the management group properties will be updated. + * + * @param groupId Management Group ID. + * @param createManagementGroupRequest Management group creation parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the ManagementGroupInner object + */ + public Observable> createOrUpdateWithServiceResponseAsync(String groupId, CreateManagementGroupRequestInner createManagementGroupRequest) { + if (groupId == null) { + throw new IllegalArgumentException("Parameter groupId is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + if (createManagementGroupRequest == null) { + throw new IllegalArgumentException("Parameter createManagementGroupRequest is required and cannot be null."); + } + Validator.validate(createManagementGroupRequest); + final String cacheControl = null; + return service.createOrUpdate(groupId, this.client.apiVersion(), createManagementGroupRequest, cacheControl, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = createOrUpdateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * Create or update a management group. + If a management group is already created and a subsequent create request is issued with different properties, the management group properties will be updated. + * + * @param groupId Management Group ID. + * @param createManagementGroupRequest Management group creation parameters. + * @param cacheControl Indicates that the request shouldn't utilize any caches. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the ManagementGroupInner object if successful. + */ + public ManagementGroupInner createOrUpdate(String groupId, CreateManagementGroupRequestInner createManagementGroupRequest, String cacheControl) { + return createOrUpdateWithServiceResponseAsync(groupId, createManagementGroupRequest, cacheControl).toBlocking().single().body(); + } + + /** + * Create or update a management group. + If a management group is already created and a subsequent create request is issued with different properties, the management group properties will be updated. + * + * @param groupId Management Group ID. + * @param createManagementGroupRequest Management group creation parameters. + * @param cacheControl Indicates that the request shouldn't utilize any caches. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture createOrUpdateAsync(String groupId, CreateManagementGroupRequestInner createManagementGroupRequest, String cacheControl, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(createOrUpdateWithServiceResponseAsync(groupId, createManagementGroupRequest, cacheControl), serviceCallback); + } + + /** + * Create or update a management group. + If a management group is already created and a subsequent create request is issued with different properties, the management group properties will be updated. + * + * @param groupId Management Group ID. + * @param createManagementGroupRequest Management group creation parameters. + * @param cacheControl Indicates that the request shouldn't utilize any caches. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the ManagementGroupInner object + */ + public Observable createOrUpdateAsync(String groupId, CreateManagementGroupRequestInner createManagementGroupRequest, String cacheControl) { + return createOrUpdateWithServiceResponseAsync(groupId, createManagementGroupRequest, cacheControl).map(new Func1, ManagementGroupInner>() { + @Override + public ManagementGroupInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Create or update a management group. + If a management group is already created and a subsequent create request is issued with different properties, the management group properties will be updated. + * + * @param groupId Management Group ID. + * @param createManagementGroupRequest Management group creation parameters. + * @param cacheControl Indicates that the request shouldn't utilize any caches. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the ManagementGroupInner object + */ + public Observable> createOrUpdateWithServiceResponseAsync(String groupId, CreateManagementGroupRequestInner createManagementGroupRequest, String cacheControl) { + if (groupId == null) { + throw new IllegalArgumentException("Parameter groupId is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + if (createManagementGroupRequest == null) { + throw new IllegalArgumentException("Parameter createManagementGroupRequest is required and cannot be null."); + } + Validator.validate(createManagementGroupRequest); + return service.createOrUpdate(groupId, this.client.apiVersion(), createManagementGroupRequest, cacheControl, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = createOrUpdateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse createOrUpdateDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Update a management group. + * + * @param groupId Management Group ID. + * @param createManagementGroupRequest Management group creation parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the ManagementGroupInner object if successful. + */ + public ManagementGroupInner update(String groupId, CreateManagementGroupRequestInner createManagementGroupRequest) { + return updateWithServiceResponseAsync(groupId, createManagementGroupRequest).toBlocking().single().body(); + } + + /** + * Update a management group. + * + * @param groupId Management Group ID. + * @param createManagementGroupRequest Management group creation parameters. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture updateAsync(String groupId, CreateManagementGroupRequestInner createManagementGroupRequest, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(updateWithServiceResponseAsync(groupId, createManagementGroupRequest), serviceCallback); + } + + /** + * Update a management group. + * + * @param groupId Management Group ID. + * @param createManagementGroupRequest Management group creation parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the ManagementGroupInner object + */ + public Observable updateAsync(String groupId, CreateManagementGroupRequestInner createManagementGroupRequest) { + return updateWithServiceResponseAsync(groupId, createManagementGroupRequest).map(new Func1, ManagementGroupInner>() { + @Override + public ManagementGroupInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Update a management group. + * + * @param groupId Management Group ID. + * @param createManagementGroupRequest Management group creation parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the ManagementGroupInner object + */ + public Observable> updateWithServiceResponseAsync(String groupId, CreateManagementGroupRequestInner createManagementGroupRequest) { + if (groupId == null) { + throw new IllegalArgumentException("Parameter groupId is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + if (createManagementGroupRequest == null) { + throw new IllegalArgumentException("Parameter createManagementGroupRequest is required and cannot be null."); + } + Validator.validate(createManagementGroupRequest); + final String cacheControl = null; + return service.update(groupId, this.client.apiVersion(), createManagementGroupRequest, cacheControl, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = updateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * Update a management group. + * + * @param groupId Management Group ID. + * @param createManagementGroupRequest Management group creation parameters. + * @param cacheControl Indicates that the request shouldn't utilize any caches. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the ManagementGroupInner object if successful. + */ + public ManagementGroupInner update(String groupId, CreateManagementGroupRequestInner createManagementGroupRequest, String cacheControl) { + return updateWithServiceResponseAsync(groupId, createManagementGroupRequest, cacheControl).toBlocking().single().body(); + } + + /** + * Update a management group. + * + * @param groupId Management Group ID. + * @param createManagementGroupRequest Management group creation parameters. + * @param cacheControl Indicates that the request shouldn't utilize any caches. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture updateAsync(String groupId, CreateManagementGroupRequestInner createManagementGroupRequest, String cacheControl, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(updateWithServiceResponseAsync(groupId, createManagementGroupRequest, cacheControl), serviceCallback); + } + + /** + * Update a management group. + * + * @param groupId Management Group ID. + * @param createManagementGroupRequest Management group creation parameters. + * @param cacheControl Indicates that the request shouldn't utilize any caches. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the ManagementGroupInner object + */ + public Observable updateAsync(String groupId, CreateManagementGroupRequestInner createManagementGroupRequest, String cacheControl) { + return updateWithServiceResponseAsync(groupId, createManagementGroupRequest, cacheControl).map(new Func1, ManagementGroupInner>() { + @Override + public ManagementGroupInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Update a management group. + * + * @param groupId Management Group ID. + * @param createManagementGroupRequest Management group creation parameters. + * @param cacheControl Indicates that the request shouldn't utilize any caches. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the ManagementGroupInner object + */ + public Observable> updateWithServiceResponseAsync(String groupId, CreateManagementGroupRequestInner createManagementGroupRequest, String cacheControl) { + if (groupId == null) { + throw new IllegalArgumentException("Parameter groupId is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + if (createManagementGroupRequest == null) { + throw new IllegalArgumentException("Parameter createManagementGroupRequest is required and cannot be null."); + } + Validator.validate(createManagementGroupRequest); + return service.update(groupId, this.client.apiVersion(), createManagementGroupRequest, cacheControl, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = updateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse updateDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Delete management group. + If a management group contains child resources, the request will fail. + * + * @param groupId Management Group ID. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void delete(String groupId) { + deleteWithServiceResponseAsync(groupId).toBlocking().single().body(); + } + + /** + * Delete management group. + If a management group contains child resources, the request will fail. + * + * @param groupId Management Group ID. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture deleteAsync(String groupId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(deleteWithServiceResponseAsync(groupId), serviceCallback); + } + + /** + * Delete management group. + If a management group contains child resources, the request will fail. + * + * @param groupId Management Group ID. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable deleteAsync(String groupId) { + return deleteWithServiceResponseAsync(groupId).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Delete management group. + If a management group contains child resources, the request will fail. + * + * @param groupId Management Group ID. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> deleteWithServiceResponseAsync(String groupId) { + if (groupId == null) { + throw new IllegalArgumentException("Parameter groupId is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + final String cacheControl = null; + return service.delete(groupId, this.client.apiVersion(), cacheControl, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = deleteDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * Delete management group. + If a management group contains child resources, the request will fail. + * + * @param groupId Management Group ID. + * @param cacheControl Indicates that the request shouldn't utilize any caches. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void delete(String groupId, String cacheControl) { + deleteWithServiceResponseAsync(groupId, cacheControl).toBlocking().single().body(); + } + + /** + * Delete management group. + If a management group contains child resources, the request will fail. + * + * @param groupId Management Group ID. + * @param cacheControl Indicates that the request shouldn't utilize any caches. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture deleteAsync(String groupId, String cacheControl, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(deleteWithServiceResponseAsync(groupId, cacheControl), serviceCallback); + } + + /** + * Delete management group. + If a management group contains child resources, the request will fail. + * + * @param groupId Management Group ID. + * @param cacheControl Indicates that the request shouldn't utilize any caches. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable deleteAsync(String groupId, String cacheControl) { + return deleteWithServiceResponseAsync(groupId, cacheControl).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Delete management group. + If a management group contains child resources, the request will fail. + * + * @param groupId Management Group ID. + * @param cacheControl Indicates that the request shouldn't utilize any caches. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> deleteWithServiceResponseAsync(String groupId, String cacheControl) { + if (groupId == null) { + throw new IllegalArgumentException("Parameter groupId is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + return service.delete(groupId, this.client.apiVersion(), cacheControl, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = deleteDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse deleteDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .register(204, new TypeToken() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * List management groups for the authenticated user. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<ManagementGroupInfoInner> object if successful. + */ + public PagedList listNext(final String nextPageLink) { + ServiceResponse> response = listNextSinglePageAsync(nextPageLink).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink, null).toBlocking().single().body(); + } + }; + } + + /** + * List management groups for the authenticated user. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param serviceFuture the ServiceFuture object tracking the Retrofit calls + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listNextAsync(final String nextPageLink, final ServiceFuture> serviceFuture, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listNextSinglePageAsync(nextPageLink), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink, null); + } + }, + serviceCallback); + } + + /** + * List management groups for the authenticated user. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<ManagementGroupInfoInner> object + */ + public Observable> listNextAsync(final String nextPageLink) { + return listNextWithServiceResponseAsync(nextPageLink) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * List management groups for the authenticated user. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<ManagementGroupInfoInner> object + */ + public Observable>> listNextWithServiceResponseAsync(final String nextPageLink) { + return listNextSinglePageAsync(nextPageLink) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listNextWithServiceResponseAsync(nextPageLink, null)); + } + }); + } + + /** + * List management groups for the authenticated user. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<ManagementGroupInfoInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listNextSinglePageAsync(final String nextPageLink) { + if (nextPageLink == null) { + throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); + } + final String cacheControl = null; + String nextUrl = String.format("%s", nextPageLink); + return service.listNext(nextUrl, cacheControl, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listNextDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * List management groups for the authenticated user. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param cacheControl Indicates that the request shouldn't utilize any caches. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<ManagementGroupInfoInner> object if successful. + */ + public PagedList listNext(final String nextPageLink, final String cacheControl) { + ServiceResponse> response = listNextSinglePageAsync(nextPageLink, cacheControl).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink, cacheControl).toBlocking().single().body(); + } + }; + } + + /** + * List management groups for the authenticated user. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param cacheControl Indicates that the request shouldn't utilize any caches. + * @param serviceFuture the ServiceFuture object tracking the Retrofit calls + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listNextAsync(final String nextPageLink, final String cacheControl, final ServiceFuture> serviceFuture, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listNextSinglePageAsync(nextPageLink, cacheControl), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink, cacheControl); + } + }, + serviceCallback); + } + + /** + * List management groups for the authenticated user. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param cacheControl Indicates that the request shouldn't utilize any caches. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<ManagementGroupInfoInner> object + */ + public Observable> listNextAsync(final String nextPageLink, final String cacheControl) { + return listNextWithServiceResponseAsync(nextPageLink, cacheControl) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * List management groups for the authenticated user. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param cacheControl Indicates that the request shouldn't utilize any caches. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<ManagementGroupInfoInner> object + */ + public Observable>> listNextWithServiceResponseAsync(final String nextPageLink, final String cacheControl) { + return listNextSinglePageAsync(nextPageLink, cacheControl) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listNextWithServiceResponseAsync(nextPageLink, cacheControl)); + } + }); + } + + /** + * List management groups for the authenticated user. + * + ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. + ServiceResponse> * @param cacheControl Indicates that the request shouldn't utilize any caches. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<ManagementGroupInfoInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listNextSinglePageAsync(final String nextPageLink, final String cacheControl) { + if (nextPageLink == null) { + throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); + } + String nextUrl = String.format("%s", nextPageLink); + return service.listNext(nextUrl, cacheControl, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listNextDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listNextDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorResponseException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + +} diff --git a/azure-mgmt-managementgroups/src/main/java/com/microsoft/azure/management/managementgroups/implementation/OperationInner.java b/azure-mgmt-managementgroups/src/main/java/com/microsoft/azure/management/managementgroups/implementation/OperationInner.java new file mode 100644 index 00000000000..fc9ee1f4ad3 --- /dev/null +++ b/azure-mgmt-managementgroups/src/main/java/com/microsoft/azure/management/managementgroups/implementation/OperationInner.java @@ -0,0 +1,59 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.managementgroups.implementation; + +import com.microsoft.azure.management.managementgroups.OperationDisplay; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Operation supported by the Microsoft.Management resource provider. + */ +public class OperationInner { + /** + * Operation name: {provider}/{resource}/{operation}. + */ + @JsonProperty(value = "name", access = JsonProperty.Access.WRITE_ONLY) + private String name; + + /** + * The object that represents the operation. + */ + @JsonProperty(value = "display") + private OperationDisplay display; + + /** + * Get the name value. + * + * @return the name value + */ + public String name() { + return this.name; + } + + /** + * Get the display value. + * + * @return the display value + */ + public OperationDisplay display() { + return this.display; + } + + /** + * Set the display value. + * + * @param display the display value to set + * @return the OperationInner object itself. + */ + public OperationInner withDisplay(OperationDisplay display) { + this.display = display; + return this; + } + +} diff --git a/azure-mgmt-managementgroups/src/main/java/com/microsoft/azure/management/managementgroups/implementation/OperationsInner.java b/azure-mgmt-managementgroups/src/main/java/com/microsoft/azure/management/managementgroups/implementation/OperationsInner.java new file mode 100644 index 00000000000..f8acae3fc5b --- /dev/null +++ b/azure-mgmt-managementgroups/src/main/java/com/microsoft/azure/management/managementgroups/implementation/OperationsInner.java @@ -0,0 +1,283 @@ +/** + * 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.managementgroups.implementation; + +import retrofit2.Retrofit; +import com.google.common.reflect.TypeToken; +import com.microsoft.azure.AzureServiceFuture; +import com.microsoft.azure.ListOperationCallback; +import com.microsoft.azure.management.managementgroups.ErrorResponseException; +import com.microsoft.azure.Page; +import com.microsoft.azure.PagedList; +import com.microsoft.rest.ServiceFuture; +import com.microsoft.rest.ServiceResponse; +import java.io.IOException; +import java.util.List; +import okhttp3.ResponseBody; +import retrofit2.http.GET; +import retrofit2.http.Header; +import retrofit2.http.Headers; +import retrofit2.http.Query; +import retrofit2.http.Url; +import retrofit2.Response; +import rx.functions.Func1; +import rx.Observable; + +/** + * An instance of this class provides access to all the operations defined + * in Operations. + */ +public class OperationsInner { + /** The Retrofit service to perform REST calls. */ + private OperationsService service; + /** The service client containing this operation class. */ + private ManagementGroupsAPIImpl client; + + /** + * Initializes an instance of OperationsInner. + * + * @param retrofit the Retrofit instance built from a Retrofit Builder. + * @param client the instance of the service client containing this operation class. + */ + public OperationsInner(Retrofit retrofit, ManagementGroupsAPIImpl client) { + this.service = retrofit.create(OperationsService.class); + this.client = client; + } + + /** + * The interface defining all the services for Operations to be + * used by Retrofit to perform actually REST calls. + */ + interface OperationsService { + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.managementgroups.Operations list" }) + @GET("providers/Microsoft.Management/operations") + Observable> list(@Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.managementgroups.Operations listNext" }) + @GET + Observable> listNext(@Url String nextUrl, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + } + + /** + * Lists all of the available Management REST API operations. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<OperationInner> object if successful. + */ + public PagedList list() { + ServiceResponse> response = listSinglePageAsync().toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Lists all of the available Management REST API operations. + * + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listAsync(final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listSinglePageAsync(), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Lists all of the available Management REST API operations. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<OperationInner> object + */ + public Observable> listAsync() { + return listWithServiceResponseAsync() + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Lists all of the available Management REST API operations. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<OperationInner> object + */ + public Observable>> listWithServiceResponseAsync() { + return listSinglePageAsync() + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Lists all of the available Management REST API operations. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<OperationInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listSinglePageAsync() { + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + return service.list(this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorResponseException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Lists all of the available Management REST API operations. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<OperationInner> object if successful. + */ + public PagedList listNext(final String nextPageLink) { + ServiceResponse> response = listNextSinglePageAsync(nextPageLink).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Lists all of the available Management REST API operations. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param serviceFuture the ServiceFuture object tracking the Retrofit calls + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listNextAsync(final String nextPageLink, final ServiceFuture> serviceFuture, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listNextSinglePageAsync(nextPageLink), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Lists all of the available Management REST API operations. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<OperationInner> object + */ + public Observable> listNextAsync(final String nextPageLink) { + return listNextWithServiceResponseAsync(nextPageLink) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Lists all of the available Management REST API operations. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<OperationInner> object + */ + public Observable>> listNextWithServiceResponseAsync(final String nextPageLink) { + return listNextSinglePageAsync(nextPageLink) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Lists all of the available Management REST API operations. + * + ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<OperationInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listNextSinglePageAsync(final String nextPageLink) { + if (nextPageLink == null) { + throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); + } + String nextUrl = String.format("%s", nextPageLink); + return service.listNext(nextUrl, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listNextDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listNextDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorResponseException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + +} diff --git a/azure-mgmt-managementgroups/src/main/java/com/microsoft/azure/management/managementgroups/implementation/PageImpl.java b/azure-mgmt-managementgroups/src/main/java/com/microsoft/azure/management/managementgroups/implementation/PageImpl.java new file mode 100644 index 00000000000..3119f9eae35 --- /dev/null +++ b/azure-mgmt-managementgroups/src/main/java/com/microsoft/azure/management/managementgroups/implementation/PageImpl.java @@ -0,0 +1,75 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.managementgroups.implementation; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.microsoft.azure.Page; +import java.util.List; + +/** + * An instance of this class defines a page of Azure resources and a link to + * get the next page of resources, if any. + * + * @param type of Azure resource + */ +public class PageImpl implements Page { + /** + * The link to the next page. + */ + @JsonProperty("nextLink") + private String nextPageLink; + + /** + * The list of items. + */ + @JsonProperty("value") + private List items; + + /** + * Gets the link to the next page. + * + * @return the link to the next page. + */ + @Override + public String nextPageLink() { + return this.nextPageLink; + } + + /** + * Gets the list of items. + * + * @return the list of items in {@link List}. + */ + @Override + public List items() { + return items; + } + + /** + * Sets the link to the next page. + * + * @param nextPageLink the link to the next page. + * @return this Page object itself. + */ + public PageImpl setNextPageLink(String nextPageLink) { + this.nextPageLink = nextPageLink; + return this; + } + + /** + * Sets the list of items. + * + * @param items the list of items in {@link List}. + * @return this Page object itself. + */ + public PageImpl setItems(List items) { + this.items = items; + return this; + } +} diff --git a/azure-mgmt-managementgroups/src/main/java/com/microsoft/azure/management/managementgroups/implementation/package-info.java b/azure-mgmt-managementgroups/src/main/java/com/microsoft/azure/management/managementgroups/implementation/package-info.java new file mode 100644 index 00000000000..30edd37d5ad --- /dev/null +++ b/azure-mgmt-managementgroups/src/main/java/com/microsoft/azure/management/managementgroups/implementation/package-info.java @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** + * This package contains the implementation classes for ManagementGroupsAPI. + * The Azure Management Groups API enables consolidation of multiple + subscriptions/resources into an organizational hierarchy and centrally + manage access control, policies, alerting and reporting for those resources. + */ +package com.microsoft.azure.management.managementgroups.implementation; diff --git a/azure-mgmt-managementgroups/src/main/java/com/microsoft/azure/management/managementgroups/package-info.java b/azure-mgmt-managementgroups/src/main/java/com/microsoft/azure/management/managementgroups/package-info.java new file mode 100644 index 00000000000..6ae0d2c5307 --- /dev/null +++ b/azure-mgmt-managementgroups/src/main/java/com/microsoft/azure/management/managementgroups/package-info.java @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** + * This package contains the classes for ManagementGroupsAPI. + * The Azure Management Groups API enables consolidation of multiple + subscriptions/resources into an organizational hierarchy and centrally + manage access control, policies, alerting and reporting for those resources. + */ +package com.microsoft.azure.management.managementgroups;