diff --git a/billing/resource-manager/v2018_11_01_preview/src/main/java/com/microsoft/azure/management/billing/v2018_11_01_preview/BillingAccount.java b/billing/resource-manager/v2018_11_01_preview/src/main/java/com/microsoft/azure/management/billing/v2018_11_01_preview/BillingAccount.java index 60f230d241c9..41da7b613a81 100644 --- a/billing/resource-manager/v2018_11_01_preview/src/main/java/com/microsoft/azure/management/billing/v2018_11_01_preview/BillingAccount.java +++ b/billing/resource-manager/v2018_11_01_preview/src/main/java/com/microsoft/azure/management/billing/v2018_11_01_preview/BillingAccount.java @@ -9,11 +9,15 @@ package com.microsoft.azure.management.billing.v2018_11_01_preview; import com.microsoft.azure.arm.model.HasInner; +import com.microsoft.azure.management.billing.v2018_11_01_preview.implementation.BillingAccountInner; +import com.microsoft.azure.arm.model.Indexable; +import com.microsoft.azure.arm.model.Updatable; +import com.microsoft.azure.arm.model.Appliable; +import com.microsoft.azure.arm.model.Refreshable; import com.microsoft.azure.arm.resources.models.HasManager; import com.microsoft.azure.management.billing.v2018_11_01_preview.implementation.BillingManager; -import com.microsoft.azure.management.billing.v2018_11_01_preview.implementation.BillingAccountInner; -import com.microsoft.azure.management.billing.v2018_11_01_preview.implementation.BillingProfileInner; import java.util.List; +import com.microsoft.azure.management.billing.v2018_11_01_preview.implementation.BillingProfileInner; import com.microsoft.azure.management.billing.v2018_11_01_preview.implementation.DepartmentInner; import com.microsoft.azure.management.billing.v2018_11_01_preview.implementation.EnrollmentAccountInner; import com.microsoft.azure.management.billing.v2018_11_01_preview.implementation.InvoiceSectionInner; @@ -21,7 +25,7 @@ /** * Type representing BillingAccount. */ -public interface BillingAccount extends HasInner, HasManager { +public interface BillingAccount extends HasInner, Indexable, Updatable, Refreshable, HasManager { /** * @return the accountType value. */ @@ -35,7 +39,7 @@ public interface BillingAccount extends HasInner, HasManage /** * @return the billingProfiles value. */ - List billingProfiles(); + List billingProfiles(); /** * @return the company value. @@ -50,7 +54,7 @@ public interface BillingAccount extends HasInner, HasManage /** * @return the departments value. */ - List departments(); + List departments(); /** * @return the displayName value. @@ -60,7 +64,7 @@ public interface BillingAccount extends HasInner, HasManage /** * @return the enrollmentAccounts value. */ - List enrollmentAccounts(); + List enrollmentAccounts(); /** * @return the enrollmentDetails value. @@ -80,7 +84,7 @@ public interface BillingAccount extends HasInner, HasManage /** * @return the invoiceSections value. */ - List invoiceSections(); + List invoiceSections(); /** * @return the name value. @@ -92,4 +96,75 @@ public interface BillingAccount extends HasInner, HasManage */ String type(); + /** + * The template for a BillingAccount update operation, containing all the settings that can be modified. + */ + interface Update extends Appliable, UpdateStages.WithAddress, UpdateStages.WithBillingProfiles, UpdateStages.WithDepartments, UpdateStages.WithEnrollmentAccounts, UpdateStages.WithInvoiceSections { + } + + /** + * Grouping of BillingAccount update stages. + */ + interface UpdateStages { + /** + * The stage of the billingaccount update allowing to specify Address. + */ + interface WithAddress { + /** + * Specifies address. + * @param address The address associated with billing account + * @return the next update stage + */ + Update withAddress(Address address); + } + + /** + * The stage of the billingaccount update allowing to specify BillingProfiles. + */ + interface WithBillingProfiles { + /** + * Specifies billingProfiles. + * @param billingProfiles The billing profiles associated to the billing account. By default this is not populated, unless it's specified in $expand + * @return the next update stage + */ + Update withBillingProfiles(List billingProfiles); + } + + /** + * The stage of the billingaccount update allowing to specify Departments. + */ + interface WithDepartments { + /** + * Specifies departments. + * @param departments The departments associated to the enrollment + * @return the next update stage + */ + Update withDepartments(List departments); + } + + /** + * The stage of the billingaccount update allowing to specify EnrollmentAccounts. + */ + interface WithEnrollmentAccounts { + /** + * Specifies enrollmentAccounts. + * @param enrollmentAccounts The accounts associated to the enrollment + * @return the next update stage + */ + Update withEnrollmentAccounts(List enrollmentAccounts); + } + + /** + * The stage of the billingaccount update allowing to specify InvoiceSections. + */ + interface WithInvoiceSections { + /** + * Specifies invoiceSections. + * @param invoiceSections The invoice sections associated to the billing account. By default this is not populated, unless it's specified in $expand + * @return the next update stage + */ + Update withInvoiceSections(List invoiceSections); + } + + } } diff --git a/billing/resource-manager/v2018_11_01_preview/src/main/java/com/microsoft/azure/management/billing/v2018_11_01_preview/BillingAccountsUpdateHeaders.java b/billing/resource-manager/v2018_11_01_preview/src/main/java/com/microsoft/azure/management/billing/v2018_11_01_preview/BillingAccountsUpdateHeaders.java new file mode 100644 index 000000000000..db366f435f39 --- /dev/null +++ b/billing/resource-manager/v2018_11_01_preview/src/main/java/com/microsoft/azure/management/billing/v2018_11_01_preview/BillingAccountsUpdateHeaders.java @@ -0,0 +1,70 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.billing.v2018_11_01_preview; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Defines headers for Update operation. + */ +public class BillingAccountsUpdateHeaders { + /** + * GET this URL to retrieve the status of the asynchronous operation. + */ + @JsonProperty(value = "Location") + private String location; + + /** + * The amount of delay to use while the status of the operation is checked. + * The value is expressed in seconds. + */ + @JsonProperty(value = "Retry-After") + private String retryAfter; + + /** + * Get gET this URL to retrieve the status of the asynchronous operation. + * + * @return the location value + */ + public String location() { + return this.location; + } + + /** + * Set gET this URL to retrieve the status of the asynchronous operation. + * + * @param location the location value to set + * @return the BillingAccountsUpdateHeaders object itself. + */ + public BillingAccountsUpdateHeaders withLocation(String location) { + this.location = location; + return this; + } + + /** + * Get the amount of delay to use while the status of the operation is checked. The value is expressed in seconds. + * + * @return the retryAfter value + */ + public String retryAfter() { + return this.retryAfter; + } + + /** + * Set the amount of delay to use while the status of the operation is checked. The value is expressed in seconds. + * + * @param retryAfter the retryAfter value to set + * @return the BillingAccountsUpdateHeaders object itself. + */ + public BillingAccountsUpdateHeaders withRetryAfter(String retryAfter) { + this.retryAfter = retryAfter; + return this; + } + +} diff --git a/billing/resource-manager/v2018_11_01_preview/src/main/java/com/microsoft/azure/management/billing/v2018_11_01_preview/implementation/BillingAccountImpl.java b/billing/resource-manager/v2018_11_01_preview/src/main/java/com/microsoft/azure/management/billing/v2018_11_01_preview/implementation/BillingAccountImpl.java index decba4a00699..0e0fd3a9fa64 100644 --- a/billing/resource-manager/v2018_11_01_preview/src/main/java/com/microsoft/azure/management/billing/v2018_11_01_preview/implementation/BillingAccountImpl.java +++ b/billing/resource-manager/v2018_11_01_preview/src/main/java/com/microsoft/azure/management/billing/v2018_11_01_preview/implementation/BillingAccountImpl.java @@ -4,21 +4,43 @@ * license information. * * Code generated by Microsoft (R) AutoRest Code Generator. + * */ package com.microsoft.azure.management.billing.v2018_11_01_preview.implementation; import com.microsoft.azure.management.billing.v2018_11_01_preview.BillingAccount; -import com.microsoft.azure.arm.model.implementation.WrapperImpl; +import com.microsoft.azure.arm.model.implementation.CreatableUpdatableImpl; +import rx.Observable; import com.microsoft.azure.management.billing.v2018_11_01_preview.Address; import java.util.List; import com.microsoft.azure.management.billing.v2018_11_01_preview.Enrollment; - -class BillingAccountImpl extends WrapperImpl implements BillingAccount { +import java.util.ArrayList; +import com.microsoft.azure.management.billing.v2018_11_01_preview.BillingProfile; +import com.microsoft.azure.management.billing.v2018_11_01_preview.Department; +import com.microsoft.azure.management.billing.v2018_11_01_preview.EnrollmentAccount; +import com.microsoft.azure.management.billing.v2018_11_01_preview.InvoiceSection; + +class BillingAccountImpl extends CreatableUpdatableImpl implements BillingAccount, BillingAccount.Update { + private String billingAccountName; private final BillingManager manager; + + BillingAccountImpl(String name, BillingManager manager) { + super(name, new BillingAccountInner()); + this.manager = manager; + // Set resource name + this.billingAccountName = name; + // + } + BillingAccountImpl(BillingAccountInner inner, BillingManager manager) { - super(inner); + super(inner.name(), inner); this.manager = manager; + // Set resource name + this.billingAccountName = inner.name(); + // set resource ancestor and positional variables + this.billingAccountName = IdParsingUtils.getValueFromIdByName(inner.id(), "billingAccounts"); + // set other parameters for create and update } @Override @@ -26,6 +48,31 @@ public BillingManager manager() { return this.manager; } + @Override + public Observable createResourceAsync() { + BillingAccountsInner client = this.manager().inner().billingAccounts(); + return null; // NOP createResourceAsync implementation as create is not supported + } + + @Override + public Observable updateResourceAsync() { + BillingAccountsInner client = this.manager().inner().billingAccounts(); + return client.updateAsync(this.billingAccountName, this.inner()) + .map(innerToFluentMap(this)); + } + + @Override + protected Observable getInnerAsync() { + BillingAccountsInner client = this.manager().inner().billingAccounts(); + return client.getAsync(this.billingAccountName); + } + + @Override + public boolean isInCreateMode() { + return this.inner().id() == null; + } + + @Override public String accountType() { return this.inner().accountType(); @@ -37,8 +84,14 @@ public Address address() { } @Override - public List billingProfiles() { - return this.inner().billingProfiles(); + public List billingProfiles() { + List lst = new ArrayList(); + if (this.inner().billingProfiles() != null) { + for (BillingProfileInner inner : this.inner().billingProfiles()) { + lst.add( new BillingProfileImpl(inner, manager())); + } + } + return lst; } @Override @@ -52,8 +105,14 @@ public String country() { } @Override - public List departments() { - return this.inner().departments(); + public List departments() { + List lst = new ArrayList(); + if (this.inner().departments() != null) { + for (DepartmentInner inner : this.inner().departments()) { + lst.add( new DepartmentImpl(inner, manager())); + } + } + return lst; } @Override @@ -62,8 +121,14 @@ public String displayName() { } @Override - public List enrollmentAccounts() { - return this.inner().enrollmentAccounts(); + public List enrollmentAccounts() { + List lst = new ArrayList(); + if (this.inner().enrollmentAccounts() != null) { + for (EnrollmentAccountInner inner : this.inner().enrollmentAccounts()) { + lst.add( new EnrollmentAccountImpl(inner, manager())); + } + } + return lst; } @Override @@ -82,8 +147,14 @@ public String id() { } @Override - public List invoiceSections() { - return this.inner().invoiceSections(); + public List invoiceSections() { + List lst = new ArrayList(); + if (this.inner().invoiceSections() != null) { + for (InvoiceSectionInner inner : this.inner().invoiceSections()) { + lst.add( new InvoiceSectionImpl(inner, manager())); + } + } + return lst; } @Override @@ -96,4 +167,34 @@ public String type() { return this.inner().type(); } + @Override + public BillingAccountImpl withAddress(Address address) { + this.inner().withAddress(address); + return this; + } + + @Override + public BillingAccountImpl withBillingProfiles(List billingProfiles) { + this.inner().withBillingProfiles(billingProfiles); + return this; + } + + @Override + public BillingAccountImpl withDepartments(List departments) { + this.inner().withDepartments(departments); + return this; + } + + @Override + public BillingAccountImpl withEnrollmentAccounts(List enrollmentAccounts) { + this.inner().withEnrollmentAccounts(enrollmentAccounts); + return this; + } + + @Override + public BillingAccountImpl withInvoiceSections(List invoiceSections) { + this.inner().withInvoiceSections(invoiceSections); + return this; + } + } diff --git a/billing/resource-manager/v2018_11_01_preview/src/main/java/com/microsoft/azure/management/billing/v2018_11_01_preview/implementation/BillingAccountsImpl.java b/billing/resource-manager/v2018_11_01_preview/src/main/java/com/microsoft/azure/management/billing/v2018_11_01_preview/implementation/BillingAccountsImpl.java index 00934242c26f..a33944f1153d 100644 --- a/billing/resource-manager/v2018_11_01_preview/src/main/java/com/microsoft/azure/management/billing/v2018_11_01_preview/implementation/BillingAccountsImpl.java +++ b/billing/resource-manager/v2018_11_01_preview/src/main/java/com/microsoft/azure/management/billing/v2018_11_01_preview/implementation/BillingAccountsImpl.java @@ -4,7 +4,7 @@ * license information. * * Code generated by Microsoft (R) AutoRest Code Generator. - * abc + * jkl */ package com.microsoft.azure.management.billing.v2018_11_01_preview.implementation; @@ -28,6 +28,10 @@ public BillingManager manager() { return this.manager; } + private BillingAccountImpl wrapModel(BillingAccountInner inner) { + return new BillingAccountImpl(inner, manager()); + } + @Override public Observable getAsync(String billingAccountName) { BillingAccountsInner client = this.inner(); diff --git a/billing/resource-manager/v2018_11_01_preview/src/main/java/com/microsoft/azure/management/billing/v2018_11_01_preview/implementation/BillingAccountsInner.java b/billing/resource-manager/v2018_11_01_preview/src/main/java/com/microsoft/azure/management/billing/v2018_11_01_preview/implementation/BillingAccountsInner.java index 02fd548b7a82..f4b8d53c89e4 100644 --- a/billing/resource-manager/v2018_11_01_preview/src/main/java/com/microsoft/azure/management/billing/v2018_11_01_preview/implementation/BillingAccountsInner.java +++ b/billing/resource-manager/v2018_11_01_preview/src/main/java/com/microsoft/azure/management/billing/v2018_11_01_preview/implementation/BillingAccountsInner.java @@ -10,15 +10,20 @@ import retrofit2.Retrofit; import com.google.common.reflect.TypeToken; +import com.microsoft.azure.management.billing.v2018_11_01_preview.BillingAccountsUpdateHeaders; import com.microsoft.azure.management.billing.v2018_11_01_preview.ErrorResponseException; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceFuture; import com.microsoft.rest.ServiceResponse; +import com.microsoft.rest.ServiceResponseWithHeaders; +import com.microsoft.rest.Validator; import java.io.IOException; import okhttp3.ResponseBody; +import retrofit2.http.Body; import retrofit2.http.GET; import retrofit2.http.Header; import retrofit2.http.Headers; +import retrofit2.http.PATCH; import retrofit2.http.Path; import retrofit2.http.Query; import retrofit2.Response; @@ -59,6 +64,14 @@ interface BillingAccountsService { @GET("providers/Microsoft.Billing/billingAccounts/{billingAccountName}") Observable> get(@Path("billingAccountName") String billingAccountName, @Query("api-version") String apiVersion, @Query("$expand") String expand, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.billing.v2018_11_01_preview.BillingAccounts update" }) + @PATCH("providers/Microsoft.Billing/billingAccounts/{billingAccountName}") + Observable> update(@Path("billingAccountName") String billingAccountName, @Query("api-version") String apiVersion, @Body BillingAccountInner parameters, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.billing.v2018_11_01_preview.BillingAccounts beginUpdate" }) + @PATCH("providers/Microsoft.Billing/billingAccounts/{billingAccountName}") + Observable> beginUpdate(@Path("billingAccountName") String billingAccountName, @Query("api-version") String apiVersion, @Body BillingAccountInner parameters, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + } /** @@ -347,4 +360,156 @@ private ServiceResponse getDelegate(Response .build(response); } + /** + * The operation to update a billing account. + * + * @param billingAccountName billing Account Id. + * @param parameters Parameters supplied to the update billing account operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the BillingAccountInner object if successful. + */ + public BillingAccountInner update(String billingAccountName, BillingAccountInner parameters) { + return updateWithServiceResponseAsync(billingAccountName, parameters).toBlocking().last().body(); + } + + /** + * The operation to update a billing account. + * + * @param billingAccountName billing Account Id. + * @param parameters Parameters supplied to the update billing account operation. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture updateAsync(String billingAccountName, BillingAccountInner parameters, final ServiceCallback serviceCallback) { + return ServiceFuture.fromHeaderResponse(updateWithServiceResponseAsync(billingAccountName, parameters), serviceCallback); + } + + /** + * The operation to update a billing account. + * + * @param billingAccountName billing Account Id. + * @param parameters Parameters supplied to the update billing account operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + public Observable updateAsync(String billingAccountName, BillingAccountInner parameters) { + return updateWithServiceResponseAsync(billingAccountName, parameters).map(new Func1, BillingAccountInner>() { + @Override + public BillingAccountInner call(ServiceResponseWithHeaders response) { + return response.body(); + } + }); + } + + /** + * The operation to update a billing account. + * + * @param billingAccountName billing Account Id. + * @param parameters Parameters supplied to the update billing account operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + public Observable> updateWithServiceResponseAsync(String billingAccountName, BillingAccountInner parameters) { + if (billingAccountName == null) { + throw new IllegalArgumentException("Parameter billingAccountName is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + if (parameters == null) { + throw new IllegalArgumentException("Parameter parameters is required and cannot be null."); + } + Validator.validate(parameters); + Observable> observable = service.update(billingAccountName, this.client.apiVersion(), parameters, this.client.acceptLanguage(), this.client.userAgent()); + return client.getAzureClient().getPutOrPatchResultWithHeadersAsync(observable, new TypeToken() { }.getType(), BillingAccountsUpdateHeaders.class); + } + + /** + * The operation to update a billing account. + * + * @param billingAccountName billing Account Id. + * @param parameters Parameters supplied to the update billing account operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the BillingAccountInner object if successful. + */ + public BillingAccountInner beginUpdate(String billingAccountName, BillingAccountInner parameters) { + return beginUpdateWithServiceResponseAsync(billingAccountName, parameters).toBlocking().single().body(); + } + + /** + * The operation to update a billing account. + * + * @param billingAccountName billing Account Id. + * @param parameters Parameters supplied to the update billing account operation. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture beginUpdateAsync(String billingAccountName, BillingAccountInner parameters, final ServiceCallback serviceCallback) { + return ServiceFuture.fromHeaderResponse(beginUpdateWithServiceResponseAsync(billingAccountName, parameters), serviceCallback); + } + + /** + * The operation to update a billing account. + * + * @param billingAccountName billing Account Id. + * @param parameters Parameters supplied to the update billing account operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the BillingAccountInner object + */ + public Observable beginUpdateAsync(String billingAccountName, BillingAccountInner parameters) { + return beginUpdateWithServiceResponseAsync(billingAccountName, parameters).map(new Func1, BillingAccountInner>() { + @Override + public BillingAccountInner call(ServiceResponseWithHeaders response) { + return response.body(); + } + }); + } + + /** + * The operation to update a billing account. + * + * @param billingAccountName billing Account Id. + * @param parameters Parameters supplied to the update billing account operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the BillingAccountInner object + */ + public Observable> beginUpdateWithServiceResponseAsync(String billingAccountName, BillingAccountInner parameters) { + if (billingAccountName == null) { + throw new IllegalArgumentException("Parameter billingAccountName is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + if (parameters == null) { + throw new IllegalArgumentException("Parameter parameters is required and cannot be null."); + } + Validator.validate(parameters); + return service.beginUpdate(billingAccountName, this.client.apiVersion(), parameters, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponseWithHeaders clientResponse = beginUpdateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponseWithHeaders beginUpdateDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .register(202, new TypeToken() { }.getType()) + .registerError(ErrorResponseException.class) + .buildWithHeaders(response, BillingAccountsUpdateHeaders.class); + } + }