You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jclouds.apache.org by Andrew Bayer <no...@github.com> on 2013/11/26 01:44:11 UTC

[jclouds] JCLOUDS-218. List templates in all known projects for CloudStack. (#215)

You can merge this Pull Request by running:

  git pull https://github.com/abayer/jclouds-1 jclouds-218

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

  https://github.com/jclouds/jclouds/pull/215

-- Commit Summary --

  * JCLOUDS-218. List templates in all known projects for CloudStack.

-- File Changes --

    M apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackApi.java (7)
    M apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/config/CloudStackComputeServiceContextModule.java (11)
    M apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/strategy/CloudStackComputeServiceAdapter.java (41)
    A apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Project.java (243)
    A apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/ProjectApi.java (77)
    A apis/cloudstack/src/main/java/org/jclouds/cloudstack/options/ListProjectsOptions.java (171)
    A apis/cloudstack/src/main/java/org/jclouds/cloudstack/suppliers/ProjectsForCurrentUser.java (64)
    M apis/cloudstack/src/test/java/org/jclouds/cloudstack/compute/CloudStackComputeServiceAdapterExpectTest.java (149)
    A apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/ProjectApiExpectTest.java (79)
    A apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/ProjectApiLiveTest.java (47)
    A apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/ProjectApiTest.java (98)
    M apis/cloudstack/src/test/java/org/jclouds/cloudstack/internal/BaseCloudStackComputeServiceContextExpectTest.java (17)
    A apis/cloudstack/src/test/resources/listprojectsresponse.json (1)

-- Patch Links --

https://github.com/jclouds/jclouds/pull/215.patch
https://github.com/jclouds/jclouds/pull/215.diff

Re: [jclouds] JCLOUDS-218. List templates in all known projects for CloudStack. (#215)

Posted by Andrew Phillips <no...@github.com>.
> + * 
> + * @see <a
> + *      href="http://download.cloud.com/releases/3.0.6/api_3.0.6/root_admin/listProjects.html"
> + *      />
> + * @author Andrew Bayer
> + */
> +public class ListProjectsOptions extends AccountInDomainOptions {
> +
> +   public static final ListProjectsOptions NONE = new ListProjectsOptions();
> +
> +   /**
> +    * @param id
> +    *           list projects by project ID
> +    */
> +   public ListProjectsOptions id(String id) {
> +      this.queryParameters.replaceValues("id", ImmutableSet.of(id + ""));

Just curious...why the `id + ""` here?

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

Re: [jclouds] JCLOUDS-218. List templates in all known projects for CloudStack. (#215)

Posted by CloudBees pull request builder plugin <no...@github.com>.
[jclouds-pull-requests #420](https://jclouds.ci.cloudbees.com/job/jclouds-pull-requests/420/) SUCCESS
This pull request looks good

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

Re: [jclouds] JCLOUDS-218. List templates in all known projects for CloudStack. (#215)

Posted by Andrew Bayer <no...@github.com>.
> @@ -223,6 +225,15 @@ public String toString() {
>     @Provides
>     @Singleton
>     @Memoized
> +   public Supplier<Map<String, Project>> listProjects(AtomicReference<AuthorizationException> authException, @Named(PROPERTY_SESSION_INTERVAL) long seconds,
> +                                                      final ProjectsForCurrentUser projectsForCurrentUser) {

Don't know if it's strictly needed - I was aping what we're doing for similar methods.

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

Re: [jclouds] JCLOUDS-218. List templates in all known projects for CloudStack. (#215)

Posted by Andrew Bayer <no...@github.com>.
> +public interface ProjectApi {
> +   /**
> +    * List the projects this account has access to.
> +    *
> +    * @param options if present, how to constrain the list
> +    */
> +   @Named("listProjects")
> +   @GET
> +   @QueryParams(keys = { "command", "listAll" }, values = { "listProjects", "true" })
> +   @SelectJson("project")
> +   @Consumes(MediaType.APPLICATION_JSON)
> +   @Fallback(EmptySetOnNotFoundOr404.class)
> +   Set<Project> listProjects(ListProjectsOptions... options);
> +
> +   /**
> +    * get a specific Project by id

Done.

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

Re: [jclouds] JCLOUDS-218. List templates in all known projects for CloudStack. (#215)

Posted by Andrew Bayer <no...@github.com>.
> + * 
> + * @author Andrew Bayer
> + */
> +@Test(groups = "live", singleThreaded = true, testName = "ProjectApiLiveTest")
> +public class ProjectApiLiveTest extends BaseCloudStackApiLiveTest {
> +
> +   @Test
> +   public void testListAccounts() throws Exception {
> +      for (Project project : client.getProjectApi().listProjects())
> +         checkProject(project);
> +   }
> +
> +   protected void checkProject(Project project) {
> +      assertNotNull(project.getId());
> +      assertEquals(project.toString(), client.getProjectApi().getProject(project.getId()).toString());
> +      assertTrue(project.getState() != null && project.getState() != Project.State.UNRECOGNIZED);

Ah, you got me - I got lazy. =) Fixing!

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

Re: [jclouds] JCLOUDS-218. List templates in all known projects for CloudStack. (#215)

Posted by Andrew Phillips <no...@github.com>.
> +      }
> +   }
> +
> +   private final String id;
> +   private final String account;
> +   private final String displayText;
> +   private final String domain;
> +   private final String domainId;
> +   private final String name;
> +   private final State state;
> +
> +   @ConstructorProperties({
> +         "id", "account", "displaytext", "domain", "domainid", "name", "state"
> +   })
> +   protected Project(String id, String account, String displayText, String domain, String domainId,
> +                     String name, State state) {

Let's keep the cargo cult going, then ;-)

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

Re: [jclouds] JCLOUDS-218. List templates in all known projects for CloudStack. (#215)

Posted by CloudBees pull request builder plugin <no...@github.com>.
[jclouds-pull-requests #421](https://jclouds.ci.cloudbees.com/job/jclouds-pull-requests/421/) SUCCESS
This pull request looks good

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

Re: [jclouds] JCLOUDS-218. List templates in all known projects for CloudStack. (#215)

Posted by Andrew Phillips <no...@github.com>.
> +   @Override
> +   public boolean equals(Object obj) {
> +      if (this == obj) return true;
> +      if (obj == null || getClass() != obj.getClass()) return false;
> +      Project that = Project.class.cast(obj);
> +      return Objects.equal(this.id, that.id)
> +            && Objects.equal(this.account, that.account)
> +            && Objects.equal(this.displayText, that.displayText)
> +            && Objects.equal(this.domain, that.domain)
> +            && Objects.equal(this.domainId, that.domainId)
> +            && Objects.equal(this.name, that.name)
> +            && Objects.equal(this.state, that.state);
> +   }
> +
> +   protected ToStringHelper string() {
> +      return Objects.toStringHelper(this)

Omit nulls or not?

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

Re: [jclouds] JCLOUDS-218. List templates in all known projects for CloudStack. (#215)

Posted by CloudBees pull request builder plugin <no...@github.com>.
[jclouds-java-7-pull-requests #883](https://jclouds.ci.cloudbees.com/job/jclouds-java-7-pull-requests/883/) SUCCESS
This pull request looks good

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

Re: [jclouds] JCLOUDS-218. List templates in all known projects for CloudStack. (#215)

Posted by Andrew Bayer <no...@github.com>.
Squashed, rebased, waiting to see how it does to be safe.

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

Re: [jclouds] JCLOUDS-218. List templates in all known projects for CloudStack. (#215)

Posted by Andrew Bayer <no...@github.com>.
> @@ -270,9 +275,31 @@ public CloudStackComputeServiceAdapter(CloudStackApi client, Predicate<String> j
>  
>     @Override
>     public Iterable<Template> listImages() {
> -      // TODO: we may need to filter these further
> -      // we may also want to see if we can work with ssh keys
> -      return filter(client.getTemplateApi().listTemplates(), isReady());
> +      Set<String> projects = ImmutableSet.copyOf(transform(projectSupplier.get().values(),
> +              new Function<Project, String>() {
> +
> +                 @Override
> +                 public String apply(Project project) {
> +                    return project.getId();
> +                 }
> +              }));
> +
> +      return filter(concat(transform(ImmutableSet.<String> builder().addAll(projects).add("").build(),

fwiw, my brain farted - the keys are actually the IDs we need. d'oh!

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

Re: [jclouds] JCLOUDS-218. List templates in all known projects for CloudStack. (#215)

Posted by Andrew Bayer <no...@github.com>.
> + * 
> + * @see <a
> + *      href="http://download.cloud.com/releases/3.0.6/api_3.0.6/root_admin/listProjects.html"
> + *      />
> + * @author Andrew Bayer
> + */
> +public class ListProjectsOptions extends AccountInDomainOptions {
> +
> +   public static final ListProjectsOptions NONE = new ListProjectsOptions();
> +
> +   /**
> +    * @param id
> +    *           list projects by project ID
> +    */
> +   public ListProjectsOptions id(String id) {
> +      this.queryParameters.replaceValues("id", ImmutableSet.of(id + ""));

Ah! No, it's not a null avoidance thing, it's a legacy thingie to deal with when IDs in CloudStack were ints, I think. Not sure it's actually needed at this point, though, so I'll remove it.

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

Re: [jclouds] JCLOUDS-218. List templates in all known projects for CloudStack. (#215)

Posted by Andrew Phillips <no...@github.com>.
> @@ -270,9 +275,31 @@ public CloudStackComputeServiceAdapter(CloudStackApi client, Predicate<String> j
>  
>     @Override
>     public Iterable<Template> listImages() {
> -      // TODO: we may need to filter these further
> -      // we may also want to see if we can work with ssh keys
> -      return filter(client.getTemplateApi().listTemplates(), isReady());
> +      Set<String> projects = ImmutableSet.copyOf(transform(projectSupplier.get().values(),
> +              new Function<Project, String>() {
> +
> +                 @Override
> +                 public String apply(Project project) {
> +                    return project.getId();
> +                 }
> +              }));
> +
> +      return filter(concat(transform(ImmutableSet.<String> builder().addAll(projects).add("").build(),

Any reason for all these immutable sets and builders here? How about just making `projects` a `newHashMap`, then simply adding `""` and transforming that?

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

Re: [jclouds] JCLOUDS-218. List templates in all known projects for CloudStack. (#215)

Posted by Andrew Phillips <no...@github.com>.
> +import org.jclouds.rest.annotations.RequestFilters;
> +import org.jclouds.rest.annotations.SelectJson;
> +
> +/**
> + * Provides synchronous access to CloudStack project features.
> + *
> + * @author Andrew Bayer
> + * @see <a
> + *      href="http://download.cloud.com/releases/3.0.6/api_3.0.6/TOC_Root_Admin.html"
> + *      />
> + */
> +@RequestFilters(AuthenticationFilter.class)
> +@QueryParams(keys = "response", values = "json")
> +public interface ProjectApi {
> +   /**
> +    * List the projects this account has access to.

"Lists..."?

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

Re: [jclouds] JCLOUDS-218. List templates in all known projects for CloudStack. (#215)

Posted by Andrew Bayer <no...@github.com>.
> +   @Override
> +   public boolean equals(Object obj) {
> +      if (this == obj) return true;
> +      if (obj == null || getClass() != obj.getClass()) return false;
> +      Project that = Project.class.cast(obj);
> +      return Objects.equal(this.id, that.id)
> +            && Objects.equal(this.account, that.account)
> +            && Objects.equal(this.displayText, that.displayText)
> +            && Objects.equal(this.domain, that.domain)
> +            && Objects.equal(this.domainId, that.domainId)
> +            && Objects.equal(this.name, that.name)
> +            && Objects.equal(this.state, that.state);
> +   }
> +
> +   protected ToStringHelper string() {
> +      return Objects.toStringHelper(this)

Aaaaaah. Gotcha. Lemme clean that up. I got confused.

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

Re: [jclouds] JCLOUDS-218. List templates in all known projects for CloudStack. (#215)

Posted by CloudBees pull request builder plugin <no...@github.com>.
[jclouds-pull-requests #418](https://jclouds.ci.cloudbees.com/job/jclouds-pull-requests/418/) SUCCESS
This pull request looks good

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

Re: [jclouds] JCLOUDS-218. List templates in all known projects for CloudStack. (#215)

Posted by Andrew Bayer <no...@github.com>.
> +      }
> +   }
> +
> +   private final String id;
> +   private final String account;
> +   private final String displayText;
> +   private final String domain;
> +   private final String domainId;
> +   private final String name;
> +   private final State state;
> +
> +   @ConstructorProperties({
> +         "id", "account", "displaytext", "domain", "domainid", "name", "state"
> +   })
> +   protected Project(String id, String account, String displayText, String domain, String domainId,
> +                     String name, State state) {

I'll do a dive through CloudStack and engage in a fit of code modernization post-1.7.0 - proper nullable usage in constructors, get rid of all foo.size() > 0s, etc, etc... =)

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

Re: [jclouds] JCLOUDS-218. List templates in all known projects for CloudStack. (#215)

Posted by Andrew Phillips <no...@github.com>.
> @@ -223,6 +225,15 @@ public String toString() {
>     @Provides
>     @Singleton
>     @Memoized
> +   public Supplier<Map<String, Project>> listProjects(AtomicReference<AuthorizationException> authException, @Named(PROPERTY_SESSION_INTERVAL) long seconds,
> +                                                      final ProjectsForCurrentUser projectsForCurrentUser) {

`final` needed here?

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

Re: [jclouds] JCLOUDS-218. List templates in all known projects for CloudStack. (#215)

Posted by Andrew Bayer <no...@github.com>.
> + * 
> + * @see <a
> + *      href="http://download.cloud.com/releases/3.0.6/api_3.0.6/root_admin/listProjects.html"
> + *      />
> + * @author Andrew Bayer
> + */
> +public class ListProjectsOptions extends AccountInDomainOptions {
> +
> +   public static final ListProjectsOptions NONE = new ListProjectsOptions();
> +
> +   /**
> +    * @param id
> +    *           list projects by project ID
> +    */
> +   public ListProjectsOptions id(String id) {
> +      this.queryParameters.replaceValues("id", ImmutableSet.of(id + ""));

Null avoidance, I believe.

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

Re: [jclouds] JCLOUDS-218. List templates in all known projects for CloudStack. (#215)

Posted by Andrew Bayer <no...@github.com>.
> +   }
> +
> +   public static class Builder {
> +
> +      /**
> +       * @see org.jclouds.cloudstack.options.ListProjectsOptions#accountInDomain(String, String)
> +       */
> +      public static ListProjectsOptions accountInDomain(String project, String domain) {
> +         ListProjectsOptions options = new ListProjectsOptions();
> +         return options.accountInDomain(project, domain);
> +      }
> +
> +      /**
> +       * @see org.jclouds.cloudstack.options.ListProjectsOptions#domainId
> +       */
> +      public static ListProjectsOptions domainId(String id) {

Done.

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

Re: [jclouds] JCLOUDS-218. List templates in all known projects for CloudStack. (#215)

Posted by Andrew Phillips <no...@github.com>.
> + * 
> + * @see <a
> + *      href="http://download.cloud.com/releases/3.0.6/api_3.0.6/root_admin/listProjects.html"
> + *      />
> + * @author Andrew Bayer
> + */
> +public class ListProjectsOptions extends AccountInDomainOptions {
> +
> +   public static final ListProjectsOptions NONE = new ListProjectsOptions();
> +
> +   /**
> +    * @param id
> +    *           list projects by project ID
> +    */
> +   public ListProjectsOptions id(String id) {
> +      this.queryParameters.replaceValues("id", ImmutableSet.of(id + ""));

Wouldn't that create a set with an entry `"null`"?

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

Re: [jclouds] JCLOUDS-218. List templates in all known projects for CloudStack. (#215)

Posted by Andrew Phillips <no...@github.com>.
> +public interface ProjectApi {
> +   /**
> +    * List the projects this account has access to.
> +    *
> +    * @param options if present, how to constrain the list
> +    */
> +   @Named("listProjects")
> +   @GET
> +   @QueryParams(keys = { "command", "listAll" }, values = { "listProjects", "true" })
> +   @SelectJson("project")
> +   @Consumes(MediaType.APPLICATION_JSON)
> +   @Fallback(EmptySetOnNotFoundOr404.class)
> +   Set<Project> listProjects(ListProjectsOptions... options);
> +
> +   /**
> +    * get a specific Project by id

"Gets..."?

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

Re: [jclouds] JCLOUDS-218. List templates in all known projects for CloudStack. (#215)

Posted by Andrew Bayer <no...@github.com>.
Well, then, pushed! =)

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

Re: [jclouds] JCLOUDS-218. List templates in all known projects for CloudStack. (#215)

Posted by Andrew Phillips <no...@github.com>.
> + * 
> + * @author Andrew Bayer
> + */
> +@Test(groups = "live", singleThreaded = true, testName = "ProjectApiLiveTest")
> +public class ProjectApiLiveTest extends BaseCloudStackApiLiveTest {
> +
> +   @Test
> +   public void testListAccounts() throws Exception {
> +      for (Project project : client.getProjectApi().listProjects())
> +         checkProject(project);
> +   }
> +
> +   protected void checkProject(Project project) {
> +      assertNotNull(project.getId());
> +      assertEquals(project.toString(), client.getProjectApi().getProject(project.getId()).toString());
> +      assertTrue(project.getState() != null && project.getState() != Project.State.UNRECOGNIZED);

[minor] Split into two asserts or add a message showing what the offending value actually is?

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

Re: [jclouds] JCLOUDS-218. List templates in all known projects for CloudStack. (#215)

Posted by Andrew Phillips <no...@github.com>.
> +      return filter(concat(transform(ImmutableSet.<String> builder().addAll(projects).add("").build(),
> +              allTemplatesForProject())), isReady());
> +   }
> +
> +   protected Function<String, Set<? extends Template>> allTemplatesForProject() {
> +      return new Function<String, Set<? extends Template>>() {
> +
> +         @Override
> +         public Set<? extends Template> apply(String from) {
> +            if (from != "")
> +               return client.getTemplateApi().listTemplates(ListTemplatesOptions.Builder.projectId(from));
> +            else
> +               return client.getTemplateApi().listTemplates();
> +         }
> +
> +      };

Functional, I know, but could an evil imperative style be clearer and shorter here?
```
TemplateApi templateApi = client.getTemplateApi();
ImmutableSet.Builder<? extends Template> templates = ImmutableSet.builder();
// add non-project templates
templates.addAll(templateApi.listTemplates());
for (Project project : projectSupplier.get().values()) {
  templates.addAll(templateApi.listTemplates(ListTemplatesOptions.Builder.projectId(project.getId()));
}
return filter(templates.build(), isReady());
```
And the use of the empty string as a "magic value" to force the non-project values to be added seems a bit hacky? If anything, add them to the template iterable explicitly before filtering?

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

Re: [jclouds] JCLOUDS-218. List templates in all known projects for CloudStack. (#215)

Posted by Andrew Phillips <no...@github.com>.
> +   @Override
> +   public boolean equals(Object obj) {
> +      if (this == obj) return true;
> +      if (obj == null || getClass() != obj.getClass()) return false;
> +      Project that = Project.class.cast(obj);
> +      return Objects.equal(this.id, that.id)
> +            && Objects.equal(this.account, that.account)
> +            && Objects.equal(this.displayText, that.displayText)
> +            && Objects.equal(this.domain, that.domain)
> +            && Objects.equal(this.domainId, that.domainId)
> +            && Objects.equal(this.name, that.name)
> +            && Objects.equal(this.state, that.state);
> +   }
> +
> +   protected ToStringHelper string() {
> +      return Objects.toStringHelper(this)

Compare, probably...but in a `toString`? I recall places where we do `omitNullValues`, that's all that prompted the comment.

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

Re: [jclouds] JCLOUDS-218. List templates in all known projects for CloudStack. (#215)

Posted by Andrew Phillips <no...@github.com>.
Waiting for BuildHive, but (pending squash'n'commit) looks good to me! Thanks, @abayer!

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

Re: [jclouds] JCLOUDS-218. List templates in all known projects for CloudStack. (#215)

Posted by Andrew Bayer <no...@github.com>.
> +      }
> +   }
> +
> +   private final String id;
> +   private final String account;
> +   private final String displayText;
> +   private final String domain;
> +   private final String domainId;
> +   private final String name;
> +   private final State state;
> +
> +   @ConstructorProperties({
> +         "id", "account", "displaytext", "domain", "domainid", "name", "state"
> +   })
> +   protected Project(String id, String account, String displayText, String domain, String domainId,
> +                     String name, State state) {

I honestly don't know, nor do I really have an opinion - this is cargo-cult-coding, just aping the other domain classes here. =)

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

Re: [jclouds] JCLOUDS-218. List templates in all known projects for CloudStack. (#215)

Posted by Andrew Phillips <no...@github.com>.
> Squashed, rebased, waiting to see how it does to be safe.

All the builders are happy, it seems! ;-)

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

Re: [jclouds] JCLOUDS-218. List templates in all known projects for CloudStack. (#215)

Posted by Andrew Phillips <no...@github.com>.
> +   }
> +
> +   public static class Builder {
> +
> +      /**
> +       * @see org.jclouds.cloudstack.options.ListProjectsOptions#accountInDomain(String, String)
> +       */
> +      public static ListProjectsOptions accountInDomain(String project, String domain) {
> +         ListProjectsOptions options = new ListProjectsOptions();
> +         return options.accountInDomain(project, domain);
> +      }
> +
> +      /**
> +       * @see org.jclouds.cloudstack.options.ListProjectsOptions#domainId
> +       */
> +      public static ListProjectsOptions domainId(String id) {

[minor] Name parameter `domainId`?

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

Re: [jclouds] JCLOUDS-218. List templates in all known projects for CloudStack. (#215)

Posted by Andrew Bayer <no...@github.com>.
> +import org.jclouds.rest.annotations.RequestFilters;
> +import org.jclouds.rest.annotations.SelectJson;
> +
> +/**
> + * Provides synchronous access to CloudStack project features.
> + *
> + * @author Andrew Bayer
> + * @see <a
> + *      href="http://download.cloud.com/releases/3.0.6/api_3.0.6/TOC_Root_Admin.html"
> + *      />
> + */
> +@RequestFilters(AuthenticationFilter.class)
> +@QueryParams(keys = "response", values = "json")
> +public interface ProjectApi {
> +   /**
> +    * List the projects this account has access to.

Done.

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

Re: [jclouds] JCLOUDS-218. List templates in all known projects for CloudStack. (#215)

Posted by CloudBees pull request builder plugin <no...@github.com>.
[jclouds-java-7-pull-requests #881](https://jclouds.ci.cloudbees.com/job/jclouds-java-7-pull-requests/881/) SUCCESS
This pull request looks good

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

Re: [jclouds] JCLOUDS-218. List templates in all known projects for CloudStack. (#215)

Posted by Andrew Bayer <no...@github.com>.
> +      return filter(concat(transform(ImmutableSet.<String> builder().addAll(projects).add("").build(),
> +              allTemplatesForProject())), isReady());
> +   }
> +
> +   protected Function<String, Set<? extends Template>> allTemplatesForProject() {
> +      return new Function<String, Set<? extends Template>>() {
> +
> +         @Override
> +         public Set<? extends Template> apply(String from) {
> +            if (from != "")
> +               return client.getTemplateApi().listTemplates(ListTemplatesOptions.Builder.projectId(from));
> +            else
> +               return client.getTemplateApi().listTemplates();
> +         }
> +
> +      };

Yeah, that code is pretty awful. It's here at least in part for advice on
improvements. =) I'll make another run at it tomorrow.

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

Re: [jclouds] JCLOUDS-218. List templates in all known projects for CloudStack. (#215)

Posted by CloudBees pull request builder plugin <no...@github.com>.
[jclouds-java-7-pull-requests #885](https://jclouds.ci.cloudbees.com/job/jclouds-java-7-pull-requests/885/) SUCCESS
This pull request looks good

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

Re: [jclouds] JCLOUDS-218. List templates in all known projects for CloudStack. (#215)

Posted by Andrew Bayer <no...@github.com>.
> +   @Override
> +   public boolean equals(Object obj) {
> +      if (this == obj) return true;
> +      if (obj == null || getClass() != obj.getClass()) return false;
> +      Project that = Project.class.cast(obj);
> +      return Objects.equal(this.id, that.id)
> +            && Objects.equal(this.account, that.account)
> +            && Objects.equal(this.displayText, that.displayText)
> +            && Objects.equal(this.domain, that.domain)
> +            && Objects.equal(this.domainId, that.domainId)
> +            && Objects.equal(this.name, that.name)
> +            && Objects.equal(this.state, that.state);
> +   }
> +
> +   protected ToStringHelper string() {
> +      return Objects.toStringHelper(this)

Not sure what you mean? We want to compare even nullable fields, don't we?

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

Re: [jclouds] JCLOUDS-218. List templates in all known projects for CloudStack. (#215)

Posted by CloudBees pull request builder plugin <no...@github.com>.
[jclouds-java-7-pull-requests #884](https://jclouds.ci.cloudbees.com/job/jclouds-java-7-pull-requests/884/) SUCCESS
This pull request looks good

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

Re: [jclouds] JCLOUDS-218. List templates in all known projects for CloudStack. (#215)

Posted by CloudBees pull request builder plugin <no...@github.com>.
[jclouds-pull-requests #422](https://jclouds.ci.cloudbees.com/job/jclouds-pull-requests/422/) SUCCESS
This pull request looks good

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

Re: [jclouds] JCLOUDS-218. List templates in all known projects for CloudStack. (#215)

Posted by Andrew Phillips <no...@github.com>.
> +      }
> +   }
> +
> +   private final String id;
> +   private final String account;
> +   private final String displayText;
> +   private final String domain;
> +   private final String domainId;
> +   private final String name;
> +   private final State state;
> +
> +   @ConstructorProperties({
> +         "id", "account", "displaytext", "domain", "domainid", "name", "state"
> +   })
> +   protected Project(String id, String account, String displayText, String domain, String domainId,
> +                     String name, State state) {

Mark as `@Nullable` where appropriate? Or not for a non-public constructor?

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