You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by na...@apache.org on 2016/04/07 12:07:34 UTC
[2/2] jclouds-labs git commit: Azure ARM fixes
Azure ARM fixes
Project: http://git-wip-us.apache.org/repos/asf/jclouds-labs/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds-labs/commit/17f7c452
Tree: http://git-wip-us.apache.org/repos/asf/jclouds-labs/tree/17f7c452
Diff: http://git-wip-us.apache.org/repos/asf/jclouds-labs/diff/17f7c452
Branch: refs/heads/master
Commit: 17f7c4528472c87799df28512b7a97571f11f625
Parents: a4334d4
Author: Ignasi Barrera <na...@apache.org>
Authored: Wed Apr 6 23:16:46 2016 +0200
Committer: Ignasi Barrera <na...@apache.org>
Committed: Thu Apr 7 11:58:36 2016 +0200
----------------------------------------------------------------------
azurecompute-arm/README.md | 58 +------
azurecompute-arm/pom.xml | 12 +-
.../azurecompute.arm/AzureComputeApi.java | 43 ------
.../AzureComputeProviderMetadata.java | 94 ------------
.../AzureManagementApiMetadata.java | 86 -----------
.../config/AzureComputeHttpApiModule.java | 57 -------
.../config/AzureComputeParserModule.java | 29 ----
.../config/AzureComputeProperties.java | 34 -----
.../azurecompute.arm/domain/ResourceGroup.java | 51 -------
.../azurecompute.arm/features/JobApi.java | 41 -----
.../features/ResourceGroupApi.java | 96 ------------
.../functions/ParseJobStatus.java | 54 -------
.../azurecompute.arm/functions/URIParser.java | 39 -----
.../handlers/AzureComputeErrorHandler.java | 86 -----------
.../azurecompute/arm/AzureComputeApi.java | 43 ++++++
.../arm/AzureComputeProviderMetadata.java | 92 ++++++++++++
.../arm/AzureManagementApiMetadata.java | 86 +++++++++++
.../arm/config/AzureComputeHttpApiModule.java | 57 +++++++
.../arm/config/AzureComputeParserModule.java | 29 ++++
.../arm/config/AzureComputeProperties.java | 34 +++++
.../azurecompute/arm/domain/ResourceGroup.java | 51 +++++++
.../azurecompute/arm/features/JobApi.java | 41 +++++
.../arm/features/ResourceGroupApi.java | 96 ++++++++++++
.../arm/functions/ParseJobStatus.java | 54 +++++++
.../azurecompute/arm/functions/URIParser.java | 39 +++++
.../arm/handlers/AzureComputeErrorHandler.java | 86 +++++++++++
.../AzureComputeProviderMetadataTest.java | 28 ----
.../features/JobApiMockTest.java | 62 --------
.../features/ResourceGroupApiLiveTest.java | 137 -----------------
.../features/ResourceGroupApiMockTest.java | 150 -------------------
.../functions/URIParserTest.java | 51 -------
.../AbstractAzureComputeApiLiveTest.java | 69 ---------
.../internal/AzureLiveTestUtils.java | 34 -----
.../internal/BaseAzureComputeApiLiveTest.java | 65 --------
.../internal/BaseAzureComputeApiMockTest.java | 134 -----------------
.../arm/AzureComputeProviderMetadataTest.java | 28 ++++
.../arm/features/JobApiMockTest.java | 62 ++++++++
.../arm/features/ResourceGroupApiLiveTest.java | 137 +++++++++++++++++
.../arm/features/ResourceGroupApiMockTest.java | 150 +++++++++++++++++++
.../arm/functions/URIParserTest.java | 51 +++++++
.../AbstractAzureComputeApiLiveTest.java | 69 +++++++++
.../arm/internal/AzureLiveTestUtils.java | 34 +++++
.../internal/BaseAzureComputeApiLiveTest.java | 65 ++++++++
.../internal/BaseAzureComputeApiMockTest.java | 130 ++++++++++++++++
44 files changed, 1447 insertions(+), 1497 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/17f7c452/azurecompute-arm/README.md
----------------------------------------------------------------------
diff --git a/azurecompute-arm/README.md b/azurecompute-arm/README.md
index a3abe63..85e39e5 100644
--- a/azurecompute-arm/README.md
+++ b/azurecompute-arm/README.md
@@ -2,7 +2,8 @@ jclouds Labs - Azure Compute ARM Provider
============
Build status for azurecomputearm module:
-[![Build Status](http://devopsfunjenkins.westus.cloudapp.azure.com:8080/buildStatus/icon?job=jclouds-labs-azurecompute-arm/org.apache.jclouds.labs:azurecomputearm)](http://devopsfunjenkins.westus.cloudapp.azure.com:8080/job/jclouds-labs-azurecompute-arm/org.apache.jclouds.labs$azurecomputearm/)
+[![Build Status](https://jclouds.ci.cloudbees.com/buildStatus/icon?job=jclouds-labs/org.apache.jclouds.labs$azurecompute-arm)](https://jclouds.ci.cloudbees.com/buildStatus/icon?job=jclouds-labs/org.apache.jclouds.labs$azurecompute-arm)
+
## Setting Up Test Credentials
@@ -42,68 +43,23 @@ Run the following commands to assign roles to the service principal
```bash
# Assign roles for this service principal
azure role assignment create --objectId <Object-id> -o Contributor -c /subscriptions/<Subscription-id>/
-
```
Verify service principal
```bash
azure login -u <Application-id> -p <password> --service-principal --tenant <Tenant-id>
-
```
## Run Live Tests
-
Use the following to run the live tests
```bash
-# ResourceGroupApiLiveTest:
-
-mvn -Dtest=ResourceGroupApiLiveTest -Dtest.azurecompute-arm.identity=<Application-id> -Dtest.azurecompute-arm.subscriptionid=<Subscription-id> -Dtest.azurecompute-arm.credential=<password> -Dtest.azurecompute-arm.endpoint="https://management.azure.com" -Dtest.jclouds.oauth.resource="https://management.azure.com/" -Dtest.oauth.endpoint="https://login.microsoftonline.com/<Tenant-id>/oauth2/token" test
-
-# AuthorizationApiLiveTest:
-
-mvn -Dtest=AuthorizationApiLiveTest -Dtest.oauth.identity=<Application-id> -Dtest.oauth.credential=<password> -Dtest.jclouds.oauth.resource="https://management.azure.com/" -Dtest.oauth.endpoint="https://login.microsoftonline.com/<Tenant-id>/oauth2/token" -Dtest.jclouds.oauth.audience="https://management.azure.com/" test
-
-# LocationApiLiveTest:
-
-mvn -Dtest=LocationApiLiveTest -Dtest.azurecompute-arm.identity=<Application-id> -Dtest.azurecompute-arm.subscriptionid=<Subscription-id> -Dtest.azurecompute-arm.credential=<password> -Dtest.azurecompute-arm.endpoint="https://management.azure.com" -Dtest.jclouds.oauth.resource="https://management.azure.com/" -Dtest.oauth.endpoint="https://login.microsoftonline.com/<Tenant-id>/oauth2/token" test
-
-# StorageAccountApiLiveTest:
-
-mvn -Dtest=StorageAccountApiLiveTest -Dtest.azurecompute-arm.identity=<Application-id> -Dtest.azurecompute-arm.subscriptionid=<Subscription-id> -Dtest.azurecompute-arm.credential=<password> -Dtest.azurecompute-arm.endpoint="https://management.azure.com" -Dtest.jclouds.oauth.resource="https://management.azure.com/" -Dtest.oauth.endpoint="https://login.microsoftonline.com/<Tenant-id>/oauth2/token" test
-
-# VirtualNetworkApiLiveTest:
-
-mvn -Dtest=VirtualNetworkApiLiveTest -Dtest.azurecompute-arm.identity=<Application-id> -Dtest.azurecompute-arm.subscriptionid=<Subscription-id> -Dtest.azurecompute-arm.credential=<password> -Dtest.azurecompute-arm.resourcegroup="jcloudstest" -Dtest.azurecompute-arm.endpoint="https://management.azure.com" -Dtest.jclouds.oauth.resource="https://management.azure.com/" -Dtest.oauth.endpoint="https://login.microsoftonline.com/<Tenant-id>/oauth2/token" test
-
-# SubnetApiLiveTest
-
-mvn -Dtest=SubnetApiLiveTest -Dtest.azurecompute-arm.identity=<Application-id> -Dtest.azurecompute-arm.subscriptionid=<Subscription-id> -Dtest.azurecompute-arm.credential=<password> -Dtest.azurecompute-arm.resourcegroup="jcloudstest" -Dtest.azurecompute-arm.endpoint="https://management.azure.com" -Dtest.jclouds.oauth.resource="https://management.azure.com/" -Dtest.oauth.endpoint="https://login.microsoftonline.com/<Tenant-id>/oauth2/token" test
-
-# NetworkInterfaceCardApiLiveTest
-
-mvn -Dtest=NetworkInterfaceCardApiLiveTest -Dtest.azurecompute-arm.identity=<Application-id> -Dtest.azurecompute-arm.subscriptionid=<Subscription-id> -Dtest.azurecompute-arm.credential=<password> -Dtest.azurecompute-arm.resourcegroup="jcloudstest" -Dtest.azurecompute-arm.endpoint="https://management.azure.com" -Dtest.jclouds.oauth.resource="https://management.azure.com/" -Dtest.oauth.endpoint="https://login.microsoftonline.com/<Tenant-id>/oauth2/token" test
-
-# VirtualMachineApiLiveTest:
-
-mvn -Dtest=VirtualMachineApiLiveTest -Dtest.azurecompute-arm.identity=<Application-id> -Dtest.azurecompute-arm.subscriptionid=<Subscription-id> -Dtest.azurecompute-arm.credential=<password> -Dtest.azurecompute-arm.endpoint="https://management.azure.com" -Dtest.jclouds.oauth.resource="https://management.azure.com/" -Dtest.oauth.endpoint="https://login.microsoftonline.com/<Tenant-id>/oauth2/token" test
-
-# VMSizeApiLiveTest:
-
-mvn -Dtest=VMSizeApiLiveTest -Dtest.azurecompute-arm.identity=<Application-id> -Dtest.azurecompute-arm.subscriptionid=<Subscription-id> -Dtest.azurecompute-arm.credential=<password> -Dtest.azurecompute-arm.endpoint="https://management.azure.com" -Dtest.jclouds.oauth.resource="https://management.azure.com/" -Dtest.oauth.endpoint="https://login.microsoftonline.com/<Tenant-id>/oauth2/token" test
-
-# PublicIPAddressApiLiveTest
-
-mvn -Dtest=PublicIPAddressApiLiveTest -Dtest.azurecompute-arm.identity=<Application-id> -Dtest.azurecompute-arm.subscriptionid=<Subscription-id> -Dtest.azurecompute-arm.credential=<password> -Dtest.azurecompute-arm.endpoint="https://management.azure.com" -Dtest.jclouds.oauth.resource="https://management.azure.com/" -Dtest.oauth.endpoint="https://login.microsoftonline.com/<Tenant-id>/oauth2/token" test
-
-# OSImageApiLiveTest:
-
-mvn -Dtest=OSImageApiLiveTest -Dtest.azurecompute-arm.identity=<Application-id> -Dtest.azurecompute-arm.subscriptionid=<Subscription-id> -Dtest.azurecompute-arm.credential=<password> -Dtest.azurecompute-arm.endpoint="https://management.azure.com" -Dtest.jclouds.oauth.resource="https://management.azure.com/" -Dtest.oauth.endpoint="https://login.microsoftonline.com/<Tenant-id>/oauth2/token" test
-
-# DeploymentApiLiveTest:
-
-mvn -Dtest=DeploymentApiLiveTest -Dtest.azurecompute-arm.identity=<Application-id> -Dtest.azurecompute-arm.subscriptionid=<Subscription-id> -Dtest.azurecompute-arm.credential=<password> -Dtest.azurecompute-arm.endpoint="https://management.azure.com/" -Dtest.jclouds.oauth.resource="https://management.azure.com/" -Dtest.oauth.endpoint="https://login.microsoftonline.com/<Tenant-id>/oauth2/token" test
+mvn clean verify -Plive \
+ -Dtest.azurecompute-arm.identity=<Application-id> \
+ -Dtest.azurecompute-arm.credential=<password> \
+ -Dtest.azurecompute-arm.endpoint=https://management.azure.com/subscriptions/<Subscription-id> \
+ -Dtest.oauth.endpoint=https://login.microsoftonline.com/<Tenant-id>/oauth2/token
```
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/17f7c452/azurecompute-arm/pom.xml
----------------------------------------------------------------------
diff --git a/azurecompute-arm/pom.xml b/azurecompute-arm/pom.xml
index 807ab20..33251fd 100644
--- a/azurecompute-arm/pom.xml
+++ b/azurecompute-arm/pom.xml
@@ -31,10 +31,10 @@
<packaging>bundle</packaging>
<properties>
- <test.jclouds.azurecompute-arm.subscription-id>FIXME_subscription-id</test.jclouds.azurecompute-arm.subscription-id>
- <test.jclouds.azurecompute-arm.tenant-id>FIXME_tenant-id</test.jclouds.azurecompute-arm.tenant-id>
- <test.azurecompute-arm.endpoint>https://management.azure.com/subscriptions/${test.jclouds.azurecompute-arm.subscription-id}</test.azurecompute-arm.endpoint>
- <test.azurecompute-arm.api-version>2014-04-01-preview</test.azurecompute-arm.api-version>
+ <test.jclouds.oauth.resource>https://management.azure.com/</test.jclouds.oauth.resource>
+ <test.oauth.endpoint>https://login.microsoftonline.com/FIXME_tenant-id/oauth2/token</test.oauth.endpoint>
+ <test.azurecompute-arm.endpoint>https://management.azure.com/subscriptions/FIXME_subscription-id</test.azurecompute-arm.endpoint>
+ <test.azurecompute-arm.api-version></test.azurecompute-arm.api-version>
<test.azurecompute-arm.build-version />
<test.azurecompute-arm.identity>app id</test.azurecompute-arm.identity>
<test.azurecompute-arm.credential>app password</test.azurecompute-arm.credential>
@@ -162,8 +162,8 @@
<test.azurecompute-arm.build-version>${test.azurecompute-arm.build-version}</test.azurecompute-arm.build-version>
<test.azurecompute-arm.identity>${test.azurecompute-arm.identity}</test.azurecompute-arm.identity>
<test.azurecompute-arm.credential>${test.azurecompute-arm.credential}</test.azurecompute-arm.credential>
- <test.jclouds.azurecompute-arm.subscription-id>${test.jclouds.azurecompute-arm.subscription-id}</test.jclouds.azurecompute-arm.subscription-id>
- <test.jclouds.azurecompute-arm.tenant-id>${test.jclouds.azurecompute-arm.tenant-id}</test.jclouds.azurecompute-arm.tenant-id>
+ <test.jclouds.oauth.resource>${test.jclouds.oauth.resource}</test.jclouds.oauth.resource>
+ <test.oauth.endpoint>${test.oauth.endpoint}</test.oauth.endpoint>
</systemPropertyVariables>
</configuration>
</execution>
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/17f7c452/azurecompute-arm/src/main/java/org/jclouds/azurecompute.arm/AzureComputeApi.java
----------------------------------------------------------------------
diff --git a/azurecompute-arm/src/main/java/org/jclouds/azurecompute.arm/AzureComputeApi.java b/azurecompute-arm/src/main/java/org/jclouds/azurecompute.arm/AzureComputeApi.java
deleted file mode 100644
index a897c9a..0000000
--- a/azurecompute-arm/src/main/java/org/jclouds/azurecompute.arm/AzureComputeApi.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.jclouds.azurecompute.arm;
-
-import java.io.Closeable;
-
-import org.jclouds.azurecompute.arm.features.JobApi;
-import org.jclouds.azurecompute.arm.features.ResourceGroupApi;
-import org.jclouds.rest.annotations.Delegate;
-
-/**
- * The Azure Resource Manager API is a REST API for managing your services and deployments.
- * <p/>
- *
- * @see <a href="https://msdn.microsoft.com/en-us/library/azure/dn790568.aspx" >doc</a>
- */
-public interface AzureComputeApi extends Closeable {
-
- /**
- * The Azure Resource Manager API includes operations for managing resource groups in your subscription.
- *
- * @see <a href="https://msdn.microsoft.com/en-us/library/azure/dn790546.aspx">docs</a>
- */
- @Delegate
- ResourceGroupApi getResourceGroupApi();
-
- @Delegate
- JobApi getJobApi();
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/17f7c452/azurecompute-arm/src/main/java/org/jclouds/azurecompute.arm/AzureComputeProviderMetadata.java
----------------------------------------------------------------------
diff --git a/azurecompute-arm/src/main/java/org/jclouds/azurecompute.arm/AzureComputeProviderMetadata.java b/azurecompute-arm/src/main/java/org/jclouds/azurecompute.arm/AzureComputeProviderMetadata.java
deleted file mode 100644
index 68d7a86..0000000
--- a/azurecompute-arm/src/main/java/org/jclouds/azurecompute.arm/AzureComputeProviderMetadata.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.jclouds.azurecompute.arm;
-
-import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.OPERATION_POLL_INITIAL_PERIOD;
-import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.OPERATION_POLL_MAX_PERIOD;
-import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.OPERATION_TIMEOUT;
-import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.TCP_RULE_FORMAT;
-import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.TCP_RULE_REGEXP;
-import static org.jclouds.oauth.v2.config.CredentialType.CLIENT_CREDENTIALS_SECRET;
-import static org.jclouds.oauth.v2.config.OAuthProperties.RESOURCE;
-import static org.jclouds.oauth.v2.config.OAuthProperties.CREDENTIAL_TYPE;
-
-import java.net.URI;
-import java.util.Properties;
-import org.jclouds.providers.ProviderMetadata;
-import org.jclouds.providers.internal.BaseProviderMetadata;
-
-import com.google.auto.service.AutoService;
-
-@AutoService(ProviderMetadata.class)
-public class AzureComputeProviderMetadata extends BaseProviderMetadata {
-
- public static Builder builder() {
- return new Builder();
- }
-
- @Override
- public Builder toBuilder() {
- return builder().fromProviderMetadata(this);
- }
-
- public AzureComputeProviderMetadata() {
- super(builder());
- }
-
- public static Properties defaultProperties() {
- final Properties properties = AzureManagementApiMetadata.defaultProperties();
- properties.setProperty(OPERATION_TIMEOUT, "60000");
- properties.setProperty(OPERATION_POLL_INITIAL_PERIOD, "5");
- properties.setProperty(OPERATION_POLL_MAX_PERIOD, "15");
- properties.setProperty(TCP_RULE_FORMAT, "tcp_%s-%s");
- properties.setProperty(TCP_RULE_REGEXP, "tcp_\\d{1,5}-\\d{1,5}");
- properties.put("oauth.endpoint", "https://login.microsoftonline.com/oauth2/token");
- properties.put(RESOURCE, "https://management.azure.com");
- properties.put(CREDENTIAL_TYPE, CLIENT_CREDENTIALS_SECRET.toString());
- return properties;
- }
-
- public AzureComputeProviderMetadata(final Builder builder) {
- super(builder);
- }
-
- public static class Builder extends BaseProviderMetadata.Builder {
-
- protected Builder() {
- super();
-
- id("azurecompute-arm")
- .name("Azure Resource Management ")
- .apiMetadata(new AzureManagementApiMetadata())
- .endpoint("https://management.azure.com/subscriptions/SUBSCRIPTION_ID")
- .homepage(URI.create("https://www.windowsazure.com/"))
- .console(URI.create("https://windows.azure.com/default.aspx"))
- .linkedServices("azureblob")
- .defaultProperties(AzureComputeProviderMetadata.defaultProperties());
- }
-
- @Override
- public AzureComputeProviderMetadata build() {
- return new AzureComputeProviderMetadata(this);
- }
-
- @Override
- public Builder fromProviderMetadata(final ProviderMetadata providerMetadata) {
- super.fromProviderMetadata(providerMetadata);
- return this;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/17f7c452/azurecompute-arm/src/main/java/org/jclouds/azurecompute.arm/AzureManagementApiMetadata.java
----------------------------------------------------------------------
diff --git a/azurecompute-arm/src/main/java/org/jclouds/azurecompute.arm/AzureManagementApiMetadata.java b/azurecompute-arm/src/main/java/org/jclouds/azurecompute.arm/AzureManagementApiMetadata.java
deleted file mode 100644
index 9a3292c..0000000
--- a/azurecompute-arm/src/main/java/org/jclouds/azurecompute.arm/AzureManagementApiMetadata.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.jclouds.azurecompute.arm;
-
-import static org.jclouds.reflect.Reflection2.typeToken;
-
-import java.net.URI;
-import java.util.Properties;
-
-import org.jclouds.apis.ApiMetadata;
-import org.jclouds.azurecompute.arm.config.AzureComputeHttpApiModule;
-import org.jclouds.compute.ComputeServiceContext;
-import org.jclouds.rest.internal.BaseHttpApiMetadata;
-import org.jclouds.oauth.v2.config.OAuthModule;
-
-import com.google.common.collect.ImmutableSet;
-import com.google.inject.Module;
-import org.jclouds.http.okhttp.config.OkHttpCommandExecutorServiceModule;
-
-/**
- * Implementation of {@link ApiMetadata} for Microsoft Azure Resource Manager REST API
- */
-public class AzureManagementApiMetadata extends BaseHttpApiMetadata<AzureComputeApi> {
-
- @Override
- public Builder toBuilder() {
- return new Builder().fromApiMetadata(this);
- }
-
- public AzureManagementApiMetadata() {
- this(new Builder());
- }
-
- protected AzureManagementApiMetadata(final Builder builder) {
- super(builder);
- }
-
- public static Properties defaultProperties() {
- final Properties properties = BaseHttpApiMetadata.defaultProperties();
- return properties;
- }
-
- public static class Builder extends BaseHttpApiMetadata.Builder<AzureComputeApi, Builder> {
-
- protected Builder() {
- super();
-
- id("azurecompute-arm")
- .name("Microsoft Azure Resource Manager REST API")
- .identityName("Azure Service Principal Application Id")
- .credentialName("Azure Service Principal Application Password")
- .endpointName("Resource Manager Endpoint ending in your Subscription Id")
- .documentation(URI.create("https://msdn.microsoft.com/en-us/library/azure/dn790568.aspx"))
- .defaultProperties(AzureManagementApiMetadata.defaultProperties())
- .view(typeToken(ComputeServiceContext.class))
- .defaultModules(ImmutableSet.<Class<? extends Module>>builder()
- .add(OAuthModule.class)
- .add(OkHttpCommandExecutorServiceModule.class)
- .add(AzureComputeHttpApiModule.class).build());
- }
-
- @Override
- public AzureManagementApiMetadata build() {
- return new AzureManagementApiMetadata(this);
- }
-
- @Override
- protected Builder self() {
- return this;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/17f7c452/azurecompute-arm/src/main/java/org/jclouds/azurecompute.arm/config/AzureComputeHttpApiModule.java
----------------------------------------------------------------------
diff --git a/azurecompute-arm/src/main/java/org/jclouds/azurecompute.arm/config/AzureComputeHttpApiModule.java b/azurecompute-arm/src/main/java/org/jclouds/azurecompute.arm/config/AzureComputeHttpApiModule.java
deleted file mode 100644
index 9041d96..0000000
--- a/azurecompute-arm/src/main/java/org/jclouds/azurecompute.arm/config/AzureComputeHttpApiModule.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.jclouds.azurecompute.arm.config;
-import org.jclouds.azurecompute.arm.AzureComputeApi;
-import org.jclouds.azurecompute.arm.handlers.AzureComputeErrorHandler;
-import org.jclouds.http.HttpErrorHandler;
-import org.jclouds.http.annotation.ClientError;
-import org.jclouds.http.annotation.Redirection;
-import org.jclouds.http.annotation.ServerError;
-import org.jclouds.location.suppliers.ImplicitLocationSupplier;
-import org.jclouds.location.suppliers.implicit.OnlyLocationOrFirstRegionOptionallyMatchingRegionId;
-
-import org.jclouds.rest.ConfiguresHttpApi;
-import org.jclouds.rest.config.HttpApiModule;
-import org.jclouds.oauth.v2.config.OAuthScopes;
-
-import com.google.inject.Scopes;
-
-@ConfiguresHttpApi
-public class AzureComputeHttpApiModule extends HttpApiModule<AzureComputeApi> {
-
- @Override
- protected void bindErrorHandlers() {
- bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(AzureComputeErrorHandler.class);
- bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(AzureComputeErrorHandler.class);
- bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(AzureComputeErrorHandler.class);
- }
-
- @Override
- protected void installLocations() {
- super.installLocations();
- bind(ImplicitLocationSupplier.class).
- to(OnlyLocationOrFirstRegionOptionallyMatchingRegionId.class).
- in(Scopes.SINGLETON);
- }
-
- @Override
- protected void configure() {
- install(new AzureComputeParserModule());
- super.configure();
- bind(OAuthScopes.class).toInstance(OAuthScopes.ReadOrWriteScopes.create("read", "read write"));
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/17f7c452/azurecompute-arm/src/main/java/org/jclouds/azurecompute.arm/config/AzureComputeParserModule.java
----------------------------------------------------------------------
diff --git a/azurecompute-arm/src/main/java/org/jclouds/azurecompute.arm/config/AzureComputeParserModule.java b/azurecompute-arm/src/main/java/org/jclouds/azurecompute.arm/config/AzureComputeParserModule.java
deleted file mode 100644
index 396f5be..0000000
--- a/azurecompute-arm/src/main/java/org/jclouds/azurecompute.arm/config/AzureComputeParserModule.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.jclouds.azurecompute.arm.config;
-
-import org.jclouds.json.config.GsonModule;
-
-import com.google.inject.AbstractModule;
-
-public class AzureComputeParserModule extends AbstractModule {
-
- @Override
- protected void configure() {
- bind(GsonModule.DateAdapter.class).to(GsonModule.Iso8601DateAdapter.class);
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/17f7c452/azurecompute-arm/src/main/java/org/jclouds/azurecompute.arm/config/AzureComputeProperties.java
----------------------------------------------------------------------
diff --git a/azurecompute-arm/src/main/java/org/jclouds/azurecompute.arm/config/AzureComputeProperties.java b/azurecompute-arm/src/main/java/org/jclouds/azurecompute.arm/config/AzureComputeProperties.java
deleted file mode 100644
index e16b5da..0000000
--- a/azurecompute-arm/src/main/java/org/jclouds/azurecompute.arm/config/AzureComputeProperties.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.jclouds.azurecompute.arm.config;
-
-/**
- * Configuration properties and constants used in Azure Resource Manager connections.
- */
-public class AzureComputeProperties {
-
- public static final String OPERATION_TIMEOUT = "jclouds.azurecompute.arm.operation.timeout";
-
- public static final String OPERATION_POLL_INITIAL_PERIOD = "jclouds.azurecompute.arm.operation.poll.initial.period";
-
- public static final String OPERATION_POLL_MAX_PERIOD = "jclouds.azurecompute.arm.operation.poll.max.period";
-
- public static final String TCP_RULE_FORMAT = "jclouds.azurecompute.arm.tcp.rule.format";
-
- public static final String TCP_RULE_REGEXP = "jclouds.azurecompute.arm.tcp.rule.regexp";
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/17f7c452/azurecompute-arm/src/main/java/org/jclouds/azurecompute.arm/domain/ResourceGroup.java
----------------------------------------------------------------------
diff --git a/azurecompute-arm/src/main/java/org/jclouds/azurecompute.arm/domain/ResourceGroup.java b/azurecompute-arm/src/main/java/org/jclouds/azurecompute.arm/domain/ResourceGroup.java
deleted file mode 100644
index 1be93ab..0000000
--- a/azurecompute-arm/src/main/java/org/jclouds/azurecompute.arm/domain/ResourceGroup.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.jclouds.azurecompute.arm.domain;
-
-import com.google.auto.value.AutoValue;
-import java.util.Map;
-import org.jclouds.javax.annotation.Nullable;
-import org.jclouds.json.SerializedNames;
-import com.google.common.collect.ImmutableMap;
-
-
-@AutoValue
-public abstract class ResourceGroup {
-
- @AutoValue
- public abstract static class ResourceGroupProperties{
- @Nullable
- public abstract String provisioningState();
-
- @SerializedNames({"provisioningState"})
- public static ResourceGroupProperties create(final String provisioningState) {
- return new AutoValue_ResourceGroup_ResourceGroupProperties(provisioningState);
- }
- }
-
- public abstract String id();
- public abstract String name();
- public abstract String location();
- @Nullable
- public abstract Map<String, String> tags();
- public abstract ResourceGroupProperties properties();
-
- @SerializedNames({"id", "name", "location", "tags", "properties"})
- public static ResourceGroup create(String id, String name, String location, @Nullable Map<String, String> tags, ResourceGroupProperties properties) {
- return new AutoValue_ResourceGroup(id, name, location, tags == null ? ImmutableMap.<String, String>builder().build() : ImmutableMap.copyOf(tags), properties);
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/17f7c452/azurecompute-arm/src/main/java/org/jclouds/azurecompute.arm/features/JobApi.java
----------------------------------------------------------------------
diff --git a/azurecompute-arm/src/main/java/org/jclouds/azurecompute.arm/features/JobApi.java b/azurecompute-arm/src/main/java/org/jclouds/azurecompute.arm/features/JobApi.java
deleted file mode 100644
index 7dd75a9..0000000
--- a/azurecompute-arm/src/main/java/org/jclouds/azurecompute.arm/features/JobApi.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.jclouds.azurecompute.arm.features;
-import java.io.Closeable;
-import java.net.URI;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.GET;
-import org.jclouds.oauth.v2.filters.OAuthFilter;
-import org.jclouds.rest.annotations.EndpointParam;
-import org.jclouds.rest.annotations.RequestFilters;
-import org.jclouds.rest.annotations.ResponseParser;
-import org.jclouds.azurecompute.arm.functions.ParseJobStatus;
-import org.jclouds.azurecompute.arm.functions.ParseJobStatus.JobStatus;
-
-/**
- * The Azure Resource Manager API checks for job status and progress.
- */
-
-@RequestFilters(OAuthFilter.class)
-@Consumes(MediaType.APPLICATION_JSON)
-public interface JobApi extends Closeable{
- @GET
- @ResponseParser(ParseJobStatus.class)
- JobStatus jobStatus(@EndpointParam URI jobURI);
-}
-
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/17f7c452/azurecompute-arm/src/main/java/org/jclouds/azurecompute.arm/features/ResourceGroupApi.java
----------------------------------------------------------------------
diff --git a/azurecompute-arm/src/main/java/org/jclouds/azurecompute.arm/features/ResourceGroupApi.java b/azurecompute-arm/src/main/java/org/jclouds/azurecompute.arm/features/ResourceGroupApi.java
deleted file mode 100644
index 1ad47d9..0000000
--- a/azurecompute-arm/src/main/java/org/jclouds/azurecompute.arm/features/ResourceGroupApi.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.jclouds.azurecompute.arm.features;
-import java.io.Closeable;
-import java.net.URI;
-import java.util.List;
-import java.util.Map;
-import javax.inject.Named;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-
-import org.jclouds.Fallbacks.EmptyListOnNotFoundOr404;
-import org.jclouds.Fallbacks.NullOnNotFoundOr404;
-import org.jclouds.azurecompute.arm.domain.ResourceGroup;
-import org.jclouds.javax.annotation.Nullable;
-import org.jclouds.oauth.v2.filters.OAuthFilter;
-import org.jclouds.rest.annotations.QueryParams;
-import org.jclouds.rest.annotations.RequestFilters;
-import org.jclouds.rest.annotations.SelectJson;
-import org.jclouds.rest.annotations.Fallback;
-import org.jclouds.rest.annotations.MapBinder;
-import org.jclouds.rest.annotations.PayloadParam;
-import org.jclouds.rest.annotations.PATCH;
-import org.jclouds.rest.annotations.ResponseParser;
-import org.jclouds.azurecompute.arm.functions.URIParser;
-
-
-import org.jclouds.rest.binders.BindToJsonPayload;
-
-/**
- * The Azure Resource Manager API includes operations for managing resource groups in your subscription.
- *
- * @see <a href="https://msdn.microsoft.com/en-us/library/azure/dn790546.aspx">docs</a>
- */
-@Path("/resourcegroups")
-
-@QueryParams(keys = "api-version", values = "2015-01-01")
-@RequestFilters(OAuthFilter.class)
-@Consumes(MediaType.APPLICATION_JSON)
-public interface ResourceGroupApi extends Closeable{
-
- @Named("resourcegroup:list")
- @SelectJson("value")
- @GET
- @Fallback(EmptyListOnNotFoundOr404.class)
- List<ResourceGroup> list();
-
- @Named("resourcegroup:create")
- @PUT
- @Path("/{name}")
- @Produces(MediaType.APPLICATION_JSON)
- @MapBinder(BindToJsonPayload.class)
- ResourceGroup create(@PathParam("name") String name, @PayloadParam("location") String location, @Nullable @PayloadParam("tags")Map<String, String> tags);
-
- @Named("resourcegroup:get")
- @GET
- @Path("/{name}")
- @Fallback(NullOnNotFoundOr404.class)
- @Nullable
- ResourceGroup get(@PathParam("name") String name);
-
- @Named("resourcegroup:update")
- @PATCH
- @Produces(MediaType.APPLICATION_JSON)
- @Path("/{name}")
- @MapBinder(BindToJsonPayload.class)
- ResourceGroup update(@PathParam("name") String name, @Nullable @PayloadParam("tags")Map<String, String> tags);
-
- @Named("resourcegroup:delete")
- @DELETE
- @ResponseParser(URIParser.class)
- @Path("/{name}")
- @Fallback(NullOnNotFoundOr404.class)
- URI delete(@PathParam("name") String name);
-}
-
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/17f7c452/azurecompute-arm/src/main/java/org/jclouds/azurecompute.arm/functions/ParseJobStatus.java
----------------------------------------------------------------------
diff --git a/azurecompute-arm/src/main/java/org/jclouds/azurecompute.arm/functions/ParseJobStatus.java b/azurecompute-arm/src/main/java/org/jclouds/azurecompute.arm/functions/ParseJobStatus.java
deleted file mode 100644
index f39db90..0000000
--- a/azurecompute-arm/src/main/java/org/jclouds/azurecompute.arm/functions/ParseJobStatus.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.jclouds.azurecompute.arm.functions;
-import com.google.common.base.Function;
-import org.jclouds.http.HttpResponse;
-
-import javax.inject.Singleton;
-/**
- * Parses job status from http response
- */
-@Singleton
-public class ParseJobStatus implements Function<HttpResponse, ParseJobStatus.JobStatus> {
- public enum JobStatus {
-
- DONE,
- IN_PROGRESS,
- FAILED,
- UNRECOGNIZED;
-
- public static JobStatus fromString(final String text) {
- if (text != null) {
- for (JobStatus status : JobStatus.values()) {
- if (text.equalsIgnoreCase(status.name())) {
- return status;
- }
- }
- }
- return UNRECOGNIZED;
- }
- }
- public JobStatus apply(final HttpResponse from) {
- if (from.getStatusCode() == 202 ){
- return JobStatus.IN_PROGRESS;
- } else if (from.getStatusCode() == 200 ){
- return JobStatus.DONE;
- } else {
- return JobStatus.FAILED;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/17f7c452/azurecompute-arm/src/main/java/org/jclouds/azurecompute.arm/functions/URIParser.java
----------------------------------------------------------------------
diff --git a/azurecompute-arm/src/main/java/org/jclouds/azurecompute.arm/functions/URIParser.java b/azurecompute-arm/src/main/java/org/jclouds/azurecompute.arm/functions/URIParser.java
deleted file mode 100644
index 78fd10d..0000000
--- a/azurecompute-arm/src/main/java/org/jclouds/azurecompute.arm/functions/URIParser.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.jclouds.azurecompute.arm.functions;
-import com.google.common.base.Function;
-import org.jclouds.http.HttpResponse;
-
-import javax.inject.Singleton;
-
-import java.net.URI;
-/**
- * Parses job status from http response
- */
-@Singleton
-public class URIParser implements Function<HttpResponse, URI> {
- public URI apply(final HttpResponse from) {
- if (from.getStatusCode() == 202 && from.getHeaders().containsKey("Location")){
- String uri = from.getFirstHeaderOrNull("Location");
- return URI.create(uri);
-
- } else if (from.getStatusCode() == 200){
- return null;
- }
- throw new IllegalStateException("did not receive expected response code and header in: " + from);
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/17f7c452/azurecompute-arm/src/main/java/org/jclouds/azurecompute.arm/handlers/AzureComputeErrorHandler.java
----------------------------------------------------------------------
diff --git a/azurecompute-arm/src/main/java/org/jclouds/azurecompute.arm/handlers/AzureComputeErrorHandler.java b/azurecompute-arm/src/main/java/org/jclouds/azurecompute.arm/handlers/AzureComputeErrorHandler.java
deleted file mode 100644
index d5a2d69..0000000
--- a/azurecompute-arm/src/main/java/org/jclouds/azurecompute.arm/handlers/AzureComputeErrorHandler.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.jclouds.azurecompute.arm.handlers;
-
-import java.io.IOException;
-
-import javax.inject.Singleton;
-
-import org.jclouds.http.HttpCommand;
-import org.jclouds.http.HttpErrorHandler;
-import org.jclouds.http.HttpResponse;
-import org.jclouds.http.HttpResponseException;
-import org.jclouds.rest.AuthorizationException;
-import org.jclouds.rest.ResourceNotFoundException;
-import org.jclouds.util.Closeables2;
-import org.jclouds.util.Strings2;
-
-/**
- * This will parse and set an appropriate exception on the command object.
- */
-@Singleton
-public class AzureComputeErrorHandler implements HttpErrorHandler {
-
- @Override
- public void handleError(final HttpCommand command, final HttpResponse response) {
- // it is important to always read fully and close streams
- String message = parseMessage(response);
- Exception exception = message == null
- ? new HttpResponseException(command, response)
- : new HttpResponseException(command, response, message);
- try {
- message = message == null
- ? String.format("%s -> %s", command.getCurrentRequest().getRequestLine(), response.getStatusLine())
- : message;
- switch (response.getStatusCode()) {
- case 400:
- exception = new IllegalArgumentException(message, exception);
- break;
- case 401:
- case 403:
- exception = new AuthorizationException(message, exception);
- break;
-
- case 404:
- if (!command.getCurrentRequest().getMethod().equals("DELETE")) {
- exception = new ResourceNotFoundException(message, exception);
- }
- break;
-
- case 409:
- exception = new IllegalStateException(message, exception);
- break;
-
- default:
- }
- } finally {
- Closeables2.closeQuietly(response.getPayload());
- command.setException(exception);
- }
- }
-
- public String parseMessage(final HttpResponse response) {
- if (response.getPayload() == null) {
- return null;
- }
- try {
- return Strings2.toStringAndClose(response.getPayload().openStream());
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/17f7c452/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/AzureComputeApi.java
----------------------------------------------------------------------
diff --git a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/AzureComputeApi.java b/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/AzureComputeApi.java
new file mode 100644
index 0000000..a897c9a
--- /dev/null
+++ b/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/AzureComputeApi.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.jclouds.azurecompute.arm;
+
+import java.io.Closeable;
+
+import org.jclouds.azurecompute.arm.features.JobApi;
+import org.jclouds.azurecompute.arm.features.ResourceGroupApi;
+import org.jclouds.rest.annotations.Delegate;
+
+/**
+ * The Azure Resource Manager API is a REST API for managing your services and deployments.
+ * <p/>
+ *
+ * @see <a href="https://msdn.microsoft.com/en-us/library/azure/dn790568.aspx" >doc</a>
+ */
+public interface AzureComputeApi extends Closeable {
+
+ /**
+ * The Azure Resource Manager API includes operations for managing resource groups in your subscription.
+ *
+ * @see <a href="https://msdn.microsoft.com/en-us/library/azure/dn790546.aspx">docs</a>
+ */
+ @Delegate
+ ResourceGroupApi getResourceGroupApi();
+
+ @Delegate
+ JobApi getJobApi();
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/17f7c452/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/AzureComputeProviderMetadata.java
----------------------------------------------------------------------
diff --git a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/AzureComputeProviderMetadata.java b/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/AzureComputeProviderMetadata.java
new file mode 100644
index 0000000..958a6dd
--- /dev/null
+++ b/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/AzureComputeProviderMetadata.java
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.jclouds.azurecompute.arm;
+
+import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.OPERATION_POLL_INITIAL_PERIOD;
+import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.OPERATION_POLL_MAX_PERIOD;
+import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.OPERATION_TIMEOUT;
+import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.TCP_RULE_FORMAT;
+import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.TCP_RULE_REGEXP;
+import static org.jclouds.oauth.v2.config.CredentialType.CLIENT_CREDENTIALS_SECRET;
+import static org.jclouds.oauth.v2.config.OAuthProperties.RESOURCE;
+import static org.jclouds.oauth.v2.config.OAuthProperties.CREDENTIAL_TYPE;
+
+import java.net.URI;
+import java.util.Properties;
+import org.jclouds.providers.ProviderMetadata;
+import org.jclouds.providers.internal.BaseProviderMetadata;
+
+import com.google.auto.service.AutoService;
+
+@AutoService(ProviderMetadata.class)
+public class AzureComputeProviderMetadata extends BaseProviderMetadata {
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ @Override
+ public Builder toBuilder() {
+ return builder().fromProviderMetadata(this);
+ }
+
+ public AzureComputeProviderMetadata() {
+ super(builder());
+ }
+
+ public static Properties defaultProperties() {
+ final Properties properties = AzureManagementApiMetadata.defaultProperties();
+ properties.setProperty(OPERATION_TIMEOUT, "60000");
+ properties.setProperty(OPERATION_POLL_INITIAL_PERIOD, "5");
+ properties.setProperty(OPERATION_POLL_MAX_PERIOD, "15");
+ properties.setProperty(TCP_RULE_FORMAT, "tcp_%s-%s");
+ properties.setProperty(TCP_RULE_REGEXP, "tcp_\\d{1,5}-\\d{1,5}");
+ properties.put(RESOURCE, "https://management.azure.com");
+ properties.put(CREDENTIAL_TYPE, CLIENT_CREDENTIALS_SECRET.toString());
+ return properties;
+ }
+
+ public AzureComputeProviderMetadata(final Builder builder) {
+ super(builder);
+ }
+
+ public static class Builder extends BaseProviderMetadata.Builder {
+
+ protected Builder() {
+ super();
+ id("azurecompute-arm")
+ .name("Azure Resource Management")
+ .apiMetadata(new AzureManagementApiMetadata())
+ .endpoint("https://management.azure.com/subscriptions/SUBSCRIPTION_ID")
+ .homepage(URI.create("https://www.windowsazure.com/"))
+ .console(URI.create("https://windows.azure.com/default.aspx"))
+ .linkedServices("azureblob")
+ .defaultProperties(AzureComputeProviderMetadata.defaultProperties());
+ }
+
+ @Override
+ public AzureComputeProviderMetadata build() {
+ return new AzureComputeProviderMetadata(this);
+ }
+
+ @Override
+ public Builder fromProviderMetadata(final ProviderMetadata providerMetadata) {
+ super.fromProviderMetadata(providerMetadata);
+ return this;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/17f7c452/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/AzureManagementApiMetadata.java
----------------------------------------------------------------------
diff --git a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/AzureManagementApiMetadata.java b/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/AzureManagementApiMetadata.java
new file mode 100644
index 0000000..9a3292c
--- /dev/null
+++ b/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/AzureManagementApiMetadata.java
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.jclouds.azurecompute.arm;
+
+import static org.jclouds.reflect.Reflection2.typeToken;
+
+import java.net.URI;
+import java.util.Properties;
+
+import org.jclouds.apis.ApiMetadata;
+import org.jclouds.azurecompute.arm.config.AzureComputeHttpApiModule;
+import org.jclouds.compute.ComputeServiceContext;
+import org.jclouds.rest.internal.BaseHttpApiMetadata;
+import org.jclouds.oauth.v2.config.OAuthModule;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.inject.Module;
+import org.jclouds.http.okhttp.config.OkHttpCommandExecutorServiceModule;
+
+/**
+ * Implementation of {@link ApiMetadata} for Microsoft Azure Resource Manager REST API
+ */
+public class AzureManagementApiMetadata extends BaseHttpApiMetadata<AzureComputeApi> {
+
+ @Override
+ public Builder toBuilder() {
+ return new Builder().fromApiMetadata(this);
+ }
+
+ public AzureManagementApiMetadata() {
+ this(new Builder());
+ }
+
+ protected AzureManagementApiMetadata(final Builder builder) {
+ super(builder);
+ }
+
+ public static Properties defaultProperties() {
+ final Properties properties = BaseHttpApiMetadata.defaultProperties();
+ return properties;
+ }
+
+ public static class Builder extends BaseHttpApiMetadata.Builder<AzureComputeApi, Builder> {
+
+ protected Builder() {
+ super();
+
+ id("azurecompute-arm")
+ .name("Microsoft Azure Resource Manager REST API")
+ .identityName("Azure Service Principal Application Id")
+ .credentialName("Azure Service Principal Application Password")
+ .endpointName("Resource Manager Endpoint ending in your Subscription Id")
+ .documentation(URI.create("https://msdn.microsoft.com/en-us/library/azure/dn790568.aspx"))
+ .defaultProperties(AzureManagementApiMetadata.defaultProperties())
+ .view(typeToken(ComputeServiceContext.class))
+ .defaultModules(ImmutableSet.<Class<? extends Module>>builder()
+ .add(OAuthModule.class)
+ .add(OkHttpCommandExecutorServiceModule.class)
+ .add(AzureComputeHttpApiModule.class).build());
+ }
+
+ @Override
+ public AzureManagementApiMetadata build() {
+ return new AzureManagementApiMetadata(this);
+ }
+
+ @Override
+ protected Builder self() {
+ return this;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/17f7c452/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/config/AzureComputeHttpApiModule.java
----------------------------------------------------------------------
diff --git a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/config/AzureComputeHttpApiModule.java b/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/config/AzureComputeHttpApiModule.java
new file mode 100644
index 0000000..eb6a6d6
--- /dev/null
+++ b/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/config/AzureComputeHttpApiModule.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.jclouds.azurecompute.arm.config;
+import org.jclouds.azurecompute.arm.AzureComputeApi;
+import org.jclouds.azurecompute.arm.handlers.AzureComputeErrorHandler;
+import org.jclouds.http.HttpErrorHandler;
+import org.jclouds.http.annotation.ClientError;
+import org.jclouds.http.annotation.Redirection;
+import org.jclouds.http.annotation.ServerError;
+import org.jclouds.location.suppliers.ImplicitLocationSupplier;
+import org.jclouds.location.suppliers.implicit.OnlyLocationOrFirstRegionOptionallyMatchingRegionId;
+
+import org.jclouds.rest.ConfiguresHttpApi;
+import org.jclouds.rest.config.HttpApiModule;
+import org.jclouds.oauth.v2.config.OAuthScopes;
+
+import com.google.inject.Scopes;
+
+@ConfiguresHttpApi
+public class AzureComputeHttpApiModule extends HttpApiModule<AzureComputeApi> {
+
+ @Override
+ protected void bindErrorHandlers() {
+ bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(AzureComputeErrorHandler.class);
+ bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(AzureComputeErrorHandler.class);
+ bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(AzureComputeErrorHandler.class);
+ }
+
+ @Override
+ protected void installLocations() {
+ super.installLocations();
+ bind(ImplicitLocationSupplier.class).
+ to(OnlyLocationOrFirstRegionOptionallyMatchingRegionId.class).
+ in(Scopes.SINGLETON);
+ }
+
+ @Override
+ protected void configure() {
+ install(new AzureComputeParserModule());
+ super.configure();
+ bind(OAuthScopes.class).toInstance(OAuthScopes.NoScopes.create());
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/17f7c452/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/config/AzureComputeParserModule.java
----------------------------------------------------------------------
diff --git a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/config/AzureComputeParserModule.java b/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/config/AzureComputeParserModule.java
new file mode 100644
index 0000000..396f5be
--- /dev/null
+++ b/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/config/AzureComputeParserModule.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.jclouds.azurecompute.arm.config;
+
+import org.jclouds.json.config.GsonModule;
+
+import com.google.inject.AbstractModule;
+
+public class AzureComputeParserModule extends AbstractModule {
+
+ @Override
+ protected void configure() {
+ bind(GsonModule.DateAdapter.class).to(GsonModule.Iso8601DateAdapter.class);
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/17f7c452/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/config/AzureComputeProperties.java
----------------------------------------------------------------------
diff --git a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/config/AzureComputeProperties.java b/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/config/AzureComputeProperties.java
new file mode 100644
index 0000000..e16b5da
--- /dev/null
+++ b/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/config/AzureComputeProperties.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.jclouds.azurecompute.arm.config;
+
+/**
+ * Configuration properties and constants used in Azure Resource Manager connections.
+ */
+public class AzureComputeProperties {
+
+ public static final String OPERATION_TIMEOUT = "jclouds.azurecompute.arm.operation.timeout";
+
+ public static final String OPERATION_POLL_INITIAL_PERIOD = "jclouds.azurecompute.arm.operation.poll.initial.period";
+
+ public static final String OPERATION_POLL_MAX_PERIOD = "jclouds.azurecompute.arm.operation.poll.max.period";
+
+ public static final String TCP_RULE_FORMAT = "jclouds.azurecompute.arm.tcp.rule.format";
+
+ public static final String TCP_RULE_REGEXP = "jclouds.azurecompute.arm.tcp.rule.regexp";
+
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/17f7c452/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/ResourceGroup.java
----------------------------------------------------------------------
diff --git a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/ResourceGroup.java b/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/ResourceGroup.java
new file mode 100644
index 0000000..1be93ab
--- /dev/null
+++ b/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/ResourceGroup.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.jclouds.azurecompute.arm.domain;
+
+import com.google.auto.value.AutoValue;
+import java.util.Map;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.json.SerializedNames;
+import com.google.common.collect.ImmutableMap;
+
+
+@AutoValue
+public abstract class ResourceGroup {
+
+ @AutoValue
+ public abstract static class ResourceGroupProperties{
+ @Nullable
+ public abstract String provisioningState();
+
+ @SerializedNames({"provisioningState"})
+ public static ResourceGroupProperties create(final String provisioningState) {
+ return new AutoValue_ResourceGroup_ResourceGroupProperties(provisioningState);
+ }
+ }
+
+ public abstract String id();
+ public abstract String name();
+ public abstract String location();
+ @Nullable
+ public abstract Map<String, String> tags();
+ public abstract ResourceGroupProperties properties();
+
+ @SerializedNames({"id", "name", "location", "tags", "properties"})
+ public static ResourceGroup create(String id, String name, String location, @Nullable Map<String, String> tags, ResourceGroupProperties properties) {
+ return new AutoValue_ResourceGroup(id, name, location, tags == null ? ImmutableMap.<String, String>builder().build() : ImmutableMap.copyOf(tags), properties);
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/17f7c452/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/features/JobApi.java
----------------------------------------------------------------------
diff --git a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/features/JobApi.java b/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/features/JobApi.java
new file mode 100644
index 0000000..7dd75a9
--- /dev/null
+++ b/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/features/JobApi.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.jclouds.azurecompute.arm.features;
+import java.io.Closeable;
+import java.net.URI;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.GET;
+import org.jclouds.oauth.v2.filters.OAuthFilter;
+import org.jclouds.rest.annotations.EndpointParam;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.ResponseParser;
+import org.jclouds.azurecompute.arm.functions.ParseJobStatus;
+import org.jclouds.azurecompute.arm.functions.ParseJobStatus.JobStatus;
+
+/**
+ * The Azure Resource Manager API checks for job status and progress.
+ */
+
+@RequestFilters(OAuthFilter.class)
+@Consumes(MediaType.APPLICATION_JSON)
+public interface JobApi extends Closeable{
+ @GET
+ @ResponseParser(ParseJobStatus.class)
+ JobStatus jobStatus(@EndpointParam URI jobURI);
+}
+
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/17f7c452/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/features/ResourceGroupApi.java
----------------------------------------------------------------------
diff --git a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/features/ResourceGroupApi.java b/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/features/ResourceGroupApi.java
new file mode 100644
index 0000000..1ad47d9
--- /dev/null
+++ b/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/features/ResourceGroupApi.java
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.jclouds.azurecompute.arm.features;
+import java.io.Closeable;
+import java.net.URI;
+import java.util.List;
+import java.util.Map;
+import javax.inject.Named;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+
+import org.jclouds.Fallbacks.EmptyListOnNotFoundOr404;
+import org.jclouds.Fallbacks.NullOnNotFoundOr404;
+import org.jclouds.azurecompute.arm.domain.ResourceGroup;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.oauth.v2.filters.OAuthFilter;
+import org.jclouds.rest.annotations.QueryParams;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.SelectJson;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.MapBinder;
+import org.jclouds.rest.annotations.PayloadParam;
+import org.jclouds.rest.annotations.PATCH;
+import org.jclouds.rest.annotations.ResponseParser;
+import org.jclouds.azurecompute.arm.functions.URIParser;
+
+
+import org.jclouds.rest.binders.BindToJsonPayload;
+
+/**
+ * The Azure Resource Manager API includes operations for managing resource groups in your subscription.
+ *
+ * @see <a href="https://msdn.microsoft.com/en-us/library/azure/dn790546.aspx">docs</a>
+ */
+@Path("/resourcegroups")
+
+@QueryParams(keys = "api-version", values = "2015-01-01")
+@RequestFilters(OAuthFilter.class)
+@Consumes(MediaType.APPLICATION_JSON)
+public interface ResourceGroupApi extends Closeable{
+
+ @Named("resourcegroup:list")
+ @SelectJson("value")
+ @GET
+ @Fallback(EmptyListOnNotFoundOr404.class)
+ List<ResourceGroup> list();
+
+ @Named("resourcegroup:create")
+ @PUT
+ @Path("/{name}")
+ @Produces(MediaType.APPLICATION_JSON)
+ @MapBinder(BindToJsonPayload.class)
+ ResourceGroup create(@PathParam("name") String name, @PayloadParam("location") String location, @Nullable @PayloadParam("tags")Map<String, String> tags);
+
+ @Named("resourcegroup:get")
+ @GET
+ @Path("/{name}")
+ @Fallback(NullOnNotFoundOr404.class)
+ @Nullable
+ ResourceGroup get(@PathParam("name") String name);
+
+ @Named("resourcegroup:update")
+ @PATCH
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/{name}")
+ @MapBinder(BindToJsonPayload.class)
+ ResourceGroup update(@PathParam("name") String name, @Nullable @PayloadParam("tags")Map<String, String> tags);
+
+ @Named("resourcegroup:delete")
+ @DELETE
+ @ResponseParser(URIParser.class)
+ @Path("/{name}")
+ @Fallback(NullOnNotFoundOr404.class)
+ URI delete(@PathParam("name") String name);
+}
+
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/17f7c452/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/functions/ParseJobStatus.java
----------------------------------------------------------------------
diff --git a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/functions/ParseJobStatus.java b/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/functions/ParseJobStatus.java
new file mode 100644
index 0000000..f39db90
--- /dev/null
+++ b/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/functions/ParseJobStatus.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.jclouds.azurecompute.arm.functions;
+import com.google.common.base.Function;
+import org.jclouds.http.HttpResponse;
+
+import javax.inject.Singleton;
+/**
+ * Parses job status from http response
+ */
+@Singleton
+public class ParseJobStatus implements Function<HttpResponse, ParseJobStatus.JobStatus> {
+ public enum JobStatus {
+
+ DONE,
+ IN_PROGRESS,
+ FAILED,
+ UNRECOGNIZED;
+
+ public static JobStatus fromString(final String text) {
+ if (text != null) {
+ for (JobStatus status : JobStatus.values()) {
+ if (text.equalsIgnoreCase(status.name())) {
+ return status;
+ }
+ }
+ }
+ return UNRECOGNIZED;
+ }
+ }
+ public JobStatus apply(final HttpResponse from) {
+ if (from.getStatusCode() == 202 ){
+ return JobStatus.IN_PROGRESS;
+ } else if (from.getStatusCode() == 200 ){
+ return JobStatus.DONE;
+ } else {
+ return JobStatus.FAILED;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/17f7c452/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/functions/URIParser.java
----------------------------------------------------------------------
diff --git a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/functions/URIParser.java b/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/functions/URIParser.java
new file mode 100644
index 0000000..78fd10d
--- /dev/null
+++ b/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/functions/URIParser.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.jclouds.azurecompute.arm.functions;
+import com.google.common.base.Function;
+import org.jclouds.http.HttpResponse;
+
+import javax.inject.Singleton;
+
+import java.net.URI;
+/**
+ * Parses job status from http response
+ */
+@Singleton
+public class URIParser implements Function<HttpResponse, URI> {
+ public URI apply(final HttpResponse from) {
+ if (from.getStatusCode() == 202 && from.getHeaders().containsKey("Location")){
+ String uri = from.getFirstHeaderOrNull("Location");
+ return URI.create(uri);
+
+ } else if (from.getStatusCode() == 200){
+ return null;
+ }
+ throw new IllegalStateException("did not receive expected response code and header in: " + from);
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/17f7c452/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/handlers/AzureComputeErrorHandler.java
----------------------------------------------------------------------
diff --git a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/handlers/AzureComputeErrorHandler.java b/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/handlers/AzureComputeErrorHandler.java
new file mode 100644
index 0000000..d5a2d69
--- /dev/null
+++ b/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/handlers/AzureComputeErrorHandler.java
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.jclouds.azurecompute.arm.handlers;
+
+import java.io.IOException;
+
+import javax.inject.Singleton;
+
+import org.jclouds.http.HttpCommand;
+import org.jclouds.http.HttpErrorHandler;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.http.HttpResponseException;
+import org.jclouds.rest.AuthorizationException;
+import org.jclouds.rest.ResourceNotFoundException;
+import org.jclouds.util.Closeables2;
+import org.jclouds.util.Strings2;
+
+/**
+ * This will parse and set an appropriate exception on the command object.
+ */
+@Singleton
+public class AzureComputeErrorHandler implements HttpErrorHandler {
+
+ @Override
+ public void handleError(final HttpCommand command, final HttpResponse response) {
+ // it is important to always read fully and close streams
+ String message = parseMessage(response);
+ Exception exception = message == null
+ ? new HttpResponseException(command, response)
+ : new HttpResponseException(command, response, message);
+ try {
+ message = message == null
+ ? String.format("%s -> %s", command.getCurrentRequest().getRequestLine(), response.getStatusLine())
+ : message;
+ switch (response.getStatusCode()) {
+ case 400:
+ exception = new IllegalArgumentException(message, exception);
+ break;
+ case 401:
+ case 403:
+ exception = new AuthorizationException(message, exception);
+ break;
+
+ case 404:
+ if (!command.getCurrentRequest().getMethod().equals("DELETE")) {
+ exception = new ResourceNotFoundException(message, exception);
+ }
+ break;
+
+ case 409:
+ exception = new IllegalStateException(message, exception);
+ break;
+
+ default:
+ }
+ } finally {
+ Closeables2.closeQuietly(response.getPayload());
+ command.setException(exception);
+ }
+ }
+
+ public String parseMessage(final HttpResponse response) {
+ if (response.getPayload() == null) {
+ return null;
+ }
+ try {
+ return Strings2.toStringAndClose(response.getPayload().openStream());
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/17f7c452/azurecompute-arm/src/test/java/org/jclouds/azurecompute.arm/AzureComputeProviderMetadataTest.java
----------------------------------------------------------------------
diff --git a/azurecompute-arm/src/test/java/org/jclouds/azurecompute.arm/AzureComputeProviderMetadataTest.java b/azurecompute-arm/src/test/java/org/jclouds/azurecompute.arm/AzureComputeProviderMetadataTest.java
deleted file mode 100644
index 2003f9a..0000000
--- a/azurecompute-arm/src/test/java/org/jclouds/azurecompute.arm/AzureComputeProviderMetadataTest.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.jclouds.azurecompute.arm;
-
-import org.jclouds.providers.internal.BaseProviderMetadataTest;
-import org.testng.annotations.Test;
-
-@Test(groups = "unit", testName = "AzureManagementProviderMetadataTest")
-public class AzureComputeProviderMetadataTest extends BaseProviderMetadataTest {
-
- public AzureComputeProviderMetadataTest() {
- super(new AzureComputeProviderMetadata(), new AzureManagementApiMetadata());
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/17f7c452/azurecompute-arm/src/test/java/org/jclouds/azurecompute.arm/features/JobApiMockTest.java
----------------------------------------------------------------------
diff --git a/azurecompute-arm/src/test/java/org/jclouds/azurecompute.arm/features/JobApiMockTest.java b/azurecompute-arm/src/test/java/org/jclouds/azurecompute.arm/features/JobApiMockTest.java
deleted file mode 100644
index ba87ca5..0000000
--- a/azurecompute-arm/src/test/java/org/jclouds/azurecompute.arm/features/JobApiMockTest.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.jclouds.azurecompute.arm.features;
-
-import java.io.IOException;
-import java.net.URI;
-import org.jclouds.azurecompute.arm.functions.ParseJobStatus.JobStatus;
-import org.jclouds.azurecompute.arm.internal.BaseAzureComputeApiMockTest;
-import org.testng.annotations.Test;
-
-import static org.testng.Assert.assertEquals;
-
-@Test(groups = "unit", testName = "JobApiMockTest", singleThreaded = true)
-public class JobApiMockTest extends BaseAzureComputeApiMockTest {
-
- final String requestUrl = "/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1SVEVTVC1DRU5UUkFMVVMiLCJqb2JMb2NhdGlvbiI6ImNlbnRyYWx1cyJ9?api-version=2014-04-01";
-
- public void testGetJobStatus() throws IOException, InterruptedException {
- server.enqueue(response200());
-
- JobStatus status = api.getJobApi().jobStatus(URI.create(requestUrl));
-
- assertEquals(status, JobStatus.DONE);
-
- assertSent(server, "GET", requestUrl);
- }
-
- public void testGetJobStatusInProgress() throws InterruptedException {
- server.enqueue(response202WithHeader());
-
- JobStatus status = api.getJobApi().jobStatus(URI.create(requestUrl));
-
- assertEquals(status, JobStatus.IN_PROGRESS);
-
- assertSent(server, "GET", requestUrl);
- }
-
- public void testGetJobStatusFailed() throws InterruptedException {
- server.enqueue(jsonResponse("/resourcegroup.json").setStatus("HTTP/1.1 204 No Content"));
-
- JobStatus status = api.getJobApi().jobStatus(URI.create(requestUrl));
-
- assertEquals(status, JobStatus.FAILED);
-
- assertSent(server, "GET", requestUrl);
- }
-
-}