/sdk/batchai/mgmt-v2017_09_01_preview/src/main/java/com/microsoft/azure/management/batchai/v2017_09_01_preview/implementation/ClusterImpl.java

http://github.com/WindowsAzure/azure-sdk-for-java · Java · 206 lines · 168 code · 31 blank · 7 comment · 3 complexity · 3ec26bd17a28e864587cec37a269abf6 MD5 · raw file

  1. /**
  2. * Copyright (c) Microsoft Corporation. All rights reserved.
  3. * Licensed under the MIT License. See License.txt in the project root for
  4. * license information.
  5. *
  6. * Code generated by Microsoft (R) AutoRest Code Generator.
  7. */
  8. package com.microsoft.azure.management.batchai.v2017_09_01_preview.implementation;
  9. import com.microsoft.azure.arm.resources.models.implementation.GroupableResourceCoreImpl;
  10. import com.microsoft.azure.management.batchai.v2017_09_01_preview.Cluster;
  11. import rx.Observable;
  12. import com.microsoft.azure.management.batchai.v2017_09_01_preview.ClusterUpdateParameters;
  13. import com.microsoft.azure.management.batchai.v2017_09_01_preview.ClusterCreateParameters;
  14. import com.microsoft.azure.management.batchai.v2017_09_01_preview.AllocationState;
  15. import org.joda.time.DateTime;
  16. import java.util.List;
  17. import com.microsoft.azure.management.batchai.v2017_09_01_preview.BatchAIError;
  18. import com.microsoft.azure.management.batchai.v2017_09_01_preview.NodeSetup;
  19. import com.microsoft.azure.management.batchai.v2017_09_01_preview.NodeStateCounts;
  20. import com.microsoft.azure.management.batchai.v2017_09_01_preview.ProvisioningState;
  21. import com.microsoft.azure.management.batchai.v2017_09_01_preview.ScaleSettings;
  22. import com.microsoft.azure.management.batchai.v2017_09_01_preview.ResourceId;
  23. import com.microsoft.azure.management.batchai.v2017_09_01_preview.UserAccountSettings;
  24. import com.microsoft.azure.management.batchai.v2017_09_01_preview.VirtualMachineConfiguration;
  25. import com.microsoft.azure.management.batchai.v2017_09_01_preview.VmPriority;
  26. import rx.functions.Func1;
  27. class ClusterImpl extends GroupableResourceCoreImpl<Cluster, ClusterInner, ClusterImpl, BatchAIManager> implements Cluster, Cluster.Definition, Cluster.Update {
  28. private ClusterCreateParameters createParameter;
  29. private ClusterUpdateParameters updateParameter;
  30. ClusterImpl(String name, ClusterInner inner, BatchAIManager manager) {
  31. super(name, inner, manager);
  32. this.createParameter = new ClusterCreateParameters();
  33. this.updateParameter = new ClusterUpdateParameters();
  34. }
  35. @Override
  36. public Observable<Cluster> createResourceAsync() {
  37. ClustersInner client = this.manager().inner().clusters();
  38. this.createParameter.withLocation(inner().location());
  39. this.createParameter.withTags(inner().getTags());
  40. return client.createAsync(this.resourceGroupName(), this.name(), this.createParameter)
  41. .map(new Func1<ClusterInner, ClusterInner>() {
  42. @Override
  43. public ClusterInner call(ClusterInner resource) {
  44. resetCreateUpdateParameters();
  45. return resource;
  46. }
  47. })
  48. .map(innerToFluentMap(this));
  49. }
  50. @Override
  51. public Observable<Cluster> updateResourceAsync() {
  52. ClustersInner client = this.manager().inner().clusters();
  53. return client.updateAsync(this.resourceGroupName(), this.name(), this.updateParameter)
  54. .map(new Func1<ClusterInner, ClusterInner>() {
  55. @Override
  56. public ClusterInner call(ClusterInner resource) {
  57. resetCreateUpdateParameters();
  58. return resource;
  59. }
  60. })
  61. .map(innerToFluentMap(this));
  62. }
  63. @Override
  64. protected Observable<ClusterInner> getInnerAsync() {
  65. ClustersInner client = this.manager().inner().clusters();
  66. return client.getByResourceGroupAsync(this.resourceGroupName(), this.name());
  67. }
  68. @Override
  69. public boolean isInCreateMode() {
  70. return this.inner().id() == null;
  71. }
  72. private void resetCreateUpdateParameters() {
  73. this.createParameter = new ClusterCreateParameters();
  74. this.updateParameter = new ClusterUpdateParameters();
  75. }
  76. @Override
  77. public AllocationState allocationState() {
  78. return this.inner().allocationState();
  79. }
  80. @Override
  81. public DateTime allocationStateTransitionTime() {
  82. return this.inner().allocationStateTransitionTime();
  83. }
  84. @Override
  85. public DateTime creationTime() {
  86. return this.inner().creationTime();
  87. }
  88. @Override
  89. public Integer currentNodeCount() {
  90. return this.inner().currentNodeCount();
  91. }
  92. @Override
  93. public List<BatchAIError> errors() {
  94. return this.inner().errors();
  95. }
  96. @Override
  97. public NodeSetup nodeSetup() {
  98. return this.inner().nodeSetup();
  99. }
  100. @Override
  101. public NodeStateCounts nodeStateCounts() {
  102. return this.inner().nodeStateCounts();
  103. }
  104. @Override
  105. public ProvisioningState provisioningState() {
  106. return this.inner().provisioningState();
  107. }
  108. @Override
  109. public DateTime provisioningStateTransitionTime() {
  110. return this.inner().provisioningStateTransitionTime();
  111. }
  112. @Override
  113. public ScaleSettings scaleSettings() {
  114. return this.inner().scaleSettings();
  115. }
  116. @Override
  117. public ResourceId subnet() {
  118. return this.inner().subnet();
  119. }
  120. @Override
  121. public UserAccountSettings userAccountSettings() {
  122. return this.inner().userAccountSettings();
  123. }
  124. @Override
  125. public VirtualMachineConfiguration virtualMachineConfiguration() {
  126. return this.inner().virtualMachineConfiguration();
  127. }
  128. @Override
  129. public VmPriority vmPriority() {
  130. return this.inner().vmPriority();
  131. }
  132. @Override
  133. public String vmSize() {
  134. return this.inner().vmSize();
  135. }
  136. @Override
  137. public ClusterImpl withUserAccountSettings(UserAccountSettings userAccountSettings) {
  138. this.createParameter.withUserAccountSettings(userAccountSettings);
  139. return this;
  140. }
  141. @Override
  142. public ClusterImpl withVmSize(String vmSize) {
  143. this.createParameter.withVmSize(vmSize);
  144. return this;
  145. }
  146. @Override
  147. public ClusterImpl withNodeSetup(NodeSetup nodeSetup) {
  148. this.createParameter.withNodeSetup(nodeSetup);
  149. return this;
  150. }
  151. @Override
  152. public ClusterImpl withSubnet(ResourceId subnet) {
  153. this.createParameter.withSubnet(subnet);
  154. return this;
  155. }
  156. @Override
  157. public ClusterImpl withVirtualMachineConfiguration(VirtualMachineConfiguration virtualMachineConfiguration) {
  158. this.createParameter.withVirtualMachineConfiguration(virtualMachineConfiguration);
  159. return this;
  160. }
  161. @Override
  162. public ClusterImpl withVmPriority(VmPriority vmPriority) {
  163. this.createParameter.withVmPriority(vmPriority);
  164. return this;
  165. }
  166. @Override
  167. public ClusterImpl withScaleSettings(ScaleSettings scaleSettings) {
  168. if (isInCreateMode()) {
  169. this.createParameter.withScaleSettings(scaleSettings);
  170. } else {
  171. this.updateParameter.withScaleSettings(scaleSettings);
  172. }
  173. return this;
  174. }
  175. }