/**
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for
* license information.
*/
package com.microsoft.azure.batch;
import com.microsoft.azure.PagedList;
import com.microsoft.azure.batch.protocol.models.AccountListNodeAgentSkusHeaders;
import com.microsoft.azure.batch.protocol.models.AccountListNodeAgentSkusOptions;
import com.microsoft.azure.batch.protocol.models.BatchErrorException;
import com.microsoft.azure.batch.protocol.models.NodeAgentSku;
import com.microsoft.rest.ServiceResponseWithHeaders;
import java.io.IOException;
import java.util.Collection;
import java.util.List;
/**
* Performs account related operations on an Azure Batch account.
*/
public class AccountOperations implements IInheritedBehaviors {
AccountOperations(BatchClient batchClient, Collection<BatchClientBehavior> customBehaviors) {
_parentBatchClient = batchClient;
// inherit from instantiating parent
InternalHelper.InheritClientBehaviorsAndSetPublicProperty(this, customBehaviors);
}
private Collection<BatchClientBehavior> _customBehaviors;
private BatchClient _parentBatchClient;
/**
* Gets a list of behaviors that modify or customize requests to the Batch service.
*
* @return A list of BatchClientBehavior
*/
@Override
public Collection<BatchClientBehavior> customBehaviors() {
return _customBehaviors;
}
/**
* Sets a list of behaviors that modify or customize requests to the Batch service.
*
* @param behaviors The collection of BatchClientBehavior classes
* @return The current instance
*/
@Override
public IInheritedBehaviors withCustomBehaviors(Collection<BatchClientBehavior> behaviors) {
_customBehaviors = behaviors;
return this;
}
/**
* Enumerates the node agent SKU values supported by Batch Service.
*
* @return A collection of {@link NodeAgentSku} that can be used to enumerate node agent SKU values
* @throws BatchErrorException Exception thrown from REST call
* @throws IOException Exception thrown from serialization/deserialization
*/
public List<NodeAgentSku> listNodeAgentSkus() throws BatchErrorException, IOException {
return listNodeAgentSkus(null, null);
}
/**
* Enumerates the node agent SKU values supported by Batch Service.
*
* @param detailLevel A {@link DetailLevel} used for filtering the list and for controlling which properties are retrieved from the service.
* @return An collection of {@link NodeAgentSku} that can be used to enumerate node agent SKU values
* @throws BatchErrorException Exception thrown from REST call
* @throws IOException Exception thrown from serialization/deserialization
*/
public List<NodeAgentSku> listNodeAgentSkus(DetailLevel detailLevel) throws BatchErrorException, IOException {
return listNodeAgentSkus(detailLevel, null);
}
/**
* Enumerates the node agent SKU values supported by Batch Service.
*
* @param detailLevel A {@link DetailLevel} used for filtering the list and for controlling which properties are retrieved from the service.
* @param additionalBehaviors A collection of {@link BatchClientBehavior} instances that are applied to the Batch service request.
* @return A collection of {@link NodeAgentSku} that can be used to enumerate node agent SKU values
* @throws BatchErrorException Exception thrown from REST call
* @throws IOException Exception thrown from serialization/deserialization
*/
public List<NodeAgentSku> listNodeAgentSkus(DetailLevel detailLevel, Iterable<BatchClientBehavior> additionalBehaviors) throws BatchErrorException, IOException {
AccountListNodeAgentSkusOptions options = new AccountListNodeAgentSkusOptions();
BehaviorManager bhMgr = new BehaviorManager(this.customBehaviors(), additionalBehaviors);
bhMgr.appendDetailLevelToPerCallBehaviors(detailLevel);
bhMgr.applyRequestBehaviors(options);
ServiceResponseWithHeaders<PagedList<NodeAgentSku>, AccountListNodeAgentSkusHeaders> response = this._parentBatchClient.protocolLayer().accounts().listNodeAgentSkus(options);
return response.getBody();
}
}