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.
/** * 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.storage.implementation; import com.microsoft.azure.management.resources.fluentcore.collection.InnerSupportsDelete; import retrofit2.Retrofit; import com.google.common.reflect.TypeToken; import com.microsoft.azure.CloudException; import com.microsoft.azure.management.storage.ManagementPolicySchema; 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.GET; import retrofit2.http.Header; import retrofit2.http.Headers; import retrofit2.http.HTTP; import retrofit2.http.Path; import retrofit2.http.PUT; import retrofit2.http.Query; import retrofit2.Response; import rx.functions.Func1; import rx.Observable;
An instance of this class provides access to all the operations defined in ManagementPolicies.
/** * An instance of this class provides access to all the operations defined * in ManagementPolicies. */
public class ManagementPoliciesInner implements InnerSupportsDelete<Void> {
The Retrofit service to perform REST calls.
/** The Retrofit service to perform REST calls. */
private ManagementPoliciesService service;
The service client containing this operation class.
/** The service client containing this operation class. */
private StorageManagementClientImpl client;
Initializes an instance of ManagementPoliciesInner.
Params:
  • retrofit – the Retrofit instance built from a Retrofit Builder.
  • client – the instance of the service client containing this operation class.
/** * Initializes an instance of ManagementPoliciesInner. * * @param retrofit the Retrofit instance built from a Retrofit Builder. * @param client the instance of the service client containing this operation class. */
public ManagementPoliciesInner(Retrofit retrofit, StorageManagementClientImpl client) { this.service = retrofit.create(ManagementPoliciesService.class); this.client = client; }
The interface defining all the services for ManagementPolicies to be used by Retrofit to perform actually REST calls.
/** * The interface defining all the services for ManagementPolicies to be * used by Retrofit to perform actually REST calls. */
interface ManagementPoliciesService { @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.storage.ManagementPolicies get" }) @GET("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") Observable<Response<ResponseBody>> get(@Path("resourceGroupName") String resourceGroupName, @Path("accountName") String accountName, @Path("subscriptionId") String subscriptionId, @Path("managementPolicyName") String managementPolicyName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.storage.ManagementPolicies createOrUpdate" }) @PUT("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") Observable<Response<ResponseBody>> createOrUpdate(@Path("resourceGroupName") String resourceGroupName, @Path("accountName") String accountName, @Path("subscriptionId") String subscriptionId, @Path("managementPolicyName") String managementPolicyName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body ManagementPolicyInner properties, @Header("User-Agent") String userAgent); @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.storage.ManagementPolicies delete" }) @HTTP(path = "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}", method = "DELETE", hasBody = true) Observable<Response<ResponseBody>> delete(@Path("resourceGroupName") String resourceGroupName, @Path("accountName") String accountName, @Path("subscriptionId") String subscriptionId, @Path("managementPolicyName") String managementPolicyName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); }
Gets the managementpolicy associated with the specified storage account.
Params:
  • resourceGroupName – The name of the resource group within the user's subscription. The name is case insensitive.
  • accountName – The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only.
Throws:
Returns:the ManagementPolicyInner object if successful.
/** * Gets the managementpolicy associated with the specified storage account. * * @param resourceGroupName The name of the resource group within the user's subscription. The name is case insensitive. * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. * @throws IllegalArgumentException thrown if parameters fail the validation * @throws CloudException thrown if the request is rejected by server * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent * @return the ManagementPolicyInner object if successful. */
public ManagementPolicyInner get(String resourceGroupName, String accountName) { return getWithServiceResponseAsync(resourceGroupName, accountName).toBlocking().single().body(); }
Gets the managementpolicy associated with the specified storage account.
Params:
  • resourceGroupName – The name of the resource group within the user's subscription. The name is case insensitive.
  • accountName – The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only.
  • serviceCallback – the async ServiceCallback to handle successful and failed responses.
Throws:
Returns:the ServiceFuture object
/** * Gets the managementpolicy associated with the specified storage account. * * @param resourceGroupName The name of the resource group within the user's subscription. The name is case insensitive. * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. * @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<ManagementPolicyInner> getAsync(String resourceGroupName, String accountName, final ServiceCallback<ManagementPolicyInner> serviceCallback) { return ServiceFuture.fromResponse(getWithServiceResponseAsync(resourceGroupName, accountName), serviceCallback); }
Gets the managementpolicy associated with the specified storage account.
Params:
  • resourceGroupName – The name of the resource group within the user's subscription. The name is case insensitive.
  • accountName – The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only.
Throws:
Returns:the observable to the ManagementPolicyInner object
/** * Gets the managementpolicy associated with the specified storage account. * * @param resourceGroupName The name of the resource group within the user's subscription. The name is case insensitive. * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the ManagementPolicyInner object */
public Observable<ManagementPolicyInner> getAsync(String resourceGroupName, String accountName) { return getWithServiceResponseAsync(resourceGroupName, accountName).map(new Func1<ServiceResponse<ManagementPolicyInner>, ManagementPolicyInner>() { @Override public ManagementPolicyInner call(ServiceResponse<ManagementPolicyInner> response) { return response.body(); } }); }
Gets the managementpolicy associated with the specified storage account.
Params:
  • resourceGroupName – The name of the resource group within the user's subscription. The name is case insensitive.
  • accountName – The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only.
