Re: [jclouds-examples] Add an example to create/delete/list Google Cloud Storage buckets. (#64)

2015-03-24 Thread Everett Toews
Thanks for the pull request but it's release week in jclouds and that means 
it's time to clean up the PR queue. This PR will be over 6 months old as of 
April 1. If you intend to continue work on it, please make a comment by April 
2. Otherwise it will be closed on April 3.

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-examples/pull/64#issuecomment-85717886

[jclouds-examples] Add an example to create/delete/list Google Cloud Storage buckets. (#64)

2014-09-06 Thread najtmar

You can merge this Pull Request by running:

  git pull https://github.com/najtmar/jclouds-examples storage

Or you can view, comment on it, or merge it online at:

  https://github.com/jclouds/jclouds-examples/pull/64

-- Commit Summary --

  * Add an example to create/delete/list Google Cloud Storage buckets.

-- File Changes --

M google/pom.xml (5)
A 
google/src/main/java/org/jclouds/examples/google/cloudstorage/Constants.java 
(29)
A 
google/src/main/java/org/jclouds/examples/google/cloudstorage/ManageBuckets.java
 (185)

-- Patch Links --

https://github.com/jclouds/jclouds-examples/pull/64.patch
https://github.com/jclouds/jclouds-examples/pull/64.diff

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-examples/pull/64


Re: [jclouds-examples] Add an example to create/delete/list Google Cloud Storage buckets. (#64)

2014-09-06 Thread Andrew Phillips
 @@ -50,5 +50,10 @@
artifactIdgoogle-compute-engine/artifactId
version${jclouds.version}/version
  /dependency
 +dependency
 +  groupIdorg.apache.jclouds.labs/groupId
 +  artifactIdgoogle-cloud-storage/artifactId
 +  version1.8.0/version

Use `jclouds.version` here?

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-examples/pull/64/files#r17208815

Re: [jclouds-examples] Add an example to create/delete/list Google Cloud Storage buckets. (#64)

2014-09-06 Thread Andrew Phillips
 +  String command = args[2];
 +  String projectName = null;
 +  String bucketName = null;
 +  if (command.equals(create)) {
 + projectName = args[3];
 + bucketName = args[4];
 +  } else if (command.equals(delete)) {
 + bucketName = args[3];
 + if (args.length = 5) {
 +System.err.println(Command 'delete' require only one additional 
 parameter (bucketName).);
 +System.exit(1);
 + }
 +  } else if (command.equals(list)) {
 + projectName = args[3];
 + if (args.length = 5) {
 +System.err.println(Command 'list' require only one additional 
 parameters (projectName).);

Is this worth an error? Might just warn and continue?

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-examples/pull/64/files#r17208827

Re: [jclouds-examples] Add an example to create/delete/list Google Cloud Storage buckets. (#64)

2014-09-06 Thread Andrew Phillips
 +  try {
 + serviceAccountKey = Files.toString(new File(args[1]), 
 Charset.defaultCharset());
 +  } catch (IOException e) {
 + System.err.println(Cannot open service account private key PEM 
 file:  + args[1] + \n + e.getMessage());
 + System.exit(1);
 +  }
 +  String command = args[2];
 +  String projectName = null;
 +  String bucketName = null;
 +  if (command.equals(create)) {
 + projectName = args[3];
 + bucketName = args[4];
 +  } else if (command.equals(delete)) {
 + bucketName = args[3];
 + if (args.length = 5) {
 +System.err.println(Command 'delete' require only one additional 
 parameter (bucketName).);

Is this worth an error? Might just warn and continue?

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-examples/pull/64/files#r17208826

Re: [jclouds-examples] Add an example to create/delete/list Google Cloud Storage buckets. (#64)

2014-09-06 Thread Andrew Phillips
 +*planetnikbucketname
 +*
 +* java org.jclouds.examples.google.cloudstorage.ManageBuckets \
 +*somecrypticn...@developer.gserviceaccount.com \
 +*/home/planetnik/Work/Cloud/OSS/certificate/gcp-oss.pem \
 +*delete \
 +*planetnikbucketname
 +*
 +* java org.jclouds.examples.google.cloudstorage.ManageBuckets \
 +*somecrypticn...@developer.gserviceaccount.com \
 +*/home/planetnik/Work/Cloud/OSS/certificate/gcp-oss.pem \
 +*list \
 +*myprojectname
 +*/
 +   public static void main(final String[] args) {
 +  String serviceAccountEmailAddress = args[0];

How about combining the arg parsing with the comment selection? Something like:
```
// parse args required for all commands and command
ManageBuckets manageBuckets = ...
if (command.equals(...)) {
  // parse additional args for this command
  manageBuckets...
} else if (command.equals(...)) {
  // parse options for this command
  ...
}
```

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-examples/pull/64/files#r17208859

Re: [jclouds-examples] Add an example to create/delete/list Google Cloud Storage buckets. (#64)

2014-09-06 Thread Andrew Phillips
 + System.exit(1);
 +  }
 +   }
 +
 +   public ManageBuckets(final String serviceAccountEmailAddress, final 
 String serviceAccountKey) {
 +  cloudStorageApi = ContextBuilder.newBuilder(PROVIDER)
 +.credentials(serviceAccountEmailAddress, serviceAccountKey)
 +.buildApi(GoogleCloudStorageApi.class);
 +  /*
 +  // This works fine:
 +  // System.out.println(result:  + 
 cloudStorageApi.getBucketApi().listBucket(googpl-gcp-oss-7).size());
 +  ///
 +  cloudStorageApi.getBucketApi().createBucket(googpl-gcp-oss-7, new 
 BucketTemplate().name(marekws));
 +  System.out.println(result:  + 
 cloudStorageApi.getBucketApi().listBucket(googpl-gcp-oss-7).size());
 +  //
 +   */

Remove commented-out code?

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-examples/pull/64/files#r17208863

Re: [jclouds-examples] Add an example to create/delete/list Google Cloud Storage buckets. (#64)

2014-09-06 Thread Andrew Phillips
 +* @param bucketName Name of the bucket to create.
 +*/
 +   public final void createBucket(final String projectName, final String 
 bucketName) {
 +  Bucket bucket = null;
 +  try {
 + bucket = cloudStorageApi.getBucketApi().createBucket(projectName, 
 new BucketTemplate().name(bucketName));
 +  } catch (RuntimeException e) {
 + System.err.println(Creating bucket  + bucketName +  failed.\n + 
 e.getMessage());
 + System.exit(1);
 +  }
 +  if (bucket != null) {
 + System.out.print(Bucket  + bucket.getName() +  successfully 
 created in project  + projectName +  .);
 +  } else {
 + System.err.println(Creating bucket  + bucketName + failed.);
 + System.exit(1);
 +  }

Remove all the `try...catch` in the individual methods and have one central 
try/catch in the main method? See e.g. [this 
example](https://github.com/jclouds/jclouds-examples/blob/master/rackspace/src/main/java/org/jclouds/examples/rackspace/cloudservers/CloudServersPublish.java)...

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-examples/pull/64/files#r17208866

Re: [jclouds-examples] Add an example to create/delete/list Google Cloud Storage buckets. (#64)

2014-09-06 Thread Andrew Gaul
 @@ -50,5 +50,10 @@
artifactIdgoogle-compute-engine/artifactId
version${jclouds.version}/version
  /dependency
 +dependency
 +  groupIdorg.apache.jclouds.labs/groupId
 +  artifactIdgoogle-cloud-storage/artifactId
 +  version1.8.0/version

We have not (intentionally) released google-cloud-storage yet.  Please see 
jclouds/jclouds-labs-google#48 where this provider is under active development. 
 We should close this pull request until we are satisfied with the existing 
APIs and release the code in either 2.0.0 or some future 1.8.x release.

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-examples/pull/64/files#r17209254

Re: [jclouds-examples] Add an example to create/delete/list Google Cloud Storage buckets. (#64)

2014-09-06 Thread najtmar
 +  try {
 + serviceAccountKey = Files.toString(new File(args[1]), 
 Charset.defaultCharset());
 +  } catch (IOException e) {
 + System.err.println(Cannot open service account private key PEM 
 file:  + args[1] + \n + e.getMessage());
 + System.exit(1);
 +  }
 +  String command = args[2];
 +  String projectName = null;
 +  String bucketName = null;
 +  if (command.equals(create)) {
 + projectName = args[3];
 + bucketName = args[4];
 +  } else if (command.equals(delete)) {
 + bucketName = args[3];
 + if (args.length = 5) {
 +System.err.println(Command 'delete' require only one additional 
 parameter (bucketName).);

Done.

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-examples/pull/64/files#r17209524

Re: [jclouds-examples] Add an example to create/delete/list Google Cloud Storage buckets. (#64)

2014-09-06 Thread najtmar
 + * 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 org.jclouds.examples.google.cloudstorage;
 +
 +/**
 + * Constants used by the Google Cloud Storage Examples.
 + */
 +public interface Constants {
 +   String PROVIDER = System.getProperty(provider.cs, 
 google-cloud-storage);
 +   String ZONE = System.getProperty(zone, europe-west1-a);
 +
 +   String NAME = jclouds-example;

I copied it from 
https://github.com/jclouds/jclouds-examples/blob/master/google/src/main/java/org/jclouds/examples/google/computeengine/Constants.java
 , so it is at least consistent.

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-examples/pull/64/files#r17209522

Re: [jclouds-examples] Add an example to create/delete/list Google Cloud Storage buckets. (#64)

2014-09-06 Thread najtmar
 +  String command = args[2];
 +  String projectName = null;
 +  String bucketName = null;
 +  if (command.equals(create)) {
 + projectName = args[3];
 + bucketName = args[4];
 +  } else if (command.equals(delete)) {
 + bucketName = args[3];
 + if (args.length = 5) {
 +System.err.println(Command 'delete' require only one additional 
 parameter (bucketName).);
 +System.exit(1);
 + }
 +  } else if (command.equals(list)) {
 + projectName = args[3];
 + if (args.length = 5) {
 +System.err.println(Command 'list' require only one additional 
 parameters (projectName).);

Done.

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-examples/pull/64/files#r17209525

Re: [jclouds-examples] Add an example to create/delete/list Google Cloud Storage buckets. (#64)

2014-09-06 Thread najtmar
 +*planetnikbucketname
 +*
 +* java org.jclouds.examples.google.cloudstorage.ManageBuckets \
 +*somecrypticn...@developer.gserviceaccount.com \
 +*/home/planetnik/Work/Cloud/OSS/certificate/gcp-oss.pem \
 +*delete \
 +*planetnikbucketname
 +*
 +* java org.jclouds.examples.google.cloudstorage.ManageBuckets \
 +*somecrypticn...@developer.gserviceaccount.com \
 +*/home/planetnik/Work/Cloud/OSS/certificate/gcp-oss.pem \
 +*list \
 +*myprojectname
 +*/
 +   public static void main(final String[] args) {
 +  String serviceAccountEmailAddress = args[0];

Good idea, thanks!

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-examples/pull/64/files#r17209532

Re: [jclouds-examples] Add an example to create/delete/list Google Cloud Storage buckets. (#64)

2014-09-06 Thread najtmar
 + System.exit(1);
 +  }
 +   }
 +
 +   public ManageBuckets(final String serviceAccountEmailAddress, final 
 String serviceAccountKey) {
 +  cloudStorageApi = ContextBuilder.newBuilder(PROVIDER)
 +.credentials(serviceAccountEmailAddress, serviceAccountKey)
 +.buildApi(GoogleCloudStorageApi.class);
 +  /*
 +  // This works fine:
 +  // System.out.println(result:  + 
 cloudStorageApi.getBucketApi().listBucket(googpl-gcp-oss-7).size());
 +  ///
 +  cloudStorageApi.getBucketApi().createBucket(googpl-gcp-oss-7, new 
 BucketTemplate().name(marekws));
 +  System.out.println(result:  + 
 cloudStorageApi.getBucketApi().listBucket(googpl-gcp-oss-7).size());
 +  //
 +   */

Ah, right, sorry :) Removed.

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-examples/pull/64/files#r17209537

Re: [jclouds-examples] Add an example to create/delete/list Google Cloud Storage buckets. (#64)

2014-09-06 Thread najtmar
 +* @param bucketName Name of the bucket to create.
 +*/
 +   public final void createBucket(final String projectName, final String 
 bucketName) {
 +  Bucket bucket = null;
 +  try {
 + bucket = cloudStorageApi.getBucketApi().createBucket(projectName, 
 new BucketTemplate().name(bucketName));
 +  } catch (RuntimeException e) {
 + System.err.println(Creating bucket  + bucketName +  failed.\n + 
 e.getMessage());
 + System.exit(1);
 +  }
 +  if (bucket != null) {
 + System.out.print(Bucket  + bucket.getName() +  successfully 
 created in project  + projectName +  .);
 +  } else {
 + System.err.println(Creating bucket  + bucketName + failed.);
 + System.exit(1);
 +  }

Done.

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-examples/pull/64/files#r17209539

Re: [jclouds-examples] Add an example to create/delete/list Google Cloud Storage buckets. (#64)

2014-09-06 Thread najtmar
 @@ -50,5 +50,10 @@
artifactIdgoogle-compute-engine/artifactId
version${jclouds.version}/version
  /dependency
 +dependency
 +  groupIdorg.apache.jclouds.labs/groupId
 +  artifactIdgoogle-cloud-storage/artifactId
 +  version1.8.0/version

Ok, I got it. Thanks for all the comments - I applied them and will keep them 
until google-cloud-storage is released.

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-examples/pull/64/files#r17209543

Re: [jclouds-examples] Add an example to create/delete/list Google Cloud Storage buckets. (#64)

2014-09-06 Thread Andrew Phillips
 @@ -50,5 +50,10 @@
artifactIdgoogle-compute-engine/artifactId
version${jclouds.version}/version
  /dependency
 +dependency
 +  groupIdorg.apache.jclouds.labs/groupId
 +  artifactIdgoogle-cloud-storage/artifactId
 +  version1.8.0/version

 Ok, I got it. Thanks for all the comments - I applied them and will keep them 
 until google-cloud-storage is released.

Thanks for the updates, @najtmar!

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-examples/pull/64/files#r17212114