Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AutoPR billing/resource-manager] ARM spec review for validateAddress for BillingRP #3687

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* 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 java.util.Collection;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.microsoft.rest.ExpandableStringEnum;

/**
* Defines values for AddressValidationStatus.
*/
public final class AddressValidationStatus extends ExpandableStringEnum<AddressValidationStatus> {
/** Static value Valid for AddressValidationStatus. */
public static final AddressValidationStatus VALID = fromString("Valid");

/** Static value Invalid for AddressValidationStatus. */
public static final AddressValidationStatus INVALID = fromString("Invalid");

/**
* Creates or finds a AddressValidationStatus from its string representation.
* @param name a name to look for
* @return the corresponding AddressValidationStatus
*/
@JsonCreator
public static AddressValidationStatus fromString(String name) {
return fromString(name, AddressValidationStatus.class);
}

/**
* @return known AddressValidationStatus values
*/
public static Collection<AddressValidationStatus> values() {
return values(AddressValidationStatus.class);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* 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 rx.Observable;
import com.microsoft.azure.management.billing.v2018_11_01_preview.implementation.BillingAccountsValidateAddressInner;
import com.microsoft.azure.arm.model.HasInner;

/**
* Type representing BillingAccountsValidateAddress.
*/
public interface BillingAccountsValidateAddress extends HasInner<BillingAccountsValidateAddressInner> {
/**
* Validates the address.
*
* @param billingAccountName billing Account Id.
* @param address the Address value
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable for the request
*/
Observable<ValidateAddressResponse> postAsync(String billingAccountName, Address address);

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,13 @@ public interface PaymentMethods extends HasInner<PaymentMethodsInner> {
*/
Observable<PaymentMethod> listByBillingProfileNameAsync(final String billingAccountName, final String billingProfileName);

/**
* Lists the Payment Methods by billing account Id.
*
* @param billingAccountName billing Account Id.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable for the request
*/
Observable<PaymentMethod> listByBillingAccountNameAsync(final String billingAccountName);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* 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.microsoft.azure.arm.model.HasInner;
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.ValidateAddressResponseInner;
import java.util.List;

/**
* Type representing ValidateAddressResponse.
*/
public interface ValidateAddressResponse extends HasInner<ValidateAddressResponseInner>, HasManager<BillingManager> {
/**
* @return the status value.
*/
AddressValidationStatus status();

/**
* @return the suggestedAddresses value.
*/
List<Address> suggestedAddresses();

/**
* @return the validationMessage value.
*/
String validationMessage();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for
* license information.
*
* Code generated by Microsoft (R) AutoRest Code Generator.
* abc
*/

package com.microsoft.azure.management.billing.v2018_11_01_preview.implementation;

import com.microsoft.azure.arm.model.implementation.WrapperImpl;
import com.microsoft.azure.management.billing.v2018_11_01_preview.BillingAccountsValidateAddress;
import rx.functions.Func1;
import rx.Observable;
import com.microsoft.azure.management.billing.v2018_11_01_preview.ValidateAddressResponse;
import com.microsoft.azure.management.billing.v2018_11_01_preview.Address;

class BillingAccountsValidateAddressImpl extends WrapperImpl<BillingAccountsValidateAddressInner> implements BillingAccountsValidateAddress {
private final BillingManager manager;

BillingAccountsValidateAddressImpl(BillingManager manager) {
super(manager.inner().billingAccountsValidateAddress());
this.manager = manager;
}

public BillingManager manager() {
return this.manager;
}

@Override
public Observable<ValidateAddressResponse> postAsync(String billingAccountName, Address address) {
BillingAccountsValidateAddressInner client = this.inner();
return client.postAsync(billingAccountName, address)
.map(new Func1<ValidateAddressResponseInner, ValidateAddressResponse>() {
@Override
public ValidateAddressResponse call(ValidateAddressResponseInner inner) {
return new ValidateAddressResponseImpl(inner, manager());
}
});
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
/**
* 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.implementation;

import retrofit2.Retrofit;
import com.google.common.reflect.TypeToken;
import com.microsoft.azure.management.billing.v2018_11_01_preview.Address;
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.Validator;
import java.io.IOException;
import okhttp3.ResponseBody;
import retrofit2.http.Body;
import retrofit2.http.Header;
import retrofit2.http.Headers;
import retrofit2.http.Path;
import retrofit2.http.POST;
import retrofit2.http.Query;
import retrofit2.Response;
import rx.functions.Func1;
import rx.Observable;

/**
* An instance of this class provides access to all the operations defined
* in BillingAccountsValidateAddress.
*/
public class BillingAccountsValidateAddressInner {
/** The Retrofit service to perform REST calls. */
private BillingAccountsValidateAddressService service;
/** The service client containing this operation class. */
private BillingManagementClientImpl client;

/**
* Initializes an instance of BillingAccountsValidateAddressInner.
*
* @param retrofit the Retrofit instance built from a Retrofit Builder.
* @param client the instance of the service client containing this operation class.
*/
public BillingAccountsValidateAddressInner(Retrofit retrofit, BillingManagementClientImpl client) {
this.service = retrofit.create(BillingAccountsValidateAddressService.class);
this.client = client;
}

/**
* The interface defining all the services for BillingAccountsValidateAddress to be
* used by Retrofit to perform actually REST calls.
*/
interface BillingAccountsValidateAddressService {
@Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.billing.v2018_11_01_preview.BillingAccountsValidateAddress post" })
@POST("providers/Microsoft.Billing/billingAccounts/{billingAccountName}/validateAddress")
Observable<Response<ResponseBody>> post(@Path("billingAccountName") String billingAccountName, @Query("api-version") String apiVersion, @Body Address address, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent);

}

/**
* Validates the address.
*
* @param billingAccountName billing Account Id.
* @param address the Address value
* @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 ValidateAddressResponseInner object if successful.
*/
public ValidateAddressResponseInner post(String billingAccountName, Address address) {
return postWithServiceResponseAsync(billingAccountName, address).toBlocking().single().body();
}

/**
* Validates the address.
*
* @param billingAccountName billing Account Id.
* @param address the Address value
* @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<ValidateAddressResponseInner> postAsync(String billingAccountName, Address address, final ServiceCallback<ValidateAddressResponseInner> serviceCallback) {
return ServiceFuture.fromResponse(postWithServiceResponseAsync(billingAccountName, address), serviceCallback);
}

/**
* Validates the address.
*
* @param billingAccountName billing Account Id.
* @param address the Address value
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the ValidateAddressResponseInner object
*/
public Observable<ValidateAddressResponseInner> postAsync(String billingAccountName, Address address) {
return postWithServiceResponseAsync(billingAccountName, address).map(new Func1<ServiceResponse<ValidateAddressResponseInner>, ValidateAddressResponseInner>() {
@Override
public ValidateAddressResponseInner call(ServiceResponse<ValidateAddressResponseInner> response) {
return response.body();
}
});
}

/**
* Validates the address.
*
* @param billingAccountName billing Account Id.
* @param address the Address value
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the ValidateAddressResponseInner object
*/
public Observable<ServiceResponse<ValidateAddressResponseInner>> postWithServiceResponseAsync(String billingAccountName, Address address) {
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 (address == null) {
throw new IllegalArgumentException("Parameter address is required and cannot be null.");
}
Validator.validate(address);
return service.post(billingAccountName, this.client.apiVersion(), address, this.client.acceptLanguage(), this.client.userAgent())
.flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<ValidateAddressResponseInner>>>() {
@Override
public Observable<ServiceResponse<ValidateAddressResponseInner>> call(Response<ResponseBody> response) {
try {
ServiceResponse<ValidateAddressResponseInner> clientResponse = postDelegate(response);
return Observable.just(clientResponse);
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}

private ServiceResponse<ValidateAddressResponseInner> postDelegate(Response<ResponseBody> response) throws ErrorResponseException, IOException, IllegalArgumentException {
return this.client.restClient().responseBuilderFactory().<ValidateAddressResponseInner, ErrorResponseException>newInstance(this.client.serializerAdapter())
.register(200, new TypeToken<ValidateAddressResponseInner>() { }.getType())
.registerError(ErrorResponseException.class)
.build(response);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -146,29 +146,42 @@ public BillingAccountsInner billingAccounts() {
}

/**
* The AvailableBalancesInner object to access its operations.
* The PaymentMethodsInner object to access its operations.
*/
private AvailableBalancesInner availableBalances;
private PaymentMethodsInner paymentMethods;

/**
* Gets the AvailableBalancesInner object to access its operations.
* @return the AvailableBalancesInner object.
* Gets the PaymentMethodsInner object to access its operations.
* @return the PaymentMethodsInner object.
*/
public AvailableBalancesInner availableBalances() {
return this.availableBalances;
public PaymentMethodsInner paymentMethods() {
return this.paymentMethods;
}

/**
* The PaymentMethodsInner object to access its operations.
* The BillingAccountsValidateAddressInner object to access its operations.
*/
private PaymentMethodsInner paymentMethods;
private BillingAccountsValidateAddressInner billingAccountsValidateAddress;

/**
* Gets the PaymentMethodsInner object to access its operations.
* @return the PaymentMethodsInner object.
* Gets the BillingAccountsValidateAddressInner object to access its operations.
* @return the BillingAccountsValidateAddressInner object.
*/
public PaymentMethodsInner paymentMethods() {
return this.paymentMethods;
public BillingAccountsValidateAddressInner billingAccountsValidateAddress() {
return this.billingAccountsValidateAddress;
}

/**
* The AvailableBalancesInner object to access its operations.
*/
private AvailableBalancesInner availableBalances;

/**
* Gets the AvailableBalancesInner object to access its operations.
* @return the AvailableBalancesInner object.
*/
public AvailableBalancesInner availableBalances() {
return this.availableBalances;
}

/**
Expand Down Expand Up @@ -441,8 +454,9 @@ protected void initialize() {
this.longRunningOperationRetryTimeout = 30;
this.generateClientRequestId = true;
this.billingAccounts = new BillingAccountsInner(restClient().retrofit(), this);
this.availableBalances = new AvailableBalancesInner(restClient().retrofit(), this);
this.paymentMethods = new PaymentMethodsInner(restClient().retrofit(), this);
this.billingAccountsValidateAddress = new BillingAccountsValidateAddressInner(restClient().retrofit(), this);
this.availableBalances = new AvailableBalancesInner(restClient().retrofit(), this);
this.billingProfiles = new BillingProfilesInner(restClient().retrofit(), this);
this.invoiceSections = new InvoiceSectionsInner(restClient().retrofit(), this);
this.departments = new DepartmentsInner(restClient().retrofit(), this);
Expand Down
Loading