You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@jclouds.apache.org by Rita Zhang <no...@github.com> on 2016/04/12 02:06:21 UTC

[jclouds/jclouds-labs] JCLOUDS-664 Azurecompute-arm LocationApi (#256)

@nacx @andreaturli 
This PR is part of the foundations needed for interacting with Azure Resource Manager (ARM) Rest APIs. The Location API is the second API.

FYI
@jmspring @jtjk @isalento
You can view, comment on, or merge this pull request online at:

  https://github.com/jclouds/jclouds-labs/pull/256

-- Commit Summary --

  * JCLOUDS-664 Azurecompute-arm LocationApi

-- File Changes --

    M azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/AzureComputeApi.java (9)
    M azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/AzureComputeProviderMetadata.java (2)
    A azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/functions/LocationToLocation.java (62)
    A azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/Location.java (58)
    A azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/Region.java (90)
    A azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/features/LocationApi.java (57)
    A azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/LocationApiLiveTest.java (39)
    A azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/LocationApiMockTest.java (50)
    M azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/ResourceGroupApiMockTest.java (2)
    M azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/internal/BaseAzureComputeApiMockTest.java (4)
    A azurecompute-arm/src/test/resources/locations.json (10)
    M azurecompute-arm/src/test/resources/resourcegroup.json (2)
    M azurecompute-arm/src/test/resources/resourcegroups.json (6)
    M azurecompute-arm/src/test/resources/resourcegroupupdated.json (2)

-- Patch Links --

https://github.com/jclouds/jclouds-labs/pull/256.patch
https://github.com/jclouds/jclouds-labs/pull/256.diff

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/256

Re: [jclouds/jclouds-labs] JCLOUDS-664 Azurecompute-arm LocationApi (#256)

Posted by Rita Zhang <no...@github.com>.
@nacx Regarding list of locations, from the official Azure REST API [doc](https://msdn.microsoft.com/en-US/library/azure/dn790540.aspx):
"This API provides all of the locations that are available for resource providers; however, each resource provider may support a subset of this list." It might make more sense to do this dynamically since it will change over time. 

Here is how we are implementing [listLocations](https://github.com/ritazh/jclouds-labs/blob/azurecompute-arm-dev/azurecompute-arm-dev/src/main/java/org/jclouds/azurecompute/arm/compute/AzureComputeServiceAdapter.java#L416-L418) in `AzureComputeServiceAdapter.java` now. There is also [LocationToLocation.java](https://github.com/ritazh/jclouds-labs/blob/azurecompute-arm-dev/azurecompute-arm-dev/src/main/java/org/jclouds/azurecompute/arm/compute/functions/LocationToLocation.java). WDYT?



---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/256#issuecomment-209544071

Re: [jclouds/jclouds-labs] JCLOUDS-664 Azurecompute-arm LocationApi (#256)

Posted by Andrea Turli <no...@github.com>.
> + */
> +package org.jclouds.azurecompute.arm.features;
> +
> +import org.jclouds.azurecompute.arm.domain.Location;
> +import org.jclouds.azurecompute.arm.internal.BaseAzureComputeApiLiveTest;
> +import org.testng.annotations.Test;
> +
> +import static org.testng.Assert.assertTrue;
> +
> +@Test(groups = "live", testName = "LocationApiLiveTest")
> +public class LocationApiLiveTest extends BaseAzureComputeApiLiveTest {
> +
> +   @Test
> +   public void testList() {
> +      for (Location location : api().list()) {
> +          assertTrue(!location.id().isEmpty());

could you please add a "checkLocation(location);" where you assertNotNull on all the fields of Location?

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/256/files/1552b1cc04701f6ec9c7eb1a90f91bf4bc5bf769#r59344866

Re: [jclouds/jclouds-labs] JCLOUDS-664 Azurecompute-arm LocationApi (#256)

Posted by Andrea Turli <no...@github.com>.
> + * This Azure Resource Manager API provides all of the locations that are available for resource providers
> + * <p/>
> + *
> + * @see <a href="https://msdn.microsoft.com/en-US/library/azure/dn790540.aspx">docs</a>
> + */
> +@Path("/locations")
> +@RequestFilters(OAuthFilter.class)
> +@QueryParams(keys = "api-version", values = "2015-11-01")
> +@Produces(MediaType.APPLICATION_JSON)
> +@Consumes(MediaType.APPLICATION_JSON)
> +public interface LocationApi {
> +
> +   /**
> +    * The List Locations operation lists all of the data center locations that are valid for your subscription.
> +    */
> +   @Named("ListLocations")

[minor] jclouds tends to use "location:list" 

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/256/files/1552b1cc04701f6ec9c7eb1a90f91bf4bc5bf769#r59344511

Re: [jclouds/jclouds-labs] JCLOUDS-664 Azurecompute-arm LocationApi (#256)

Posted by Ignasi Barrera <no...@github.com>.
Thanks @ritazh! This looks great.

One small question regarding the future implementation of the ComputeService interface: I've seen you've populated the ISO code list in the metadata (great!). When implementing the ComputeService, there are two approaches to get the list of available locations:

* Dynamically, in the [ComputeServiceAdapter#listLocations](https://github.com/jclouds/jclouds/blob/master/compute/src/main/java/org/jclouds/compute/ComputeServiceAdapter.java#L129) method (like in the [DigitalOcean2 provider](https://github.com/jclouds/jclouds/blob/master/providers/digitalocean2/src/main/java/org/jclouds/digitalocean2/compute/DigitalOcean2ComputeServiceAdapter.java#L165-L174)).
* Statically, by providing the location properties, like in AWS or [ProfitBricks](https://github.com/jclouds/jclouds/blob/master/providers/profitbricks/src/main/java/org/jclouds/profitbricks/ProfitBricksProviderMetadata.java#L64-L74).

Do all subscriptions have access to all regions in the Region enum? And are they generally available? If that is the case, we might want to preconfigure the regions in the metadata like in AWS or ProfitBricks, as that gives users more control by letting them override the properties to make jclouds just work with a specific subset of regions (this has some use cases, for example [JCLOUDS-540](https://issues.apache.org/jira/browse/JCLOUDS-540).

Which do you think would be the best approach for the ARM provider?

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/256#issuecomment-209302576

Re: [jclouds/jclouds-labs] JCLOUDS-664 Azurecompute-arm LocationApi (#256)

Posted by Ignasi Barrera <no...@github.com>.
> +
> +   public String getName() {
> +      return name;
> +   }
> +
> +   public String iso3166Code() {
> +      return iso3166Code;
> +   }
> +
> +   public static Region byName(final String name) {
> +      Preconditions.checkNotNull(name);
> +
> +      Region result = null;
> +      for (Region region : values()) {
> +         if (name.equals(region.name)) {
> +            result = region;

[minor] Just `return region` here to avoid unnecessary iterations.

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/256/files/31c19ca63db70375d41b33769f04ba2cd7af9c97#r59509955

Re: [jclouds/jclouds-labs] JCLOUDS-664 Azurecompute-arm LocationApi (#256)

Posted by Rita Zhang <no...@github.com>.
@andreaturli Seems 559fdec is missing changes made based on your feedback from the latest commit in PR #256. I will create another PR for those changes and adding @nacx's suggestion for `Region`.

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/256#issuecomment-209528744

Re: [jclouds/jclouds-labs] JCLOUDS-664 Azurecompute-arm LocationApi (#256)

Posted by Andrea Turli <no...@github.com>.
merged at [master](http://git-wip-us.apache.org/repos/asf/jclouds-labs/commit/559fdecf)

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/256#issuecomment-209285813

Re: [jclouds/jclouds-labs] JCLOUDS-664 Azurecompute-arm LocationApi (#256)

Posted by Andrea Turli <no...@github.com>.
great! merging now, thanks @ritazh 

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/256#issuecomment-209278722

Re: [jclouds/jclouds-labs] JCLOUDS-664 Azurecompute-arm LocationApi (#256)

Posted by Rita Zhang <no...@github.com>.
@andreaturli @nacx Please review the latest.

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/256#issuecomment-209169672

Re: [jclouds/jclouds-labs] JCLOUDS-664 Azurecompute-arm LocationApi (#256)

Posted by Ignasi Barrera <no...@github.com>.
That looks fine. +1 to implement it dynamically given the docs. Thanks for sharing!

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/256#issuecomment-209661959

Re: [jclouds/jclouds-labs] JCLOUDS-664 Azurecompute-arm LocationApi (#256)

Posted by Andrea Turli <no...@github.com>.
Closed #256.

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/256#event-625326123

Re: [jclouds/jclouds-labs] JCLOUDS-664 Azurecompute-arm LocationApi (#256)

Posted by Andrea Turli <no...@github.com>.
great job @ritazh 
only few minor comments from my side: please address them so we can merge this PR as well.

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/256#issuecomment-208812302