diff --git a/sdk/reservations/Azure.ResourceManager.Reservations/api/Azure.ResourceManager.Reservations.netstandard2.0.cs b/sdk/reservations/Azure.ResourceManager.Reservations/api/Azure.ResourceManager.Reservations.netstandard2.0.cs index cde39d904f9e..1ae2ed69e622 100644 --- a/sdk/reservations/Azure.ResourceManager.Reservations/api/Azure.ResourceManager.Reservations.netstandard2.0.cs +++ b/sdk/reservations/Azure.ResourceManager.Reservations/api/Azure.ResourceManager.Reservations.netstandard2.0.cs @@ -61,11 +61,15 @@ public partial class ReservationDetailResource : Azure.ResourceManager.ArmResour protected ReservationDetailResource() { } public virtual Azure.ResourceManager.Reservations.ReservationDetailData Data { get { throw null; } } public virtual bool HasData { get { throw null; } } + public virtual Azure.Response Archive(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task ArchiveAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public static Azure.Core.ResourceIdentifier CreateResourceIdentifier(System.Guid reservationOrderId, System.Guid reservationId) { throw null; } public virtual Azure.Response Get(string expand = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> GetAsync(string expand = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.ResourceManager.ArmOperation GetAvailableScopes(Azure.WaitUntil waitUntil, Azure.ResourceManager.Reservations.Models.AvailableScopesContent content, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> GetAvailableScopesAsync(Azure.WaitUntil waitUntil, Azure.ResourceManager.Reservations.Models.AvailableScopesContent content, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Unarchive(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task UnarchiveAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.ResourceManager.ArmOperation Update(Azure.WaitUntil waitUntil, Azure.ResourceManager.Reservations.Models.ReservationDetailPatch patch, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> UpdateAsync(Azure.WaitUntil waitUntil, Azure.ResourceManager.Reservations.Models.ReservationDetailPatch patch, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } } @@ -116,6 +120,10 @@ protected ReservationOrderResource() { } public virtual Azure.ResourceManager.Reservations.ReservationDetailCollection GetReservationDetails() { throw null; } public virtual Azure.ResourceManager.ArmOperation> MergeReservation(Azure.WaitUntil waitUntil, Azure.ResourceManager.Reservations.Models.MergeContent content, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task>> MergeReservationAsync(Azure.WaitUntil waitUntil, Azure.ResourceManager.Reservations.Models.MergeContent content, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response PostCalculateRefund(Azure.ResourceManager.Reservations.Models.CalculateRefundContent content, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> PostCalculateRefundAsync(Azure.ResourceManager.Reservations.Models.CalculateRefundContent content, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response PostReturn(Azure.ResourceManager.Reservations.Models.RefundContent content, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> PostReturnAsync(Azure.ResourceManager.Reservations.Models.RefundContent content, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.ResourceManager.ArmOperation> SplitReservation(Azure.WaitUntil waitUntil, Azure.ResourceManager.Reservations.Models.SplitContent content, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task>> SplitReservationAsync(Azure.WaitUntil waitUntil, Azure.ResourceManager.Reservations.Models.SplitContent content, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.ResourceManager.ArmOperation Update(Azure.WaitUntil waitUntil, Azure.ResourceManager.Reservations.Models.ReservationPurchaseContent content, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } @@ -195,6 +203,13 @@ internal AppliedReservationList() { } public string NextLink { get { throw null; } } public System.Collections.Generic.IReadOnlyList Value { get { throw null; } } } + public partial class AppliedScopeProperties + { + internal AppliedScopeProperties() { } + public string DisplayName { get { throw null; } } + public string ManagementGroupId { get { throw null; } } + public System.Guid? TenantId { get { throw null; } } + } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct AppliedScopeType : System.IEquatable { @@ -313,6 +328,24 @@ internal CalculatePriceResultPropertiesPricingCurrencyTotal() { } public float? Amount { get { throw null; } } public string CurrencyCode { get { throw null; } } } + public partial class CalculateRefundContent + { + public CalculateRefundContent() { } + public string Id { get { throw null; } set { } } + public Azure.ResourceManager.Reservations.Models.CalculateRefundRequestProperties Properties { get { throw null; } set { } } + } + public partial class CalculateRefundRequestProperties + { + public CalculateRefundRequestProperties() { } + public Azure.ResourceManager.Reservations.Models.ReservationToReturn ReservationToReturn { get { throw null; } set { } } + public string Scope { get { throw null; } set { } } + } + public partial class CalculateRefundResponse + { + internal CalculateRefundResponse() { } + public string Id { get { throw null; } } + public Azure.ResourceManager.Reservations.Models.RefundResponseProperties Properties { get { throw null; } } + } public partial class ChangeDirectoryContent { public ChangeDirectoryContent() { } @@ -332,6 +365,80 @@ internal ChangeDirectoryResult() { } public bool? IsSucceeded { get { throw null; } } public string Name { get { throw null; } } } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct ErrorResponseCode : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public ErrorResponseCode(string value) { throw null; } + public static Azure.ResourceManager.Reservations.Models.ErrorResponseCode ActivateQuoteFailed { get { throw null; } } + public static Azure.ResourceManager.Reservations.Models.ErrorResponseCode AppliedScopesNotAssociatedWithCommerceAccount { get { throw null; } } + public static Azure.ResourceManager.Reservations.Models.ErrorResponseCode AppliedScopesSameAsExisting { get { throw null; } } + public static Azure.ResourceManager.Reservations.Models.ErrorResponseCode AuthorizationFailed { get { throw null; } } + public static Azure.ResourceManager.Reservations.Models.ErrorResponseCode BadRequest { get { throw null; } } + public static Azure.ResourceManager.Reservations.Models.ErrorResponseCode BillingCustomerInputError { get { throw null; } } + public static Azure.ResourceManager.Reservations.Models.ErrorResponseCode BillingError { get { throw null; } } + public static Azure.ResourceManager.Reservations.Models.ErrorResponseCode BillingPaymentInstrumentHardError { get { throw null; } } + public static Azure.ResourceManager.Reservations.Models.ErrorResponseCode BillingPaymentInstrumentSoftError { get { throw null; } } + public static Azure.ResourceManager.Reservations.Models.ErrorResponseCode BillingScopeIdCannotBeChanged { get { throw null; } } + public static Azure.ResourceManager.Reservations.Models.ErrorResponseCode BillingTransientError { get { throw null; } } + public static Azure.ResourceManager.Reservations.Models.ErrorResponseCode CalculatePriceFailed { get { throw null; } } + public static Azure.ResourceManager.Reservations.Models.ErrorResponseCode CapacityUpdateScopesFailed { get { throw null; } } + public static Azure.ResourceManager.Reservations.Models.ErrorResponseCode ClientCertificateThumbprintNotSet { get { throw null; } } + public static Azure.ResourceManager.Reservations.Models.ErrorResponseCode CreateQuoteFailed { get { throw null; } } + public static Azure.ResourceManager.Reservations.Models.ErrorResponseCode Forbidden { get { throw null; } } + public static Azure.ResourceManager.Reservations.Models.ErrorResponseCode FulfillmentConfigurationError { get { throw null; } } + public static Azure.ResourceManager.Reservations.Models.ErrorResponseCode FulfillmentError { get { throw null; } } + public static Azure.ResourceManager.Reservations.Models.ErrorResponseCode FulfillmentOutOfStockError { get { throw null; } } + public static Azure.ResourceManager.Reservations.Models.ErrorResponseCode FulfillmentTransientError { get { throw null; } } + public static Azure.ResourceManager.Reservations.Models.ErrorResponseCode HttpMethodNotSupported { get { throw null; } } + public static Azure.ResourceManager.Reservations.Models.ErrorResponseCode InternalServerError { get { throw null; } } + public static Azure.ResourceManager.Reservations.Models.ErrorResponseCode InvalidAccessToken { get { throw null; } } + public static Azure.ResourceManager.Reservations.Models.ErrorResponseCode InvalidFulfillmentRequestParameters { get { throw null; } } + public static Azure.ResourceManager.Reservations.Models.ErrorResponseCode InvalidHealthCheckType { get { throw null; } } + public static Azure.ResourceManager.Reservations.Models.ErrorResponseCode InvalidLocationId { get { throw null; } } + public static Azure.ResourceManager.Reservations.Models.ErrorResponseCode InvalidRefundQuantity { get { throw null; } } + public static Azure.ResourceManager.Reservations.Models.ErrorResponseCode InvalidRequestContent { get { throw null; } } + public static Azure.ResourceManager.Reservations.Models.ErrorResponseCode InvalidRequestUri { get { throw null; } } + public static Azure.ResourceManager.Reservations.Models.ErrorResponseCode InvalidReservationId { get { throw null; } } + public static Azure.ResourceManager.Reservations.Models.ErrorResponseCode InvalidReservationOrderId { get { throw null; } } + public static Azure.ResourceManager.Reservations.Models.ErrorResponseCode InvalidSingleAppliedScopesCount { get { throw null; } } + public static Azure.ResourceManager.Reservations.Models.ErrorResponseCode InvalidSubscriptionId { get { throw null; } } + public static Azure.ResourceManager.Reservations.Models.ErrorResponseCode InvalidTenantId { get { throw null; } } + public static Azure.ResourceManager.Reservations.Models.ErrorResponseCode MissingAppliedScopesForSingle { get { throw null; } } + public static Azure.ResourceManager.Reservations.Models.ErrorResponseCode MissingTenantId { get { throw null; } } + public static Azure.ResourceManager.Reservations.Models.ErrorResponseCode NonsupportedAccountId { get { throw null; } } + public static Azure.ResourceManager.Reservations.Models.ErrorResponseCode NotSpecified { get { throw null; } } + public static Azure.ResourceManager.Reservations.Models.ErrorResponseCode NotSupportedCountry { get { throw null; } } + public static Azure.ResourceManager.Reservations.Models.ErrorResponseCode NoValidReservationsToReRate { get { throw null; } } + public static Azure.ResourceManager.Reservations.Models.ErrorResponseCode OperationCannotBePerformedInCurrentState { get { throw null; } } + public static Azure.ResourceManager.Reservations.Models.ErrorResponseCode OperationFailed { get { throw null; } } + public static Azure.ResourceManager.Reservations.Models.ErrorResponseCode PatchValuesSameAsExisting { get { throw null; } } + public static Azure.ResourceManager.Reservations.Models.ErrorResponseCode PaymentInstrumentNotFound { get { throw null; } } + public static Azure.ResourceManager.Reservations.Models.ErrorResponseCode PurchaseError { get { throw null; } } + public static Azure.ResourceManager.Reservations.Models.ErrorResponseCode RefundLimitExceeded { get { throw null; } } + public static Azure.ResourceManager.Reservations.Models.ErrorResponseCode ReRateOnlyAllowedForEA { get { throw null; } } + public static Azure.ResourceManager.Reservations.Models.ErrorResponseCode ReservationIdNotInReservationOrder { get { throw null; } } + public static Azure.ResourceManager.Reservations.Models.ErrorResponseCode ReservationOrderCreationFailed { get { throw null; } } + public static Azure.ResourceManager.Reservations.Models.ErrorResponseCode ReservationOrderIdAlreadyExists { get { throw null; } } + public static Azure.ResourceManager.Reservations.Models.ErrorResponseCode ReservationOrderNotEnabled { get { throw null; } } + public static Azure.ResourceManager.Reservations.Models.ErrorResponseCode ReservationOrderNotFound { get { throw null; } } + public static Azure.ResourceManager.Reservations.Models.ErrorResponseCode RiskCheckFailed { get { throw null; } } + public static Azure.ResourceManager.Reservations.Models.ErrorResponseCode RoleAssignmentCreationFailed { get { throw null; } } + public static Azure.ResourceManager.Reservations.Models.ErrorResponseCode SelfServiceRefundNotSupported { get { throw null; } } + public static Azure.ResourceManager.Reservations.Models.ErrorResponseCode ServerTimeout { get { throw null; } } + public static Azure.ResourceManager.Reservations.Models.ErrorResponseCode UnauthenticatedRequestsThrottled { get { throw null; } } + public static Azure.ResourceManager.Reservations.Models.ErrorResponseCode UnsupportedReservationTerm { get { throw null; } } + public bool Equals(Azure.ResourceManager.Reservations.Models.ErrorResponseCode other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.ResourceManager.Reservations.Models.ErrorResponseCode left, Azure.ResourceManager.Reservations.Models.ErrorResponseCode right) { throw null; } + public static implicit operator Azure.ResourceManager.Reservations.Models.ErrorResponseCode (string value) { throw null; } + public static bool operator !=(Azure.ResourceManager.Reservations.Models.ErrorResponseCode left, Azure.ResourceManager.Reservations.Models.ErrorResponseCode right) { throw null; } + public override string ToString() { throw null; } + } public partial class ExchangeContent { public ExchangeContent() { } @@ -488,6 +595,58 @@ public QuotaProperties() { } public static bool operator !=(Azure.ResourceManager.Reservations.Models.QuotaRequestState left, Azure.ResourceManager.Reservations.Models.QuotaRequestState right) { throw null; } public override string ToString() { throw null; } } + public partial class RefundBillingInformation + { + internal RefundBillingInformation() { } + public Azure.ResourceManager.Reservations.Models.PurchasePrice BillingCurrencyProratedAmount { get { throw null; } } + public Azure.ResourceManager.Reservations.Models.PurchasePrice BillingCurrencyRemainingCommitmentAmount { get { throw null; } } + public Azure.ResourceManager.Reservations.Models.PurchasePrice BillingCurrencyTotalPaidAmount { get { throw null; } } + public Azure.ResourceManager.Reservations.Models.ReservationBillingPlan? BillingPlan { get { throw null; } } + public int? CompletedTransactions { get { throw null; } } + public int? TotalTransactions { get { throw null; } } + } + public partial class RefundContent + { + public RefundContent() { } + public Azure.ResourceManager.Reservations.Models.RefundRequestProperties Properties { get { throw null; } set { } } + } + public partial class RefundPolicyError + { + internal RefundPolicyError() { } + public Azure.ResourceManager.Reservations.Models.ErrorResponseCode? Code { get { throw null; } } + public string Message { get { throw null; } } + } + public partial class RefundPolicyResultProperty + { + internal RefundPolicyResultProperty() { } + public Azure.ResourceManager.Reservations.Models.PurchasePrice ConsumedRefundsTotal { get { throw null; } } + public Azure.ResourceManager.Reservations.Models.PurchasePrice MaxRefundLimit { get { throw null; } } + public System.Collections.Generic.IReadOnlyList PolicyErrors { get { throw null; } } + } + public partial class RefundRequestProperties + { + public RefundRequestProperties() { } + public Azure.ResourceManager.Reservations.Models.ReservationToReturn ReservationToReturn { get { throw null; } set { } } + public string ReturnReason { get { throw null; } set { } } + public string Scope { get { throw null; } set { } } + public System.Guid? SessionId { get { throw null; } set { } } + } + public partial class RefundResponse + { + internal RefundResponse() { } + public string Id { get { throw null; } } + public Azure.ResourceManager.Reservations.Models.RefundResponseProperties Properties { get { throw null; } } + } + public partial class RefundResponseProperties + { + internal RefundResponseProperties() { } + public Azure.ResourceManager.Reservations.Models.RefundBillingInformation BillingInformation { get { throw null; } } + public Azure.ResourceManager.Reservations.Models.PurchasePrice BillingRefundAmount { get { throw null; } } + public Azure.ResourceManager.Reservations.Models.RefundPolicyResultProperty PolicyResultProperties { get { throw null; } } + public Azure.ResourceManager.Reservations.Models.PurchasePrice PricingRefundAmount { get { throw null; } } + public int? Quantity { get { throw null; } } + public System.Guid? SessionId { get { throw null; } } + } public partial class RenewProperties { internal RenewProperties() { } @@ -604,6 +763,7 @@ internal ReservationOrderBillingPlanInformation() { } public partial class ReservationProperties { internal ReservationProperties() { } + public Azure.ResourceManager.Reservations.Models.AppliedScopeProperties AppliedScopeProperties { get { throw null; } } public System.Collections.Generic.IReadOnlyList AppliedScopes { get { throw null; } } public Azure.ResourceManager.Reservations.Models.AppliedScopeType? AppliedScopeType { get { throw null; } } public System.DateTimeOffset? BenefitStartOn { get { throw null; } } @@ -630,6 +790,7 @@ internal ReservationProperties() { } public Azure.ResourceManager.Reservations.Models.ReservedResourceType? ReservedResourceType { get { throw null; } } public string SkuDescription { get { throw null; } } public Azure.ResourceManager.Reservations.Models.ReservationSplitProperties SplitProperties { get { throw null; } } + public Azure.ResourceManager.Reservations.Models.ReservationSwapProperties SwapProperties { get { throw null; } } public Azure.ResourceManager.Reservations.Models.ReservationTerm? Term { get { throw null; } } public string UserFriendlyAppliedScopeType { get { throw null; } } public string UserFriendlyRenewState { get { throw null; } } @@ -724,6 +885,12 @@ internal ReservationSplitProperties() { } public static bool operator !=(Azure.ResourceManager.Reservations.Models.ReservationStatusCode left, Azure.ResourceManager.Reservations.Models.ReservationStatusCode right) { throw null; } public override string ToString() { throw null; } } + public partial class ReservationSwapProperties + { + internal ReservationSwapProperties() { } + public string SwapDestination { get { throw null; } } + public string SwapSource { get { throw null; } } + } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct ReservationTerm : System.IEquatable { diff --git a/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/AppliedScopeProperties.Serialization.cs b/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/AppliedScopeProperties.Serialization.cs new file mode 100644 index 000000000000..5b89304597e5 --- /dev/null +++ b/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/AppliedScopeProperties.Serialization.cs @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Reservations.Models +{ + public partial class AppliedScopeProperties + { + internal static AppliedScopeProperties DeserializeAppliedScopeProperties(JsonElement element) + { + Optional tenantId = default; + Optional managementGroupId = default; + Optional displayName = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("tenantId")) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + tenantId = property.Value.GetGuid(); + continue; + } + if (property.NameEquals("managementGroupId")) + { + managementGroupId = property.Value.GetString(); + continue; + } + if (property.NameEquals("displayName")) + { + displayName = property.Value.GetString(); + continue; + } + } + return new AppliedScopeProperties(Optional.ToNullable(tenantId), managementGroupId.Value, displayName.Value); + } + } +} diff --git a/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/AppliedScopeProperties.cs b/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/AppliedScopeProperties.cs new file mode 100644 index 000000000000..59197030d4fd --- /dev/null +++ b/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/AppliedScopeProperties.cs @@ -0,0 +1,38 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.Reservations.Models +{ + /// The AppliedScopeProperties. + public partial class AppliedScopeProperties + { + /// Initializes a new instance of AppliedScopeProperties. + internal AppliedScopeProperties() + { + } + + /// Initializes a new instance of AppliedScopeProperties. + /// Tenant ID of the applied scope type. + /// Management group ID of the format /providers/Microsoft.Management/managementGroups/{managementGroupId}. + /// Management group display name. + internal AppliedScopeProperties(Guid? tenantId, string managementGroupId, string displayName) + { + TenantId = tenantId; + ManagementGroupId = managementGroupId; + DisplayName = displayName; + } + + /// Tenant ID of the applied scope type. + public Guid? TenantId { get; } + /// Management group ID of the format /providers/Microsoft.Management/managementGroups/{managementGroupId}. + public string ManagementGroupId { get; } + /// Management group display name. + public string DisplayName { get; } + } +} diff --git a/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/CalculateRefundContent.Serialization.cs b/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/CalculateRefundContent.Serialization.cs new file mode 100644 index 000000000000..41dc2cac066e --- /dev/null +++ b/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/CalculateRefundContent.Serialization.cs @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Reservations.Models +{ + public partial class CalculateRefundContent : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsDefined(Id)) + { + writer.WritePropertyName("id"); + writer.WriteStringValue(Id); + } + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"); + writer.WriteObjectValue(Properties); + } + writer.WriteEndObject(); + } + } +} diff --git a/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/CalculateRefundContent.cs b/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/CalculateRefundContent.cs new file mode 100644 index 000000000000..7f193489dd2f --- /dev/null +++ b/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/CalculateRefundContent.cs @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Reservations.Models +{ + /// The CalculateRefundContent. + public partial class CalculateRefundContent + { + /// Initializes a new instance of CalculateRefundContent. + public CalculateRefundContent() + { + } + + /// Fully qualified identifier of the reservation order being returned. + public string Id { get; set; } + /// Gets or sets the properties. + public CalculateRefundRequestProperties Properties { get; set; } + } +} diff --git a/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/CalculateRefundRequestProperties.Serialization.cs b/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/CalculateRefundRequestProperties.Serialization.cs new file mode 100644 index 000000000000..ab65d888438e --- /dev/null +++ b/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/CalculateRefundRequestProperties.Serialization.cs @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Reservations.Models +{ + public partial class CalculateRefundRequestProperties : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsDefined(Scope)) + { + writer.WritePropertyName("scope"); + writer.WriteStringValue(Scope); + } + if (Optional.IsDefined(ReservationToReturn)) + { + writer.WritePropertyName("reservationToReturn"); + writer.WriteObjectValue(ReservationToReturn); + } + writer.WriteEndObject(); + } + } +} diff --git a/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/CalculateRefundRequestProperties.cs b/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/CalculateRefundRequestProperties.cs new file mode 100644 index 000000000000..70dd4d6120e9 --- /dev/null +++ b/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/CalculateRefundRequestProperties.cs @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Reservations.Models +{ + /// The CalculateRefundRequestProperties. + public partial class CalculateRefundRequestProperties + { + /// Initializes a new instance of CalculateRefundRequestProperties. + public CalculateRefundRequestProperties() + { + } + + /// The scope of the refund, e.g. Reservation. + public string Scope { get; set; } + /// Reservation to return. + public ReservationToReturn ReservationToReturn { get; set; } + } +} diff --git a/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/CalculateRefundResponse.Serialization.cs b/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/CalculateRefundResponse.Serialization.cs new file mode 100644 index 000000000000..bd52ca09604d --- /dev/null +++ b/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/CalculateRefundResponse.Serialization.cs @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Reservations.Models +{ + public partial class CalculateRefundResponse + { + internal static CalculateRefundResponse DeserializeCalculateRefundResponse(JsonElement element) + { + Optional id = default; + Optional properties = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id")) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("properties")) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + properties = RefundResponseProperties.DeserializeRefundResponseProperties(property.Value); + continue; + } + } + return new CalculateRefundResponse(id.Value, properties.Value); + } + } +} diff --git a/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/CalculateRefundResponse.cs b/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/CalculateRefundResponse.cs new file mode 100644 index 000000000000..4fd4bca75e7e --- /dev/null +++ b/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/CalculateRefundResponse.cs @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Reservations.Models +{ + /// The CalculateRefundResponse. + public partial class CalculateRefundResponse + { + /// Initializes a new instance of CalculateRefundResponse. + internal CalculateRefundResponse() + { + } + + /// Initializes a new instance of CalculateRefundResponse. + /// Fully qualified identifier of the reservation being returned. + /// + internal CalculateRefundResponse(string id, RefundResponseProperties properties) + { + Id = id; + Properties = properties; + } + + /// Fully qualified identifier of the reservation being returned. + public string Id { get; } + /// Gets the properties. + public RefundResponseProperties Properties { get; } + } +} diff --git a/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/ErrorResponseCode.cs b/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/ErrorResponseCode.cs new file mode 100644 index 000000000000..f26e9280d889 --- /dev/null +++ b/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/ErrorResponseCode.cs @@ -0,0 +1,219 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Reservations.Models +{ + /// The ErrorResponseCode. + public readonly partial struct ErrorResponseCode : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public ErrorResponseCode(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string NotSpecifiedValue = "NotSpecified"; + private const string InternalServerErrorValue = "InternalServerError"; + private const string ServerTimeoutValue = "ServerTimeout"; + private const string AuthorizationFailedValue = "AuthorizationFailed"; + private const string BadRequestValue = "BadRequest"; + private const string ClientCertificateThumbprintNotSetValue = "ClientCertificateThumbprintNotSet"; + private const string InvalidRequestContentValue = "InvalidRequestContent"; + private const string OperationFailedValue = "OperationFailed"; + private const string HttpMethodNotSupportedValue = "HttpMethodNotSupported"; + private const string InvalidRequestUriValue = "InvalidRequestUri"; + private const string MissingTenantIdValue = "MissingTenantId"; + private const string InvalidTenantIdValue = "InvalidTenantId"; + private const string InvalidReservationOrderIdValue = "InvalidReservationOrderId"; + private const string InvalidReservationIdValue = "InvalidReservationId"; + private const string ReservationIdNotInReservationOrderValue = "ReservationIdNotInReservationOrder"; + private const string ReservationOrderNotFoundValue = "ReservationOrderNotFound"; + private const string InvalidSubscriptionIdValue = "InvalidSubscriptionId"; + private const string InvalidAccessTokenValue = "InvalidAccessToken"; + private const string InvalidLocationIdValue = "InvalidLocationId"; + private const string UnauthenticatedRequestsThrottledValue = "UnauthenticatedRequestsThrottled"; + private const string InvalidHealthCheckTypeValue = "InvalidHealthCheckType"; + private const string ForbiddenValue = "Forbidden"; + private const string BillingScopeIdCannotBeChangedValue = "BillingScopeIdCannotBeChanged"; + private const string AppliedScopesNotAssociatedWithCommerceAccountValue = "AppliedScopesNotAssociatedWithCommerceAccount"; + private const string PatchValuesSameAsExistingValue = "PatchValuesSameAsExisting"; + private const string RoleAssignmentCreationFailedValue = "RoleAssignmentCreationFailed"; + private const string ReservationOrderCreationFailedValue = "ReservationOrderCreationFailed"; + private const string ReservationOrderNotEnabledValue = "ReservationOrderNotEnabled"; + private const string CapacityUpdateScopesFailedValue = "CapacityUpdateScopesFailed"; + private const string UnsupportedReservationTermValue = "UnsupportedReservationTerm"; + private const string ReservationOrderIdAlreadyExistsValue = "ReservationOrderIdAlreadyExists"; + private const string RiskCheckFailedValue = "RiskCheckFailed"; + private const string CreateQuoteFailedValue = "CreateQuoteFailed"; + private const string ActivateQuoteFailedValue = "ActivateQuoteFailed"; + private const string NonsupportedAccountIdValue = "NonsupportedAccountId"; + private const string PaymentInstrumentNotFoundValue = "PaymentInstrumentNotFound"; + private const string MissingAppliedScopesForSingleValue = "MissingAppliedScopesForSingle"; + private const string NoValidReservationsToReRateValue = "NoValidReservationsToReRate"; + private const string ReRateOnlyAllowedForEAValue = "ReRateOnlyAllowedForEA"; + private const string OperationCannotBePerformedInCurrentStateValue = "OperationCannotBePerformedInCurrentState"; + private const string InvalidSingleAppliedScopesCountValue = "InvalidSingleAppliedScopesCount"; + private const string InvalidFulfillmentRequestParametersValue = "InvalidFulfillmentRequestParameters"; + private const string NotSupportedCountryValue = "NotSupportedCountry"; + private const string InvalidRefundQuantityValue = "InvalidRefundQuantity"; + private const string PurchaseErrorValue = "PurchaseError"; + private const string BillingCustomerInputErrorValue = "BillingCustomerInputError"; + private const string BillingPaymentInstrumentSoftErrorValue = "BillingPaymentInstrumentSoftError"; + private const string BillingPaymentInstrumentHardErrorValue = "BillingPaymentInstrumentHardError"; + private const string BillingTransientErrorValue = "BillingTransientError"; + private const string BillingErrorValue = "BillingError"; + private const string FulfillmentConfigurationErrorValue = "FulfillmentConfigurationError"; + private const string FulfillmentOutOfStockErrorValue = "FulfillmentOutOfStockError"; + private const string FulfillmentTransientErrorValue = "FulfillmentTransientError"; + private const string FulfillmentErrorValue = "FulfillmentError"; + private const string CalculatePriceFailedValue = "CalculatePriceFailed"; + private const string AppliedScopesSameAsExistingValue = "AppliedScopesSameAsExisting"; + private const string SelfServiceRefundNotSupportedValue = "SelfServiceRefundNotSupported"; + private const string RefundLimitExceededValue = "RefundLimitExceeded"; + + /// NotSpecified. + public static ErrorResponseCode NotSpecified { get; } = new ErrorResponseCode(NotSpecifiedValue); + /// InternalServerError. + public static ErrorResponseCode InternalServerError { get; } = new ErrorResponseCode(InternalServerErrorValue); + /// ServerTimeout. + public static ErrorResponseCode ServerTimeout { get; } = new ErrorResponseCode(ServerTimeoutValue); + /// AuthorizationFailed. + public static ErrorResponseCode AuthorizationFailed { get; } = new ErrorResponseCode(AuthorizationFailedValue); + /// BadRequest. + public static ErrorResponseCode BadRequest { get; } = new ErrorResponseCode(BadRequestValue); + /// ClientCertificateThumbprintNotSet. + public static ErrorResponseCode ClientCertificateThumbprintNotSet { get; } = new ErrorResponseCode(ClientCertificateThumbprintNotSetValue); + /// InvalidRequestContent. + public static ErrorResponseCode InvalidRequestContent { get; } = new ErrorResponseCode(InvalidRequestContentValue); + /// OperationFailed. + public static ErrorResponseCode OperationFailed { get; } = new ErrorResponseCode(OperationFailedValue); + /// HttpMethodNotSupported. + public static ErrorResponseCode HttpMethodNotSupported { get; } = new ErrorResponseCode(HttpMethodNotSupportedValue); + /// InvalidRequestUri. + public static ErrorResponseCode InvalidRequestUri { get; } = new ErrorResponseCode(InvalidRequestUriValue); + /// MissingTenantId. + public static ErrorResponseCode MissingTenantId { get; } = new ErrorResponseCode(MissingTenantIdValue); + /// InvalidTenantId. + public static ErrorResponseCode InvalidTenantId { get; } = new ErrorResponseCode(InvalidTenantIdValue); + /// InvalidReservationOrderId. + public static ErrorResponseCode InvalidReservationOrderId { get; } = new ErrorResponseCode(InvalidReservationOrderIdValue); + /// InvalidReservationId. + public static ErrorResponseCode InvalidReservationId { get; } = new ErrorResponseCode(InvalidReservationIdValue); + /// ReservationIdNotInReservationOrder. + public static ErrorResponseCode ReservationIdNotInReservationOrder { get; } = new ErrorResponseCode(ReservationIdNotInReservationOrderValue); + /// ReservationOrderNotFound. + public static ErrorResponseCode ReservationOrderNotFound { get; } = new ErrorResponseCode(ReservationOrderNotFoundValue); + /// InvalidSubscriptionId. + public static ErrorResponseCode InvalidSubscriptionId { get; } = new ErrorResponseCode(InvalidSubscriptionIdValue); + /// InvalidAccessToken. + public static ErrorResponseCode InvalidAccessToken { get; } = new ErrorResponseCode(InvalidAccessTokenValue); + /// InvalidLocationId. + public static ErrorResponseCode InvalidLocationId { get; } = new ErrorResponseCode(InvalidLocationIdValue); + /// UnauthenticatedRequestsThrottled. + public static ErrorResponseCode UnauthenticatedRequestsThrottled { get; } = new ErrorResponseCode(UnauthenticatedRequestsThrottledValue); + /// InvalidHealthCheckType. + public static ErrorResponseCode InvalidHealthCheckType { get; } = new ErrorResponseCode(InvalidHealthCheckTypeValue); + /// Forbidden. + public static ErrorResponseCode Forbidden { get; } = new ErrorResponseCode(ForbiddenValue); + /// BillingScopeIdCannotBeChanged. + public static ErrorResponseCode BillingScopeIdCannotBeChanged { get; } = new ErrorResponseCode(BillingScopeIdCannotBeChangedValue); + /// AppliedScopesNotAssociatedWithCommerceAccount. + public static ErrorResponseCode AppliedScopesNotAssociatedWithCommerceAccount { get; } = new ErrorResponseCode(AppliedScopesNotAssociatedWithCommerceAccountValue); + /// PatchValuesSameAsExisting. + public static ErrorResponseCode PatchValuesSameAsExisting { get; } = new ErrorResponseCode(PatchValuesSameAsExistingValue); + /// RoleAssignmentCreationFailed. + public static ErrorResponseCode RoleAssignmentCreationFailed { get; } = new ErrorResponseCode(RoleAssignmentCreationFailedValue); + /// ReservationOrderCreationFailed. + public static ErrorResponseCode ReservationOrderCreationFailed { get; } = new ErrorResponseCode(ReservationOrderCreationFailedValue); + /// ReservationOrderNotEnabled. + public static ErrorResponseCode ReservationOrderNotEnabled { get; } = new ErrorResponseCode(ReservationOrderNotEnabledValue); + /// CapacityUpdateScopesFailed. + public static ErrorResponseCode CapacityUpdateScopesFailed { get; } = new ErrorResponseCode(CapacityUpdateScopesFailedValue); + /// UnsupportedReservationTerm. + public static ErrorResponseCode UnsupportedReservationTerm { get; } = new ErrorResponseCode(UnsupportedReservationTermValue); + /// ReservationOrderIdAlreadyExists. + public static ErrorResponseCode ReservationOrderIdAlreadyExists { get; } = new ErrorResponseCode(ReservationOrderIdAlreadyExistsValue); + /// RiskCheckFailed. + public static ErrorResponseCode RiskCheckFailed { get; } = new ErrorResponseCode(RiskCheckFailedValue); + /// CreateQuoteFailed. + public static ErrorResponseCode CreateQuoteFailed { get; } = new ErrorResponseCode(CreateQuoteFailedValue); + /// ActivateQuoteFailed. + public static ErrorResponseCode ActivateQuoteFailed { get; } = new ErrorResponseCode(ActivateQuoteFailedValue); + /// NonsupportedAccountId. + public static ErrorResponseCode NonsupportedAccountId { get; } = new ErrorResponseCode(NonsupportedAccountIdValue); + /// PaymentInstrumentNotFound. + public static ErrorResponseCode PaymentInstrumentNotFound { get; } = new ErrorResponseCode(PaymentInstrumentNotFoundValue); + /// MissingAppliedScopesForSingle. + public static ErrorResponseCode MissingAppliedScopesForSingle { get; } = new ErrorResponseCode(MissingAppliedScopesForSingleValue); + /// NoValidReservationsToReRate. + public static ErrorResponseCode NoValidReservationsToReRate { get; } = new ErrorResponseCode(NoValidReservationsToReRateValue); + /// ReRateOnlyAllowedForEA. + public static ErrorResponseCode ReRateOnlyAllowedForEA { get; } = new ErrorResponseCode(ReRateOnlyAllowedForEAValue); + /// OperationCannotBePerformedInCurrentState. + public static ErrorResponseCode OperationCannotBePerformedInCurrentState { get; } = new ErrorResponseCode(OperationCannotBePerformedInCurrentStateValue); + /// InvalidSingleAppliedScopesCount. + public static ErrorResponseCode InvalidSingleAppliedScopesCount { get; } = new ErrorResponseCode(InvalidSingleAppliedScopesCountValue); + /// InvalidFulfillmentRequestParameters. + public static ErrorResponseCode InvalidFulfillmentRequestParameters { get; } = new ErrorResponseCode(InvalidFulfillmentRequestParametersValue); + /// NotSupportedCountry. + public static ErrorResponseCode NotSupportedCountry { get; } = new ErrorResponseCode(NotSupportedCountryValue); + /// InvalidRefundQuantity. + public static ErrorResponseCode InvalidRefundQuantity { get; } = new ErrorResponseCode(InvalidRefundQuantityValue); + /// PurchaseError. + public static ErrorResponseCode PurchaseError { get; } = new ErrorResponseCode(PurchaseErrorValue); + /// BillingCustomerInputError. + public static ErrorResponseCode BillingCustomerInputError { get; } = new ErrorResponseCode(BillingCustomerInputErrorValue); + /// BillingPaymentInstrumentSoftError. + public static ErrorResponseCode BillingPaymentInstrumentSoftError { get; } = new ErrorResponseCode(BillingPaymentInstrumentSoftErrorValue); + /// BillingPaymentInstrumentHardError. + public static ErrorResponseCode BillingPaymentInstrumentHardError { get; } = new ErrorResponseCode(BillingPaymentInstrumentHardErrorValue); + /// BillingTransientError. + public static ErrorResponseCode BillingTransientError { get; } = new ErrorResponseCode(BillingTransientErrorValue); + /// BillingError. + public static ErrorResponseCode BillingError { get; } = new ErrorResponseCode(BillingErrorValue); + /// FulfillmentConfigurationError. + public static ErrorResponseCode FulfillmentConfigurationError { get; } = new ErrorResponseCode(FulfillmentConfigurationErrorValue); + /// FulfillmentOutOfStockError. + public static ErrorResponseCode FulfillmentOutOfStockError { get; } = new ErrorResponseCode(FulfillmentOutOfStockErrorValue); + /// FulfillmentTransientError. + public static ErrorResponseCode FulfillmentTransientError { get; } = new ErrorResponseCode(FulfillmentTransientErrorValue); + /// FulfillmentError. + public static ErrorResponseCode FulfillmentError { get; } = new ErrorResponseCode(FulfillmentErrorValue); + /// CalculatePriceFailed. + public static ErrorResponseCode CalculatePriceFailed { get; } = new ErrorResponseCode(CalculatePriceFailedValue); + /// AppliedScopesSameAsExisting. + public static ErrorResponseCode AppliedScopesSameAsExisting { get; } = new ErrorResponseCode(AppliedScopesSameAsExistingValue); + /// SelfServiceRefundNotSupported. + public static ErrorResponseCode SelfServiceRefundNotSupported { get; } = new ErrorResponseCode(SelfServiceRefundNotSupportedValue); + /// RefundLimitExceeded. + public static ErrorResponseCode RefundLimitExceeded { get; } = new ErrorResponseCode(RefundLimitExceededValue); + /// Determines if two values are the same. + public static bool operator ==(ErrorResponseCode left, ErrorResponseCode right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(ErrorResponseCode left, ErrorResponseCode right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator ErrorResponseCode(string value) => new ErrorResponseCode(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ErrorResponseCode other && Equals(other); + /// + public bool Equals(ErrorResponseCode other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/RefundBillingInformation.Serialization.cs b/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/RefundBillingInformation.Serialization.cs new file mode 100644 index 000000000000..6929bba4db9e --- /dev/null +++ b/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/RefundBillingInformation.Serialization.cs @@ -0,0 +1,89 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Reservations.Models +{ + public partial class RefundBillingInformation + { + internal static RefundBillingInformation DeserializeRefundBillingInformation(JsonElement element) + { + Optional billingPlan = default; + Optional completedTransactions = default; + Optional totalTransactions = default; + Optional billingCurrencyTotalPaidAmount = default; + Optional billingCurrencyProratedAmount = default; + Optional billingCurrencyRemainingCommitmentAmount = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("billingPlan")) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + billingPlan = new ReservationBillingPlan(property.Value.GetString()); + continue; + } + if (property.NameEquals("completedTransactions")) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + completedTransactions = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("totalTransactions")) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + totalTransactions = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("billingCurrencyTotalPaidAmount")) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + billingCurrencyTotalPaidAmount = PurchasePrice.DeserializePurchasePrice(property.Value); + continue; + } + if (property.NameEquals("billingCurrencyProratedAmount")) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + billingCurrencyProratedAmount = PurchasePrice.DeserializePurchasePrice(property.Value); + continue; + } + if (property.NameEquals("billingCurrencyRemainingCommitmentAmount")) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + billingCurrencyRemainingCommitmentAmount = PurchasePrice.DeserializePurchasePrice(property.Value); + continue; + } + } + return new RefundBillingInformation(Optional.ToNullable(billingPlan), Optional.ToNullable(completedTransactions), Optional.ToNullable(totalTransactions), billingCurrencyTotalPaidAmount.Value, billingCurrencyProratedAmount.Value, billingCurrencyRemainingCommitmentAmount.Value); + } + } +} diff --git a/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/RefundBillingInformation.cs b/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/RefundBillingInformation.cs new file mode 100644 index 000000000000..67abc5328383 --- /dev/null +++ b/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/RefundBillingInformation.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Reservations.Models +{ + /// billing information. + public partial class RefundBillingInformation + { + /// Initializes a new instance of RefundBillingInformation. + internal RefundBillingInformation() + { + } + + /// Initializes a new instance of RefundBillingInformation. + /// Represent the billing plans. + /// The number of completed transactions in this reservation's payment. + /// The number of total transactions in this reservation's payment. + /// + /// + /// + internal RefundBillingInformation(ReservationBillingPlan? billingPlan, int? completedTransactions, int? totalTransactions, PurchasePrice billingCurrencyTotalPaidAmount, PurchasePrice billingCurrencyProratedAmount, PurchasePrice billingCurrencyRemainingCommitmentAmount) + { + BillingPlan = billingPlan; + CompletedTransactions = completedTransactions; + TotalTransactions = totalTransactions; + BillingCurrencyTotalPaidAmount = billingCurrencyTotalPaidAmount; + BillingCurrencyProratedAmount = billingCurrencyProratedAmount; + BillingCurrencyRemainingCommitmentAmount = billingCurrencyRemainingCommitmentAmount; + } + + /// Represent the billing plans. + public ReservationBillingPlan? BillingPlan { get; } + /// The number of completed transactions in this reservation's payment. + public int? CompletedTransactions { get; } + /// The number of total transactions in this reservation's payment. + public int? TotalTransactions { get; } + /// Gets the billing currency total paid amount. + public PurchasePrice BillingCurrencyTotalPaidAmount { get; } + /// Gets the billing currency prorated amount. + public PurchasePrice BillingCurrencyProratedAmount { get; } + /// Gets the billing currency remaining commitment amount. + public PurchasePrice BillingCurrencyRemainingCommitmentAmount { get; } + } +} diff --git a/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/RefundContent.Serialization.cs b/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/RefundContent.Serialization.cs new file mode 100644 index 000000000000..ace6dce8cedd --- /dev/null +++ b/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/RefundContent.Serialization.cs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Reservations.Models +{ + public partial class RefundContent : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"); + writer.WriteObjectValue(Properties); + } + writer.WriteEndObject(); + } + } +} diff --git a/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/RefundContent.cs b/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/RefundContent.cs new file mode 100644 index 000000000000..6a656d5cee50 --- /dev/null +++ b/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/RefundContent.cs @@ -0,0 +1,21 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Reservations.Models +{ + /// The RefundContent. + public partial class RefundContent + { + /// Initializes a new instance of RefundContent. + public RefundContent() + { + } + + /// Gets or sets the properties. + public RefundRequestProperties Properties { get; set; } + } +} diff --git a/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/RefundPolicyError.Serialization.cs b/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/RefundPolicyError.Serialization.cs new file mode 100644 index 000000000000..607d0e9d8d78 --- /dev/null +++ b/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/RefundPolicyError.Serialization.cs @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Reservations.Models +{ + public partial class RefundPolicyError + { + internal static RefundPolicyError DeserializeRefundPolicyError(JsonElement element) + { + Optional code = default; + Optional message = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("code")) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + code = new ErrorResponseCode(property.Value.GetString()); + continue; + } + if (property.NameEquals("message")) + { + message = property.Value.GetString(); + continue; + } + } + return new RefundPolicyError(Optional.ToNullable(code), message.Value); + } + } +} diff --git a/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/RefundPolicyError.cs b/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/RefundPolicyError.cs new file mode 100644 index 000000000000..1cb1d40a48af --- /dev/null +++ b/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/RefundPolicyError.cs @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Reservations.Models +{ + /// error details. + public partial class RefundPolicyError + { + /// Initializes a new instance of RefundPolicyError. + internal RefundPolicyError() + { + } + + /// Initializes a new instance of RefundPolicyError. + /// + /// + internal RefundPolicyError(ErrorResponseCode? code, string message) + { + Code = code; + Message = message; + } + + /// Gets the code. + public ErrorResponseCode? Code { get; } + /// Gets the message. + public string Message { get; } + } +} diff --git a/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/RefundPolicyResult.Serialization.cs b/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/RefundPolicyResult.Serialization.cs new file mode 100644 index 000000000000..9a067000aa94 --- /dev/null +++ b/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/RefundPolicyResult.Serialization.cs @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Reservations.Models +{ + internal partial class RefundPolicyResult + { + internal static RefundPolicyResult DeserializeRefundPolicyResult(JsonElement element) + { + Optional properties = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("properties")) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + properties = RefundPolicyResultProperty.DeserializeRefundPolicyResultProperty(property.Value); + continue; + } + } + return new RefundPolicyResult(properties.Value); + } + } +} diff --git a/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/RefundPolicyResult.cs b/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/RefundPolicyResult.cs new file mode 100644 index 000000000000..7beef8994432 --- /dev/null +++ b/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/RefundPolicyResult.cs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Reservations.Models +{ + /// Refund policy result. + internal partial class RefundPolicyResult + { + /// Initializes a new instance of RefundPolicyResult. + internal RefundPolicyResult() + { + } + + /// Initializes a new instance of RefundPolicyResult. + /// Refund policy result property. + internal RefundPolicyResult(RefundPolicyResultProperty properties) + { + Properties = properties; + } + + /// Refund policy result property. + public RefundPolicyResultProperty Properties { get; } + } +} diff --git a/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/RefundPolicyResultProperty.Serialization.cs b/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/RefundPolicyResultProperty.Serialization.cs new file mode 100644 index 000000000000..55b9ec50b345 --- /dev/null +++ b/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/RefundPolicyResultProperty.Serialization.cs @@ -0,0 +1,62 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Reservations.Models +{ + public partial class RefundPolicyResultProperty + { + internal static RefundPolicyResultProperty DeserializeRefundPolicyResultProperty(JsonElement element) + { + Optional consumedRefundsTotal = default; + Optional maxRefundLimit = default; + Optional> policyErrors = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("consumedRefundsTotal")) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + consumedRefundsTotal = PurchasePrice.DeserializePurchasePrice(property.Value); + continue; + } + if (property.NameEquals("maxRefundLimit")) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + maxRefundLimit = PurchasePrice.DeserializePurchasePrice(property.Value); + continue; + } + if (property.NameEquals("policyErrors")) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(RefundPolicyError.DeserializeRefundPolicyError(item)); + } + policyErrors = array; + continue; + } + } + return new RefundPolicyResultProperty(consumedRefundsTotal.Value, maxRefundLimit.Value, Optional.ToList(policyErrors)); + } + } +} diff --git a/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/RefundPolicyResultProperty.cs b/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/RefundPolicyResultProperty.cs new file mode 100644 index 000000000000..4d82128c77c5 --- /dev/null +++ b/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/RefundPolicyResultProperty.cs @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.Reservations.Models +{ + /// Refund policy result property. + public partial class RefundPolicyResultProperty + { + /// Initializes a new instance of RefundPolicyResultProperty. + internal RefundPolicyResultProperty() + { + PolicyErrors = new ChangeTrackingList(); + } + + /// Initializes a new instance of RefundPolicyResultProperty. + /// + /// + /// Refund Policy errors. + internal RefundPolicyResultProperty(PurchasePrice consumedRefundsTotal, PurchasePrice maxRefundLimit, IReadOnlyList policyErrors) + { + ConsumedRefundsTotal = consumedRefundsTotal; + MaxRefundLimit = maxRefundLimit; + PolicyErrors = policyErrors; + } + + /// Gets the consumed refunds total. + public PurchasePrice ConsumedRefundsTotal { get; } + /// Gets the max refund limit. + public PurchasePrice MaxRefundLimit { get; } + /// Refund Policy errors. + public IReadOnlyList PolicyErrors { get; } + } +} diff --git a/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/RefundRequestProperties.Serialization.cs b/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/RefundRequestProperties.Serialization.cs new file mode 100644 index 000000000000..989cff471a89 --- /dev/null +++ b/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/RefundRequestProperties.Serialization.cs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Reservations.Models +{ + public partial class RefundRequestProperties : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsDefined(SessionId)) + { + writer.WritePropertyName("sessionId"); + writer.WriteStringValue(SessionId.Value); + } + if (Optional.IsDefined(Scope)) + { + writer.WritePropertyName("scope"); + writer.WriteStringValue(Scope); + } + if (Optional.IsDefined(ReservationToReturn)) + { + writer.WritePropertyName("reservationToReturn"); + writer.WriteObjectValue(ReservationToReturn); + } + if (Optional.IsDefined(ReturnReason)) + { + writer.WritePropertyName("returnReason"); + writer.WriteStringValue(ReturnReason); + } + writer.WriteEndObject(); + } + } +} diff --git a/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/RefundRequestProperties.cs b/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/RefundRequestProperties.cs new file mode 100644 index 000000000000..717f7bfe9520 --- /dev/null +++ b/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/RefundRequestProperties.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.Reservations.Models +{ + /// The RefundRequestProperties. + public partial class RefundRequestProperties + { + /// Initializes a new instance of RefundRequestProperties. + public RefundRequestProperties() + { + } + + /// SessionId that was returned by CalculateRefund API. + public Guid? SessionId { get; set; } + /// The scope of the refund, e.g. Reservation. + public string Scope { get; set; } + /// Reservation to return. + public ReservationToReturn ReservationToReturn { get; set; } + /// The reason of returning the reservation. + public string ReturnReason { get; set; } + } +} diff --git a/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/RefundResponse.Serialization.cs b/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/RefundResponse.Serialization.cs new file mode 100644 index 000000000000..b5bd020cea59 --- /dev/null +++ b/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/RefundResponse.Serialization.cs @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Reservations.Models +{ + public partial class RefundResponse + { + internal static RefundResponse DeserializeRefundResponse(JsonElement element) + { + Optional id = default; + Optional properties = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id")) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("properties")) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + properties = RefundResponseProperties.DeserializeRefundResponseProperties(property.Value); + continue; + } + } + return new RefundResponse(id.Value, properties.Value); + } + } +} diff --git a/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/RefundResponse.cs b/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/RefundResponse.cs new file mode 100644 index 000000000000..397e912b9e89 --- /dev/null +++ b/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/RefundResponse.cs @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Reservations.Models +{ + /// The RefundResponse. + public partial class RefundResponse + { + /// Initializes a new instance of RefundResponse. + internal RefundResponse() + { + } + + /// Initializes a new instance of RefundResponse. + /// Fully qualified identifier of the reservation being returned. + /// + internal RefundResponse(string id, RefundResponseProperties properties) + { + Id = id; + Properties = properties; + } + + /// Fully qualified identifier of the reservation being returned. + public string Id { get; } + /// Gets the properties. + public RefundResponseProperties Properties { get; } + } +} diff --git a/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/RefundResponseProperties.Serialization.cs b/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/RefundResponseProperties.Serialization.cs new file mode 100644 index 000000000000..499c4bd9430e --- /dev/null +++ b/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/RefundResponseProperties.Serialization.cs @@ -0,0 +1,90 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Reservations.Models +{ + public partial class RefundResponseProperties + { + internal static RefundResponseProperties DeserializeRefundResponseProperties(JsonElement element) + { + Optional sessionId = default; + Optional quantity = default; + Optional billingRefundAmount = default; + Optional pricingRefundAmount = default; + Optional policyResult = default; + Optional billingInformation = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("sessionId")) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + sessionId = property.Value.GetGuid(); + continue; + } + if (property.NameEquals("quantity")) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + quantity = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("billingRefundAmount")) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + billingRefundAmount = PurchasePrice.DeserializePurchasePrice(property.Value); + continue; + } + if (property.NameEquals("pricingRefundAmount")) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + pricingRefundAmount = PurchasePrice.DeserializePurchasePrice(property.Value); + continue; + } + if (property.NameEquals("policyResult")) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + policyResult = RefundPolicyResult.DeserializeRefundPolicyResult(property.Value); + continue; + } + if (property.NameEquals("billingInformation")) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + billingInformation = RefundBillingInformation.DeserializeRefundBillingInformation(property.Value); + continue; + } + } + return new RefundResponseProperties(Optional.ToNullable(sessionId), Optional.ToNullable(quantity), billingRefundAmount.Value, pricingRefundAmount.Value, policyResult.Value, billingInformation.Value); + } + } +} diff --git a/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/RefundResponseProperties.cs b/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/RefundResponseProperties.cs new file mode 100644 index 000000000000..bc2175663d7e --- /dev/null +++ b/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/RefundResponseProperties.cs @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.Reservations.Models +{ + /// The RefundResponseProperties. + public partial class RefundResponseProperties + { + /// Initializes a new instance of RefundResponseProperties. + internal RefundResponseProperties() + { + } + + /// Initializes a new instance of RefundResponseProperties. + /// Refund session identifier. + /// Quantity to be returned. + /// + /// + /// Refund policy result. + /// billing information. + internal RefundResponseProperties(Guid? sessionId, int? quantity, PurchasePrice billingRefundAmount, PurchasePrice pricingRefundAmount, RefundPolicyResult policyResult, RefundBillingInformation billingInformation) + { + SessionId = sessionId; + Quantity = quantity; + BillingRefundAmount = billingRefundAmount; + PricingRefundAmount = pricingRefundAmount; + PolicyResult = policyResult; + BillingInformation = billingInformation; + } + + /// Refund session identifier. + public Guid? SessionId { get; } + /// Quantity to be returned. + public int? Quantity { get; } + /// Gets the billing refund amount. + public PurchasePrice BillingRefundAmount { get; } + /// Gets the pricing refund amount. + public PurchasePrice PricingRefundAmount { get; } + /// Refund policy result. + internal RefundPolicyResult PolicyResult { get; } + /// Refund policy result property. + public RefundPolicyResultProperty PolicyResultProperties + { + get => PolicyResult?.Properties; + } + + /// billing information. + public RefundBillingInformation BillingInformation { get; } + } +} diff --git a/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/ReservationProperties.Serialization.cs b/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/ReservationProperties.Serialization.cs index 16de5917f86b..81841ded3d98 100644 --- a/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/ReservationProperties.Serialization.cs +++ b/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/ReservationProperties.Serialization.cs @@ -37,6 +37,8 @@ internal static ReservationProperties DeserializeReservationProperties(JsonEleme Optional purchaseDate = default; Optional splitProperties = default; Optional mergeProperties = default; + Optional swapProperties = default; + Optional appliedScopeProperties = default; Optional billingScopeId = default; Optional renew = default; Optional renewSource = default; @@ -238,6 +240,26 @@ internal static ReservationProperties DeserializeReservationProperties(JsonEleme mergeProperties = ReservationMergeProperties.DeserializeReservationMergeProperties(property.Value); continue; } + if (property.NameEquals("swapProperties")) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + swapProperties = ReservationSwapProperties.DeserializeReservationSwapProperties(property.Value); + continue; + } + if (property.NameEquals("appliedScopeProperties")) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + appliedScopeProperties = AppliedScopeProperties.DeserializeAppliedScopeProperties(property.Value); + continue; + } if (property.NameEquals("billingScopeId")) { if (property.Value.ValueKind == JsonValueKind.Null) @@ -309,7 +331,7 @@ internal static ReservationProperties DeserializeReservationProperties(JsonEleme continue; } } - return new ReservationProperties(Optional.ToNullable(reservedResourceType), Optional.ToNullable(instanceFlexibility), displayName.Value, Optional.ToList(appliedScopes), Optional.ToNullable(appliedScopeType), Optional.ToNullable(archived), capabilities.Value, Optional.ToNullable(quantity), Optional.ToNullable(provisioningState), Optional.ToNullable(effectiveDateTime), Optional.ToNullable(benefitStartTime), Optional.ToNullable(lastUpdatedDateTime), Optional.ToNullable(expiryDate), skuDescription.Value, extendedStatusInfo.Value, Optional.ToNullable(billingPlan), displayProvisioningState.Value, provisioningSubState.Value, Optional.ToNullable(purchaseDate), splitProperties.Value, mergeProperties.Value, billingScopeId.Value, Optional.ToNullable(renew), renewSource.Value, renewDestination.Value, renewProperties.Value, Optional.ToNullable(term), userFriendlyAppliedScopeType.Value, userFriendlyRenewState.Value, utilization.Value); + return new ReservationProperties(Optional.ToNullable(reservedResourceType), Optional.ToNullable(instanceFlexibility), displayName.Value, Optional.ToList(appliedScopes), Optional.ToNullable(appliedScopeType), Optional.ToNullable(archived), capabilities.Value, Optional.ToNullable(quantity), Optional.ToNullable(provisioningState), Optional.ToNullable(effectiveDateTime), Optional.ToNullable(benefitStartTime), Optional.ToNullable(lastUpdatedDateTime), Optional.ToNullable(expiryDate), skuDescription.Value, extendedStatusInfo.Value, Optional.ToNullable(billingPlan), displayProvisioningState.Value, provisioningSubState.Value, Optional.ToNullable(purchaseDate), splitProperties.Value, mergeProperties.Value, swapProperties.Value, appliedScopeProperties.Value, billingScopeId.Value, Optional.ToNullable(renew), renewSource.Value, renewDestination.Value, renewProperties.Value, Optional.ToNullable(term), userFriendlyAppliedScopeType.Value, userFriendlyRenewState.Value, utilization.Value); } } } diff --git a/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/ReservationProperties.cs b/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/ReservationProperties.cs index 916155930fe7..a77a49a3a56a 100644 --- a/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/ReservationProperties.cs +++ b/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/ReservationProperties.cs @@ -42,6 +42,8 @@ internal ReservationProperties() /// This is the date when the Reservation was purchased. /// /// + /// + /// /// Subscription that will be charged for purchasing Reservation. /// Setting this to true will automatically purchase a new reservation on the expiration date time. /// Reservation Id of the reservation from which this reservation is renewed. Format of the resource Id is /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}. @@ -51,7 +53,7 @@ internal ReservationProperties() /// The applied scope type of the reservation for display, e.g. Shared. /// The renew state of the reservation for display, e.g. On. /// Reservation utilization. - internal ReservationProperties(ReservedResourceType? reservedResourceType, InstanceFlexibility? instanceFlexibility, string displayName, IReadOnlyList appliedScopes, AppliedScopeType? appliedScopeType, bool? isArchived, string capabilities, int? quantity, ReservationProvisioningState? provisioningState, DateTimeOffset? effectOn, DateTimeOffset? benefitStartOn, DateTimeOffset? lastUpdatedOn, DateTimeOffset? expireOn, string skuDescription, ExtendedStatusInfo extendedStatusInfo, ReservationBillingPlan? billingPlan, string displayProvisioningState, string provisioningSubState, DateTimeOffset? purchaseOn, ReservationSplitProperties splitProperties, ReservationMergeProperties mergeProperties, ResourceIdentifier billingScopeId, bool? isRenewEnabled, string renewSource, string renewDestination, RenewProperties renewProperties, ReservationTerm? term, string userFriendlyAppliedScopeType, string userFriendlyRenewState, ReservationPropertiesUtilization utilization) + internal ReservationProperties(ReservedResourceType? reservedResourceType, InstanceFlexibility? instanceFlexibility, string displayName, IReadOnlyList appliedScopes, AppliedScopeType? appliedScopeType, bool? isArchived, string capabilities, int? quantity, ReservationProvisioningState? provisioningState, DateTimeOffset? effectOn, DateTimeOffset? benefitStartOn, DateTimeOffset? lastUpdatedOn, DateTimeOffset? expireOn, string skuDescription, ExtendedStatusInfo extendedStatusInfo, ReservationBillingPlan? billingPlan, string displayProvisioningState, string provisioningSubState, DateTimeOffset? purchaseOn, ReservationSplitProperties splitProperties, ReservationMergeProperties mergeProperties, ReservationSwapProperties swapProperties, AppliedScopeProperties appliedScopeProperties, ResourceIdentifier billingScopeId, bool? isRenewEnabled, string renewSource, string renewDestination, RenewProperties renewProperties, ReservationTerm? term, string userFriendlyAppliedScopeType, string userFriendlyRenewState, ReservationPropertiesUtilization utilization) { ReservedResourceType = reservedResourceType; InstanceFlexibility = instanceFlexibility; @@ -74,6 +76,8 @@ internal ReservationProperties(ReservedResourceType? reservedResourceType, Insta PurchaseOn = purchaseOn; SplitProperties = splitProperties; MergeProperties = mergeProperties; + SwapProperties = swapProperties; + AppliedScopeProperties = appliedScopeProperties; BillingScopeId = billingScopeId; IsRenewEnabled = isRenewEnabled; RenewSource = renewSource; @@ -127,6 +131,10 @@ internal ReservationProperties(ReservedResourceType? reservedResourceType, Insta public ReservationSplitProperties SplitProperties { get; } /// Gets the merge properties. public ReservationMergeProperties MergeProperties { get; } + /// Gets the swap properties. + public ReservationSwapProperties SwapProperties { get; } + /// Gets the applied scope properties. + public AppliedScopeProperties AppliedScopeProperties { get; } /// Subscription that will be charged for purchasing Reservation. public ResourceIdentifier BillingScopeId { get; } /// Setting this to true will automatically purchase a new reservation on the expiration date time. diff --git a/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/ReservationSwapProperties.Serialization.cs b/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/ReservationSwapProperties.Serialization.cs new file mode 100644 index 000000000000..c0694657e576 --- /dev/null +++ b/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/ReservationSwapProperties.Serialization.cs @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Reservations.Models +{ + public partial class ReservationSwapProperties + { + internal static ReservationSwapProperties DeserializeReservationSwapProperties(JsonElement element) + { + Optional swapSource = default; + Optional swapDestination = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("swapSource")) + { + swapSource = property.Value.GetString(); + continue; + } + if (property.NameEquals("swapDestination")) + { + swapDestination = property.Value.GetString(); + continue; + } + } + return new ReservationSwapProperties(swapSource.Value, swapDestination.Value); + } + } +} diff --git a/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/ReservationSwapProperties.cs b/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/ReservationSwapProperties.cs new file mode 100644 index 000000000000..00806c63934b --- /dev/null +++ b/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/Models/ReservationSwapProperties.cs @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Reservations.Models +{ + /// The ReservationSwapProperties. + public partial class ReservationSwapProperties + { + /// Initializes a new instance of ReservationSwapProperties. + internal ReservationSwapProperties() + { + } + + /// Initializes a new instance of ReservationSwapProperties. + /// Resource Id of the Source Reservation that gets swapped. Format of the resource Id is /providers/microsoft.capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}. + /// Reservation Resource Id that the original resource gets swapped to. Format of the resource Id is /providers/microsoft.capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}. + internal ReservationSwapProperties(string swapSource, string swapDestination) + { + SwapSource = swapSource; + SwapDestination = swapDestination; + } + + /// Resource Id of the Source Reservation that gets swapped. Format of the resource Id is /providers/microsoft.capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}. + public string SwapSource { get; } + /// Reservation Resource Id that the original resource gets swapped to. Format of the resource Id is /providers/microsoft.capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}. + public string SwapDestination { get; } + } +} diff --git a/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/ReservationDetailResource.cs b/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/ReservationDetailResource.cs index 95e71868aefa..14cf05bdeecb 100644 --- a/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/ReservationDetailResource.cs +++ b/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/ReservationDetailResource.cs @@ -258,5 +258,95 @@ public virtual ArmOperation GetAvailableScopes(WaitUn throw; } } + + /// + /// Archiving a `Reservation` moves it to `Archived` state. + /// Request Path: /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}/archive + /// Operation Id: Reservation_Archive + /// + /// The cancellation token to use. + public virtual async Task ArchiveAsync(CancellationToken cancellationToken = default) + { + using var scope = _reservationDetailReservationClientDiagnostics.CreateScope("ReservationDetailResource.Archive"); + scope.Start(); + try + { + var response = await _reservationDetailReservationRestClient.ArchiveAsync(Guid.Parse(Id.Parent.Name), Guid.Parse(Id.Name), cancellationToken).ConfigureAwait(false); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Archiving a `Reservation` moves it to `Archived` state. + /// Request Path: /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}/archive + /// Operation Id: Reservation_Archive + /// + /// The cancellation token to use. + public virtual Response Archive(CancellationToken cancellationToken = default) + { + using var scope = _reservationDetailReservationClientDiagnostics.CreateScope("ReservationDetailResource.Archive"); + scope.Start(); + try + { + var response = _reservationDetailReservationRestClient.Archive(Guid.Parse(Id.Parent.Name), Guid.Parse(Id.Name), cancellationToken); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Unarchiving a `Reservation` moves it to the state it was before archiving. + /// + /// Request Path: /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}/unarchive + /// Operation Id: Reservation_Unarchive + /// + /// The cancellation token to use. + public virtual async Task UnarchiveAsync(CancellationToken cancellationToken = default) + { + using var scope = _reservationDetailReservationClientDiagnostics.CreateScope("ReservationDetailResource.Unarchive"); + scope.Start(); + try + { + var response = await _reservationDetailReservationRestClient.UnarchiveAsync(Guid.Parse(Id.Parent.Name), Guid.Parse(Id.Name), cancellationToken).ConfigureAwait(false); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Unarchiving a `Reservation` moves it to the state it was before archiving. + /// + /// Request Path: /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}/unarchive + /// Operation Id: Reservation_Unarchive + /// + /// The cancellation token to use. + public virtual Response Unarchive(CancellationToken cancellationToken = default) + { + using var scope = _reservationDetailReservationClientDiagnostics.CreateScope("ReservationDetailResource.Unarchive"); + scope.Start(); + try + { + var response = _reservationDetailReservationRestClient.Unarchive(Guid.Parse(Id.Parent.Name), Guid.Parse(Id.Name), cancellationToken); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } } } diff --git a/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/ReservationOrderResource.cs b/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/ReservationOrderResource.cs index 49f7d5e49f6e..d9e8ea16d802 100644 --- a/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/ReservationOrderResource.cs +++ b/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/ReservationOrderResource.cs @@ -38,6 +38,10 @@ public static ResourceIdentifier CreateResourceIdentifier(Guid reservationOrderI private readonly ReservationOrderRestOperations _reservationOrderRestClient; private readonly ClientDiagnostics _reservationDetailReservationClientDiagnostics; private readonly ReservationRestOperations _reservationDetailReservationRestClient; + private readonly ClientDiagnostics _calculateRefundClientDiagnostics; + private readonly CalculateRefundRestOperations _calculateRefundRestClient; + private readonly ClientDiagnostics _returnClientDiagnostics; + private readonly ReturnRestOperations _returnRestClient; private readonly ReservationOrderData _data; /// Initializes a new instance of the class for mocking. @@ -65,6 +69,10 @@ internal ReservationOrderResource(ArmClient client, ResourceIdentifier id) : bas _reservationDetailReservationClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Reservations", ReservationDetailResource.ResourceType.Namespace, Diagnostics); TryGetApiVersion(ReservationDetailResource.ResourceType, out string reservationDetailReservationApiVersion); _reservationDetailReservationRestClient = new ReservationRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, reservationDetailReservationApiVersion); + _calculateRefundClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Reservations", ProviderConstants.DefaultProviderNamespace, Diagnostics); + _calculateRefundRestClient = new CalculateRefundRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint); + _returnClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Reservations", ProviderConstants.DefaultProviderNamespace, Diagnostics); + _returnRestClient = new ReturnRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint); #if DEBUG ValidateResourceId(Id); #endif @@ -410,5 +418,111 @@ public virtual Response ChangeDirectory(ChangeDirectoryCo throw; } } + + /// + /// Calculate price for returning `Reservations` if there are no policy errors. + /// + /// Request Path: /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/calculateRefund + /// Operation Id: CalculateRefund_Post + /// + /// Information needed for calculating refund of a reservation. + /// The cancellation token to use. + /// is null. + public virtual async Task> PostCalculateRefundAsync(CalculateRefundContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = _calculateRefundClientDiagnostics.CreateScope("ReservationOrderResource.PostCalculateRefund"); + scope.Start(); + try + { + var response = await _calculateRefundRestClient.PostAsync(Guid.Parse(Id.Name), content, cancellationToken).ConfigureAwait(false); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Calculate price for returning `Reservations` if there are no policy errors. + /// + /// Request Path: /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/calculateRefund + /// Operation Id: CalculateRefund_Post + /// + /// Information needed for calculating refund of a reservation. + /// The cancellation token to use. + /// is null. + public virtual Response PostCalculateRefund(CalculateRefundContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = _calculateRefundClientDiagnostics.CreateScope("ReservationOrderResource.PostCalculateRefund"); + scope.Start(); + try + { + var response = _calculateRefundRestClient.Post(Guid.Parse(Id.Name), content, cancellationToken); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Return a reservation. + /// Request Path: /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/return + /// Operation Id: Return_Post + /// + /// Information needed for returning reservation. + /// The cancellation token to use. + /// is null. + public virtual async Task> PostReturnAsync(RefundContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = _returnClientDiagnostics.CreateScope("ReservationOrderResource.PostReturn"); + scope.Start(); + try + { + var response = await _returnRestClient.PostAsync(Guid.Parse(Id.Name), content, cancellationToken).ConfigureAwait(false); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Return a reservation. + /// Request Path: /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/return + /// Operation Id: Return_Post + /// + /// Information needed for returning reservation. + /// The cancellation token to use. + /// is null. + public virtual Response PostReturn(RefundContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = _returnClientDiagnostics.CreateScope("ReservationOrderResource.PostReturn"); + scope.Start(); + try + { + var response = _returnRestClient.Post(Guid.Parse(Id.Name), content, cancellationToken); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } } } diff --git a/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/RestOperations/CalculateRefundRestOperations.cs b/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/RestOperations/CalculateRefundRestOperations.cs new file mode 100644 index 000000000000..beee1c923dd9 --- /dev/null +++ b/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/RestOperations/CalculateRefundRestOperations.cs @@ -0,0 +1,117 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Reservations.Models; + +namespace Azure.ResourceManager.Reservations +{ + internal partial class CalculateRefundRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of CalculateRefundRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// server parameter. + /// Api Version. + /// or is null. + public CalculateRefundRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + { + _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); + _endpoint = endpoint ?? new Uri("https://management.azure.com"); + _apiVersion = apiVersion ?? "2022-03-01"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal HttpMessage CreatePostRequest(Guid reservationOrderId, CalculateRefundContent content) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/providers/Microsoft.Capacity/reservationOrders/", false); + uri.AppendPath(reservationOrderId, true); + uri.AppendPath("/calculateRefund", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content0 = new Utf8JsonRequestContent(); + content0.JsonWriter.WriteObjectValue(content); + request.Content = content0; + _userAgent.Apply(message); + return message; + } + + /// + /// Calculate price for returning `Reservations` if there are no policy errors. + /// + /// + /// Order Id of the reservation. + /// Information needed for calculating refund of a reservation. + /// The cancellation token to use. + /// is null. + public async Task> PostAsync(Guid reservationOrderId, CalculateRefundContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(content, nameof(content)); + + using var message = CreatePostRequest(reservationOrderId, content); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + CalculateRefundResponse value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = CalculateRefundResponse.DeserializeCalculateRefundResponse(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// + /// Calculate price for returning `Reservations` if there are no policy errors. + /// + /// + /// Order Id of the reservation. + /// Information needed for calculating refund of a reservation. + /// The cancellation token to use. + /// is null. + public Response Post(Guid reservationOrderId, CalculateRefundContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(content, nameof(content)); + + using var message = CreatePostRequest(reservationOrderId, content); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + CalculateRefundResponse value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = CalculateRefundResponse.DeserializeCalculateRefundResponse(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/RestOperations/ReservationRestOperations.cs b/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/RestOperations/ReservationRestOperations.cs index 9d9f0ca3a607..12be81d168a9 100644 --- a/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/RestOperations/ReservationRestOperations.cs +++ b/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/RestOperations/ReservationRestOperations.cs @@ -431,6 +431,118 @@ public Response Update(Guid reservationOrderId, Guid reservationId, ReservationD } } + internal HttpMessage CreateArchiveRequest(Guid reservationOrderId, Guid reservationId) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/providers/Microsoft.Capacity/reservationOrders/", false); + uri.AppendPath(reservationOrderId, true); + uri.AppendPath("/reservations/", false); + uri.AppendPath(reservationId, true); + uri.AppendPath("/archive", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Archiving a `Reservation` moves it to `Archived` state. + /// Order Id of the reservation. + /// Id of the Reservation Item. + /// The cancellation token to use. + public async Task ArchiveAsync(Guid reservationOrderId, Guid reservationId, CancellationToken cancellationToken = default) + { + using var message = CreateArchiveRequest(reservationOrderId, reservationId); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Archiving a `Reservation` moves it to `Archived` state. + /// Order Id of the reservation. + /// Id of the Reservation Item. + /// The cancellation token to use. + public Response Archive(Guid reservationOrderId, Guid reservationId, CancellationToken cancellationToken = default) + { + using var message = CreateArchiveRequest(reservationOrderId, reservationId); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateUnarchiveRequest(Guid reservationOrderId, Guid reservationId) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/providers/Microsoft.Capacity/reservationOrders/", false); + uri.AppendPath(reservationOrderId, true); + uri.AppendPath("/reservations/", false); + uri.AppendPath(reservationId, true); + uri.AppendPath("/unarchive", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// + /// Unarchiving a `Reservation` moves it to the state it was before archiving. + /// + /// + /// Order Id of the reservation. + /// Id of the Reservation Item. + /// The cancellation token to use. + public async Task UnarchiveAsync(Guid reservationOrderId, Guid reservationId, CancellationToken cancellationToken = default) + { + using var message = CreateUnarchiveRequest(reservationOrderId, reservationId); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// + /// Unarchiving a `Reservation` moves it to the state it was before archiving. + /// + /// + /// Order Id of the reservation. + /// Id of the Reservation Item. + /// The cancellation token to use. + public Response Unarchive(Guid reservationOrderId, Guid reservationId, CancellationToken cancellationToken = default) + { + using var message = CreateUnarchiveRequest(reservationOrderId, reservationId); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + internal HttpMessage CreateListRevisionsRequest(Guid reservationOrderId, Guid reservationId) { var message = _pipeline.CreateMessage(); diff --git a/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/RestOperations/ReturnRestOperations.cs b/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/RestOperations/ReturnRestOperations.cs new file mode 100644 index 000000000000..4ce137049f61 --- /dev/null +++ b/sdk/reservations/Azure.ResourceManager.Reservations/src/Generated/RestOperations/ReturnRestOperations.cs @@ -0,0 +1,111 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Reservations.Models; + +namespace Azure.ResourceManager.Reservations +{ + internal partial class ReturnRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of ReturnRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// server parameter. + /// Api Version. + /// or is null. + public ReturnRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + { + _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); + _endpoint = endpoint ?? new Uri("https://management.azure.com"); + _apiVersion = apiVersion ?? "2022-03-01"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal HttpMessage CreatePostRequest(Guid reservationOrderId, RefundContent content) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/providers/Microsoft.Capacity/reservationOrders/", false); + uri.AppendPath(reservationOrderId, true); + uri.AppendPath("/return", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content0 = new Utf8JsonRequestContent(); + content0.JsonWriter.WriteObjectValue(content); + request.Content = content0; + _userAgent.Apply(message); + return message; + } + + /// Return a reservation. + /// Order Id of the reservation. + /// Information needed for returning reservation. + /// The cancellation token to use. + /// is null. + public async Task> PostAsync(Guid reservationOrderId, RefundContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(content, nameof(content)); + + using var message = CreatePostRequest(reservationOrderId, content); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 202: + { + RefundResponse value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = RefundResponse.DeserializeRefundResponse(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Return a reservation. + /// Order Id of the reservation. + /// Information needed for returning reservation. + /// The cancellation token to use. + /// is null. + public Response Post(Guid reservationOrderId, RefundContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(content, nameof(content)); + + using var message = CreatePostRequest(reservationOrderId, content); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 202: + { + RefundResponse value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = RefundResponse.DeserializeRefundResponse(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/reservations/Azure.ResourceManager.Reservations/src/autorest.md b/sdk/reservations/Azure.ResourceManager.Reservations/src/autorest.md index 403cf490d428..3e94f324ddfc 100644 --- a/sdk/reservations/Azure.ResourceManager.Reservations/src/autorest.md +++ b/sdk/reservations/Azure.ResourceManager.Reservations/src/autorest.md @@ -7,7 +7,7 @@ azure-arm: true csharp: true library-name: Reservations namespace: Azure.ResourceManager.Reservations -require: https://github.com/Azure/azure-rest-api-specs/blob/42f123a0ca6cd5f8f01f3463ecb47999fdbf3a18/specification/reservations/resource-manager/readme.md +require: /mnt/vss/_work/1/s/azure-rest-api-specs/specification/reservations/resource-manager/readme.md tag: package-2022-03 output-folder: $(this-folder)/Generated clear-output-folder: true