-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #659 from mziccard/compute
Add gcloud-java-compute module and immutable resources
- Loading branch information
Showing
38 changed files
with
4,003 additions
and
0 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,101 @@ | ||
Google Cloud Java Client for Compute (Alpha) | ||
==================================== | ||
|
||
Java idiomatic client for [Google Cloud Compute] (https://cloud.google.com/compute). | ||
|
||
[![Build Status](https://travis-ci.org/GoogleCloudPlatform/gcloud-java.svg?branch=master)](https://travis-ci.org/GoogleCloudPlatform/gcloud-java) | ||
[![Coverage Status](https://coveralls.io/repos/GoogleCloudPlatform/gcloud-java/badge.svg?branch=master)](https://coveralls.io/r/GoogleCloudPlatform/gcloud-java?branch=master) | ||
<!-- TODO(mziccard): add in the maven shield once the artifact is pushed to maven --> | ||
[![Codacy Badge](https://api.codacy.com/project/badge/grade/9da006ad7c3a4fe1abd142e77c003917)](https://www.codacy.com/app/mziccard/gcloud-java) | ||
[![Dependency Status](https://www.versioneye.com/user/projects/56bd8ee72a29ed002d2b0969/badge.svg?style=flat)](https://www.versioneye.com/user/projects/56bd8ee72a29ed002d2b0969) | ||
|
||
- [Homepage] (https://googlecloudplatform.github.io/gcloud-java/) | ||
|
||
<!-- TODO(mziccard): add link to API documentation --> | ||
|
||
> Note: This client is a work-in-progress, and may occasionally | ||
> make backwards-incompatible changes. | ||
Quickstart | ||
---------- | ||
If you are using Maven, add this to your pom.xml file | ||
<!-- TODO(mziccard): add maven dependency code --> | ||
If you are using Gradle, add this to your dependencies | ||
<!-- TODO(mziccard): add gradle dependency code --> | ||
If you are using SBT, add this to your dependencies | ||
<!-- TODO(mziccard): add sbt dependency code --> | ||
|
||
Example Application | ||
------------------- | ||
<!-- TODO(mziccard): add example application --> | ||
|
||
Authentication | ||
-------------- | ||
|
||
See the [Authentication](https://github.com/GoogleCloudPlatform/gcloud-java#authentication) section in the base directory's README. | ||
|
||
About Google Cloud Compute | ||
-------------------------- | ||
|
||
[Google Cloud Compute][cloud-compute] delivers virtual machines running in Google's innovative data | ||
centers and worldwide fiber network. Compute Engine's tooling and workflow support enable scaling | ||
from single instances to global, load-balanced cloud computing. Compute Engine's VMs boot quickly, | ||
come with persistent disk storage, deliver consistent performance and are available in many | ||
configurations. | ||
|
||
Be sure to activate the Google Cloud Compute API on the Developer's Console to use Compute from | ||
your project. | ||
|
||
See the ``gcloud-java`` API [compute documentation][compute-api] to learn how to interact | ||
with Google Cloud Compute using this Client Library. | ||
|
||
Getting Started | ||
--------------- | ||
<!-- TODO(mziccard): add code snippet --> | ||
|
||
Troubleshooting | ||
--------------- | ||
|
||
To get help, follow the `gcloud-java` links in the `gcloud-*`[shared Troubleshooting document](https://github.com/GoogleCloudPlatform/gcloud-common/blob/master/troubleshooting/readme.md#troubleshooting). | ||
|
||
Java Versions | ||
------------- | ||
|
||
Java 7 or above is required for using this client. | ||
|
||
Testing | ||
------- | ||
|
||
This library has tools to help make tests for code using Cloud Compute. | ||
|
||
See [TESTING] to read more about testing. | ||
|
||
Versioning | ||
---------- | ||
|
||
This library follows [Semantic Versioning] (http://semver.org/). | ||
|
||
It is currently in major version zero (``0.y.z``), which means that anything | ||
may change at any time and the public API should not be considered | ||
stable. | ||
|
||
Contributing | ||
------------ | ||
|
||
Contributions to this library are always welcome and highly encouraged. | ||
|
||
See [CONTRIBUTING] for more information on how to get started. | ||
|
||
License | ||
------- | ||
|
||
Apache 2.0 - See [LICENSE] for more information. | ||
|
||
|
||
[CONTRIBUTING]:https://github.com/GoogleCloudPlatform/gcloud-java/blob/master/CONTRIBUTING.md | ||
[LICENSE]: https://github.com/GoogleCloudPlatform/gcloud-java/blob/master/LICENSE | ||
[TESTING]: https://github.com/GoogleCloudPlatform/gcloud-java/blob/master/TESTING.md#testing-code-that-uses-compute | ||
[cloud-platform]: https://cloud.google.com/ | ||
|
||
[cloud-compute]: https://cloud.google.com/compute/ | ||
[compute-api]: http://googlecloudplatform.github.io/gcloud-java/apidocs/index.html?com/google/gcloud/compute/package-summary.html |
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,49 @@ | ||
<?xml version="1.0"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<artifactId>gcloud-java-compute</artifactId> | ||
<packaging>jar</packaging> | ||
<name>GCloud Java compute</name> | ||
<description> | ||
Java idiomatic client for Google Cloud Compute Engine. | ||
</description> | ||
<parent> | ||
<groupId>com.google.gcloud</groupId> | ||
<artifactId>gcloud-java-pom</artifactId> | ||
<version>0.1.5-SNAPSHOT</version> | ||
</parent> | ||
<properties> | ||
<site.installationModule>gcloud-java-compute</site.installationModule> | ||
</properties> | ||
<dependencies> | ||
<dependency> | ||
<groupId>${project.groupId}</groupId> | ||
<artifactId>gcloud-java-core</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.google.apis</groupId> | ||
<artifactId>google-api-services-compute</artifactId> | ||
<version>v1-rev97-1.21.0</version> | ||
<scope>compile</scope> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>com.google.guava</groupId> | ||
<artifactId>guava-jdk5</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>4.12</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.easymock</groupId> | ||
<artifactId>easymock</artifactId> | ||
<version>3.4</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> |
27 changes: 27 additions & 0 deletions
27
gcloud-java-compute/src/main/java/com/google/gcloud/compute/Compute.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,27 @@ | ||
/* | ||
* Copyright 2016 Google Inc. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.google.gcloud.compute; | ||
|
||
import com.google.gcloud.Service; | ||
|
||
/** | ||
* An interface for Google Cloud Compute Engine. | ||
* | ||
* @see <a href="https://cloud.google.com/compute/docs/">Google Cloud Compute Engine</a> | ||
*/ | ||
public interface Compute extends Service<ComputeOptions> { | ||
} |
59 changes: 59 additions & 0 deletions
59
gcloud-java-compute/src/main/java/com/google/gcloud/compute/ComputeException.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,59 @@ | ||
/* | ||
* Copyright 2016 Google Inc. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.google.gcloud.compute; | ||
|
||
import com.google.common.collect.ImmutableSet; | ||
import com.google.gcloud.BaseServiceException; | ||
import com.google.gcloud.RetryHelper.RetryHelperException; | ||
import com.google.gcloud.RetryHelper.RetryInterruptedException; | ||
|
||
import java.io.IOException; | ||
import java.util.Set; | ||
|
||
/** | ||
* Compute Engine service exception. | ||
*/ | ||
public class ComputeException extends BaseServiceException { | ||
|
||
private static final Set<Error> RETRYABLE_ERRORS = ImmutableSet.of(new Error(500, null)); | ||
private static final long serialVersionUID = -8039359778707845810L; | ||
|
||
public ComputeException(int code, String message) { | ||
super(code, message, null, true); | ||
} | ||
|
||
public ComputeException(IOException exception) { | ||
super(exception, true); | ||
} | ||
|
||
@Override | ||
protected Set<Error> retryableErrors() { | ||
return RETRYABLE_ERRORS; | ||
} | ||
|
||
/** | ||
* Translate RetryHelperException to the ComputeException that caused the error. This method will | ||
* always throw an exception. | ||
* | ||
* @throws ComputeException when {@code ex} was caused by a {@code ComputeException} | ||
* @throws RetryInterruptedException when {@code ex} is a {@code RetryInterruptedException} | ||
*/ | ||
static BaseServiceException translateAndThrow(RetryHelperException ex) { | ||
BaseServiceException.translateAndPropagateIfPossible(ex); | ||
throw new ComputeException(UNKNOWN_CODE, ex.getMessage()); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
gcloud-java-compute/src/main/java/com/google/gcloud/compute/ComputeFactory.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,25 @@ | ||
/* | ||
* Copyright 2016 Google Inc. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.google.gcloud.compute; | ||
|
||
import com.google.gcloud.ServiceFactory; | ||
|
||
/** | ||
* An interface for Compute factories. | ||
*/ | ||
public interface ComputeFactory extends ServiceFactory<Compute, ComputeOptions> { | ||
} |
30 changes: 30 additions & 0 deletions
30
gcloud-java-compute/src/main/java/com/google/gcloud/compute/ComputeImpl.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,30 @@ | ||
/* | ||
* Copyright 2016 Google Inc. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.google.gcloud.compute; | ||
|
||
import com.google.gcloud.BaseService; | ||
import com.google.gcloud.spi.ComputeRpc; | ||
|
||
final class ComputeImpl extends BaseService<ComputeOptions> implements Compute { | ||
|
||
private final ComputeRpc computeRpc; | ||
|
||
ComputeImpl(ComputeOptions options) { | ||
super(options); | ||
computeRpc = options.rpc(); | ||
} | ||
} |
Oops, something went wrong.