Skip to content
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 1 commit into from
Sep 15, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions azure-mgmt-batch/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@
<version>1.0.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-mgmt-storage</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<plugins>
Expand Down
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;

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()

Copy link
Contributor Author

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.

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)


/**
* @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();
}
}
}

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;
}

}
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> {
}
Loading