diff --git a/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/AppliedReservationList.java b/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/AppliedReservationList.java new file mode 100644 index 00000000000..e4a440407b5 --- /dev/null +++ b/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/AppliedReservationList.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.reservations; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The AppliedReservationList model. + */ +public class AppliedReservationList { + /** + * The value property. + */ + @JsonProperty(value = "value") + private List value; + + /** + * Url to get the next page of reservations. + */ + @JsonProperty(value = "nextLink") + private String nextLink; + + /** + * Get the value value. + * + * @return the value value + */ + public List value() { + return this.value; + } + + /** + * Set the value value. + * + * @param value the value value to set + * @return the AppliedReservationList object itself. + */ + public AppliedReservationList withValue(List value) { + this.value = value; + return this; + } + + /** + * Get url to get the next page of reservations. + * + * @return the nextLink value + */ + public String nextLink() { + return this.nextLink; + } + + /** + * Set url to get the next page of reservations. + * + * @param nextLink the nextLink value to set + * @return the AppliedReservationList object itself. + */ + public AppliedReservationList withNextLink(String nextLink) { + this.nextLink = nextLink; + return this; + } + +} diff --git a/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/Error.java b/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/Error.java new file mode 100644 index 00000000000..1b95063788e --- /dev/null +++ b/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/Error.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.reservations; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The Error model. + */ +public class Error { + /** + * The error property. + */ + @JsonProperty(value = "error") + private ExtendedErrorInfo error; + + /** + * Get the error value. + * + * @return the error value + */ + public ExtendedErrorInfo error() { + return this.error; + } + + /** + * Set the error value. + * + * @param error the error value to set + * @return the Error object itself. + */ + public Error withError(ExtendedErrorInfo error) { + this.error = error; + return this; + } + +} diff --git a/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/ErrorException.java b/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/ErrorException.java new file mode 100644 index 00000000000..581570b4248 --- /dev/null +++ b/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/ErrorException.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.reservations; + +import com.microsoft.rest.RestException; +import okhttp3.ResponseBody; +import retrofit2.Response; + +/** + * Exception thrown for an invalid response with Error information. + */ +public class ErrorException extends RestException { + /** + * Initializes a new instance of the ErrorException class. + * + * @param message the exception message or the response content if a message is not available + * @param response the HTTP response + */ + public ErrorException(final String message, final Response response) { + super(message, response); + } + + /** + * Initializes a new instance of the ErrorException 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 ErrorException(final String message, final Response response, final Error body) { + super(message, response, body); + } + + @Override + public Error body() { + return (Error) super.body(); + } +} diff --git a/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/ExtendedErrorInfo.java b/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/ExtendedErrorInfo.java new file mode 100644 index 00000000000..a9b08964663 --- /dev/null +++ b/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/ExtendedErrorInfo.java @@ -0,0 +1,95 @@ +/** + * 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.reservations; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The ExtendedErrorInfo model. + */ +public class ExtendedErrorInfo { + /** + * Possible values include: 'NotSpecified', 'InternalServerError', + * 'ServerTimeout', 'AuthorizationFailed', 'BadRequest', + * 'ClientCertificateThumbprintNotSet', 'InvalidRequestContent', + * 'OperationFailed', 'HttpMethodNotSupported', 'InvalidRequestUri', + * 'MissingTenantId', 'InvalidTenantId', 'InvalidReservationOrderId', + * 'InvalidReservationId', 'ReservationIdNotInReservationOrder', + * 'ReservationOrderNotFound', 'InvalidSubscriptionId', + * 'InvalidAccessToken', 'InvalidLocationId', + * 'UnauthenticatedRequestsThrottled', 'InvalidHealthCheckType', + * 'Forbidden', 'BillingScopeIdCannotBeChanged', + * 'AppliedScopesNotAssociatedWithCommerceAccount', + * 'PatchValuesSameAsExisting', 'RoleAssignmentCreationFailed', + * 'ReservationOrderCreationFailed', 'ReservationOrderNotEnabled', + * 'CapacityUpdateScopesFailed', 'UnsupportedReservationTerm', + * 'ReservationOrderIdAlreadyExists', 'RiskCheckFailed', + * 'CreateQuoteFailed', 'ActivateQuoteFailed', 'NonsupportedAccountId', + * 'PaymentInstrumentNotFound', 'MissingAppliedScopesForSingle', + * 'NoValidReservationsToReRate', 'ReRateOnlyAllowedForEA', + * 'OperationCannotBePerformedInCurrentState', + * 'InvalidSingleAppliedScopesCount', + * 'InvalidFulfillmentRequestParameters', 'NotSupportedCountry', + * 'InvalidRefundQuantity', 'PurchaseError', 'BillingCustomerInputError', + * 'BillingPaymentInstrumentSoftError', + * 'BillingPaymentInstrumentHardError', 'BillingTransientError', + * 'BillingError', 'FulfillmentConfigurationError', + * 'FulfillmentOutOfStockError', 'FulfillmentTransientError', + * 'FulfillmentError', 'CalculatePriceFailed'. + */ + @JsonProperty(value = "code") + private String code; + + /** + * The message property. + */ + @JsonProperty(value = "message") + private String message; + + /** + * Get possible values include: 'NotSpecified', 'InternalServerError', 'ServerTimeout', 'AuthorizationFailed', 'BadRequest', 'ClientCertificateThumbprintNotSet', 'InvalidRequestContent', 'OperationFailed', 'HttpMethodNotSupported', 'InvalidRequestUri', 'MissingTenantId', 'InvalidTenantId', 'InvalidReservationOrderId', 'InvalidReservationId', 'ReservationIdNotInReservationOrder', 'ReservationOrderNotFound', 'InvalidSubscriptionId', 'InvalidAccessToken', 'InvalidLocationId', 'UnauthenticatedRequestsThrottled', 'InvalidHealthCheckType', 'Forbidden', 'BillingScopeIdCannotBeChanged', 'AppliedScopesNotAssociatedWithCommerceAccount', 'PatchValuesSameAsExisting', 'RoleAssignmentCreationFailed', 'ReservationOrderCreationFailed', 'ReservationOrderNotEnabled', 'CapacityUpdateScopesFailed', 'UnsupportedReservationTerm', 'ReservationOrderIdAlreadyExists', 'RiskCheckFailed', 'CreateQuoteFailed', 'ActivateQuoteFailed', 'NonsupportedAccountId', 'PaymentInstrumentNotFound', 'MissingAppliedScopesForSingle', 'NoValidReservationsToReRate', 'ReRateOnlyAllowedForEA', 'OperationCannotBePerformedInCurrentState', 'InvalidSingleAppliedScopesCount', 'InvalidFulfillmentRequestParameters', 'NotSupportedCountry', 'InvalidRefundQuantity', 'PurchaseError', 'BillingCustomerInputError', 'BillingPaymentInstrumentSoftError', 'BillingPaymentInstrumentHardError', 'BillingTransientError', 'BillingError', 'FulfillmentConfigurationError', 'FulfillmentOutOfStockError', 'FulfillmentTransientError', 'FulfillmentError', 'CalculatePriceFailed'. + * + * @return the code value + */ + public String code() { + return this.code; + } + + /** + * Set possible values include: 'NotSpecified', 'InternalServerError', 'ServerTimeout', 'AuthorizationFailed', 'BadRequest', 'ClientCertificateThumbprintNotSet', 'InvalidRequestContent', 'OperationFailed', 'HttpMethodNotSupported', 'InvalidRequestUri', 'MissingTenantId', 'InvalidTenantId', 'InvalidReservationOrderId', 'InvalidReservationId', 'ReservationIdNotInReservationOrder', 'ReservationOrderNotFound', 'InvalidSubscriptionId', 'InvalidAccessToken', 'InvalidLocationId', 'UnauthenticatedRequestsThrottled', 'InvalidHealthCheckType', 'Forbidden', 'BillingScopeIdCannotBeChanged', 'AppliedScopesNotAssociatedWithCommerceAccount', 'PatchValuesSameAsExisting', 'RoleAssignmentCreationFailed', 'ReservationOrderCreationFailed', 'ReservationOrderNotEnabled', 'CapacityUpdateScopesFailed', 'UnsupportedReservationTerm', 'ReservationOrderIdAlreadyExists', 'RiskCheckFailed', 'CreateQuoteFailed', 'ActivateQuoteFailed', 'NonsupportedAccountId', 'PaymentInstrumentNotFound', 'MissingAppliedScopesForSingle', 'NoValidReservationsToReRate', 'ReRateOnlyAllowedForEA', 'OperationCannotBePerformedInCurrentState', 'InvalidSingleAppliedScopesCount', 'InvalidFulfillmentRequestParameters', 'NotSupportedCountry', 'InvalidRefundQuantity', 'PurchaseError', 'BillingCustomerInputError', 'BillingPaymentInstrumentSoftError', 'BillingPaymentInstrumentHardError', 'BillingTransientError', 'BillingError', 'FulfillmentConfigurationError', 'FulfillmentOutOfStockError', 'FulfillmentTransientError', 'FulfillmentError', 'CalculatePriceFailed'. + * + * @param code the code value to set + * @return the ExtendedErrorInfo object itself. + */ + public ExtendedErrorInfo 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 ExtendedErrorInfo object itself. + */ + public ExtendedErrorInfo withMessage(String message) { + this.message = message; + return this; + } + +} diff --git a/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/ExtendedStatusInfo.java b/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/ExtendedStatusInfo.java new file mode 100644 index 00000000000..67e73dcd609 --- /dev/null +++ b/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/ExtendedStatusInfo.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.reservations; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The ExtendedStatusInfo model. + */ +public class ExtendedStatusInfo { + /** + * Possible values include: 'None', 'Pending', 'Active', 'PurchaseError', + * 'PaymentInstrumentError', 'Split', 'Merged', 'Expired', 'Succeeded'. + */ + @JsonProperty(value = "statusCode") + private String statusCode; + + /** + * The message giving detailed information about the status code. + */ + @JsonProperty(value = "message") + private String message; + + /** + * Get possible values include: 'None', 'Pending', 'Active', 'PurchaseError', 'PaymentInstrumentError', 'Split', 'Merged', 'Expired', 'Succeeded'. + * + * @return the statusCode value + */ + public String statusCode() { + return this.statusCode; + } + + /** + * Set possible values include: 'None', 'Pending', 'Active', 'PurchaseError', 'PaymentInstrumentError', 'Split', 'Merged', 'Expired', 'Succeeded'. + * + * @param statusCode the statusCode value to set + * @return the ExtendedStatusInfo object itself. + */ + public ExtendedStatusInfo withStatusCode(String statusCode) { + this.statusCode = statusCode; + return this; + } + + /** + * Get the message giving detailed information about the status code. + * + * @return the message value + */ + public String message() { + return this.message; + } + + /** + * Set the message giving detailed information about the status code. + * + * @param message the message value to set + * @return the ExtendedStatusInfo object itself. + */ + public ExtendedStatusInfo withMessage(String message) { + this.message = message; + return this; + } + +} diff --git a/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/MergeRequest.java b/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/MergeRequest.java new file mode 100644 index 00000000000..fb2c4f9c6d2 --- /dev/null +++ b/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/MergeRequest.java @@ -0,0 +1,47 @@ +/** + * 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.reservations; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.microsoft.rest.serializer.JsonFlatten; + +/** + * The MergeRequest model. + */ +@JsonFlatten +public class MergeRequest { + /** + * Format of the resource id should be + * /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}. + */ + @JsonProperty(value = "properties.sources") + private List sources; + + /** + * Get format of the resource id should be /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}. + * + * @return the sources value + */ + public List sources() { + return this.sources; + } + + /** + * Set format of the resource id should be /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}. + * + * @param sources the sources value to set + * @return the MergeRequest object itself. + */ + public MergeRequest withSources(List sources) { + this.sources = sources; + return this; + } + +} diff --git a/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/OperationDisplay.java b/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/OperationDisplay.java new file mode 100644 index 00000000000..3de22635d4a --- /dev/null +++ b/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/OperationDisplay.java @@ -0,0 +1,121 @@ +/** + * 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.reservations; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The OperationDisplay model. + */ +public class OperationDisplay { + /** + * The provider property. + */ + @JsonProperty(value = "provider") + private String provider; + + /** + * The resource property. + */ + @JsonProperty(value = "resource") + private String resource; + + /** + * The operation property. + */ + @JsonProperty(value = "operation") + private String operation; + + /** + * The description property. + */ + @JsonProperty(value = "description") + private String description; + + /** + * Get the provider value. + * + * @return the provider value + */ + public String provider() { + return this.provider; + } + + /** + * Set the provider value. + * + * @param provider the provider value to set + * @return the OperationDisplay object itself. + */ + public OperationDisplay withProvider(String provider) { + this.provider = provider; + return this; + } + + /** + * Get the resource value. + * + * @return the resource value + */ + public String resource() { + return this.resource; + } + + /** + * Set the resource value. + * + * @param resource the resource value to set + * @return the OperationDisplay object itself. + */ + public OperationDisplay withResource(String resource) { + this.resource = resource; + return this; + } + + /** + * Get the operation value. + * + * @return the operation value + */ + public String operation() { + return this.operation; + } + + /** + * Set the operation value. + * + * @param operation the operation value to set + * @return the OperationDisplay object itself. + */ + public OperationDisplay withOperation(String operation) { + this.operation = operation; + return this; + } + + /** + * Get the description value. + * + * @return the description value + */ + public String description() { + return this.description; + } + + /** + * Set the description value. + * + * @param description the description value to set + * @return the OperationDisplay object itself. + */ + public OperationDisplay withDescription(String description) { + this.description = description; + return this; + } + +} diff --git a/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/Patch.java b/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/Patch.java new file mode 100644 index 00000000000..3124fa737e3 --- /dev/null +++ b/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/Patch.java @@ -0,0 +1,98 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.reservations; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.microsoft.rest.serializer.JsonFlatten; + +/** + * The Patch model. + */ +@JsonFlatten +public class Patch { + /** + * Possible values include: 'Single', 'Shared'. + */ + @JsonProperty(value = "properties.appliedScopeType") + private String appliedScopeType; + + /** + * The appliedScopes property. + */ + @JsonProperty(value = "properties.appliedScopes") + private List appliedScopes; + + /** + * Possible values include: 'On', 'Off', 'NotSupported'. + */ + @JsonProperty(value = "properties.instanceFlexibility") + private String instanceFlexibility; + + /** + * Get possible values include: 'Single', 'Shared'. + * + * @return the appliedScopeType value + */ + public String appliedScopeType() { + return this.appliedScopeType; + } + + /** + * Set possible values include: 'Single', 'Shared'. + * + * @param appliedScopeType the appliedScopeType value to set + * @return the Patch object itself. + */ + public Patch withAppliedScopeType(String appliedScopeType) { + this.appliedScopeType = appliedScopeType; + return this; + } + + /** + * Get the appliedScopes value. + * + * @return the appliedScopes value + */ + public List appliedScopes() { + return this.appliedScopes; + } + + /** + * Set the appliedScopes value. + * + * @param appliedScopes the appliedScopes value to set + * @return the Patch object itself. + */ + public Patch withAppliedScopes(List appliedScopes) { + this.appliedScopes = appliedScopes; + return this; + } + + /** + * Get possible values include: 'On', 'Off', 'NotSupported'. + * + * @return the instanceFlexibility value + */ + public String instanceFlexibility() { + return this.instanceFlexibility; + } + + /** + * Set possible values include: 'On', 'Off', 'NotSupported'. + * + * @param instanceFlexibility the instanceFlexibility value to set + * @return the Patch object itself. + */ + public Patch withInstanceFlexibility(String instanceFlexibility) { + this.instanceFlexibility = instanceFlexibility; + return this; + } + +} diff --git a/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/ReservationMergeProperties.java b/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/ReservationMergeProperties.java new file mode 100644 index 00000000000..05414b2e94b --- /dev/null +++ b/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/ReservationMergeProperties.java @@ -0,0 +1,74 @@ +/** + * 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.reservations; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The ReservationMergeProperties model. + */ +public class ReservationMergeProperties { + /** + * Reservation Resource Id Created due to the merge. Format of the resource + * Id is + * /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}. + */ + @JsonProperty(value = "mergeDestination") + private String mergeDestination; + + /** + * Resource Ids of the Source Reservation's merged to form this + * Reservation. Format of the resource Id is + * /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}. + */ + @JsonProperty(value = "mergeSources") + private List mergeSources; + + /** + * Get reservation Resource Id Created due to the merge. Format of the resource Id is /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}. + * + * @return the mergeDestination value + */ + public String mergeDestination() { + return this.mergeDestination; + } + + /** + * Set reservation Resource Id Created due to the merge. Format of the resource Id is /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}. + * + * @param mergeDestination the mergeDestination value to set + * @return the ReservationMergeProperties object itself. + */ + public ReservationMergeProperties withMergeDestination(String mergeDestination) { + this.mergeDestination = mergeDestination; + return this; + } + + /** + * Get resource Ids of the Source Reservation's merged to form this Reservation. Format of the resource Id is /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}. + * + * @return the mergeSources value + */ + public List mergeSources() { + return this.mergeSources; + } + + /** + * Set resource Ids of the Source Reservation's merged to form this Reservation. Format of the resource Id is /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}. + * + * @param mergeSources the mergeSources value to set + * @return the ReservationMergeProperties object itself. + */ + public ReservationMergeProperties withMergeSources(List mergeSources) { + this.mergeSources = mergeSources; + return this; + } + +} diff --git a/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/ReservationProperties.java b/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/ReservationProperties.java new file mode 100644 index 00000000000..bceb8615010 --- /dev/null +++ b/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/ReservationProperties.java @@ -0,0 +1,377 @@ +/** + * 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.reservations; + +import java.util.List; +import org.joda.time.DateTime; +import org.joda.time.LocalDate; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The ReservationProperties model. + */ +public class ReservationProperties { + /** + * Possible values include: 'VirtualMachines', 'SqlDatabases', 'SuseLinux'. + */ + @JsonProperty(value = "reservedResourceType") + private String reservedResourceType; + + /** + * Possible values include: 'On', 'Off', 'NotSupported'. + */ + @JsonProperty(value = "instanceFlexibility") + private String instanceFlexibility; + + /** + * Friendly name for user to easily identify the reservation. + */ + @JsonProperty(value = "displayName") + private String displayName; + + /** + * The appliedScopes property. + */ + @JsonProperty(value = "appliedScopes") + private List appliedScopes; + + /** + * Possible values include: 'Single', 'Shared'. + */ + @JsonProperty(value = "appliedScopeType") + private String appliedScopeType; + + /** + * Quantity of the SKUs that are part of the Reservation. + */ + @JsonProperty(value = "quantity") + private Integer quantity; + + /** + * Possible values include: 'Creating', 'PendingResourceHold', + * 'ConfirmedResourceHold', 'PendingBilling', 'ConfirmedBilling', + * 'Created', 'Succeeded', 'Cancelled', 'Expired', 'BillingFailed', + * 'Failed', 'Split', 'Merged'. + */ + @JsonProperty(value = "provisioningState") + private String provisioningState; + + /** + * DateTime of the Reservation starting when this version is effective + * from. + */ + @JsonProperty(value = "effectiveDateTime") + private DateTime effectiveDateTime; + + /** + * DateTime of the last time the Reservation was updated. + */ + @JsonProperty(value = "lastUpdatedDateTime", access = JsonProperty.Access.WRITE_ONLY) + private DateTime lastUpdatedDateTime; + + /** + * This is the date when the Reservation will expire. + */ + @JsonProperty(value = "expiryDate") + private LocalDate expiryDate; + + /** + * Description of the SKU in english. + */ + @JsonProperty(value = "skuDescription") + private String skuDescription; + + /** + * The extendedStatusInfo property. + */ + @JsonProperty(value = "extendedStatusInfo") + private ExtendedStatusInfo extendedStatusInfo; + + /** + * The splitProperties property. + */ + @JsonProperty(value = "splitProperties") + private ReservationSplitProperties splitProperties; + + /** + * The mergeProperties property. + */ + @JsonProperty(value = "mergeProperties") + private ReservationMergeProperties mergeProperties; + + /** + * Get possible values include: 'VirtualMachines', 'SqlDatabases', 'SuseLinux'. + * + * @return the reservedResourceType value + */ + public String reservedResourceType() { + return this.reservedResourceType; + } + + /** + * Set possible values include: 'VirtualMachines', 'SqlDatabases', 'SuseLinux'. + * + * @param reservedResourceType the reservedResourceType value to set + * @return the ReservationProperties object itself. + */ + public ReservationProperties withReservedResourceType(String reservedResourceType) { + this.reservedResourceType = reservedResourceType; + return this; + } + + /** + * Get possible values include: 'On', 'Off', 'NotSupported'. + * + * @return the instanceFlexibility value + */ + public String instanceFlexibility() { + return this.instanceFlexibility; + } + + /** + * Set possible values include: 'On', 'Off', 'NotSupported'. + * + * @param instanceFlexibility the instanceFlexibility value to set + * @return the ReservationProperties object itself. + */ + public ReservationProperties withInstanceFlexibility(String instanceFlexibility) { + this.instanceFlexibility = instanceFlexibility; + return this; + } + + /** + * Get friendly name for user to easily identify the reservation. + * + * @return the displayName value + */ + public String displayName() { + return this.displayName; + } + + /** + * Set friendly name for user to easily identify the reservation. + * + * @param displayName the displayName value to set + * @return the ReservationProperties object itself. + */ + public ReservationProperties withDisplayName(String displayName) { + this.displayName = displayName; + return this; + } + + /** + * Get the appliedScopes value. + * + * @return the appliedScopes value + */ + public List appliedScopes() { + return this.appliedScopes; + } + + /** + * Set the appliedScopes value. + * + * @param appliedScopes the appliedScopes value to set + * @return the ReservationProperties object itself. + */ + public ReservationProperties withAppliedScopes(List appliedScopes) { + this.appliedScopes = appliedScopes; + return this; + } + + /** + * Get possible values include: 'Single', 'Shared'. + * + * @return the appliedScopeType value + */ + public String appliedScopeType() { + return this.appliedScopeType; + } + + /** + * Set possible values include: 'Single', 'Shared'. + * + * @param appliedScopeType the appliedScopeType value to set + * @return the ReservationProperties object itself. + */ + public ReservationProperties withAppliedScopeType(String appliedScopeType) { + this.appliedScopeType = appliedScopeType; + return this; + } + + /** + * Get quantity of the SKUs that are part of the Reservation. + * + * @return the quantity value + */ + public Integer quantity() { + return this.quantity; + } + + /** + * Set quantity of the SKUs that are part of the Reservation. + * + * @param quantity the quantity value to set + * @return the ReservationProperties object itself. + */ + public ReservationProperties withQuantity(Integer quantity) { + this.quantity = quantity; + return this; + } + + /** + * Get possible values include: 'Creating', 'PendingResourceHold', 'ConfirmedResourceHold', 'PendingBilling', 'ConfirmedBilling', 'Created', 'Succeeded', 'Cancelled', 'Expired', 'BillingFailed', 'Failed', 'Split', 'Merged'. + * + * @return the provisioningState value + */ + public String provisioningState() { + return this.provisioningState; + } + + /** + * Set possible values include: 'Creating', 'PendingResourceHold', 'ConfirmedResourceHold', 'PendingBilling', 'ConfirmedBilling', 'Created', 'Succeeded', 'Cancelled', 'Expired', 'BillingFailed', 'Failed', 'Split', 'Merged'. + * + * @param provisioningState the provisioningState value to set + * @return the ReservationProperties object itself. + */ + public ReservationProperties withProvisioningState(String provisioningState) { + this.provisioningState = provisioningState; + return this; + } + + /** + * Get dateTime of the Reservation starting when this version is effective from. + * + * @return the effectiveDateTime value + */ + public DateTime effectiveDateTime() { + return this.effectiveDateTime; + } + + /** + * Set dateTime of the Reservation starting when this version is effective from. + * + * @param effectiveDateTime the effectiveDateTime value to set + * @return the ReservationProperties object itself. + */ + public ReservationProperties withEffectiveDateTime(DateTime effectiveDateTime) { + this.effectiveDateTime = effectiveDateTime; + return this; + } + + /** + * Get dateTime of the last time the Reservation was updated. + * + * @return the lastUpdatedDateTime value + */ + public DateTime lastUpdatedDateTime() { + return this.lastUpdatedDateTime; + } + + /** + * Get this is the date when the Reservation will expire. + * + * @return the expiryDate value + */ + public LocalDate expiryDate() { + return this.expiryDate; + } + + /** + * Set this is the date when the Reservation will expire. + * + * @param expiryDate the expiryDate value to set + * @return the ReservationProperties object itself. + */ + public ReservationProperties withExpiryDate(LocalDate expiryDate) { + this.expiryDate = expiryDate; + return this; + } + + /** + * Get description of the SKU in english. + * + * @return the skuDescription value + */ + public String skuDescription() { + return this.skuDescription; + } + + /** + * Set description of the SKU in english. + * + * @param skuDescription the skuDescription value to set + * @return the ReservationProperties object itself. + */ + public ReservationProperties withSkuDescription(String skuDescription) { + this.skuDescription = skuDescription; + return this; + } + + /** + * Get the extendedStatusInfo value. + * + * @return the extendedStatusInfo value + */ + public ExtendedStatusInfo extendedStatusInfo() { + return this.extendedStatusInfo; + } + + /** + * Set the extendedStatusInfo value. + * + * @param extendedStatusInfo the extendedStatusInfo value to set + * @return the ReservationProperties object itself. + */ + public ReservationProperties withExtendedStatusInfo(ExtendedStatusInfo extendedStatusInfo) { + this.extendedStatusInfo = extendedStatusInfo; + return this; + } + + /** + * Get the splitProperties value. + * + * @return the splitProperties value + */ + public ReservationSplitProperties splitProperties() { + return this.splitProperties; + } + + /** + * Set the splitProperties value. + * + * @param splitProperties the splitProperties value to set + * @return the ReservationProperties object itself. + */ + public ReservationProperties withSplitProperties(ReservationSplitProperties splitProperties) { + this.splitProperties = splitProperties; + return this; + } + + /** + * Get the mergeProperties value. + * + * @return the mergeProperties value + */ + public ReservationMergeProperties mergeProperties() { + return this.mergeProperties; + } + + /** + * Set the mergeProperties value. + * + * @param mergeProperties the mergeProperties value to set + * @return the ReservationProperties object itself. + */ + public ReservationProperties withMergeProperties(ReservationMergeProperties mergeProperties) { + this.mergeProperties = mergeProperties; + return this; + } + +} diff --git a/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/ReservationSplitProperties.java b/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/ReservationSplitProperties.java new file mode 100644 index 00000000000..35837540afb --- /dev/null +++ b/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/ReservationSplitProperties.java @@ -0,0 +1,74 @@ +/** + * 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.reservations; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The ReservationSplitProperties model. + */ +public class ReservationSplitProperties { + /** + * List of destination Resource Id that are created due to split. Format of + * the resource Id is + * /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}. + */ + @JsonProperty(value = "splitDestinations") + private List splitDestinations; + + /** + * Resource Id of the Reservation from which this is split. Format of the + * resource Id is + * /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}. + */ + @JsonProperty(value = "splitSource") + private String splitSource; + + /** + * Get list of destination Resource Id that are created due to split. Format of the resource Id is /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}. + * + * @return the splitDestinations value + */ + public List splitDestinations() { + return this.splitDestinations; + } + + /** + * Set list of destination Resource Id that are created due to split. Format of the resource Id is /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}. + * + * @param splitDestinations the splitDestinations value to set + * @return the ReservationSplitProperties object itself. + */ + public ReservationSplitProperties withSplitDestinations(List splitDestinations) { + this.splitDestinations = splitDestinations; + return this; + } + + /** + * Get resource Id of the Reservation from which this is split. Format of the resource Id is /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}. + * + * @return the splitSource value + */ + public String splitSource() { + return this.splitSource; + } + + /** + * Set resource Id of the Reservation from which this is split. Format of the resource Id is /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}. + * + * @param splitSource the splitSource value to set + * @return the ReservationSplitProperties object itself. + */ + public ReservationSplitProperties withSplitSource(String splitSource) { + this.splitSource = splitSource; + return this; + } + +} diff --git a/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/SkuName.java b/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/SkuName.java new file mode 100644 index 00000000000..9347fd790b6 --- /dev/null +++ b/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/SkuName.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.reservations; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The SkuName model. + */ +public class SkuName { + /** + * The name property. + */ + @JsonProperty(value = "name") + private String name; + + /** + * Get the name value. + * + * @return the name value + */ + public String name() { + return this.name; + } + + /** + * Set the name value. + * + * @param name the name value to set + * @return the SkuName object itself. + */ + public SkuName withName(String name) { + this.name = name; + return this; + } + +} diff --git a/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/SkuProperty.java b/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/SkuProperty.java new file mode 100644 index 00000000000..528ae967045 --- /dev/null +++ b/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/SkuProperty.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.reservations; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The SkuProperty model. + */ +public class SkuProperty { + /** + * An invariant to describe the feature. + */ + @JsonProperty(value = "name") + private String name; + + /** + * An invariant if the feature is measured by quantity. + */ + @JsonProperty(value = "value") + private String value; + + /** + * Get an invariant to describe the feature. + * + * @return the name value + */ + public String name() { + return this.name; + } + + /** + * Set an invariant to describe the feature. + * + * @param name the name value to set + * @return the SkuProperty object itself. + */ + public SkuProperty withName(String name) { + this.name = name; + return this; + } + + /** + * Get an invariant if the feature is measured by quantity. + * + * @return the value value + */ + public String value() { + return this.value; + } + + /** + * Set an invariant if the feature is measured by quantity. + * + * @param value the value value to set + * @return the SkuProperty object itself. + */ + public SkuProperty withValue(String value) { + this.value = value; + return this; + } + +} diff --git a/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/SkuRestriction.java b/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/SkuRestriction.java new file mode 100644 index 00000000000..ee2e3cf8410 --- /dev/null +++ b/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/SkuRestriction.java @@ -0,0 +1,97 @@ +/** + * 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.reservations; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The SkuRestriction model. + */ +public class SkuRestriction { + /** + * The type of restrictions. + */ + @JsonProperty(value = "type") + private String type; + + /** + * The value of restrictions. If the restriction type is set to location. + * This would be different locations where the SKU is restricted. + */ + @JsonProperty(value = "values") + private List values; + + /** + * The reason for restriction. + */ + @JsonProperty(value = "reasonCode") + private String reasonCode; + + /** + * Get the type of restrictions. + * + * @return the type value + */ + public String type() { + return this.type; + } + + /** + * Set the type of restrictions. + * + * @param type the type value to set + * @return the SkuRestriction object itself. + */ + public SkuRestriction withType(String type) { + this.type = type; + return this; + } + + /** + * Get the value of restrictions. If the restriction type is set to location. This would be different locations where the SKU is restricted. + * + * @return the values value + */ + public List values() { + return this.values; + } + + /** + * Set the value of restrictions. If the restriction type is set to location. This would be different locations where the SKU is restricted. + * + * @param values the values value to set + * @return the SkuRestriction object itself. + */ + public SkuRestriction withValues(List values) { + this.values = values; + return this; + } + + /** + * Get the reason for restriction. + * + * @return the reasonCode value + */ + public String reasonCode() { + return this.reasonCode; + } + + /** + * Set the reason for restriction. + * + * @param reasonCode the reasonCode value to set + * @return the SkuRestriction object itself. + */ + public SkuRestriction withReasonCode(String reasonCode) { + this.reasonCode = reasonCode; + return this; + } + +} diff --git a/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/SplitRequest.java b/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/SplitRequest.java new file mode 100644 index 00000000000..04a1ca770c7 --- /dev/null +++ b/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/SplitRequest.java @@ -0,0 +1,74 @@ +/** + * 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.reservations; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.microsoft.rest.serializer.JsonFlatten; + +/** + * The SplitRequest model. + */ +@JsonFlatten +public class SplitRequest { + /** + * List of the quantities in the new reservations to create. + */ + @JsonProperty(value = "properties.quantities") + private List quantities; + + /** + * Resource id of the reservation to be split. Format of the resource id + * should be + * /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}. + */ + @JsonProperty(value = "properties.reservationId") + private String reservationId; + + /** + * Get list of the quantities in the new reservations to create. + * + * @return the quantities value + */ + public List quantities() { + return this.quantities; + } + + /** + * Set list of the quantities in the new reservations to create. + * + * @param quantities the quantities value to set + * @return the SplitRequest object itself. + */ + public SplitRequest withQuantities(List quantities) { + this.quantities = quantities; + return this; + } + + /** + * Get resource id of the reservation to be split. Format of the resource id should be /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}. + * + * @return the reservationId value + */ + public String reservationId() { + return this.reservationId; + } + + /** + * Set resource id of the reservation to be split. Format of the resource id should be /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}. + * + * @param reservationId the reservationId value to set + * @return the SplitRequest object itself. + */ + public SplitRequest withReservationId(String reservationId) { + this.reservationId = reservationId; + return this; + } + +} diff --git a/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/implementation/AppliedReservationsInner.java b/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/implementation/AppliedReservationsInner.java new file mode 100644 index 00000000000..f46095c717e --- /dev/null +++ b/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/implementation/AppliedReservationsInner.java @@ -0,0 +1,91 @@ +/** + * 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.reservations.implementation; + +import com.microsoft.azure.management.reservations.AppliedReservationList; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.microsoft.rest.serializer.JsonFlatten; + +/** + * The AppliedReservationsInner model. + */ +@JsonFlatten +public class AppliedReservationsInner { + /** + * Identifier of the applied reservations. + */ + @JsonProperty(value = "id", access = JsonProperty.Access.WRITE_ONLY) + private String id; + + /** + * Name of resource. + */ + @JsonProperty(value = "name", access = JsonProperty.Access.WRITE_ONLY) + private String name; + + /** + * Type of resource. "Microsoft.Capacity/AppliedReservations". + */ + @JsonProperty(value = "type", access = JsonProperty.Access.WRITE_ONLY) + private String type; + + /** + * The reservationOrderIds property. + */ + @JsonProperty(value = "properties.reservationOrderIds") + private AppliedReservationList reservationOrderIds; + + /** + * Get identifier of the applied reservations. + * + * @return the id value + */ + public String id() { + return this.id; + } + + /** + * Get name of resource. + * + * @return the name value + */ + public String name() { + return this.name; + } + + /** + * Get type of resource. "Microsoft.Capacity/AppliedReservations". + * + * @return the type value + */ + public String type() { + return this.type; + } + + /** + * Get the reservationOrderIds value. + * + * @return the reservationOrderIds value + */ + public AppliedReservationList reservationOrderIds() { + return this.reservationOrderIds; + } + + /** + * Set the reservationOrderIds value. + * + * @param reservationOrderIds the reservationOrderIds value to set + * @return the AppliedReservationsInner object itself. + */ + public AppliedReservationsInner withReservationOrderIds(AppliedReservationList reservationOrderIds) { + this.reservationOrderIds = reservationOrderIds; + return this; + } + +} diff --git a/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/implementation/AzureReservationAPIImpl.java b/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/implementation/AzureReservationAPIImpl.java new file mode 100644 index 00000000000..284087f9956 --- /dev/null +++ b/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/implementation/AzureReservationAPIImpl.java @@ -0,0 +1,484 @@ +/** + * 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.reservations.implementation; + +import com.google.common.reflect.TypeToken; +import com.microsoft.azure.AzureClient; +import com.microsoft.azure.AzureServiceClient; +import com.microsoft.azure.management.reservations.ErrorException; +import com.microsoft.rest.credentials.ServiceClientCredentials; +import com.microsoft.rest.RestClient; +import com.microsoft.rest.ServiceCallback; +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.Path; +import retrofit2.http.Query; +import retrofit2.Response; +import rx.functions.Func1; +import rx.Observable; + +/** + * Initializes a new instance of the AzureReservationAPIImpl class. + */ +public class AzureReservationAPIImpl extends AzureServiceClient { + /** The Retrofit service to perform REST calls. */ + private AzureReservationAPIService service; + /** 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; + } + + /** Supported version. */ + private String apiVersion; + + /** + * Gets Supported version. + * + * @return the apiVersion value. + */ + public String apiVersion() { + return this.apiVersion; + } + + /** Gets or sets the preferred language for the response. */ + private String acceptLanguage; + + /** + * Gets Gets or sets the preferred language for the response. + * + * @return the acceptLanguage value. + */ + public String acceptLanguage() { + return this.acceptLanguage; + } + + /** + * Sets Gets or sets the preferred language for the response. + * + * @param acceptLanguage the acceptLanguage value. + * @return the service client itself + */ + public AzureReservationAPIImpl 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 AzureReservationAPIImpl 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 AzureReservationAPIImpl withGenerateClientRequestId(boolean generateClientRequestId) { + this.generateClientRequestId = generateClientRequestId; + return this; + } + + /** + * The ReservationOrdersInner object to access its operations. + */ + private ReservationOrdersInner reservationOrders; + + /** + * Gets the ReservationOrdersInner object to access its operations. + * @return the ReservationOrdersInner object. + */ + public ReservationOrdersInner reservationOrders() { + return this.reservationOrders; + } + + /** + * The ReservationsInner object to access its operations. + */ + private ReservationsInner reservations; + + /** + * Gets the ReservationsInner object to access its operations. + * @return the ReservationsInner object. + */ + public ReservationsInner reservations() { + return this.reservations; + } + + /** + * 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 AzureReservationAPI client. + * + * @param credentials the management credentials for Azure + */ + public AzureReservationAPIImpl(ServiceClientCredentials credentials) { + this("https://management.azure.com", credentials); + } + + /** + * Initializes an instance of AzureReservationAPI client. + * + * @param baseUrl the base URL of the host + * @param credentials the management credentials for Azure + */ + public AzureReservationAPIImpl(String baseUrl, ServiceClientCredentials credentials) { + super(baseUrl, credentials); + initialize(); + } + + /** + * Initializes an instance of AzureReservationAPI client. + * + * @param restClient the REST client to connect to Azure. + */ + public AzureReservationAPIImpl(RestClient restClient) { + super(restClient); + initialize(); + } + + protected void initialize() { + this.apiVersion = "2018-06-01"; + this.acceptLanguage = "en-US"; + this.longRunningOperationRetryTimeout = 30; + this.generateClientRequestId = true; + this.reservationOrders = new ReservationOrdersInner(restClient().retrofit(), this); + this.reservations = new ReservationsInner(restClient().retrofit(), this); + this.operations = new OperationsInner(restClient().retrofit(), this); + this.azureClient = new AzureClient(this); + initializeService(); + } + + /** + * 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(), "AzureReservationAPI", "2018-06-01"); + } + + private void initializeService() { + service = restClient().retrofit().create(AzureReservationAPIService.class); + } + + /** + * The interface defining all the services for AzureReservationAPI to be + * used by Retrofit to perform actually REST calls. + */ + interface AzureReservationAPIService { + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.reservations.AzureReservationAPI getCatalog" }) + @GET("subscriptions/{subscriptionId}/providers/Microsoft.Capacity/catalogs") + Observable> getCatalog(@Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Query("reservedResourceType") String reservedResourceType, @Query("location") String location, @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.reservations.AzureReservationAPI getAppliedReservationList" }) + @GET("subscriptions/{subscriptionId}/providers/Microsoft.Capacity/appliedReservations") + Observable> getAppliedReservationList(@Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + } + + /** + * Get the regions and skus that are available for RI purchase for the specified Azure subscription. + * + * @param subscriptionId Id of the subscription + * @param reservedResourceType The type of the resource for which the skus should be provided. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<CatalogInner> object if successful. + */ + public List getCatalog(String subscriptionId, String reservedResourceType) { + return getCatalogWithServiceResponseAsync(subscriptionId, reservedResourceType).toBlocking().single().body(); + } + + /** + * Get the regions and skus that are available for RI purchase for the specified Azure subscription. + * + * @param subscriptionId Id of the subscription + * @param reservedResourceType The type of the resource for which the skus should be provided. + * @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> getCatalogAsync(String subscriptionId, String reservedResourceType, final ServiceCallback> serviceCallback) { + return ServiceFuture.fromResponse(getCatalogWithServiceResponseAsync(subscriptionId, reservedResourceType), serviceCallback); + } + + /** + * Get the regions and skus that are available for RI purchase for the specified Azure subscription. + * + * @param subscriptionId Id of the subscription + * @param reservedResourceType The type of the resource for which the skus should be provided. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<CatalogInner> object + */ + public Observable> getCatalogAsync(String subscriptionId, String reservedResourceType) { + return getCatalogWithServiceResponseAsync(subscriptionId, reservedResourceType).map(new Func1>, List>() { + @Override + public List call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Get the regions and skus that are available for RI purchase for the specified Azure subscription. + * + * @param subscriptionId Id of the subscription + * @param reservedResourceType The type of the resource for which the skus should be provided. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<CatalogInner> object + */ + public Observable>> getCatalogWithServiceResponseAsync(String subscriptionId, String reservedResourceType) { + if (subscriptionId == null) { + throw new IllegalArgumentException("Parameter subscriptionId is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + if (reservedResourceType == null) { + throw new IllegalArgumentException("Parameter reservedResourceType is required and cannot be null."); + } + final String location = null; + return service.getCatalog(subscriptionId, this.apiVersion(), reservedResourceType, location, this.acceptLanguage(), this.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> clientResponse = getCatalogDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * Get the regions and skus that are available for RI purchase for the specified Azure subscription. + * + * @param subscriptionId Id of the subscription + * @param reservedResourceType The type of the resource for which the skus should be provided. + * @param location Filters the skus based on the location specified in this parameter. This can be an azure region or global + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<CatalogInner> object if successful. + */ + public List getCatalog(String subscriptionId, String reservedResourceType, String location) { + return getCatalogWithServiceResponseAsync(subscriptionId, reservedResourceType, location).toBlocking().single().body(); + } + + /** + * Get the regions and skus that are available for RI purchase for the specified Azure subscription. + * + * @param subscriptionId Id of the subscription + * @param reservedResourceType The type of the resource for which the skus should be provided. + * @param location Filters the skus based on the location specified in this parameter. This can be an azure region or global + * @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> getCatalogAsync(String subscriptionId, String reservedResourceType, String location, final ServiceCallback> serviceCallback) { + return ServiceFuture.fromResponse(getCatalogWithServiceResponseAsync(subscriptionId, reservedResourceType, location), serviceCallback); + } + + /** + * Get the regions and skus that are available for RI purchase for the specified Azure subscription. + * + * @param subscriptionId Id of the subscription + * @param reservedResourceType The type of the resource for which the skus should be provided. + * @param location Filters the skus based on the location specified in this parameter. This can be an azure region or global + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<CatalogInner> object + */ + public Observable> getCatalogAsync(String subscriptionId, String reservedResourceType, String location) { + return getCatalogWithServiceResponseAsync(subscriptionId, reservedResourceType, location).map(new Func1>, List>() { + @Override + public List call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Get the regions and skus that are available for RI purchase for the specified Azure subscription. + * + * @param subscriptionId Id of the subscription + * @param reservedResourceType The type of the resource for which the skus should be provided. + * @param location Filters the skus based on the location specified in this parameter. This can be an azure region or global + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<CatalogInner> object + */ + public Observable>> getCatalogWithServiceResponseAsync(String subscriptionId, String reservedResourceType, String location) { + if (subscriptionId == null) { + throw new IllegalArgumentException("Parameter subscriptionId is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + if (reservedResourceType == null) { + throw new IllegalArgumentException("Parameter reservedResourceType is required and cannot be null."); + } + return service.getCatalog(subscriptionId, this.apiVersion(), reservedResourceType, location, this.acceptLanguage(), this.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> clientResponse = getCatalogDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> getCatalogDelegate(Response response) throws ErrorException, IOException, IllegalArgumentException { + return this.restClient().responseBuilderFactory()., ErrorException>newInstance(this.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorException.class) + .build(response); + } + + /** + * Get list of applicable `Reservation`s. + * Get applicable `Reservation`s that are applied to this subscription. + * + * @param subscriptionId Id of the subscription + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the AppliedReservationsInner object if successful. + */ + public AppliedReservationsInner getAppliedReservationList(String subscriptionId) { + return getAppliedReservationListWithServiceResponseAsync(subscriptionId).toBlocking().single().body(); + } + + /** + * Get list of applicable `Reservation`s. + * Get applicable `Reservation`s that are applied to this subscription. + * + * @param subscriptionId Id of the subscription + * @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 getAppliedReservationListAsync(String subscriptionId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(getAppliedReservationListWithServiceResponseAsync(subscriptionId), serviceCallback); + } + + /** + * Get list of applicable `Reservation`s. + * Get applicable `Reservation`s that are applied to this subscription. + * + * @param subscriptionId Id of the subscription + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the AppliedReservationsInner object + */ + public Observable getAppliedReservationListAsync(String subscriptionId) { + return getAppliedReservationListWithServiceResponseAsync(subscriptionId).map(new Func1, AppliedReservationsInner>() { + @Override + public AppliedReservationsInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Get list of applicable `Reservation`s. + * Get applicable `Reservation`s that are applied to this subscription. + * + * @param subscriptionId Id of the subscription + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the AppliedReservationsInner object + */ + public Observable> getAppliedReservationListWithServiceResponseAsync(String subscriptionId) { + if (subscriptionId == null) { + throw new IllegalArgumentException("Parameter subscriptionId is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + return service.getAppliedReservationList(subscriptionId, this.apiVersion(), this.acceptLanguage(), this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getAppliedReservationListDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse getAppliedReservationListDelegate(Response response) throws ErrorException, IOException, IllegalArgumentException { + return this.restClient().responseBuilderFactory().newInstance(this.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(ErrorException.class) + .build(response); + } + +} diff --git a/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/implementation/CatalogInner.java b/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/implementation/CatalogInner.java new file mode 100644 index 00000000000..a813e8317b8 --- /dev/null +++ b/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/implementation/CatalogInner.java @@ -0,0 +1,110 @@ +/** + * 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.reservations.implementation; + +import java.util.List; +import com.microsoft.azure.management.reservations.SkuProperty; +import com.microsoft.azure.management.reservations.SkuRestriction; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The CatalogInner model. + */ +public class CatalogInner { + /** + * The type of resource the SKU applies to. + */ + @JsonProperty(value = "resourceType", access = JsonProperty.Access.WRITE_ONLY) + private String resourceType; + + /** + * The name of SKU. + */ + @JsonProperty(value = "name", access = JsonProperty.Access.WRITE_ONLY) + private String name; + + /** + * Available reservation terms for this resource. + */ + @JsonProperty(value = "terms", access = JsonProperty.Access.WRITE_ONLY) + private List terms; + + /** + * The locations property. + */ + @JsonProperty(value = "locations", access = JsonProperty.Access.WRITE_ONLY) + private List locations; + + /** + * The skuProperties property. + */ + @JsonProperty(value = "skuProperties", access = JsonProperty.Access.WRITE_ONLY) + private List skuProperties; + + /** + * The restrictions property. + */ + @JsonProperty(value = "restrictions", access = JsonProperty.Access.WRITE_ONLY) + private List restrictions; + + /** + * Get the type of resource the SKU applies to. + * + * @return the resourceType value + */ + public String resourceType() { + return this.resourceType; + } + + /** + * Get the name of SKU. + * + * @return the name value + */ + public String name() { + return this.name; + } + + /** + * Get available reservation terms for this resource. + * + * @return the terms value + */ + public List terms() { + return this.terms; + } + + /** + * Get the locations value. + * + * @return the locations value + */ + public List locations() { + return this.locations; + } + + /** + * Get the skuProperties value. + * + * @return the skuProperties value + */ + public List skuProperties() { + return this.skuProperties; + } + + /** + * Get the restrictions value. + * + * @return the restrictions value + */ + public List restrictions() { + return this.restrictions; + } + +} diff --git a/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/implementation/OperationResponseInner.java b/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/implementation/OperationResponseInner.java new file mode 100644 index 00000000000..8571259f1b4 --- /dev/null +++ b/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/implementation/OperationResponseInner.java @@ -0,0 +1,96 @@ +/** + * 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.reservations.implementation; + +import com.microsoft.azure.management.reservations.OperationDisplay; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The OperationResponseInner model. + */ +public class OperationResponseInner { + /** + * The name property. + */ + @JsonProperty(value = "name") + private String name; + + /** + * The display property. + */ + @JsonProperty(value = "display") + private OperationDisplay display; + + /** + * The origin property. + */ + @JsonProperty(value = "origin") + private String origin; + + /** + * Get the name value. + * + * @return the name value + */ + public String name() { + return this.name; + } + + /** + * Set the name value. + * + * @param name the name value to set + * @return the OperationResponseInner object itself. + */ + public OperationResponseInner withName(String name) { + this.name = name; + return this; + } + + /** + * 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 OperationResponseInner object itself. + */ + public OperationResponseInner withDisplay(OperationDisplay display) { + this.display = display; + return this; + } + + /** + * Get the origin value. + * + * @return the origin value + */ + public String origin() { + return this.origin; + } + + /** + * Set the origin value. + * + * @param origin the origin value to set + * @return the OperationResponseInner object itself. + */ + public OperationResponseInner withOrigin(String origin) { + this.origin = origin; + return this; + } + +} diff --git a/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/implementation/OperationsInner.java b/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/implementation/OperationsInner.java new file mode 100644 index 00000000000..806f09299b3 --- /dev/null +++ b/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/implementation/OperationsInner.java @@ -0,0 +1,293 @@ +/** + * 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.reservations.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.reservations.ErrorException; +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 AzureReservationAPIImpl 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, AzureReservationAPIImpl 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.reservations.Operations list" }) + @GET("providers/Microsoft.Capacity/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.reservations.Operations listNext" }) + @GET + Observable> listNext(@Url String nextUrl, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + } + + /** + * Get operations. + * List all the operations. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorException 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<OperationResponseInner> 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(); + } + }; + } + + /** + * Get operations. + * List all the 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); + } + + /** + * Get operations. + * List all the operations. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<OperationResponseInner> object + */ + public Observable> listAsync() { + return listWithServiceResponseAsync() + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Get operations. + * List all the operations. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<OperationResponseInner> 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)); + } + }); + } + + /** + * Get operations. + * List all the operations. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<OperationResponseInner> 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 ErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorException.class) + .build(response); + } + + /** + * Get operations. + * List all the operations. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorException 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<OperationResponseInner> 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(); + } + }; + } + + /** + * Get operations. + * List all the 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); + } + + /** + * Get operations. + * List all the 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<OperationResponseInner> object + */ + public Observable> listNextAsync(final String nextPageLink) { + return listNextWithServiceResponseAsync(nextPageLink) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Get operations. + * List all the 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<OperationResponseInner> 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)); + } + }); + } + + /** + * Get operations. + * List all the 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<OperationResponseInner> 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 ErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorException.class) + .build(response); + } + +} diff --git a/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/implementation/PageImpl.java b/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/implementation/PageImpl.java new file mode 100644 index 00000000000..8548c772c7a --- /dev/null +++ b/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/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.reservations.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-reservations/src/main/java/com/microsoft/azure/management/reservations/implementation/ReservationOrderResponseInner.java b/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/implementation/ReservationOrderResponseInner.java new file mode 100644 index 00000000000..2f4864e0242 --- /dev/null +++ b/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/implementation/ReservationOrderResponseInner.java @@ -0,0 +1,305 @@ +/** + * 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.reservations.implementation; + +import org.joda.time.DateTime; +import org.joda.time.LocalDate; +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.microsoft.rest.serializer.JsonFlatten; + +/** + * The ReservationOrderResponseInner model. + */ +@JsonFlatten +public class ReservationOrderResponseInner { + /** + * The etag property. + */ + @JsonProperty(value = "etag") + private Integer etag; + + /** + * Identifier of the reservation. + */ + @JsonProperty(value = "id", access = JsonProperty.Access.WRITE_ONLY) + private String id; + + /** + * Name of the reservation. + */ + @JsonProperty(value = "name", access = JsonProperty.Access.WRITE_ONLY) + private String name; + + /** + * Friendly name for user to easily identified the reservation. + */ + @JsonProperty(value = "properties.displayName") + private String displayName; + + /** + * This is the DateTime when the reservation was initially requested for + * purchase. + */ + @JsonProperty(value = "properties.requestDateTime") + private DateTime requestDateTime; + + /** + * This is the DateTime when the reservation was created. + */ + @JsonProperty(value = "properties.createdDateTime") + private DateTime createdDateTime; + + /** + * This is the date when the Reservation will expire. + */ + @JsonProperty(value = "properties.expiryDate") + private LocalDate expiryDate; + + /** + * Total Quantity of the SKUs purchased in the Reservation. + */ + @JsonProperty(value = "properties.originalQuantity") + private Integer originalQuantity; + + /** + * Possible values include: 'P1Y', 'P3Y'. + */ + @JsonProperty(value = "properties.term") + private String term; + + /** + * Possible values include: 'Creating', 'PendingResourceHold', + * 'ConfirmedResourceHold', 'PendingBilling', 'ConfirmedBilling', + * 'Created', 'Succeeded', 'Cancelled', 'Expired', 'BillingFailed', + * 'Failed', 'Split', 'Merged'. + */ + @JsonProperty(value = "properties.provisioningState") + private String provisioningState; + + /** + * The reservations property. + */ + @JsonProperty(value = "properties.reservations") + private List reservations; + + /** + * Type of resource. "Microsoft.Capacity/reservations". + */ + @JsonProperty(value = "type", access = JsonProperty.Access.WRITE_ONLY) + private String type; + + /** + * Get the etag value. + * + * @return the etag value + */ + public Integer etag() { + return this.etag; + } + + /** + * Set the etag value. + * + * @param etag the etag value to set + * @return the ReservationOrderResponseInner object itself. + */ + public ReservationOrderResponseInner withEtag(Integer etag) { + this.etag = etag; + return this; + } + + /** + * Get identifier of the reservation. + * + * @return the id value + */ + public String id() { + return this.id; + } + + /** + * Get name of the reservation. + * + * @return the name value + */ + public String name() { + return this.name; + } + + /** + * Get friendly name for user to easily identified the reservation. + * + * @return the displayName value + */ + public String displayName() { + return this.displayName; + } + + /** + * Set friendly name for user to easily identified the reservation. + * + * @param displayName the displayName value to set + * @return the ReservationOrderResponseInner object itself. + */ + public ReservationOrderResponseInner withDisplayName(String displayName) { + this.displayName = displayName; + return this; + } + + /** + * Get this is the DateTime when the reservation was initially requested for purchase. + * + * @return the requestDateTime value + */ + public DateTime requestDateTime() { + return this.requestDateTime; + } + + /** + * Set this is the DateTime when the reservation was initially requested for purchase. + * + * @param requestDateTime the requestDateTime value to set + * @return the ReservationOrderResponseInner object itself. + */ + public ReservationOrderResponseInner withRequestDateTime(DateTime requestDateTime) { + this.requestDateTime = requestDateTime; + return this; + } + + /** + * Get this is the DateTime when the reservation was created. + * + * @return the createdDateTime value + */ + public DateTime createdDateTime() { + return this.createdDateTime; + } + + /** + * Set this is the DateTime when the reservation was created. + * + * @param createdDateTime the createdDateTime value to set + * @return the ReservationOrderResponseInner object itself. + */ + public ReservationOrderResponseInner withCreatedDateTime(DateTime createdDateTime) { + this.createdDateTime = createdDateTime; + return this; + } + + /** + * Get this is the date when the Reservation will expire. + * + * @return the expiryDate value + */ + public LocalDate expiryDate() { + return this.expiryDate; + } + + /** + * Set this is the date when the Reservation will expire. + * + * @param expiryDate the expiryDate value to set + * @return the ReservationOrderResponseInner object itself. + */ + public ReservationOrderResponseInner withExpiryDate(LocalDate expiryDate) { + this.expiryDate = expiryDate; + return this; + } + + /** + * Get total Quantity of the SKUs purchased in the Reservation. + * + * @return the originalQuantity value + */ + public Integer originalQuantity() { + return this.originalQuantity; + } + + /** + * Set total Quantity of the SKUs purchased in the Reservation. + * + * @param originalQuantity the originalQuantity value to set + * @return the ReservationOrderResponseInner object itself. + */ + public ReservationOrderResponseInner withOriginalQuantity(Integer originalQuantity) { + this.originalQuantity = originalQuantity; + return this; + } + + /** + * Get possible values include: 'P1Y', 'P3Y'. + * + * @return the term value + */ + public String term() { + return this.term; + } + + /** + * Set possible values include: 'P1Y', 'P3Y'. + * + * @param term the term value to set + * @return the ReservationOrderResponseInner object itself. + */ + public ReservationOrderResponseInner withTerm(String term) { + this.term = term; + return this; + } + + /** + * Get possible values include: 'Creating', 'PendingResourceHold', 'ConfirmedResourceHold', 'PendingBilling', 'ConfirmedBilling', 'Created', 'Succeeded', 'Cancelled', 'Expired', 'BillingFailed', 'Failed', 'Split', 'Merged'. + * + * @return the provisioningState value + */ + public String provisioningState() { + return this.provisioningState; + } + + /** + * Set possible values include: 'Creating', 'PendingResourceHold', 'ConfirmedResourceHold', 'PendingBilling', 'ConfirmedBilling', 'Created', 'Succeeded', 'Cancelled', 'Expired', 'BillingFailed', 'Failed', 'Split', 'Merged'. + * + * @param provisioningState the provisioningState value to set + * @return the ReservationOrderResponseInner object itself. + */ + public ReservationOrderResponseInner withProvisioningState(String provisioningState) { + this.provisioningState = provisioningState; + return this; + } + + /** + * Get the reservations value. + * + * @return the reservations value + */ + public List reservations() { + return this.reservations; + } + + /** + * Set the reservations value. + * + * @param reservations the reservations value to set + * @return the ReservationOrderResponseInner object itself. + */ + public ReservationOrderResponseInner withReservations(List reservations) { + this.reservations = reservations; + return this; + } + + /** + * Get type of resource. "Microsoft.Capacity/reservations". + * + * @return the type value + */ + public String type() { + return this.type; + } + +} diff --git a/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/implementation/ReservationOrdersInner.java b/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/implementation/ReservationOrdersInner.java new file mode 100644 index 00000000000..7f479e5a9d2 --- /dev/null +++ b/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/implementation/ReservationOrdersInner.java @@ -0,0 +1,379 @@ +/** + * 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.reservations.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.reservations.ErrorException; +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 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.Path; +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 ReservationOrders. + */ +public class ReservationOrdersInner { + /** The Retrofit service to perform REST calls. */ + private ReservationOrdersService service; + /** The service client containing this operation class. */ + private AzureReservationAPIImpl client; + + /** + * Initializes an instance of ReservationOrdersInner. + * + * @param retrofit the Retrofit instance built from a Retrofit Builder. + * @param client the instance of the service client containing this operation class. + */ + public ReservationOrdersInner(Retrofit retrofit, AzureReservationAPIImpl client) { + this.service = retrofit.create(ReservationOrdersService.class); + this.client = client; + } + + /** + * The interface defining all the services for ReservationOrders to be + * used by Retrofit to perform actually REST calls. + */ + interface ReservationOrdersService { + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.reservations.ReservationOrders list" }) + @GET("providers/Microsoft.Capacity/reservationOrders") + 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.reservations.ReservationOrders get" }) + @GET("providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}") + Observable> get(@Path("reservationOrderId") String reservationOrderId, @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.reservations.ReservationOrders listNext" }) + @GET + Observable> listNext(@Url String nextUrl, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + } + + /** + * Get all `ReservationOrder`s. + * List of all the `ReservationOrder`s that the user has access to in the current tenant. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorException 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<ReservationOrderResponseInner> 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(); + } + }; + } + + /** + * Get all `ReservationOrder`s. + * List of all the `ReservationOrder`s that the user has access to in the current tenant. + * + * @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); + } + + /** + * Get all `ReservationOrder`s. + * List of all the `ReservationOrder`s that the user has access to in the current tenant. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<ReservationOrderResponseInner> object + */ + public Observable> listAsync() { + return listWithServiceResponseAsync() + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Get all `ReservationOrder`s. + * List of all the `ReservationOrder`s that the user has access to in the current tenant. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<ReservationOrderResponseInner> 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)); + } + }); + } + + /** + * Get all `ReservationOrder`s. + * List of all the `ReservationOrder`s that the user has access to in the current tenant. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<ReservationOrderResponseInner> 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 ErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorException.class) + .build(response); + } + + /** + * Get a specific `ReservationOrder`. + * Get the details of the `ReservationOrder`. + * + * @param reservationOrderId Order Id of the reservation + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the ReservationOrderResponseInner object if successful. + */ + public ReservationOrderResponseInner get(String reservationOrderId) { + return getWithServiceResponseAsync(reservationOrderId).toBlocking().single().body(); + } + + /** + * Get a specific `ReservationOrder`. + * Get the details of the `ReservationOrder`. + * + * @param reservationOrderId Order Id of the reservation + * @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 reservationOrderId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(getWithServiceResponseAsync(reservationOrderId), serviceCallback); + } + + /** + * Get a specific `ReservationOrder`. + * Get the details of the `ReservationOrder`. + * + * @param reservationOrderId Order Id of the reservation + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the ReservationOrderResponseInner object + */ + public Observable getAsync(String reservationOrderId) { + return getWithServiceResponseAsync(reservationOrderId).map(new Func1, ReservationOrderResponseInner>() { + @Override + public ReservationOrderResponseInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Get a specific `ReservationOrder`. + * Get the details of the `ReservationOrder`. + * + * @param reservationOrderId Order Id of the reservation + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the ReservationOrderResponseInner object + */ + public Observable> getWithServiceResponseAsync(String reservationOrderId) { + if (reservationOrderId == null) { + throw new IllegalArgumentException("Parameter reservationOrderId 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(reservationOrderId, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse getDelegate(Response response) throws ErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(ErrorException.class) + .build(response); + } + + /** + * Get all `ReservationOrder`s. + * List of all the `ReservationOrder`s that the user has access to in the current tenant. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorException 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<ReservationOrderResponseInner> 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(); + } + }; + } + + /** + * Get all `ReservationOrder`s. + * List of all the `ReservationOrder`s that the user has access to in the current tenant. + * + * @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); + } + + /** + * Get all `ReservationOrder`s. + * List of all the `ReservationOrder`s that the user has access to in the current tenant. + * + * @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<ReservationOrderResponseInner> object + */ + public Observable> listNextAsync(final String nextPageLink) { + return listNextWithServiceResponseAsync(nextPageLink) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Get all `ReservationOrder`s. + * List of all the `ReservationOrder`s that the user has access to in the current tenant. + * + * @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<ReservationOrderResponseInner> 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)); + } + }); + } + + /** + * Get all `ReservationOrder`s. + * List of all the `ReservationOrder`s that the user has access to in the current tenant. + * + ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<ReservationOrderResponseInner> 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 ErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorException.class) + .build(response); + } + +} diff --git a/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/implementation/ReservationResponseInner.java b/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/implementation/ReservationResponseInner.java new file mode 100644 index 00000000000..d141e7b7b84 --- /dev/null +++ b/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/implementation/ReservationResponseInner.java @@ -0,0 +1,174 @@ +/** + * 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.reservations.implementation; + +import com.microsoft.azure.management.reservations.SkuName; +import com.microsoft.azure.management.reservations.ReservationProperties; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The ReservationResponseInner model. + */ +public class ReservationResponseInner { + /** + * Possible values include: 'westus', 'eastus', 'eastus2', + * 'northcentralus', 'westus2', 'southcentralus', 'centralus', + * 'westeurope', 'northeurope', 'eastasia', 'southeastasia', 'japaneast', + * 'japanwest', 'brazilsouth', 'australiaeast', 'australiasoutheast', + * 'southindia', 'westindia', 'centralindia', 'canadacentral', + * 'canadaeast', 'uksouth', 'westcentralus', 'ukwest', 'francecentral', + * 'francesouth', 'australiac', 'australiac2'. + */ + @JsonProperty(value = "location") + private String location; + + /** + * The etag property. + */ + @JsonProperty(value = "etag") + private Integer etag; + + /** + * Identifier of the reservation. + */ + @JsonProperty(value = "id", access = JsonProperty.Access.WRITE_ONLY) + private String id; + + /** + * Name of the reservation. + */ + @JsonProperty(value = "name", access = JsonProperty.Access.WRITE_ONLY) + private String name; + + /** + * The sku property. + */ + @JsonProperty(value = "sku") + private SkuName sku; + + /** + * The properties property. + */ + @JsonProperty(value = "properties") + private ReservationProperties properties; + + /** + * Type of resource. "Microsoft.Capacity/reservationOrders/reservations". + */ + @JsonProperty(value = "type", access = JsonProperty.Access.WRITE_ONLY) + private String type; + + /** + * Get possible values include: 'westus', 'eastus', 'eastus2', 'northcentralus', 'westus2', 'southcentralus', 'centralus', 'westeurope', 'northeurope', 'eastasia', 'southeastasia', 'japaneast', 'japanwest', 'brazilsouth', 'australiaeast', 'australiasoutheast', 'southindia', 'westindia', 'centralindia', 'canadacentral', 'canadaeast', 'uksouth', 'westcentralus', 'ukwest', 'francecentral', 'francesouth', 'australiac', 'australiac2'. + * + * @return the location value + */ + public String location() { + return this.location; + } + + /** + * Set possible values include: 'westus', 'eastus', 'eastus2', 'northcentralus', 'westus2', 'southcentralus', 'centralus', 'westeurope', 'northeurope', 'eastasia', 'southeastasia', 'japaneast', 'japanwest', 'brazilsouth', 'australiaeast', 'australiasoutheast', 'southindia', 'westindia', 'centralindia', 'canadacentral', 'canadaeast', 'uksouth', 'westcentralus', 'ukwest', 'francecentral', 'francesouth', 'australiac', 'australiac2'. + * + * @param location the location value to set + * @return the ReservationResponseInner object itself. + */ + public ReservationResponseInner withLocation(String location) { + this.location = location; + return this; + } + + /** + * Get the etag value. + * + * @return the etag value + */ + public Integer etag() { + return this.etag; + } + + /** + * Set the etag value. + * + * @param etag the etag value to set + * @return the ReservationResponseInner object itself. + */ + public ReservationResponseInner withEtag(Integer etag) { + this.etag = etag; + return this; + } + + /** + * Get identifier of the reservation. + * + * @return the id value + */ + public String id() { + return this.id; + } + + /** + * Get name of the reservation. + * + * @return the name value + */ + public String name() { + return this.name; + } + + /** + * Get the sku value. + * + * @return the sku value + */ + public SkuName sku() { + return this.sku; + } + + /** + * Set the sku value. + * + * @param sku the sku value to set + * @return the ReservationResponseInner object itself. + */ + public ReservationResponseInner withSku(SkuName sku) { + this.sku = sku; + return this; + } + + /** + * Get the properties value. + * + * @return the properties value + */ + public ReservationProperties properties() { + return this.properties; + } + + /** + * Set the properties value. + * + * @param properties the properties value to set + * @return the ReservationResponseInner object itself. + */ + public ReservationResponseInner withProperties(ReservationProperties properties) { + this.properties = properties; + return this; + } + + /** + * Get type of resource. "Microsoft.Capacity/reservationOrders/reservations". + * + * @return the type value + */ + public String type() { + return this.type; + } + +} diff --git a/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/implementation/ReservationsInner.java b/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/implementation/ReservationsInner.java new file mode 100644 index 00000000000..b87baa49631 --- /dev/null +++ b/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/implementation/ReservationsInner.java @@ -0,0 +1,1307 @@ +/** + * 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.reservations.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.reservations.ErrorException; +import com.microsoft.azure.management.reservations.MergeRequest; +import com.microsoft.azure.management.reservations.Patch; +import com.microsoft.azure.management.reservations.SplitRequest; +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.PATCH; +import retrofit2.http.Path; +import retrofit2.http.POST; +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 Reservations. + */ +public class ReservationsInner { + /** The Retrofit service to perform REST calls. */ + private ReservationsService service; + /** The service client containing this operation class. */ + private AzureReservationAPIImpl client; + + /** + * Initializes an instance of ReservationsInner. + * + * @param retrofit the Retrofit instance built from a Retrofit Builder. + * @param client the instance of the service client containing this operation class. + */ + public ReservationsInner(Retrofit retrofit, AzureReservationAPIImpl client) { + this.service = retrofit.create(ReservationsService.class); + this.client = client; + } + + /** + * The interface defining all the services for Reservations to be + * used by Retrofit to perform actually REST calls. + */ + interface ReservationsService { + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.reservations.Reservations split" }) + @POST("providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/split") + Observable> split(@Path("reservationOrderId") String reservationOrderId, @Query("api-version") String apiVersion, @Body SplitRequest body, @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.reservations.Reservations beginSplit" }) + @POST("providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/split") + Observable> beginSplit(@Path("reservationOrderId") String reservationOrderId, @Query("api-version") String apiVersion, @Body SplitRequest body, @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.reservations.Reservations merge" }) + @POST("providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/merge") + Observable> merge(@Path("reservationOrderId") String reservationOrderId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body MergeRequest body, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.reservations.Reservations beginMerge" }) + @POST("providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/merge") + Observable> beginMerge(@Path("reservationOrderId") String reservationOrderId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body MergeRequest body, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.reservations.Reservations list" }) + @GET("providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations") + Observable> list(@Path("reservationOrderId") String reservationOrderId, @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.reservations.Reservations get" }) + @GET("providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}") + Observable> get(@Path("reservationId") String reservationId, @Path("reservationOrderId") String reservationOrderId, @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.reservations.Reservations update" }) + @PATCH("providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}") + Observable> update(@Path("reservationOrderId") String reservationOrderId, @Path("reservationId") String reservationId, @Query("api-version") String apiVersion, @Body Patch parameters, @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.reservations.Reservations beginUpdate" }) + @PATCH("providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}") + Observable> beginUpdate(@Path("reservationOrderId") String reservationOrderId, @Path("reservationId") String reservationId, @Query("api-version") String apiVersion, @Body Patch parameters, @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.reservations.Reservations listRevisions" }) + @GET("providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}/revisions") + Observable> listRevisions(@Path("reservationId") String reservationId, @Path("reservationOrderId") String reservationOrderId, @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.reservations.Reservations listNext" }) + @GET + Observable> listNext(@Url String nextUrl, @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.reservations.Reservations listRevisionsNext" }) + @GET + Observable> listRevisionsNext(@Url String nextUrl, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + } + + /** + * Split the `Reservation`. + * Split a `Reservation` into two `Reservation`s with specified quantity distribution. + * + * @param reservationOrderId Order Id of the reservation + * @param body Information needed to Split a reservation item + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<ReservationResponseInner> object if successful. + */ + public List split(String reservationOrderId, SplitRequest body) { + return splitWithServiceResponseAsync(reservationOrderId, body).toBlocking().last().body(); + } + + /** + * Split the `Reservation`. + * Split a `Reservation` into two `Reservation`s with specified quantity distribution. + * + * @param reservationOrderId Order Id of the reservation + * @param body Information needed to Split a reservation item + * @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> splitAsync(String reservationOrderId, SplitRequest body, final ServiceCallback> serviceCallback) { + return ServiceFuture.fromResponse(splitWithServiceResponseAsync(reservationOrderId, body), serviceCallback); + } + + /** + * Split the `Reservation`. + * Split a `Reservation` into two `Reservation`s with specified quantity distribution. + * + * @param reservationOrderId Order Id of the reservation + * @param body Information needed to Split a reservation item + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + public Observable> splitAsync(String reservationOrderId, SplitRequest body) { + return splitWithServiceResponseAsync(reservationOrderId, body).map(new Func1>, List>() { + @Override + public List call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Split the `Reservation`. + * Split a `Reservation` into two `Reservation`s with specified quantity distribution. + * + * @param reservationOrderId Order Id of the reservation + * @param body Information needed to Split a reservation item + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + public Observable>> splitWithServiceResponseAsync(String reservationOrderId, SplitRequest body) { + if (reservationOrderId == null) { + throw new IllegalArgumentException("Parameter reservationOrderId 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 (body == null) { + throw new IllegalArgumentException("Parameter body is required and cannot be null."); + } + Validator.validate(body); + Observable> observable = service.split(reservationOrderId, this.client.apiVersion(), body, this.client.acceptLanguage(), this.client.userAgent()); + return client.getAzureClient().getPostOrDeleteResultAsync(observable, new TypeToken>() { }.getType()); + } + + /** + * Split the `Reservation`. + * Split a `Reservation` into two `Reservation`s with specified quantity distribution. + * + * @param reservationOrderId Order Id of the reservation + * @param body Information needed to Split a reservation item + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<ReservationResponseInner> object if successful. + */ + public List beginSplit(String reservationOrderId, SplitRequest body) { + return beginSplitWithServiceResponseAsync(reservationOrderId, body).toBlocking().single().body(); + } + + /** + * Split the `Reservation`. + * Split a `Reservation` into two `Reservation`s with specified quantity distribution. + * + * @param reservationOrderId Order Id of the reservation + * @param body Information needed to Split a reservation item + * @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> beginSplitAsync(String reservationOrderId, SplitRequest body, final ServiceCallback> serviceCallback) { + return ServiceFuture.fromResponse(beginSplitWithServiceResponseAsync(reservationOrderId, body), serviceCallback); + } + + /** + * Split the `Reservation`. + * Split a `Reservation` into two `Reservation`s with specified quantity distribution. + * + * @param reservationOrderId Order Id of the reservation + * @param body Information needed to Split a reservation item + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<ReservationResponseInner> object + */ + public Observable> beginSplitAsync(String reservationOrderId, SplitRequest body) { + return beginSplitWithServiceResponseAsync(reservationOrderId, body).map(new Func1>, List>() { + @Override + public List call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Split the `Reservation`. + * Split a `Reservation` into two `Reservation`s with specified quantity distribution. + * + * @param reservationOrderId Order Id of the reservation + * @param body Information needed to Split a reservation item + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<ReservationResponseInner> object + */ + public Observable>> beginSplitWithServiceResponseAsync(String reservationOrderId, SplitRequest body) { + if (reservationOrderId == null) { + throw new IllegalArgumentException("Parameter reservationOrderId 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 (body == null) { + throw new IllegalArgumentException("Parameter body is required and cannot be null."); + } + Validator.validate(body); + return service.beginSplit(reservationOrderId, this.client.apiVersion(), body, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> clientResponse = beginSplitDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> beginSplitDelegate(Response response) throws ErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .register(202, new TypeToken() { }.getType()) + .registerError(ErrorException.class) + .build(response); + } + + /** + * Merges two `Reservation`s. + * Merge the specified `Reservation`s into a new `Reservation`. The two `Reservation`s being merged must have same properties. + * + * @param reservationOrderId Order Id of the reservation + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<ReservationResponseInner> object if successful. + */ + public List merge(String reservationOrderId) { + return mergeWithServiceResponseAsync(reservationOrderId).toBlocking().last().body(); + } + + /** + * Merges two `Reservation`s. + * Merge the specified `Reservation`s into a new `Reservation`. The two `Reservation`s being merged must have same properties. + * + * @param reservationOrderId Order Id of the reservation + * @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> mergeAsync(String reservationOrderId, final ServiceCallback> serviceCallback) { + return ServiceFuture.fromResponse(mergeWithServiceResponseAsync(reservationOrderId), serviceCallback); + } + + /** + * Merges two `Reservation`s. + * Merge the specified `Reservation`s into a new `Reservation`. The two `Reservation`s being merged must have same properties. + * + * @param reservationOrderId Order Id of the reservation + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + public Observable> mergeAsync(String reservationOrderId) { + return mergeWithServiceResponseAsync(reservationOrderId).map(new Func1>, List>() { + @Override + public List call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Merges two `Reservation`s. + * Merge the specified `Reservation`s into a new `Reservation`. The two `Reservation`s being merged must have same properties. + * + * @param reservationOrderId Order Id of the reservation + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + public Observable>> mergeWithServiceResponseAsync(String reservationOrderId) { + if (reservationOrderId == null) { + throw new IllegalArgumentException("Parameter reservationOrderId 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 sourcesConverted = null; + MergeRequest body = new MergeRequest(); + body.withSources(null); + Observable> observable = service.merge(reservationOrderId, this.client.apiVersion(), this.client.acceptLanguage(), body, this.client.userAgent()); + return client.getAzureClient().getPostOrDeleteResultAsync(observable, new TypeToken>() { }.getType()); + } + /** + * Merges two `Reservation`s. + * Merge the specified `Reservation`s into a new `Reservation`. The two `Reservation`s being merged must have same properties. + * + * @param reservationOrderId Order Id of the reservation + * @param sources Format of the resource id should be /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId} + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<ReservationResponseInner> object if successful. + */ + public List merge(String reservationOrderId, List sources) { + return mergeWithServiceResponseAsync(reservationOrderId, sources).toBlocking().last().body(); + } + + /** + * Merges two `Reservation`s. + * Merge the specified `Reservation`s into a new `Reservation`. The two `Reservation`s being merged must have same properties. + * + * @param reservationOrderId Order Id of the reservation + * @param sources Format of the resource id should be /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId} + * @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> mergeAsync(String reservationOrderId, List sources, final ServiceCallback> serviceCallback) { + return ServiceFuture.fromResponse(mergeWithServiceResponseAsync(reservationOrderId, sources), serviceCallback); + } + + /** + * Merges two `Reservation`s. + * Merge the specified `Reservation`s into a new `Reservation`. The two `Reservation`s being merged must have same properties. + * + * @param reservationOrderId Order Id of the reservation + * @param sources Format of the resource id should be /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId} + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + public Observable> mergeAsync(String reservationOrderId, List sources) { + return mergeWithServiceResponseAsync(reservationOrderId, sources).map(new Func1>, List>() { + @Override + public List call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Merges two `Reservation`s. + * Merge the specified `Reservation`s into a new `Reservation`. The two `Reservation`s being merged must have same properties. + * + * @param reservationOrderId Order Id of the reservation + * @param sources Format of the resource id should be /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId} + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + public Observable>> mergeWithServiceResponseAsync(String reservationOrderId, List sources) { + if (reservationOrderId == null) { + throw new IllegalArgumentException("Parameter reservationOrderId is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + Validator.validate(sources); + MergeRequest body = new MergeRequest(); + body.withSources(sources); + Observable> observable = service.merge(reservationOrderId, this.client.apiVersion(), this.client.acceptLanguage(), body, this.client.userAgent()); + return client.getAzureClient().getPostOrDeleteResultAsync(observable, new TypeToken>() { }.getType()); + } + + /** + * Merges two `Reservation`s. + * Merge the specified `Reservation`s into a new `Reservation`. The two `Reservation`s being merged must have same properties. + * + * @param reservationOrderId Order Id of the reservation + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<ReservationResponseInner> object if successful. + */ + public List beginMerge(String reservationOrderId) { + return beginMergeWithServiceResponseAsync(reservationOrderId).toBlocking().single().body(); + } + + /** + * Merges two `Reservation`s. + * Merge the specified `Reservation`s into a new `Reservation`. The two `Reservation`s being merged must have same properties. + * + * @param reservationOrderId Order Id of the reservation + * @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> beginMergeAsync(String reservationOrderId, final ServiceCallback> serviceCallback) { + return ServiceFuture.fromResponse(beginMergeWithServiceResponseAsync(reservationOrderId), serviceCallback); + } + + /** + * Merges two `Reservation`s. + * Merge the specified `Reservation`s into a new `Reservation`. The two `Reservation`s being merged must have same properties. + * + * @param reservationOrderId Order Id of the reservation + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<ReservationResponseInner> object + */ + public Observable> beginMergeAsync(String reservationOrderId) { + return beginMergeWithServiceResponseAsync(reservationOrderId).map(new Func1>, List>() { + @Override + public List call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Merges two `Reservation`s. + * Merge the specified `Reservation`s into a new `Reservation`. The two `Reservation`s being merged must have same properties. + * + * @param reservationOrderId Order Id of the reservation + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<ReservationResponseInner> object + */ + public Observable>> beginMergeWithServiceResponseAsync(String reservationOrderId) { + if (reservationOrderId == null) { + throw new IllegalArgumentException("Parameter reservationOrderId 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 List sources = null; + MergeRequest body = new MergeRequest(); + body.withSources(null); + return service.beginMerge(reservationOrderId, this.client.apiVersion(), this.client.acceptLanguage(), body, this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> clientResponse = beginMergeDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * Merges two `Reservation`s. + * Merge the specified `Reservation`s into a new `Reservation`. The two `Reservation`s being merged must have same properties. + * + * @param reservationOrderId Order Id of the reservation + * @param sources Format of the resource id should be /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId} + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<ReservationResponseInner> object if successful. + */ + public List beginMerge(String reservationOrderId, List sources) { + return beginMergeWithServiceResponseAsync(reservationOrderId, sources).toBlocking().single().body(); + } + + /** + * Merges two `Reservation`s. + * Merge the specified `Reservation`s into a new `Reservation`. The two `Reservation`s being merged must have same properties. + * + * @param reservationOrderId Order Id of the reservation + * @param sources Format of the resource id should be /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId} + * @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> beginMergeAsync(String reservationOrderId, List sources, final ServiceCallback> serviceCallback) { + return ServiceFuture.fromResponse(beginMergeWithServiceResponseAsync(reservationOrderId, sources), serviceCallback); + } + + /** + * Merges two `Reservation`s. + * Merge the specified `Reservation`s into a new `Reservation`. The two `Reservation`s being merged must have same properties. + * + * @param reservationOrderId Order Id of the reservation + * @param sources Format of the resource id should be /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId} + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<ReservationResponseInner> object + */ + public Observable> beginMergeAsync(String reservationOrderId, List sources) { + return beginMergeWithServiceResponseAsync(reservationOrderId, sources).map(new Func1>, List>() { + @Override + public List call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Merges two `Reservation`s. + * Merge the specified `Reservation`s into a new `Reservation`. The two `Reservation`s being merged must have same properties. + * + * @param reservationOrderId Order Id of the reservation + * @param sources Format of the resource id should be /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId} + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<ReservationResponseInner> object + */ + public Observable>> beginMergeWithServiceResponseAsync(String reservationOrderId, List sources) { + if (reservationOrderId == null) { + throw new IllegalArgumentException("Parameter reservationOrderId is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + Validator.validate(sources); + MergeRequest body = new MergeRequest(); + body.withSources(sources); + return service.beginMerge(reservationOrderId, this.client.apiVersion(), this.client.acceptLanguage(), body, this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> clientResponse = beginMergeDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> beginMergeDelegate(Response response) throws ErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .register(202, new TypeToken() { }.getType()) + .registerError(ErrorException.class) + .build(response); + } + + /** + * Get `Reservation`s in a given reservation Order. + * List `Reservation`s within a single `ReservationOrder`. + * + * @param reservationOrderId Order Id of the reservation + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorException 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<ReservationResponseInner> object if successful. + */ + public PagedList list(final String reservationOrderId) { + ServiceResponse> response = listSinglePageAsync(reservationOrderId).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Get `Reservation`s in a given reservation Order. + * List `Reservation`s within a single `ReservationOrder`. + * + * @param reservationOrderId Order Id of the reservation + * @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 reservationOrderId, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listSinglePageAsync(reservationOrderId), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Get `Reservation`s in a given reservation Order. + * List `Reservation`s within a single `ReservationOrder`. + * + * @param reservationOrderId Order Id of the reservation + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<ReservationResponseInner> object + */ + public Observable> listAsync(final String reservationOrderId) { + return listWithServiceResponseAsync(reservationOrderId) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Get `Reservation`s in a given reservation Order. + * List `Reservation`s within a single `ReservationOrder`. + * + * @param reservationOrderId Order Id of the reservation + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<ReservationResponseInner> object + */ + public Observable>> listWithServiceResponseAsync(final String reservationOrderId) { + return listSinglePageAsync(reservationOrderId) + .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)); + } + }); + } + + /** + * Get `Reservation`s in a given reservation Order. + * List `Reservation`s within a single `ReservationOrder`. + * + ServiceResponse> * @param reservationOrderId Order Id of the reservation + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<ReservationResponseInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listSinglePageAsync(final String reservationOrderId) { + if (reservationOrderId == null) { + throw new IllegalArgumentException("Parameter reservationOrderId 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.list(reservationOrderId, 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 ErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorException.class) + .build(response); + } + + /** + * Get `Reservation` details. + * Get specific `Reservation` details. + * + * @param reservationId Id of the Reservation Item + * @param reservationOrderId Order Id of the reservation + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the ReservationResponseInner object if successful. + */ + public ReservationResponseInner get(String reservationId, String reservationOrderId) { + return getWithServiceResponseAsync(reservationId, reservationOrderId).toBlocking().single().body(); + } + + /** + * Get `Reservation` details. + * Get specific `Reservation` details. + * + * @param reservationId Id of the Reservation Item + * @param reservationOrderId Order Id of the reservation + * @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 reservationId, String reservationOrderId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(getWithServiceResponseAsync(reservationId, reservationOrderId), serviceCallback); + } + + /** + * Get `Reservation` details. + * Get specific `Reservation` details. + * + * @param reservationId Id of the Reservation Item + * @param reservationOrderId Order Id of the reservation + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the ReservationResponseInner object + */ + public Observable getAsync(String reservationId, String reservationOrderId) { + return getWithServiceResponseAsync(reservationId, reservationOrderId).map(new Func1, ReservationResponseInner>() { + @Override + public ReservationResponseInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Get `Reservation` details. + * Get specific `Reservation` details. + * + * @param reservationId Id of the Reservation Item + * @param reservationOrderId Order Id of the reservation + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the ReservationResponseInner object + */ + public Observable> getWithServiceResponseAsync(String reservationId, String reservationOrderId) { + if (reservationId == null) { + throw new IllegalArgumentException("Parameter reservationId is required and cannot be null."); + } + if (reservationOrderId == null) { + throw new IllegalArgumentException("Parameter reservationOrderId 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(reservationId, reservationOrderId, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse getDelegate(Response response) throws ErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(ErrorException.class) + .build(response); + } + + /** + * Updates a `Reservation`. + * Updates the applied scopes of the `Reservation`. + * + * @param reservationOrderId Order Id of the reservation + * @param reservationId Id of the Reservation Item + * @param parameters Information needed to patch a reservation item + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the ReservationResponseInner object if successful. + */ + public ReservationResponseInner update(String reservationOrderId, String reservationId, Patch parameters) { + return updateWithServiceResponseAsync(reservationOrderId, reservationId, parameters).toBlocking().last().body(); + } + + /** + * Updates a `Reservation`. + * Updates the applied scopes of the `Reservation`. + * + * @param reservationOrderId Order Id of the reservation + * @param reservationId Id of the Reservation Item + * @param parameters Information needed to patch a reservation item + * @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 reservationOrderId, String reservationId, Patch parameters, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(updateWithServiceResponseAsync(reservationOrderId, reservationId, parameters), serviceCallback); + } + + /** + * Updates a `Reservation`. + * Updates the applied scopes of the `Reservation`. + * + * @param reservationOrderId Order Id of the reservation + * @param reservationId Id of the Reservation Item + * @param parameters Information needed to patch a reservation item + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + public Observable updateAsync(String reservationOrderId, String reservationId, Patch parameters) { + return updateWithServiceResponseAsync(reservationOrderId, reservationId, parameters).map(new Func1, ReservationResponseInner>() { + @Override + public ReservationResponseInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Updates a `Reservation`. + * Updates the applied scopes of the `Reservation`. + * + * @param reservationOrderId Order Id of the reservation + * @param reservationId Id of the Reservation Item + * @param parameters Information needed to patch a reservation item + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + public Observable> updateWithServiceResponseAsync(String reservationOrderId, String reservationId, Patch parameters) { + if (reservationOrderId == null) { + throw new IllegalArgumentException("Parameter reservationOrderId is required and cannot be null."); + } + if (reservationId == null) { + throw new IllegalArgumentException("Parameter reservationId 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 (parameters == null) { + throw new IllegalArgumentException("Parameter parameters is required and cannot be null."); + } + Validator.validate(parameters); + Observable> observable = service.update(reservationOrderId, reservationId, this.client.apiVersion(), parameters, this.client.acceptLanguage(), this.client.userAgent()); + return client.getAzureClient().getPutOrPatchResultAsync(observable, new TypeToken() { }.getType()); + } + + /** + * Updates a `Reservation`. + * Updates the applied scopes of the `Reservation`. + * + * @param reservationOrderId Order Id of the reservation + * @param reservationId Id of the Reservation Item + * @param parameters Information needed to patch a reservation item + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the ReservationResponseInner object if successful. + */ + public ReservationResponseInner beginUpdate(String reservationOrderId, String reservationId, Patch parameters) { + return beginUpdateWithServiceResponseAsync(reservationOrderId, reservationId, parameters).toBlocking().single().body(); + } + + /** + * Updates a `Reservation`. + * Updates the applied scopes of the `Reservation`. + * + * @param reservationOrderId Order Id of the reservation + * @param reservationId Id of the Reservation Item + * @param parameters Information needed to patch a reservation item + * @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 beginUpdateAsync(String reservationOrderId, String reservationId, Patch parameters, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(beginUpdateWithServiceResponseAsync(reservationOrderId, reservationId, parameters), serviceCallback); + } + + /** + * Updates a `Reservation`. + * Updates the applied scopes of the `Reservation`. + * + * @param reservationOrderId Order Id of the reservation + * @param reservationId Id of the Reservation Item + * @param parameters Information needed to patch a reservation item + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the ReservationResponseInner object + */ + public Observable beginUpdateAsync(String reservationOrderId, String reservationId, Patch parameters) { + return beginUpdateWithServiceResponseAsync(reservationOrderId, reservationId, parameters).map(new Func1, ReservationResponseInner>() { + @Override + public ReservationResponseInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Updates a `Reservation`. + * Updates the applied scopes of the `Reservation`. + * + * @param reservationOrderId Order Id of the reservation + * @param reservationId Id of the Reservation Item + * @param parameters Information needed to patch a reservation item + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the ReservationResponseInner object + */ + public Observable> beginUpdateWithServiceResponseAsync(String reservationOrderId, String reservationId, Patch parameters) { + if (reservationOrderId == null) { + throw new IllegalArgumentException("Parameter reservationOrderId is required and cannot be null."); + } + if (reservationId == null) { + throw new IllegalArgumentException("Parameter reservationId 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 (parameters == null) { + throw new IllegalArgumentException("Parameter parameters is required and cannot be null."); + } + Validator.validate(parameters); + return service.beginUpdate(reservationOrderId, reservationId, this.client.apiVersion(), parameters, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = beginUpdateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse beginUpdateDelegate(Response response) throws ErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .register(202, new TypeToken() { }.getType()) + .registerError(ErrorException.class) + .build(response); + } + + /** + * Get `Reservation` revisions. + * List of all the revisions for the `Reservation`. + * + * @param reservationId Id of the Reservation Item + * @param reservationOrderId Order Id of the reservation + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorException 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<ReservationResponseInner> object if successful. + */ + public PagedList listRevisions(final String reservationId, final String reservationOrderId) { + ServiceResponse> response = listRevisionsSinglePageAsync(reservationId, reservationOrderId).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listRevisionsNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Get `Reservation` revisions. + * List of all the revisions for the `Reservation`. + * + * @param reservationId Id of the Reservation Item + * @param reservationOrderId Order Id of the reservation + * @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> listRevisionsAsync(final String reservationId, final String reservationOrderId, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listRevisionsSinglePageAsync(reservationId, reservationOrderId), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listRevisionsNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Get `Reservation` revisions. + * List of all the revisions for the `Reservation`. + * + * @param reservationId Id of the Reservation Item + * @param reservationOrderId Order Id of the reservation + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<ReservationResponseInner> object + */ + public Observable> listRevisionsAsync(final String reservationId, final String reservationOrderId) { + return listRevisionsWithServiceResponseAsync(reservationId, reservationOrderId) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Get `Reservation` revisions. + * List of all the revisions for the `Reservation`. + * + * @param reservationId Id of the Reservation Item + * @param reservationOrderId Order Id of the reservation + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<ReservationResponseInner> object + */ + public Observable>> listRevisionsWithServiceResponseAsync(final String reservationId, final String reservationOrderId) { + return listRevisionsSinglePageAsync(reservationId, reservationOrderId) + .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(listRevisionsNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Get `Reservation` revisions. + * List of all the revisions for the `Reservation`. + * + ServiceResponse> * @param reservationId Id of the Reservation Item + ServiceResponse> * @param reservationOrderId Order Id of the reservation + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<ReservationResponseInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listRevisionsSinglePageAsync(final String reservationId, final String reservationOrderId) { + if (reservationId == null) { + throw new IllegalArgumentException("Parameter reservationId is required and cannot be null."); + } + if (reservationOrderId == null) { + throw new IllegalArgumentException("Parameter reservationOrderId 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.listRevisions(reservationId, reservationOrderId, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listRevisionsDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listRevisionsDelegate(Response response) throws ErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorException.class) + .build(response); + } + + /** + * Get `Reservation`s in a given reservation Order. + * List `Reservation`s within a single `ReservationOrder`. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorException 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<ReservationResponseInner> 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(); + } + }; + } + + /** + * Get `Reservation`s in a given reservation Order. + * List `Reservation`s within a single `ReservationOrder`. + * + * @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); + } + + /** + * Get `Reservation`s in a given reservation Order. + * List `Reservation`s within a single `ReservationOrder`. + * + * @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<ReservationResponseInner> object + */ + public Observable> listNextAsync(final String nextPageLink) { + return listNextWithServiceResponseAsync(nextPageLink) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Get `Reservation`s in a given reservation Order. + * List `Reservation`s within a single `ReservationOrder`. + * + * @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<ReservationResponseInner> 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)); + } + }); + } + + /** + * Get `Reservation`s in a given reservation Order. + * List `Reservation`s within a single `ReservationOrder`. + * + ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<ReservationResponseInner> 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 ErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorException.class) + .build(response); + } + + /** + * Get `Reservation` revisions. + * List of all the revisions for the `Reservation`. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorException 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<ReservationResponseInner> object if successful. + */ + public PagedList listRevisionsNext(final String nextPageLink) { + ServiceResponse> response = listRevisionsNextSinglePageAsync(nextPageLink).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listRevisionsNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Get `Reservation` revisions. + * List of all the revisions for the `Reservation`. + * + * @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> listRevisionsNextAsync(final String nextPageLink, final ServiceFuture> serviceFuture, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listRevisionsNextSinglePageAsync(nextPageLink), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listRevisionsNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Get `Reservation` revisions. + * List of all the revisions for the `Reservation`. + * + * @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<ReservationResponseInner> object + */ + public Observable> listRevisionsNextAsync(final String nextPageLink) { + return listRevisionsNextWithServiceResponseAsync(nextPageLink) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Get `Reservation` revisions. + * List of all the revisions for the `Reservation`. + * + * @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<ReservationResponseInner> object + */ + public Observable>> listRevisionsNextWithServiceResponseAsync(final String nextPageLink) { + return listRevisionsNextSinglePageAsync(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(listRevisionsNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Get `Reservation` revisions. + * List of all the revisions for the `Reservation`. + * + ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<ReservationResponseInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listRevisionsNextSinglePageAsync(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.listRevisionsNext(nextUrl, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listRevisionsNextDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listRevisionsNextDelegate(Response response) throws ErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorException.class) + .build(response); + } + +} diff --git a/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/implementation/package-info.java b/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/implementation/package-info.java new file mode 100644 index 00000000000..afee4c69c66 --- /dev/null +++ b/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/implementation/package-info.java @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** + * This package contains the implementation classes for AzureReservationAPI. + * This API describe Azure Reservation. + */ +package com.microsoft.azure.management.reservations.implementation; diff --git a/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/package-info.java b/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/package-info.java new file mode 100644 index 00000000000..58b10fe6ae2 --- /dev/null +++ b/azure-mgmt-reservations/src/main/java/com/microsoft/azure/management/reservations/package-info.java @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** + * This package contains the classes for AzureReservationAPI. + * This API describe Azure Reservation. + */ +package com.microsoft.azure.management.reservations;