1 // Copyright (c) Microsoft Corporation. All rights reserved.
2 // Licensed under the MIT License.
3
4 package com.microsoft.azure.batch;
5
6 import com.microsoft.azure.PagedList;
7 import com.microsoft.azure.batch.protocol.models.AccountListNodeAgentSkusOptions;
8 import com.microsoft.azure.batch.protocol.models.BatchErrorException;
9 import com.microsoft.azure.batch.protocol.models.NodeAgentSku;
10 import com.microsoft.azure.batch.protocol.models.PoolNodeCounts;
11 import com.microsoft.azure.batch.protocol.models.AccountListPoolNodeCountsOptions;
12
13 import java.io.IOException;
14 import java.util.Collection;
15
16 /**
17 * Performs account-related operations on an Azure Batch account.
18 */
19 public class AccountOperations implements IInheritedBehaviors {
20
21 AccountOperations(BatchClient batchClient, Collection<BatchClientBehavior> customBehaviors) {
22 parentBatchClient = batchClient;
23
24 // inherit from instantiating parent
25 InternalHelper.inheritClientBehaviorsAndSetPublicProperty(this, customBehaviors);
26 }
27
28 private Collection<BatchClientBehavior> customBehaviors;
29
30 private final BatchClient parentBatchClient;
31
32 /**
33 * Gets a collection of behaviors that modify or customize requests to the Batch service.
34 *
35 * @return A collection of {@link BatchClientBehavior} instances.
36 */
37 @Override
38 public Collection<BatchClientBehavior> customBehaviors() {
39 return customBehaviors;
40 }
41
42 /**
43 * Sets a collection of behaviors that modify or customize requests to the Batch service.
44 *
45 * @param behaviors The collection of {@link BatchClientBehavior} instances.
46 * @return The current instance.
47 */
48 @Override
49 public IInheritedBehaviors withCustomBehaviors(Collection<BatchClientBehavior> behaviors) {
50 customBehaviors = behaviors;
51 return this;
52 }
53
54 /**
55 * Lists the node agent SKU values supported by the Batch service.
56 *
57 * @return A list of {@link NodeAgentSku} objects.
58 * @throws BatchErrorException Exception thrown when an error response is received from the Batch service.
59 * @throws IOException Exception thrown when there is an error in serialization/deserialization of data sent to/received from the Batch service.
60 */
61 public PagedList<NodeAgentSku> listNodeAgentSkus() throws BatchErrorException, IOException {
62 return listNodeAgentSkus(null, null);
63 }
64
65 /**
66 * Lists the node agent SKU values supported by the Batch service.
67 *
68 * @param detailLevel A {@link DetailLevel} used for filtering the list and for controlling which properties are retrieved from the service.
69 * @return A list of {@link NodeAgentSku} objects.
70 * @throws BatchErrorException Exception thrown when an error response is received from the Batch service.
71 * @throws IOException Exception thrown when there is an error in serialization/deserialization of data sent to/received from the Batch service.
72 */
73 public PagedList<NodeAgentSku> listNodeAgentSkus(DetailLevel detailLevel) throws BatchErrorException, IOException {
74 return listNodeAgentSkus(detailLevel, null);
75 }
76
77 /**
78 * Lists the node agent SKU values supported by the Batch service.
79 *
80 * @param detailLevel A {@link DetailLevel} used for filtering the list and for controlling which properties are retrieved from the service.
81 * @param additionalBehaviors A collection of {@link BatchClientBehavior} instances that are applied to the Batch service request.
82 * @return A list of {@link NodeAgentSku} objects.
83 * @throws BatchErrorException Exception thrown when an error response is received from the Batch service.
84 * @throws IOException Exception thrown when there is an error in serialization/deserialization of data sent to/received from the Batch service.
85 */
86 public PagedList<NodeAgentSku> listNodeAgentSkus(DetailLevel detailLevel, Iterable<BatchClientBehavior> additionalBehaviors) throws BatchErrorException, IOException {
87 AccountListNodeAgentSkusOptionsodeAgentSkusOptions.html#AccountListNodeAgentSkusOptions">AccountListNodeAgentSkusOptions options = new AccountListNodeAgentSkusOptions();
88 BehaviorManagernager.html#BehaviorManager">BehaviorManager bhMgr = new BehaviorManager(this.customBehaviors(), additionalBehaviors);
89 bhMgr.appendDetailLevelToPerCallBehaviors(detailLevel);
90 bhMgr.applyRequestBehaviors(options);
91
92 return this.parentBatchClient.protocolLayer().accounts().listNodeAgentSkus(options);
93 }
94
95 /**
96 * Gets the number of nodes in each state, grouped by pool.
97 *
98 * @return A list of {@link NodeAgentSku} objects.
99 * @throws BatchErrorException Exception thrown when an error response is received from the Batch service.
100 * @throws IOException Exception thrown when there is an error in serialization/deserialization of data sent to/received from the Batch service.
101 */
102 public PagedList<PoolNodeCounts> listPoolNodeCounts() throws BatchErrorException, IOException {
103 return listPoolNodeCounts(null, null);
104 }
105
106 /**
107 * Gets the number of nodes in each state, grouped by pool.
108 *
109 * @param detailLevel A {@link DetailLevel} used for filtering the list and for controlling which properties are retrieved from the service.
110 * @param additionalBehaviors A collection of {@link BatchClientBehavior} instances that are applied to the Batch service request.
111 * @return A list of {@link PoolNodeCounts} objects.
112 * @throws BatchErrorException Exception thrown when an error response is received from the Batch service.
113 * @throws IOException Exception thrown when there is an error in serialization/deserialization of data sent to/received from the Batch service.
114 */
115 public PagedList<PoolNodeCounts> listPoolNodeCounts(DetailLevel detailLevel, Iterable<BatchClientBehavior> additionalBehaviors) throws BatchErrorException, IOException {
116 AccountListPoolNodeCountsOptionsolNodeCountsOptions.html#AccountListPoolNodeCountsOptions">AccountListPoolNodeCountsOptions options = new AccountListPoolNodeCountsOptions();
117 BehaviorManagernager.html#BehaviorManager">BehaviorManager bhMgr = new BehaviorManager(this.customBehaviors(), additionalBehaviors);
118 bhMgr.appendDetailLevelToPerCallBehaviors(detailLevel);
119 bhMgr.applyRequestBehaviors(options);
120
121 return this.parentBatchClient.protocolLayer().accounts().listPoolNodeCounts(options);
122 }
123 }