-
Notifications
You must be signed in to change notification settings - Fork 2k
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
[Ready for review] Updated batch to support batch account creation with fluent pattern. #1066
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
212 changes: 212 additions & 0 deletions
212
azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/BatchAccount.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,212 @@ | ||
/** | ||
* 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.management.batch; | ||
|
||
import com.microsoft.azure.CloudException; | ||
import com.microsoft.azure.management.batch.implementation.AccountResourceInner; | ||
import com.microsoft.azure.management.resources.fluentcore.arm.models.GroupableResource; | ||
import com.microsoft.azure.management.resources.fluentcore.arm.models.Resource; | ||
import com.microsoft.azure.management.resources.fluentcore.model.Creatable; | ||
import com.microsoft.azure.management.resources.fluentcore.model.Refreshable; | ||
import com.microsoft.azure.management.resources.fluentcore.model.Updatable; | ||
import com.microsoft.azure.management.resources.fluentcore.model.Wrapper; | ||
import com.microsoft.azure.management.resources.fluentcore.model.Appliable; | ||
import com.microsoft.azure.management.storage.StorageAccount; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* An immutable client-side representation of an Azure batch account. | ||
*/ | ||
public interface BatchAccount extends | ||
GroupableResource, | ||
Refreshable<BatchAccount>, | ||
Updatable<BatchAccount.Update>, | ||
Wrapper<AccountResourceInner> { | ||
|
||
/** | ||
* @return the provisioned state of the resource. Possible values include: | ||
* 'Invalid', 'Creating', 'Deleting', 'Succeeded', 'Failed', 'Cancelled' | ||
*/ | ||
AccountProvisioningState provisioningState(); | ||
|
||
/** | ||
* @return Get the accountEndpoint value. | ||
*/ | ||
String accountEndpoint(); | ||
|
||
/** | ||
* @return the properties and status of any auto storage account associated with | ||
* the account | ||
*/ | ||
AutoStorageProperties autoStorage(); | ||
|
||
/** | ||
* @return the core quota for this BatchAccount account | ||
*/ | ||
int coreQuota(); | ||
|
||
/** | ||
* @return the pool quota for this BatchAccount account | ||
*/ | ||
int poolQuota(); | ||
|
||
/** | ||
* @return the active job and job schedule quota for this BatchAccount account | ||
*/ | ||
int activeJobAndJobScheduleQuota(); | ||
|
||
/** | ||
* @return the access keys for this batch account | ||
* | ||
* @throws CloudException exception thrown from REST call | ||
* @throws IOException exception thrown from serialization/deserialization | ||
*/ | ||
BatchAccountKeys keys() throws CloudException, IOException; | ||
|
||
/** | ||
* @return the access keys for this batch account | ||
* | ||
* @throws CloudException exception thrown from REST call | ||
* @throws IOException exception thrown from serialization/deserialization | ||
*/ | ||
BatchAccountKeys refreshKeys() throws CloudException, IOException; | ||
|
||
/** | ||
* Regenerates the access keys for batch account. | ||
* | ||
* @param keyType either primary or secondary key to be regenerated | ||
* @return the access keys for this batch account | ||
* | ||
* @throws CloudException exception thrown from REST call | ||
* @throws IOException exception thrown from serialization/deserialization | ||
*/ | ||
BatchAccountKeys regenerateKeys(AccountKeyType keyType) throws CloudException, IOException; | ||
|
||
/** | ||
* Synchronize the storage account keys for batch account. | ||
* | ||
* @throws CloudException exception thrown from REST call | ||
* @throws IOException exception thrown from serialization/deserialization | ||
*/ | ||
void synchronizeAutoStorageKeys() throws CloudException, IOException; | ||
|
||
/************************************************************** | ||
* Fluent interfaces to provision a BatchAccount | ||
**************************************************************/ | ||
|
||
/** | ||
* Container interface for all the definitions that need to be implemented. | ||
*/ | ||
interface Definition extends | ||
DefinitionStages.Blank, | ||
DefinitionStages.WithGroup, | ||
DefinitionStages.WithCreate { | ||
} | ||
|
||
/** | ||
* Grouping of all the storage account definition stages. | ||
*/ | ||
interface DefinitionStages { | ||
/** | ||
* The first stage of the batch account definition. | ||
*/ | ||
interface Blank extends Resource.DefinitionWithRegion<WithGroup> { | ||
} | ||
|
||
/** | ||
* A batch account definition allowing resource group to be set. | ||
*/ | ||
interface WithGroup extends GroupableResource.DefinitionStages.WithGroup<WithCreate> { | ||
} | ||
|
||
/** | ||
* A batch account definition with sufficient inputs to create a new | ||
* batch account in the cloud, but exposing additional optional inputs to | ||
* specify. | ||
*/ | ||
interface WithCreate extends | ||
Creatable<BatchAccount>, | ||
Resource.DefinitionWithTags<WithCreate> { | ||
|
||
/** | ||
* Specifies that an existing storage account to be attached with the batch account. | ||
* | ||
* @param storageAccount existing storage account to be used | ||
* @return the stage representing creatable batch account definition | ||
*/ | ||
DefinitionStages.WithCreate withStorageAccount(StorageAccount storageAccount); | ||
|
||
/** | ||
* Specifies that a storage account to be attached with the batch account. | ||
* | ||
* @param storageAccountCreatable storage account to be created along with and used in batch | ||
* @return the stage representing creatable batch account definition | ||
*/ | ||
DefinitionStages.WithCreate withNewStorageAccount(Creatable<StorageAccount> storageAccountCreatable); | ||
|
||
/** | ||
* Specifies that an existing storage account to be attached with the batch account. | ||
* | ||
* @param storageAccountName name of new storage account to be created and used in batch account | ||
* @return the stage representing creatable batch account definition | ||
*/ | ||
DefinitionStages.WithCreate withNewStorageAccount(String storageAccountName); | ||
|
||
} | ||
} | ||
/** | ||
* The template for a storage account update operation, containing all the settings that can be modified. | ||
*/ | ||
interface Update extends | ||
Appliable<BatchAccount>, | ||
Resource.UpdateWithTags<Update>, | ||
UpdateStages.WithStorageAccount { | ||
} | ||
|
||
/** | ||
* Grouping of all the storage account update stages. | ||
*/ | ||
interface UpdateStages { | ||
/** | ||
* The stage of the batch account update definition allowing to specify storage account. | ||
*/ | ||
interface WithStorageAccount { | ||
/** | ||
* Specifies that an existing storage account to be attached with the batch account. | ||
* | ||
* @param storageAccount existing storage account to be used | ||
* @return the stage representing updatable batch account definition | ||
*/ | ||
Update withStorageAccount(StorageAccount storageAccount); | ||
|
||
/** | ||
* Specifies that a storage account to be attached with the batch account. | ||
* | ||
* @param storageAccountCreatable storage account to be created along with and used in batch | ||
* @return the stage representing updatable batch account definition | ||
*/ | ||
Update withNewStorageAccount(Creatable<StorageAccount> storageAccountCreatable); | ||
|
||
/** | ||
* Specifies that an existing storage account to be attached with the batch account. | ||
* | ||
* @param storageAccountName name of new storage account to be created and used in batch account | ||
* @return the stage representing updatable batch account definition | ||
*/ | ||
Update withNewStorageAccount(String storageAccountName); | ||
|
||
/** | ||
* Specifies that storage account should be removed from the batch account. | ||
* | ||
* @return the stage representing updatable batch account definition | ||
*/ | ||
Update withoutStorageAccount(); | ||
} | ||
} | ||
} | ||
|
46 changes: 46 additions & 0 deletions
46
azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/BatchAccountKeys.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.microsoft.azure.management.batch; | ||
|
||
/** | ||
* Created by ans on 9/13/2016. | ||
*/ | ||
public class BatchAccountKeys { | ||
/** | ||
* The primary key associated with the account. | ||
*/ | ||
private String primary; | ||
|
||
/** | ||
* The secondary key associated with the account. | ||
*/ | ||
private String secondary; | ||
|
||
/** | ||
* Constructor for the class. | ||
* | ||
* @param primaryKey primary key value for the batch account | ||
* @param secondaryKey secondary key value for the batch account | ||
*/ | ||
public BatchAccountKeys(String primaryKey, String secondaryKey) { | ||
primary = primaryKey; | ||
secondary = secondaryKey; | ||
} | ||
|
||
/** | ||
* Get the primary value. | ||
* | ||
* @return the primary value | ||
*/ | ||
public String primary() { | ||
return this.primary; | ||
} | ||
|
||
/** | ||
* Get the secondary value. | ||
* | ||
* @return the secondary value | ||
*/ | ||
public String secondary() { | ||
return this.secondary; | ||
} | ||
|
||
} |
24 changes: 24 additions & 0 deletions
24
azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/BatchAccounts.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.microsoft.azure.management.batch; | ||
|
||
import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsDeletingByGroup; | ||
import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingByGroup; | ||
import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingById; | ||
import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsListingByGroup; | ||
import com.microsoft.azure.management.resources.fluentcore.collection.SupportsBatchCreation; | ||
import com.microsoft.azure.management.resources.fluentcore.collection.SupportsCreating; | ||
import com.microsoft.azure.management.resources.fluentcore.collection.SupportsDeleting; | ||
import com.microsoft.azure.management.resources.fluentcore.collection.SupportsListing; | ||
|
||
/** | ||
* Entry point to batch account management API. | ||
*/ | ||
public interface BatchAccounts extends | ||
SupportsCreating<BatchAccount.DefinitionStages.Blank>, | ||
SupportsListing<BatchAccount>, | ||
SupportsListingByGroup<BatchAccount>, | ||
SupportsGettingByGroup<BatchAccount>, | ||
SupportsGettingById<BatchAccount>, | ||
SupportsDeleting, | ||
SupportsDeletingByGroup, | ||
SupportsBatchCreation<BatchAccount> { | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it looks like this is a separate call to Azure. If that's the case, we're starting to follow the convention to use "get" as the prefix on such methods, to indicate the info is not a property but a separate method that calls Azure. So in this case, we could call this
getKeys()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed it to set of 2 functions keys and refreshKeys which are similar to Storage key apis.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm guessing you mean .keys() would quickly return the locally cached keys and refreshKeys() would make th actual call (and return the keys as well, right?) that makes sense to me as well.
I assume this will be added to this PR (not seeing a new commit yet)