Throws:
Returns:the observable to the ManagementPolicyInner object
/** * Gets the managementpolicy associated with the specified storage account. * * @param resourceGroupName The name of the resource group within the user's subscription. The name is case insensitive. * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the ManagementPolicyInner object */
public Observable<ServiceResponse<ManagementPolicyInner>> getWithServiceResponseAsync(String resourceGroupName, String accountName) { if (resourceGroupName == null) { throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); } if (accountName == null) { throw new IllegalArgumentException("Parameter accountName is required and cannot be null."); } if (this.client.subscriptionId() == null) { throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); } if (this.client.apiVersion() == null) { throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); } final String managementPolicyName = "default"; return service.get(resourceGroupName, accountName, this.client.subscriptionId(), managementPolicyName, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<ManagementPolicyInner>>>() { @Override public Observable<ServiceResponse<ManagementPolicyInner>> call(Response<ResponseBody> response) { try { ServiceResponse<ManagementPolicyInner> clientResponse = getDelegate(response); return Observable.just(clientResponse); } catch (Throwable t) { return Observable.error(t); } } }); } private ServiceResponse<ManagementPolicyInner> getDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException { return this.client.restClient().responseBuilderFactory().<ManagementPolicyInner, CloudException>newInstance(this.client.serializerAdapter()) .register(200, new TypeToken<ManagementPolicyInner>() { }.getType()) .registerError(CloudException.class) .build(response); }
Sets the managementpolicy to the specified storage account.
Params:
  • resourceGroupName – The name of the resource group within the user's subscription. The name is case insensitive.
  • accountName – The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only.
  • policy – The Storage Account ManagementPolicy, in JSON format. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts.
Throws:
Returns:the ManagementPolicyInner object if successful.
/** * Sets the managementpolicy to the specified storage account. * * @param resourceGroupName The name of the resource group within the user's subscription. The name is case insensitive. * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. * @param policy The Storage Account ManagementPolicy, in JSON format. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. * @throws IllegalArgumentException thrown if parameters fail the validation * @throws CloudException thrown if the request is rejected by server * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent * @return the ManagementPolicyInner object if successful. */
public ManagementPolicyInner createOrUpdate(String resourceGroupName, String accountName, ManagementPolicySchema policy) { return createOrUpdateWithServiceResponseAsync(resourceGroupName, accountName, policy).toBlocking().single().body(); }
Sets the managementpolicy to the specified storage account.
Params:
  • resourceGroupName – The name of the resource group within the user's subscription. The name is case insensitive.
  • accountName – The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only.
  • policy – The Storage Account ManagementPolicy, in JSON format. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts.
  • serviceCallback – the async ServiceCallback to handle successful and failed responses.
Throws:
Returns:the ServiceFuture object
/** * Sets the managementpolicy to the specified storage account. * * @param resourceGroupName The name of the resource group within the user's subscription. The name is case insensitive. * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. * @param policy The Storage Account ManagementPolicy, in JSON format. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. * @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<ManagementPolicyInner> createOrUpdateAsync(String resourceGroupName, String accountName, ManagementPolicySchema policy, final ServiceCallback<ManagementPolicyInner> serviceCallback) { return ServiceFuture.fromResponse(createOrUpdateWithServiceResponseAsync(resourceGroupName, accountName, policy), serviceCallback); }
Sets the managementpolicy to the specified storage account.
Params:
  • resourceGroupName – The name of the resource group within the user's subscription. The name is case insensitive.
  • accountName – The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only.
  • policy – The Storage Account ManagementPolicy, in JSON format. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts.
Throws:
Returns:the observable to the ManagementPolicyInner object
/** * Sets the managementpolicy to the specified storage account. * * @param resourceGroupName The name of the resource group within the user's subscription. The name is case insensitive. * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. * @param policy The Storage Account ManagementPolicy, in JSON format. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the ManagementPolicyInner object */
public Observable<ManagementPolicyInner> createOrUpdateAsync(String resourceGroupName, String accountName, ManagementPolicySchema policy) { return createOrUpdateWithServiceResponseAsync(resourceGroupName, accountName, policy).map(new Func1<ServiceResponse<ManagementPolicyInner>, ManagementPolicyInner>() { @Override public ManagementPolicyInner call(ServiceResponse<ManagementPolicyInner> response) { return response.body(); } }); }
Sets the managementpolicy to the specified storage account.
Params:
  • resourceGroupName – The name of the resource group within the user's subscription. The name is case insensitive.
  • accountName – The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only.
  • policy – The Storage Account ManagementPolicy, in JSON format. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts.
