-
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.
Create packages for resource manager and outline spi layer.
- Loading branch information
Ajay Kannan
committed
Nov 3, 2015
1 parent
33bfb1e
commit e3ca489
Showing
9 changed files
with
464 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,79 @@ | ||
Google Cloud Java Client for Resource Manager | ||
============================================= | ||
|
||
Java idiomatic client for [Google Cloud Resource Manager] (https://cloud.google.com/resource-manager/). | ||
|
||
[![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(ajaykannan): add in the maven shield once the artifact is pushed to maven --> | ||
|
||
- [Homepage] (https://googlecloudplatform.github.io/gcloud-java/) | ||
|
||
<!-- TODO(ajaykannan): add in a link to javadocs once the site has been generated with resource manager docs included --> | ||
|
||
> Note: This client is a work-in-progress, and may occasionally | ||
> make backwards-incompatible changes. | ||
Quickstart | ||
---------- | ||
This library is currently under development and will be available soon! | ||
<!--TODO(ajaykannan): add in pom.xml snippet once gcloud-java-resourcemanager becomes available on maven --> | ||
|
||
<!-- TODO(ajaykannan): once the API becomes usable, make an example application | ||
Example Application | ||
-------------------- --> | ||
|
||
Authentication | ||
-------------- | ||
|
||
See the [Authentication](https://github.com/GoogleCloudPlatform/gcloud-java#authentication) section in the base directory's README. | ||
|
||
About Google Cloud Resource Manager | ||
----------------------------------- | ||
|
||
Google [Cloud Resource Manager][cloud-resourcemanager] provides a programmatic way to manage your Google Cloud Platform projects. Google Cloud Resource Manager is currently in beta and may occasionally make backwards incompatible changes. | ||
|
||
Be sure to activate the Google Cloud Resource Manager API on the Developer's Console to use Resource Manager from your project. | ||
|
||
See the ``gcloud-java`` API [Resource Manager documentation][resourcemanager-api] to learn how to interact | ||
with the Cloud Resource Manager using this client Library. | ||
|
||
<!-- TODO(ajaykannan): add code snippet --> | ||
|
||
Java Versions | ||
------------- | ||
|
||
Java 7 or above is required for using this client. | ||
|
||
<!-- TODO(ajaykannan): add this in once the RemoteGCRMHelper class is functional --> | ||
|
||
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-resource-manager | ||
[cloud-platform]: https://cloud.google.com/ | ||
[cloud-resourcemanager]: https://cloud.google.com/resource-manager/docs | ||
[resourcemanager-api]: http://googlecloudplatform.github.io/gcloud-java/apidocs/index.html?com/google/gcloud/resourcemanager/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,44 @@ | ||
<?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> | ||
<groupId>com.google.gcloud</groupId> | ||
<artifactId>gcloud-java-resourcemanager</artifactId> | ||
<packaging>jar</packaging> | ||
<name>GCloud Java resource manager</name> | ||
<description> | ||
Java idiomatic client for Google Cloud Resource Manager. | ||
</description> | ||
<parent> | ||
<groupId>com.google.gcloud</groupId> | ||
<artifactId>gcloud-java-pom</artifactId> | ||
<version>0.0.11-SNAPSHOT</version> | ||
</parent> | ||
<properties> | ||
<site.installationModule>gcloud-java-resourcemanager</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-cloudresourcemanager</artifactId> | ||
<version>v1beta1-rev6-1.19.0</version> | ||
<scope>compile</scope> | ||
</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.3</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> |
31 changes: 31 additions & 0 deletions
31
...java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ResourceManager.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,31 @@ | ||
/* | ||
* Copyright 2015 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.resourcemanager; | ||
|
||
import com.google.gcloud.Service; | ||
|
||
/** | ||
* An interface for Google Cloud Resource Manager. | ||
* | ||
* @see <a href="https://cloud.google.com/resource-manager/">Google Cloud Resource Manager</a> | ||
*/ | ||
public interface ResourceManager extends Service<ResourceManagerOptions> { | ||
|
||
public static final String DEFAULT_CONTENT_TYPE = "application/octet-stream"; | ||
|
||
// TODO(ajaykannan): Fix me! Add in missing methods. | ||
} |
65 changes: 65 additions & 0 deletions
65
...urcemanager/src/main/java/com/google/gcloud/resourcemanager/ResourceManagerException.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,65 @@ | ||
/* | ||
* Copyright 2015 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.resourcemanager; | ||
|
||
import com.google.gcloud.RetryHelper.RetryHelperException; | ||
import com.google.gcloud.RetryHelper.RetryInterruptedException; | ||
|
||
/** | ||
* Resource Manager service exception. | ||
* | ||
* @see <a href="https://cloud.google.com/resource-manager/v1/errors/core_errors">Google Cloud | ||
* Resource Manager error codes</a> | ||
*/ | ||
public class ResourceManagerException extends RuntimeException { | ||
|
||
private static final long serialVersionUID = 6841689911565501705L; | ||
private static final int UNKNOWN_CODE = -1; | ||
|
||
private final int code; | ||
private final boolean retryable; | ||
|
||
public ResourceManagerException(int code, String message, boolean retryable) { | ||
super(message); | ||
this.code = code; | ||
this.retryable = retryable; | ||
} | ||
|
||
/** | ||
* Returns the code associated with this exception. | ||
*/ | ||
public int code() { | ||
return code; | ||
} | ||
|
||
public boolean retryable() { | ||
return retryable; | ||
} | ||
|
||
/** | ||
* Translate RetryHelperException to the ResourceManagerException that caused the error. This | ||
* method will always throw an exception. | ||
* | ||
* @throws ResourceManagerException when {@code ex} was caused by a {@code | ||
* ResourceManagerException} | ||
* @throws RetryInterruptedException when {@code ex} is a {@code RetryInterruptedException} | ||
*/ | ||
static ResourceManagerException translateAndThrow(RetryHelperException ex) { | ||
throw new ResourceManagerException(UNKNOWN_CODE, ex.getMessage(), false); | ||
// TODO(ajaykannan): Fix me! | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...sourcemanager/src/main/java/com/google/gcloud/resourcemanager/ResourceManagerFactory.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 2015 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.resourcemanager; | ||
|
||
import com.google.gcloud.ServiceFactory; | ||
|
||
/** | ||
* An interface for ResourceManager factories. | ||
*/ | ||
public interface ResourceManagerFactory | ||
extends ServiceFactory<ResourceManager, ResourceManagerOptions> {} |
101 changes: 101 additions & 0 deletions
101
...sourcemanager/src/main/java/com/google/gcloud/resourcemanager/ResourceManagerOptions.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,101 @@ | ||
/* | ||
* Copyright 2015 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.resourcemanager; | ||
|
||
import com.google.common.collect.ImmutableSet; | ||
import com.google.gcloud.ServiceOptions; | ||
import com.google.gcloud.spi.ResourceManagerRpc; | ||
import com.google.gcloud.spi.ResourceManagerRpcFactory; | ||
|
||
import java.util.Set; | ||
|
||
public class ResourceManagerOptions | ||
extends ServiceOptions<ResourceManager, ResourceManagerRpc, ResourceManagerOptions> { | ||
|
||
private static final long serialVersionUID = 538303101192527452L; | ||
private static final String GCRM_SCOPE = "https://www.googleapis.com/auth/cloud-platform"; | ||
private static final Set<String> SCOPES = ImmutableSet.of(GCRM_SCOPE); | ||
|
||
public static class DefaultResourceManagerFactory implements ResourceManagerFactory { | ||
private static final ResourceManagerFactory INSTANCE = new DefaultResourceManagerFactory(); | ||
|
||
@Override | ||
public ResourceManager create(ResourceManagerOptions options) { | ||
// return new ResourceManagerImpl(options); | ||
return null; // TODO(ajaykannan): Fix me! | ||
} | ||
} | ||
|
||
public static class DefaultResourceManagerRpcFactory implements ResourceManagerRpcFactory { | ||
private static final ResourceManagerRpcFactory INSTANCE = | ||
new DefaultResourceManagerRpcFactory(); | ||
|
||
@Override | ||
public ResourceManagerRpc create(ResourceManagerOptions options) { | ||
// return new DefaultResourceManagerRpc(options); | ||
return null; // TODO(ajaykannan): Fix me! | ||
} | ||
} | ||
|
||
public static class Builder extends ServiceOptions.Builder<ResourceManager, ResourceManagerRpc, | ||
ResourceManagerOptions, Builder> { | ||
|
||
private Builder() {} | ||
|
||
private Builder(ResourceManagerOptions options) { | ||
super(options); | ||
} | ||
|
||
@Override | ||
public ResourceManagerOptions build() { | ||
return new ResourceManagerOptions(this); | ||
} | ||
} | ||
|
||
private ResourceManagerOptions(Builder builder) { | ||
super(ResourceManagerFactory.class, ResourceManagerRpcFactory.class, builder); | ||
} | ||
|
||
@Override | ||
protected ResourceManagerFactory defaultServiceFactory() { | ||
return DefaultResourceManagerFactory.INSTANCE; | ||
} | ||
|
||
@Override | ||
protected ResourceManagerRpcFactory defaultRpcFactory() { | ||
return DefaultResourceManagerRpcFactory.INSTANCE; | ||
} | ||
|
||
@Override | ||
protected Set<String> scopes() { | ||
return SCOPES; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
return obj instanceof ResourceManagerOptions && baseEquals((ResourceManagerOptions) obj); | ||
} | ||
|
||
@Override | ||
public Builder toBuilder() { | ||
return new Builder(this); | ||
} | ||
|
||
public static Builder builder() { | ||
return new Builder(); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...ud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/package-info.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,23 @@ | ||
/* | ||
* Copyright 2015 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. | ||
*/ | ||
|
||
/** | ||
* A client to Google Cloud Resource Manager. | ||
* //TODO(ajaykannan): add code example | ||
* @see <a href="https://cloud.google.com/resource-manager/">Google Cloud Resource Manager</a> | ||
*/ | ||
|
||
package com.google.gcloud.resourcemanager; |
Oops, something went wrong.