Throws:
Returns:the observable to the ManagementPolicyInner object
/** * Sets the managementpolicy to the specified storage account. * * @param resourceGroupName The name of the resource group within the user's subscription. The name is case insensitive. * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. * @param policy The Storage Account ManagementPolicy, in JSON format. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the ManagementPolicyInner object */
public Observable<ServiceResponse<ManagementPolicyInner>> createOrUpdateWithServiceResponseAsync(String resourceGroupName, String accountName, ManagementPolicySchema policy) { if (resourceGroupName == null) { throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); } if (accountName == null) { throw new IllegalArgumentException("Parameter accountName is required and cannot be null."); } if (this.client.subscriptionId() == null) { throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); } if (this.client.apiVersion() == null) { throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); } if (policy == null) { throw new IllegalArgumentException("Parameter policy is required and cannot be null."); } Validator.validate(policy); final String managementPolicyName = "default"; ManagementPolicyInner properties = new ManagementPolicyInner(); properties.withPolicy(policy); return service.createOrUpdate(resourceGroupName, accountName, this.client.subscriptionId(), managementPolicyName, this.client.apiVersion(), this.client.acceptLanguage(), properties, this.client.userAgent()) .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<ManagementPolicyInner>>>() { @Override public Observable<ServiceResponse<ManagementPolicyInner>> call(Response<ResponseBody> response) { try { ServiceResponse<ManagementPolicyInner> clientResponse = createOrUpdateDelegate(response); return Observable.just(clientResponse); } catch (Throwable t) { return Observable.error(t); } } }); } private ServiceResponse<ManagementPolicyInner> createOrUpdateDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException { return this.client.restClient().responseBuilderFactory().<ManagementPolicyInner, CloudException>newInstance(this.client.serializerAdapter()) .register(200, new TypeToken<ManagementPolicyInner>() { }.getType()) .registerError(CloudException.class) .build(response); }
Deletes the managementpolicy associated with the specified storage account.
Params:
  • resourceGroupName – The name of the resource group within the user's subscription. The name is case insensitive.
  • accountName – The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only.
Throws:
/** * Deletes the managementpolicy associated with the specified storage account. * * @param resourceGroupName The name of the resource group within the user's subscription. The name is case insensitive. * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. * @throws IllegalArgumentException thrown if parameters fail the validation * @throws CloudException thrown if the request is rejected by server * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent */
public void delete(String resourceGroupName, String accountName) { deleteWithServiceResponseAsync(resourceGroupName, accountName).toBlocking().single().body(); }
Deletes the managementpolicy associated with the specified storage account.
Params:
  • resourceGroupName – The name of the resource group within the user's subscription. The name is case insensitive.
  • accountName – The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only.
  • serviceCallback – the async ServiceCallback to handle successful and failed responses.
Throws:
Returns:the ServiceFuture object
/** * Deletes the managementpolicy associated with the specified storage account. * * @param resourceGroupName The name of the resource group within the user's subscription. The name is case insensitive. * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. * @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<Void> deleteAsync(String resourceGroupName, String accountName, final ServiceCallback<Void> serviceCallback) { return ServiceFuture.fromResponse(deleteWithServiceResponseAsync(resourceGroupName, accountName), serviceCallback); }
Deletes the managementpolicy associated with the specified storage account.
Params:
  • resourceGroupName – The name of the resource group within the user's subscription. The name is case insensitive.
  • accountName – The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only.
Throws:
Returns:the ServiceResponse object if successful.
/** * Deletes the managementpolicy associated with the specified storage account. * * @param resourceGroupName The name of the resource group within the user's subscription. The name is case insensitive. * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the {@link ServiceResponse} object if successful. */
public Observable<Void> deleteAsync(String resourceGroupName, String accountName) { return deleteWithServiceResponseAsync(resourceGroupName, accountName).map(new Func1<ServiceResponse<Void>, Void>() { @Override public Void call(ServiceResponse<Void> response) { return response.body(); } }); }
Deletes the managementpolicy associated with the specified storage account.
Params:
  • resourceGroupName – The name of the resource group within the user's subscription. The name is case insensitive.
  • accountName – The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only.
Throws:
Returns:the ServiceResponse object if successful.
/** * Deletes the managementpolicy associated with the specified storage account. * * @param resourceGroupName The name of the resource group within the user's subscription. The name is case insensitive. * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the {@link ServiceResponse} object if successful. */
public Observable<ServiceResponse<Void>> deleteWithServiceResponseAsync(String resourceGroupName, String accountName) { if (resourceGroupName == null) { throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); } if (accountName == null) { throw new IllegalArgumentException("Parameter accountName is required and cannot be null."); } if (this.client.subscriptionId() == null) { throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); } if (this.client.apiVersion() == null) { throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); } final String managementPolicyName = "default"; return service.delete(resourceGroupName, accountName, this.client.subscriptionId(), managementPolicyName, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<Void>>>() { @Override public Observable<ServiceResponse<Void>> call(Response<ResponseBody> response) { try { ServiceResponse<Void> clientResponse = deleteDelegate(response); return Observable.just(clientResponse); } catch (Throwable t) { return Observable.error(t); } } }); } private ServiceResponse<Void> deleteDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException { return this.client.restClient().responseBuilderFactory().<Void, CloudException>newInstance(this.client.serializerAdapter()) .register(200, new TypeToken<Void>() { }.getType()) .register(204, new TypeToken<Void>() { }.getType()) .registerError(CloudException.class) .build(response); } }