Issue 657:ApiMetadata

This commit is contained in:
Adrian Cole 2012-04-01 18:43:31 -07:00
parent 358737c70f
commit 764e0907f7
201 changed files with 5898 additions and 4040 deletions

View File

@ -0,0 +1,67 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.atmos;
import java.net.URI;
import org.jclouds.apis.ApiMetadata;
import org.jclouds.apis.ApiType;
import org.jclouds.apis.BaseApiMetadata;
/**
* Implementation of {@link ApiMetadata} for EMC's Atmos API.
*
* @author Adrian Cole
*/
public class AtmosApiMetadata extends BaseApiMetadata {
public AtmosApiMetadata() {
this(builder()
.id("atmos")
.type(ApiType.BLOBSTORE)
.name("EMC's Atmos API")
.identityName("Subtenant ID (UID)")
.credentialName("Shared Secret")
.documentation(URI.create("https://community.emc.com/docs/DOC-10508")));
}
// below are so that we can reuse builders, toString, hashCode, etc.
// we have to set concrete classes here, as our base class cannot be
// concrete due to serviceLoader
protected AtmosApiMetadata(Builder<?> builder) {
super(builder);
}
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
@Override
public AtmosApiMetadata build() {
return new AtmosApiMetadata(this);
}
}
public static ConcreteBuilder builder() {
return new ConcreteBuilder();
}
@Override
public ConcreteBuilder toBuilder() {
return builder().fromApiMetadata(this);
}
}

View File

@ -0,0 +1 @@
org.jclouds.atmos.AtmosApiMetadata

View File

@ -0,0 +1,35 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.atmos;
import org.jclouds.apis.ApiType;
import org.jclouds.apis.BaseApiMetadataTest;
import org.testng.annotations.Test;
/**
*
* @author Adrian Cole
*/
@Test(groups = "unit", testName = "AtmosApiMetadataTest")
public class AtmosApiMetadataTest extends BaseApiMetadataTest {
public AtmosApiMetadataTest() {
super(new AtmosApiMetadata(), ApiType.BLOBSTORE);
}
}

View File

@ -1,47 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.atmos;
import org.jclouds.blobstore.util.BlobStoreUtils;
import org.jclouds.rest.Providers;
import org.testng.annotations.Test;
import com.google.common.collect.Iterables;
/**
*
* @author Adrian Cole
*
*/
@Test(groups = "unit")
public class ProvidersInPropertiesTest {
@Test
public void testSupportedProviders() {
Iterable<String> providers = Providers.getSupportedProviders();
assert Iterables.contains(providers, "atmos") : providers;
}
@Test
public void testSupportedBlobStoreProviders() {
Iterable<String> providers = BlobStoreUtils.getSupportedProviders();
assert Iterables.contains(providers, "atmos") : providers;
}
}

View File

@ -0,0 +1,67 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.byon;
import java.net.URI;
import org.jclouds.apis.ApiMetadata;
import org.jclouds.apis.ApiType;
import org.jclouds.apis.BaseApiMetadata;
/**
* Implementation of {@link ApiMetadata} for jclouds BYON API
*
* @author Adrian Cole
*/
public class BYONApiMetadata extends BaseApiMetadata {
public BYONApiMetadata() {
this(builder()
.id("byon")
.type(ApiType.COMPUTE)
.name("Bring Your Own Node (BYON) API")
.identityName("Unused")
.documentation(URI.create("https://github.com/jclouds/jclouds/tree/master/apis/byon")));
}
// below are so that we can reuse builders, toString, hashCode, etc.
// we have to set concrete classes here, as our base class cannot be
// concrete due to serviceLoader
protected BYONApiMetadata(Builder<?> builder) {
super(builder);
}
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
@Override
public BYONApiMetadata build() {
return new BYONApiMetadata(this);
}
}
public static ConcreteBuilder builder() {
return new ConcreteBuilder();
}
@Override
public ConcreteBuilder toBuilder() {
return builder().fromApiMetadata(this);
}
}

View File

@ -0,0 +1 @@
org.jclouds.byon.BYONApiMetadata

View File

@ -0,0 +1,35 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.byon;
import org.jclouds.apis.ApiType;
import org.jclouds.apis.BaseApiMetadataTest;
import org.testng.annotations.Test;
/**
*
* @author Adrian Cole
*/
@Test(groups = "unit", testName = "BYONApiMetadataTest")
public class BYONApiMetadataTest extends BaseApiMetadataTest {
public BYONApiMetadataTest() {
super(new BYONApiMetadata(), ApiType.COMPUTE);
}
}

View File

@ -0,0 +1,68 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.cloudfiles;
import java.net.URI;
import org.jclouds.apis.ApiMetadata;
import org.jclouds.apis.ApiType;
import org.jclouds.apis.BaseApiMetadata;
/**
* Implementation of {@link ApiMetadata} for Rackspace Cloud Files API
*
* @author Dan Lo Bianco
*/
public class CloudFilesApiMetadata extends BaseApiMetadata {
public CloudFilesApiMetadata() {
this(builder()
.id("cloudfiles")
.type(ApiType.BLOBSTORE)
.name("Rackspace Cloud Files API")
.identityName("Username")
.credentialName("API Key")
.documentation(URI.create("http://docs.rackspacecloud.com/files/api/v1/cfdevguide_d5/content/ch01.html")));
}
// below are so that we can reuse builders, toString, hashCode, etc.
// we have to set concrete classes here, as our base class cannot be
// concrete due to serviceLoader
protected CloudFilesApiMetadata(Builder<?> builder) {
super(builder);
}
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
@Override
public CloudFilesApiMetadata build() {
return new CloudFilesApiMetadata(this);
}
}
public static ConcreteBuilder builder() {
return new ConcreteBuilder();
}
@Override
public ConcreteBuilder toBuilder() {
return builder().fromApiMetadata(this);
}
}

View File

@ -1,69 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.cloudfiles;
import java.net.URI;
import org.jclouds.providers.BaseProviderMetadata;
import org.jclouds.providers.ProviderMetadata;
/**
* Common implementation of {@link org.jclouds.types.ProviderMetadata} for Rackspace Cloud Files
*
* @author Dan Lo Bianco
*/
public abstract class CloudFilesProviderMetadata extends BaseProviderMetadata {
public CloudFilesProviderMetadata() {
super();
}
/**
* {@inheritDoc}
*/
@Override
public String getType() {
return ProviderMetadata.BLOBSTORE_TYPE;
}
/**
* {@inheritDoc}
*/
@Override
public String getIdentityName() {
return "Username";
}
/**
* {@inheritDoc}
*/
@Override
public String getCredentialName() {
return "API Key";
}
/**
* {@inheritDoc}
*/
@Override
public URI getApiDocumentation() {
return URI.create("http://docs.rackspacecloud.com/files/api/v1/cfdevguide_d5/content/ch01.html");
}
}

View File

@ -0,0 +1 @@
org.jclouds.cloudfiles.CloudFilesApiMetadata

View File

@ -0,0 +1,35 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.cloudfiles;
import org.jclouds.apis.ApiType;
import org.jclouds.apis.BaseApiMetadataTest;
import org.testng.annotations.Test;
/**
*
* @author Adrian Cole
*/
@Test(groups = "unit", testName = "CloudFilesApiMetadataTest")
public class CloudFilesApiMetadataTest extends BaseApiMetadataTest {
public CloudFilesApiMetadataTest() {
super(new CloudFilesApiMetadata(), ApiType.BLOBSTORE);
}
}

View File

@ -0,0 +1,68 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.cloudloadbalancers;
import java.net.URI;
import org.jclouds.apis.ApiMetadata;
import org.jclouds.apis.ApiType;
import org.jclouds.apis.BaseApiMetadata;
/**
* Implementation of {@link ApiMetadata} for Rackspace Cloud Load Balancers API
*
* @author Dan Lo Bianco
*/
public class CloudLoadBalancersApiMetadata extends BaseApiMetadata {
public CloudLoadBalancersApiMetadata() {
this(builder()
.id("cloudloadbalancers")
.type(ApiType.LOADBALANCER)
.name("Rackspace Cloud Load Balancers API")
.identityName("Username")
.credentialName("API Key")
.documentation(URI.create("http://docs.rackspacecloud.com/loadbalancers/api/v1.0/clb-devguide/content/ch01.html")));
}
// below are so that we can reuse builders, toString, hashCode, etc.
// we have to set concrete classes here, as our base class cannot be
// concrete due to serviceLoader
protected CloudLoadBalancersApiMetadata(Builder<?> builder) {
super(builder);
}
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
@Override
public CloudLoadBalancersApiMetadata build() {
return new CloudLoadBalancersApiMetadata(this);
}
}
public static ConcreteBuilder builder() {
return new ConcreteBuilder();
}
@Override
public ConcreteBuilder toBuilder() {
return builder().fromApiMetadata(this);
}
}

View File

@ -1,69 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.cloudloadbalancers;
import java.net.URI;
import org.jclouds.providers.BaseProviderMetadata;
import org.jclouds.providers.ProviderMetadata;
/**
* Common implementation of {@link org.jclouds.types.ProviderMetadata} for Rackspace Cloud LoadBalancers.
*
* @author Dan Lo Bianco
*/
public abstract class CloudLoadBalancersProviderMetadata extends BaseProviderMetadata {
public CloudLoadBalancersProviderMetadata() {
super();
}
/**
* {@inheritDoc}
*/
@Override
public String getType() {
return ProviderMetadata.LOADBALANCER_TYPE;
}
/**
* {@inheritDoc}
*/
@Override
public String getIdentityName() {
return "Username";
}
/**
* {@inheritDoc}
*/
@Override
public String getCredentialName() {
return "API Key";
}
/**
* {@inheritDoc}
*/
@Override
public URI getApiDocumentation() {
return URI.create("http://docs.rackspacecloud.com/loadbalancers/api/v1.0/clb-devguide/content/ch01.html");
}
}

View File

@ -0,0 +1 @@
org.jclouds.cloudloadbalancers.CloudLoadBalancersApiMetadata

View File

@ -0,0 +1,35 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.cloudloadbalancers;
import org.jclouds.apis.ApiType;
import org.jclouds.apis.BaseApiMetadataTest;
import org.testng.annotations.Test;
/**
*
* @author Adrian Cole
*/
@Test(groups = "unit", testName = "CloudLoadBalancersApiMetadataTest")
public class CloudLoadBalancersApiMetadataTest extends BaseApiMetadataTest {
public CloudLoadBalancersApiMetadataTest() {
super(new CloudLoadBalancersApiMetadata(), ApiType.LOADBALANCER);
}
}

View File

@ -0,0 +1,68 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.cloudservers;
import java.net.URI;
import org.jclouds.apis.ApiMetadata;
import org.jclouds.apis.ApiType;
import org.jclouds.apis.BaseApiMetadata;
/**
* Implementation of {@link ApiMetadata} for Rackspace Cloud Servers API
*
* @author Adrian Cole
*/
public class CloudServersApiMetadata extends BaseApiMetadata {
public CloudServersApiMetadata() {
this(builder()
.id("cloudservers")
.type(ApiType.COMPUTE)
.name("Rackspace Cloud Servers API")
.identityName("Username")
.credentialName("API Key")
.documentation(URI.create("http://docs.rackspacecloud.com/servers/api/v1.0/cs-devguide/content/ch01.html")));
}
// below are so that we can reuse builders, toString, hashCode, etc.
// we have to set concrete classes here, as our base class cannot be
// concrete due to serviceLoader
protected CloudServersApiMetadata(Builder<?> builder) {
super(builder);
}
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
@Override
public CloudServersApiMetadata build() {
return new CloudServersApiMetadata(this);
}
}
public static ConcreteBuilder builder() {
return new ConcreteBuilder();
}
@Override
public ConcreteBuilder toBuilder() {
return builder().fromApiMetadata(this);
}
}

View File

@ -1,69 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.cloudservers;
import java.net.URI;
import org.jclouds.providers.BaseProviderMetadata;
import org.jclouds.providers.ProviderMetadata;
/**
* Common implementation of {@link org.jclouds.types.ProviderMetadata} for Rackspace Cloud Servers.
*
* @author Dan Lo Bianco
*/
public abstract class CloudServersProviderMetadata extends BaseProviderMetadata {
public CloudServersProviderMetadata() {
super();
}
/**
* {@inheritDoc}
*/
@Override
public String getType() {
return ProviderMetadata.COMPUTE_TYPE;
}
/**
* {@inheritDoc}
*/
@Override
public String getIdentityName() {
return "Username";
}
/**
* {@inheritDoc}
*/
@Override
public String getCredentialName() {
return "API Key";
}
/**
* {@inheritDoc}
*/
@Override
public URI getApiDocumentation() {
return URI.create("http://docs.rackspacecloud.com/servers/api/v1.0/cs-devguide/content/ch01.html");
}
}

View File

@ -0,0 +1 @@
org.jclouds.cloudservers.CloudServersApiMetadata

View File

@ -16,25 +16,20 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package org.jclouds.aws.simpledb; package org.jclouds.cloudservers;
import org.jclouds.rest.Providers; import org.jclouds.apis.ApiType;
import org.jclouds.apis.BaseApiMetadataTest;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.collect.Iterables;
/** /**
* *
* @author Adrian Cole * @author Adrian Cole
*
*/ */
@Test(groups = "unit") @Test(groups = "unit", testName = "CloudServersApiMetadataTest")
public class ProvidersInPropertiesTest { public class CloudServersApiMetadataTest extends BaseApiMetadataTest {
@Test public CloudServersApiMetadataTest() {
public void testSupportedProviders() { super(new CloudServersApiMetadata(), ApiType.COMPUTE);
Iterable<String> providers = Providers.getSupportedProviders();
assert Iterables.contains(providers, "aws-simpledb") : providers;
} }
} }

View File

@ -0,0 +1,68 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.cloudsigma;
import java.net.URI;
import org.jclouds.apis.ApiMetadata;
import org.jclouds.apis.ApiType;
import org.jclouds.apis.BaseApiMetadata;
/**
* Implementation of {@link ApiMetadata} for the Cloud Sigma API
*
* @author Adrian Cole
*/
public class CloudSigmaApiMetadata extends BaseApiMetadata {
public CloudSigmaApiMetadata() {
this(builder()
.id("cloudsigma")
.type(ApiType.COMPUTE)
.name("CloudSigma API")
.identityName("Email")
.credentialName("Password")
.documentation(URI.create("http://cloudsigma.com/en/platform-details/the-api")));
}
// below are so that we can reuse builders, toString, hashCode, etc.
// we have to set concrete classes here, as our base class cannot be
// concrete due to serviceLoader
protected CloudSigmaApiMetadata(Builder<?> builder) {
super(builder);
}
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
@Override
public CloudSigmaApiMetadata build() {
return new CloudSigmaApiMetadata(this);
}
}
public static ConcreteBuilder builder() {
return new ConcreteBuilder();
}
@Override
public ConcreteBuilder toBuilder() {
return builder().fromApiMetadata(this);
}
}

View File

@ -0,0 +1 @@
org.jclouds.cloudsigma.CloudSigmaApiMetadata

View File

@ -0,0 +1,35 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.cloudsigma;
import org.jclouds.apis.ApiType;
import org.jclouds.apis.BaseApiMetadataTest;
import org.testng.annotations.Test;
/**
*
* @author Adrian Cole
*/
@Test(groups = "unit", testName = "CloudSigmaApiMetadataTest")
public class CloudSigmaApiMetadataTest extends BaseApiMetadataTest {
public CloudSigmaApiMetadataTest() {
super(new CloudSigmaApiMetadata(), ApiType.COMPUTE);
}
}

View File

@ -1,47 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.cloudsigma;
import org.jclouds.compute.util.ComputeServiceUtils;
import org.jclouds.rest.Providers;
import org.testng.annotations.Test;
import com.google.common.collect.Iterables;
/**
*
* @author Adrian Cole
*
*/
@Test(groups = "unit")
public class ProvidersInPropertiesTest {
@Test
public void testSupportedProviders() {
Iterable<String> providers = Providers.getSupportedProviders();
assert Iterables.contains(providers, "cloudsigma") : providers;
}
@Test
public void testSupportedComputeServiceProviders() {
Iterable<String> providers = ComputeServiceUtils.getSupportedProviders();
assert Iterables.contains(providers, "cloudsigma") : providers;
}
}

View File

@ -0,0 +1,68 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.cloudstack;
import java.net.URI;
import org.jclouds.apis.ApiMetadata;
import org.jclouds.apis.ApiType;
import org.jclouds.apis.BaseApiMetadata;
/**
* Implementation of {@link ApiMetadata} for Citrix CloudStack API
*
* @author Adrian Cole
*/
public class CloudStackApiMetadata extends BaseApiMetadata {
public CloudStackApiMetadata() {
this(builder()
.id("cloudstack")
.type(ApiType.COMPUTE)
.name("Citrix CloudStack API")
.identityName("API Key")
.credentialName("Secret Key")
.documentation(URI.create("http://download.cloud.com/releases/2.2.0/api_2.2.12/TOC_User.html")));
}
// below are so that we can reuse builders, toString, hashCode, etc.
// we have to set concrete classes here, as our base class cannot be
// concrete due to serviceLoader
protected CloudStackApiMetadata(Builder<?> builder) {
super(builder);
}
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
@Override
public CloudStackApiMetadata build() {
return new CloudStackApiMetadata(this);
}
}
public static ConcreteBuilder builder() {
return new ConcreteBuilder();
}
@Override
public ConcreteBuilder toBuilder() {
return builder().fromApiMetadata(this);
}
}

View File

@ -0,0 +1 @@
org.jclouds.cloudstack.CloudStackApiMetadata

View File

@ -0,0 +1,35 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.cloudstack;
import org.jclouds.apis.ApiType;
import org.jclouds.apis.BaseApiMetadataTest;
import org.testng.annotations.Test;
/**
*
* @author Adrian Cole
*/
@Test(groups = "unit", testName = "CloudStackApiMetadataTest")
public class CloudStackApiMetadataTest extends BaseApiMetadataTest {
public CloudStackApiMetadataTest() {
super(new CloudStackApiMetadata(), ApiType.COMPUTE);
}
}

View File

@ -0,0 +1,67 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.cloudwatch;
import java.net.URI;
import org.jclouds.apis.ApiMetadata;
import org.jclouds.apis.ApiType;
import org.jclouds.apis.BaseApiMetadata;
/**
* Implementation of {@link ApiMetadata} for Amazon's CloudWatch api.
*
* @author Adrian Cole
*/
public class CloudWatchApiMetadata extends BaseApiMetadata {
public CloudWatchApiMetadata() {
this(builder()
.id("cloudwatch")
.type(ApiType.MONITOR)
.name("Amazon CloudWatch Api")
.identityName("Access Key ID")
.credentialName("Secret Access Key")
.documentation(URI.create("http://docs.amazonwebservices.com/AmazonCloudWatch/latest/APIReference/")));
}
// below are so that we can reuse builders, toString, hashCode, etc.
// we have to set concrete classes here, as our base class cannot be
// concrete due to serviceLoader
protected CloudWatchApiMetadata(Builder<?> builder) {
super(builder);
}
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
@Override
public CloudWatchApiMetadata build() {
return new CloudWatchApiMetadata(this);
}
}
public static ConcreteBuilder builder() {
return new ConcreteBuilder();
}
@Override
public ConcreteBuilder toBuilder() {
return builder().fromApiMetadata(this);
}
}

View File

@ -0,0 +1 @@
org.jclouds.cloudwatch.CloudWatchApiMetadata

View File

@ -0,0 +1,35 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.cloudwatch;
import org.jclouds.apis.ApiType;
import org.jclouds.apis.BaseApiMetadataTest;
import org.testng.annotations.Test;
/**
*
* @author Adrian Cole
*/
@Test(groups = "unit", testName = "CloudWatchApiMetadataTest")
public class CloudWatchApiMetadataTest extends BaseApiMetadataTest {
public CloudWatchApiMetadataTest() {
super(new CloudWatchApiMetadata(), ApiType.MONITOR);
}
}

View File

@ -0,0 +1,68 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.deltacloud;
import java.net.URI;
import org.jclouds.apis.ApiMetadata;
import org.jclouds.apis.ApiType;
import org.jclouds.apis.BaseApiMetadata;
/**
* Implementation of {@link ApiMetadata} for Apache Deltacloud API
*
* @author Adrian Cole
*/
public class DeltacloudApiMetadata extends BaseApiMetadata {
public DeltacloudApiMetadata() {
this(builder()
.id("deltacloud")
.type(ApiType.COMPUTE)
.name("Apache Deltacloud API")
.identityName("Username")
.credentialName("Password")
.documentation(URI.create("http://deltacloud.apache.org/api.html")));
}
// below are so that we can reuse builders, toString, hashCode, etc.
// we have to set concrete classes here, as our base class cannot be
// concrete due to serviceLoader
protected DeltacloudApiMetadata(Builder<?> builder) {
super(builder);
}
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
@Override
public DeltacloudApiMetadata build() {
return new DeltacloudApiMetadata(this);
}
}
public static ConcreteBuilder builder() {
return new ConcreteBuilder();
}
@Override
public ConcreteBuilder toBuilder() {
return builder().fromApiMetadata(this);
}
}

View File

@ -0,0 +1 @@
org.jclouds.deltacloud.DeltacloudApiMetadata

View File

@ -0,0 +1,35 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.deltacloud;
import org.jclouds.apis.ApiType;
import org.jclouds.apis.BaseApiMetadataTest;
import org.testng.annotations.Test;
/**
*
* @author Adrian Cole
*/
@Test(groups = "unit", testName = "DeltacloudApiMetadataTest")
public class DeltacloudApiMetadataTest extends BaseApiMetadataTest {
public DeltacloudApiMetadataTest() {
super(new DeltacloudApiMetadata(), ApiType.COMPUTE);
}
}

View File

@ -0,0 +1,75 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.ec2;
import java.net.URI;
import org.jclouds.apis.ApiMetadata;
import org.jclouds.apis.ApiType;
import org.jclouds.apis.BaseApiMetadata;
/**
* Implementation of {@link ApiMetadata} for Amazon's EC2 api.
*
* @author Adrian Cole
*/
public class EC2ApiMetadata extends BaseApiMetadata {
public EC2ApiMetadata() {
this(builder()
.id("ec2")
.type(ApiType.COMPUTE)
.name("Amazon Elastic Compute Cloud (EC2) API")
.identityName("Access Key ID")
.credentialName("Secret Access Key")
.documentation(URI.create("http://docs.amazonwebservices.com/AWSEC2/latest/APIReference")));
}
// below are so that we can reuse builders, toString, hashCode, etc.
// we have to set concrete classes here, as our base class cannot be
// concrete due to serviceLoader
protected EC2ApiMetadata(EC2ApiMetadataBuilder<?> builder) {
super(builder);
}
public static class EC2ApiMetadataBuilder<B extends EC2ApiMetadataBuilder<B>> extends Builder<B> {
@Override
public EC2ApiMetadata build() {
return new EC2ApiMetadata(this);
}
}
private static class EC2ConcreteBuilder extends EC2ApiMetadataBuilder<EC2ConcreteBuilder> {
@Override
public EC2ApiMetadata build() {
return new EC2ApiMetadata(this);
}
}
private static EC2ConcreteBuilder builder() {
return new EC2ConcreteBuilder();
}
@Override
public EC2ApiMetadataBuilder<?> toBuilder() {
return builder().fromApiMetadata(this);
}
}

View File

@ -0,0 +1 @@
org.jclouds.ec2.EC2ApiMetadata

View File

@ -0,0 +1,35 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.ec2;
import org.jclouds.apis.ApiType;
import org.jclouds.apis.BaseApiMetadataTest;
import org.testng.annotations.Test;
/**
*
* @author Adrian Cole
*/
@Test(groups = "unit", testName = "EC2ApiMetadataTest")
public class EC2ApiMetadataTest extends BaseApiMetadataTest {
public EC2ApiMetadataTest() {
super(new EC2ApiMetadata(), ApiType.COMPUTE);
}
}

View File

@ -0,0 +1,68 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.elasticstack;
import java.net.URI;
import org.jclouds.apis.ApiMetadata;
import org.jclouds.apis.ApiType;
import org.jclouds.apis.BaseApiMetadata;
/**
* Implementation of {@link ApiMetadata} for the ElasticStack API
*
* @author Adrian Cole
*/
public class ElasticStackApiMetadata extends BaseApiMetadata {
public ElasticStackApiMetadata() {
this(builder()
.id("elasticstack")
.type(ApiType.COMPUTE)
.name("ElasticStack API")
.identityName("UUID")
.credentialName("Secret API key")
.documentation(URI.create("http://www.elasticstack.com/cloud-platform/api")));
}
// below are so that we can reuse builders, toString, hashCode, etc.
// we have to set concrete classes here, as our base class cannot be
// concrete due to serviceLoader
protected ElasticStackApiMetadata(ConcreteBuilder builder) {
super(builder);
}
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
@Override
public ElasticStackApiMetadata build() {
return new ElasticStackApiMetadata(this);
}
}
public static ConcreteBuilder builder() {
return new ConcreteBuilder();
}
@Override
public ConcreteBuilder toBuilder() {
return builder().fromApiMetadata(this);
}
}

View File

@ -0,0 +1 @@
org.jclouds.elasticstack.ElasticStackApiMetadata

View File

@ -16,25 +16,20 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package org.jclouds.cloudonestorage; package org.jclouds.elasticstack;
import org.jclouds.rest.Providers; import org.jclouds.apis.ApiType;
import org.jclouds.apis.BaseApiMetadataTest;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.collect.Iterables;
/** /**
* *
* @author Adrian Cole * @author Adrian Cole
*
*/ */
@Test(groups = "unit") @Test(groups = "unit", testName = "ElasticStackApiMetadataTest")
public class ProvidersInPropertiesTest { public class ElasticStackApiMetadataTest extends BaseApiMetadataTest {
@Test public ElasticStackApiMetadataTest() {
public void testSupportedProviders() { super(new ElasticStackApiMetadata(), ApiType.COMPUTE);
Iterable<String> providers = Providers.getSupportedProviders();
assert Iterables.contains(providers, "cloudonestorage") : providers;
} }
} }

View File

@ -1,53 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.elasticstack;
import org.jclouds.compute.util.ComputeServiceUtils;
import org.jclouds.rest.Providers;
import org.testng.annotations.Test;
import com.google.common.collect.Iterables;
/**
*
* @author Adrian Cole
*
*/
@Test(groups = "unit")
public class ProvidersInPropertiesTest {
@Test
public void testSupportedProviders() {
Iterable<String> providers = Providers.getSupportedProviders();
assert Iterables.contains(providers, "elasticstack") : providers;
assert Iterables.contains(providers, "elastichosts-lon-p") : providers;
assert Iterables.contains(providers, "elastichosts-lon-b") : providers;
assert Iterables.contains(providers, "elastichosts-sat-p") : providers;
}
@Test
public void testSupportedComputeServiceProviders() {
Iterable<String> providers = ComputeServiceUtils.getSupportedProviders();
assert Iterables.contains(providers, "elasticstack") : providers;
assert Iterables.contains(providers, "elastichosts-lon-p") : providers;
assert Iterables.contains(providers, "elastichosts-lon-b") : providers;
assert Iterables.contains(providers, "elastichosts-sat-p") : providers;
}
}

View File

@ -0,0 +1,60 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.eucalyptus;
import org.jclouds.apis.ApiMetadata;
import org.jclouds.ec2.EC2ApiMetadata;
/**
* Implementation of {@link ApiMetadata} for the Eucalyptus (EC2 clone) api.
*
* @author Adrian Cole
*/
public class EucalyptusApiMetadata extends EC2ApiMetadata {
public EucalyptusApiMetadata() {
this(builder().fromApiMetadata(new EC2ApiMetadata())
.id("eucalyptus")
.name("Eucalyptus (EC2 clone) API"));
}
// below are so that we can reuse builders, toString, hashCode, etc.
// we have to set concrete classes here, as our base class cannot be
// concrete due to serviceLoader
protected EucalyptusApiMetadata(ConcreteBuilder builder) {
super(builder);
}
private static class ConcreteBuilder extends EC2ApiMetadataBuilder<ConcreteBuilder> {
@Override
public EucalyptusApiMetadata build() {
return new EucalyptusApiMetadata(this);
}
}
private static ConcreteBuilder builder() {
return new ConcreteBuilder();
}
@Override
public ConcreteBuilder toBuilder() {
return builder().fromApiMetadata(this);
}
}

View File

@ -0,0 +1 @@
org.jclouds.eucalyptus.EucalyptusApiMetadata

View File

@ -0,0 +1,35 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.eucalyptus;
import org.jclouds.apis.ApiType;
import org.jclouds.apis.BaseApiMetadataTest;
import org.testng.annotations.Test;
/**
*
* @author Adrian Cole
*/
@Test(groups = "unit", testName = "EucalyptusApiMetadataTest")
public class EucalyptusApiMetadataTest extends BaseApiMetadataTest {
public EucalyptusApiMetadataTest() {
super(new EucalyptusApiMetadata(), ApiType.COMPUTE);
}
}

View File

@ -0,0 +1,67 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.filesystem;
import java.net.URI;
import org.jclouds.apis.ApiMetadata;
import org.jclouds.apis.ApiType;
import org.jclouds.apis.BaseApiMetadata;
/**
* Implementation of {@link ApiMetadata} for jclouds Filesystem-based BlobStore
*
* @author Adrian Cole
*/
public class FilesystemApiMetadata extends BaseApiMetadata {
public FilesystemApiMetadata() {
this(builder()
.id("filesystem")
.type(ApiType.BLOBSTORE)
.name("Filesystem-based BlobStore")
.identityName("Unused")
.documentation(URI.create("http://www.jclouds.org/documentation/userguide/blobstore-guide")));
}
// below are so that we can reuse builders, toString, hashCode, etc.
// we have to set concrete classes here, as our base class cannot be
// concrete due to serviceLoader
protected FilesystemApiMetadata(ConcreteBuilder builder) {
super(builder);
}
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
@Override
public FilesystemApiMetadata build() {
return new FilesystemApiMetadata(this);
}
}
public static ConcreteBuilder builder() {
return new ConcreteBuilder();
}
@Override
public ConcreteBuilder toBuilder() {
return builder().fromApiMetadata(this);
}
}

View File

@ -0,0 +1 @@
org.jclouds.filesystem.FilesystemApiMetadata

View File

@ -0,0 +1,35 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.filesystem;
import org.jclouds.apis.ApiType;
import org.jclouds.apis.BaseApiMetadataTest;
import org.testng.annotations.Test;
/**
*
* @author Adrian Cole
*/
@Test(groups = "unit", testName = "FilesystemApiMetadataTest")
public class FilesystemApiMetadataTest extends BaseApiMetadataTest {
public FilesystemApiMetadataTest() {
super(new FilesystemApiMetadata(), ApiType.BLOBSTORE);
}
}

View File

@ -0,0 +1,67 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.openstack.nova;
import java.net.URI;
import org.jclouds.apis.ApiMetadata;
import org.jclouds.apis.ApiType;
import org.jclouds.apis.BaseApiMetadata;
/**
* Implementation of {@link ApiMetadata} for OpenStack Nova Pre-Diablo
*
* @author Adrian Cole
*/
public class NovaApiMetadata extends BaseApiMetadata {
public NovaApiMetadata() {
this(builder()
.id("nova")
.type(ApiType.COMPUTE)
.name("OpenStack Nova Pre-Diablo API")
.identityName("accessKey")
.credentialName("secretKey")
.documentation(URI.create("http://api.openstack.org/")));
}
// below are so that we can reuse builders, toString, hashCode, etc.
// we have to set concrete classes here, as our base class cannot be
// concrete due to serviceLoader
protected NovaApiMetadata(ConcreteBuilder builder) {
super(builder);
}
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
@Override
public NovaApiMetadata build() {
return new NovaApiMetadata(this);
}
}
public static ConcreteBuilder builder() {
return new ConcreteBuilder();
}
@Override
public ConcreteBuilder toBuilder() {
return builder().fromApiMetadata(this);
}
}

View File

@ -0,0 +1 @@
org.jclouds.openstack.nova.NovaApiMetadata

View File

@ -0,0 +1,35 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.openstack.nova;
import org.jclouds.apis.ApiType;
import org.jclouds.apis.BaseApiMetadataTest;
import org.testng.annotations.Test;
/**
*
* @author Adrian Cole
*/
@Test(groups = "unit", testName = "NovaApiMetadataTest")
public class NovaApiMetadataTest extends BaseApiMetadataTest {
public NovaApiMetadataTest() {
super(new NovaApiMetadata(), ApiType.COMPUTE);
}
}

View File

@ -0,0 +1,58 @@
package org.jclouds.openstack.nova.v1_1;
import java.net.URI;
import org.jclouds.apis.ApiMetadata;
import org.jclouds.apis.ApiType;
import org.jclouds.apis.BaseApiMetadata;
/**
* Implementation of {@link ApiMetadata} for OpenStack Nova Diablo+
*
* @author Adrian Cole
*/
public class NovaApiMetadata extends BaseApiMetadata {
public NovaApiMetadata() {
this(builder()
.id("openstack-nova")
.type(ApiType.COMPUTE)
.name("OpenStack Nova Diablo+ API")
.identityName("tenantId:user")
.credentialName("password")
.documentation(URI.create("http://api.openstack.org/")));
}
// below are so that we can reuse builders, toString, hashCode, etc.
// we have to set concrete classes here, as our base class cannot be
// concrete due to serviceLoader
protected NovaApiMetadata(NovaApiMetadataBuilder<?> builder) {
super(builder);
}
public static class NovaApiMetadataBuilder<B extends NovaApiMetadataBuilder<B>> extends Builder<B> {
@Override
public NovaApiMetadata build() {
return new NovaApiMetadata(this);
}
}
private static class NovaConcreteBuilder extends NovaApiMetadataBuilder<NovaConcreteBuilder> {
@Override
public NovaApiMetadata build() {
return new NovaApiMetadata(this);
}
}
private static NovaConcreteBuilder builder() {
return new NovaConcreteBuilder();
}
@Override
public NovaApiMetadataBuilder<?> toBuilder() {
return builder().fromApiMetadata(this);
}
}

View File

@ -0,0 +1 @@
org.jclouds.openstack.nova.v1_1.NovaApiMetadata

View File

@ -0,0 +1,17 @@
package org.jclouds.openstack.nova.v1_1;
import org.jclouds.apis.ApiType;
import org.jclouds.apis.BaseApiMetadataTest;
import org.testng.annotations.Test;
/**
*
* @author Adrian Cole
*/
@Test(groups = "unit", testName = "NovaApiMetadataTest")
public class NovaApiMetadataTest extends BaseApiMetadataTest {
public NovaApiMetadataTest() {
super(new NovaApiMetadata(), ApiType.COMPUTE);
}
}

View File

@ -0,0 +1,75 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.s3;
import java.net.URI;
import org.jclouds.apis.ApiMetadata;
import org.jclouds.apis.ApiType;
import org.jclouds.apis.BaseApiMetadata;
/**
* Implementation of {@link ApiMetadata} for Amazon's S3 api.
*
* @author Adrian Cole
*/
public class S3ApiMetadata extends BaseApiMetadata {
public S3ApiMetadata() {
this(builder()
.id("s3")
.type(ApiType.BLOBSTORE)
.name("Amazon Simple Storage Service (S3) API")
.identityName("Access Key ID")
.credentialName("Secret Access Key")
.documentation(URI.create("http://docs.amazonwebservices.com/AmazonS3/latest/API")));
}
// below are so that we can reuse builders, toString, hashCode, etc.
// we have to set concrete classes here, as our base class cannot be
// concrete due to serviceLoader
protected S3ApiMetadata(S3ApiMetadataBuilder<?> builder) {
super(builder);
}
public static class S3ApiMetadataBuilder<B extends S3ApiMetadataBuilder<B>> extends Builder<B> {
@Override
public S3ApiMetadata build() {
return new S3ApiMetadata(this);
}
}
private static class S3ConcreteBuilder extends S3ApiMetadataBuilder<S3ConcreteBuilder> {
@Override
public S3ApiMetadata build() {
return new S3ApiMetadata(this);
}
}
private static S3ConcreteBuilder builder() {
return new S3ConcreteBuilder();
}
@Override
public S3ApiMetadataBuilder<?> toBuilder() {
return builder().fromApiMetadata(this);
}
}

View File

@ -0,0 +1 @@
org.jclouds.s3.S3ApiMetadata

View File

@ -0,0 +1,35 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.s3;
import org.jclouds.apis.ApiType;
import org.jclouds.apis.BaseApiMetadataTest;
import org.testng.annotations.Test;
/**
*
* @author Adrian Cole
*/
@Test(groups = "unit", testName = "S3ApiMetadataTest")
public class S3ApiMetadataTest extends BaseApiMetadataTest {
public S3ApiMetadataTest() {
super(new S3ApiMetadata(), ApiType.BLOBSTORE);
}
}

View File

@ -0,0 +1,49 @@
package org.jclouds.openstack.swift;
import java.net.URI;
import org.jclouds.apis.ApiMetadata;
import org.jclouds.apis.ApiType;
import org.jclouds.apis.BaseApiMetadata;
/**
* Implementation of {@link ApiMetadata} for OpenStack Swift Pre-Diablo
*
* @author Adrian Cole
*/
public class SwiftApiMetadata extends BaseApiMetadata {
public SwiftApiMetadata() {
this(builder()
.id("swift")
.type(ApiType.BLOBSTORE)
.name("OpenStack Swift Pre-Diablo API")
.identityName("tenantId:user")
.credentialName("password")
.documentation(URI.create("http://api.openstack.org/")));
}
// below are so that we can reuse builders, toString, hashCode, etc.
// we have to set concrete classes here, as our base class cannot be
// concrete due to serviceLoader
protected SwiftApiMetadata(ConcreteBuilder builder) {
super(builder);
}
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
@Override
public SwiftApiMetadata build() {
return new SwiftApiMetadata(this);
}
}
public static ConcreteBuilder builder() {
return new ConcreteBuilder();
}
@Override
public ConcreteBuilder toBuilder() {
return builder().fromApiMetadata(this);
}
}

View File

@ -0,0 +1 @@
org.jclouds.openstack.swift.SwiftApiMetadata

View File

@ -0,0 +1,17 @@
package org.jclouds.openstack.swift;
import org.jclouds.apis.ApiType;
import org.jclouds.apis.BaseApiMetadataTest;
import org.testng.annotations.Test;
/**
*
* @author Adrian Cole
*/
@Test(groups = "unit", testName = "SwiftApiMetadataTest")
public class SwiftApiMetadataTest extends BaseApiMetadataTest {
public SwiftApiMetadataTest() {
super(new SwiftApiMetadata(), ApiType.BLOBSTORE);
}
}

View File

@ -0,0 +1,67 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.vcloud;
import java.net.URI;
import org.jclouds.apis.ApiMetadata;
import org.jclouds.apis.ApiType;
import org.jclouds.apis.BaseApiMetadata;
/**
* Implementation of {@link ApiMetadata} for VCloud 1.0 API
*
* @author Adrian Cole
*/
public class VCloudApiMetadata extends BaseApiMetadata {
public VCloudApiMetadata() {
this(builder()
.id("vcloud")
.type(ApiType.COMPUTE)
.name("VCloud 1.0 API")
.identityName("User at Organization (user@org)")
.credentialName("Password")
.documentation(URI.create("http://www.vmware.com/support/pubs/vcd_pubs.html")));
}
// below are so that we can reuse builders, toString, hashCode, etc.
// we have to set concrete classes here, as our base class cannot be
// concrete due to serviceLoader
protected VCloudApiMetadata(ConcreteBuilder builder) {
super(builder);
}
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
@Override
public VCloudApiMetadata build() {
return new VCloudApiMetadata(this);
}
}
public static ConcreteBuilder builder() {
return new ConcreteBuilder();
}
@Override
public ConcreteBuilder toBuilder() {
return builder().fromApiMetadata(this);
}
}

View File

@ -0,0 +1 @@
org.jclouds.vcloud.VCloudApiMetadata

View File

@ -1,47 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.vcloud;
import org.jclouds.compute.util.ComputeServiceUtils;
import org.jclouds.rest.Providers;
import org.testng.annotations.Test;
import com.google.common.collect.Iterables;
/**
*
* @author Adrian Cole
*
*/
@Test(groups = "unit")
public class ProvidersInPropertiesTest {
@Test
public void testSupportedProviders() {
Iterable<String> providers = Providers.getSupportedProviders();
assert Iterables.contains(providers, "vcloud") : providers;
}
@Test
public void testSupportedComputeServiceProviders() {
Iterable<String> providers = ComputeServiceUtils.getSupportedProviders();
assert Iterables.contains(providers, "vcloud") : providers;
}
}

View File

@ -16,25 +16,20 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package org.jclouds.synaptic.storage; package org.jclouds.vcloud;
import org.jclouds.rest.Providers; import org.jclouds.apis.ApiType;
import org.jclouds.apis.BaseApiMetadataTest;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.collect.Iterables;
/** /**
* *
* @author Adrian Cole * @author Adrian Cole
*
*/ */
@Test(groups = "unit") @Test(groups = "unit", testName = "VCloudApiMetadataTest")
public class ProvidersInPropertiesTest { public class VCloudApiMetadataTest extends BaseApiMetadataTest {
@Test public VCloudApiMetadataTest() {
public void testSupportedProviders() { super(new VCloudApiMetadata(), ApiType.COMPUTE);
Iterable<String> providers = Providers.getSupportedProviders();
assert Iterables.contains(providers, "synaptic-storage") : providers;
} }
} }

View File

@ -0,0 +1,60 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.walrus;
import org.jclouds.apis.ApiMetadata;
import org.jclouds.s3.S3ApiMetadata;
/**
* Implementation of {@link ApiMetadata} for the Walrus (S3 clone) api.
*
* @author Adrian Cole
*/
public class WalrusApiMetadata extends S3ApiMetadata {
public WalrusApiMetadata() {
this(builder().fromApiMetadata(new S3ApiMetadata())
.id("walrus")
.name("Walrus (S3 clone) API"));
}
// below are so that we can reuse builders, toString, hashCode, etc.
// we have to set concrete classes here, as our base class cannot be
// concrete due to serviceLoader
protected WalrusApiMetadata(ConcreteBuilder builder) {
super(builder);
}
private static class ConcreteBuilder extends S3ApiMetadataBuilder<ConcreteBuilder> {
@Override
public WalrusApiMetadata build() {
return new WalrusApiMetadata(this);
}
}
private static ConcreteBuilder builder() {
return new ConcreteBuilder();
}
@Override
public ConcreteBuilder toBuilder() {
return builder().fromApiMetadata(this);
}
}

View File

@ -0,0 +1 @@
org.jclouds.walrus.WalrusApiMetadata

View File

@ -0,0 +1,35 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.walrus;
import org.jclouds.apis.ApiType;
import org.jclouds.apis.BaseApiMetadataTest;
import org.testng.annotations.Test;
/**
*
* @author Adrian Cole
*/
@Test(groups = "unit", testName = "WalrusApiMetadataTest")
public class WalrusApiMetadataTest extends BaseApiMetadataTest {
public WalrusApiMetadataTest() {
super(new WalrusApiMetadata(), ApiType.BLOBSTORE);
}
}

View File

@ -0,0 +1,67 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.blobstore;
import java.net.URI;
import org.jclouds.apis.ApiMetadata;
import org.jclouds.apis.ApiType;
import org.jclouds.apis.BaseApiMetadata;
/**
* Implementation of {@link ApiMetadata} for jclouds in-memory (Transient) API
*
* @author Adrian Cole
*/
public class TransientApiMetadata extends BaseApiMetadata {
public TransientApiMetadata() {
this(builder()
.id("transient")
.type(ApiType.BLOBSTORE)
.name("in-memory (Transient) API")
.identityName("Unused")
.documentation(URI.create("http://www.jclouds.org/documentation/userguide/blobstore-guide")));
}
// below are so that we can reuse builders, toString, hashCode, etc.
// we have to set concrete classes here, as our base class cannot be
// concrete due to serviceLoader
protected TransientApiMetadata(ConcreteBuilder builder) {
super(builder);
}
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
@Override
public TransientApiMetadata build() {
return new TransientApiMetadata(this);
}
}
public static ConcreteBuilder builder() {
return new ConcreteBuilder();
}
@Override
public ConcreteBuilder toBuilder() {
return builder().fromApiMetadata(this);
}
}

View File

@ -0,0 +1 @@
org.jclouds.blobstore.TransientApiMetadata

View File

@ -18,26 +18,18 @@
*/ */
package org.jclouds.blobstore; package org.jclouds.blobstore;
import org.jclouds.blobstore.util.BlobStoreUtils; import org.jclouds.apis.ApiType;
import org.jclouds.apis.BaseApiMetadataTest;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.collect.Iterables;
/** /**
* *
* @author Adrian Cole * @author Adrian Cole
*
*/ */
@Test(groups = "unit") @Test(groups = "unit", testName = "TransientApiMetadataTest")
public class ProvidersInPropertiesTest { public class TransientApiMetadataTest extends BaseApiMetadataTest {
@Test
public void testSupportedBlobStoreProviders() {
Iterable<String> providers = BlobStoreUtils.getSupportedProviders();
assert Iterables.contains(providers, "s3") : providers;
assert Iterables.contains(providers, "azureblob") : providers;
assert Iterables.contains(providers, "cloudfiles") : providers;
public TransientApiMetadataTest() {
super(new TransientApiMetadata(), ApiType.BLOBSTORE);
} }
} }

View File

@ -0,0 +1,67 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.compute.stub;
import java.net.URI;
import org.jclouds.apis.ApiMetadata;
import org.jclouds.apis.ApiType;
import org.jclouds.apis.BaseApiMetadata;
/**
* Implementation of {@link ApiMetadata} for jclouds in-memory (Stub) API
*
* @author Adrian Cole
*/
public class StubApiMetadata extends BaseApiMetadata {
public StubApiMetadata() {
this(builder()
.id("stub")
.type(ApiType.COMPUTE)
.name("in-memory (Stub) API")
.identityName("Unused")
.documentation(URI.create("http://www.jclouds.org/documentation/userguide/compute")));
}
// below are so that we can reuse builders, toString, hashCode, etc.
// we have to set concrete classes here, as our base class cannot be
// concrete due to serviceLoader
protected StubApiMetadata(ConcreteBuilder builder) {
super(builder);
}
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
@Override
public StubApiMetadata build() {
return new StubApiMetadata(this);
}
}
public static ConcreteBuilder builder() {
return new ConcreteBuilder();
}
@Override
public ConcreteBuilder toBuilder() {
return builder().fromApiMetadata(this);
}
}

View File

@ -0,0 +1 @@
org.jclouds.compute.stub.StubApiMetadata

View File

@ -0,0 +1,35 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.compute.stub;
import org.jclouds.apis.ApiType;
import org.jclouds.apis.BaseApiMetadataTest;
import org.testng.annotations.Test;
/**
*
* @author Adrian Cole
*/
@Test(groups = "unit", testName = "StubApiMetadataTest")
public class StubApiMetadataTest extends BaseApiMetadataTest {
public StubApiMetadataTest() {
super(new StubApiMetadata(), ApiType.COMPUTE);
}
}

View File

@ -0,0 +1,119 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.apis;
import java.net.URI;
import org.jclouds.javax.annotation.Nullable;
import com.google.common.annotations.Beta;
/**
* The ApiMetadata interface allows jclouds to provide a plugin framework for
* gathering cloud api metadata.
*
* @author Jeremy Whitlock <jwhitlock@apache.org>, Adrian Cole
* @since 1.5
*/
@Beta
public interface ApiMetadata {
public static interface Builder<B extends Builder<B>> {
/**
* @see ApiMetadata#getId()
*/
B id(String id);
/**
* @see ApiMetadata#getName()
*/
B name(String name);
/**
* @see ApiMetadata#getType()
*/
B type(ApiType type);
/**
* @see ApiMetadata#getIdentityName()
*/
B identityName(String identityName);
/**
* @see ApiMetadata#getCredentialName()
*/
B credentialName(@Nullable String credentialName);
/**
* @see ApiMetadata#getDocumentation()
*/
B documentation(URI documentation);
ApiMetadata build();
B fromApiMetadata(ApiMetadata in);
}
/**
* @see Builder
*/
Builder<?> toBuilder();
/**
*
* @return the api's unique identifier
*/
public String getId();
/**
*
* @return the name (display name) of the api
*/
public String getName();
/**
*
* @return the api's type
*/
public ApiType getType();
/**
*
* @return the name (display name) of an identity on this api (ex. user,
* email, account, apikey)
*/
public String getIdentityName();
/**
*
* @return the name (display name) of a credential on this api, or null if
* there is none (ex. password, secret, rsaKey)
*/
@Nullable
public String getCredentialName();
/**
*
* @return the url for the API documentation related to this service
*/
public URI getDocumentation();
}

View File

@ -0,0 +1,102 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.apis;
import static com.google.common.base.Preconditions.checkNotNull;
import org.jclouds.util.Preconditions2;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
/**
* Container for api filters (predicates).
*
* @author Jeremy Whitlock <jwhitlock@apache.org>
*/
public class ApiPredicates {
/**
* Returns all apis available to jclouds regardless of type.
*
* @return all available apis
*/
public static Predicate<ApiMetadata> all() {
return Predicates.<ApiMetadata> alwaysTrue();
}
/**
* Returns all apis with the given id.
*
* @param id
* the id of the api to return
*
* @return the apis with the given id
*/
public static Predicate<ApiMetadata> id(final String id) {
Preconditions2.checkNotEmpty(id, "id must be defined");
return new Predicate<ApiMetadata>() {
/**
* {@inheritDoc}
*/
@Override
public boolean apply(ApiMetadata apiMetadata) {
return apiMetadata.getId().equals(id);
}
/**
* {@inheritDoc}
*/
@Override
public String toString() {
return "id(" + id + ")";
}
};
}
/**
* Returns all apis with the given type.
*
* @param type
* the type of the api to return
*
* @return the apis with the given type
*/
public static Predicate<ApiMetadata> type(final ApiType type) {
checkNotNull(type, "type must be defined");
return new Predicate<ApiMetadata>() {
/**
* {@inheritDoc}
*/
@Override
public boolean apply(ApiMetadata apiMetadata) {
return apiMetadata.getType().equals(type);
}
/**
* {@inheritDoc}
*/
@Override
public String toString() {
return "type(" + type + ")";
}
};
}
}

View File

@ -0,0 +1,46 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.apis;
import static org.jclouds.util.Preconditions2.checkNotEmpty;
import com.google.common.base.CaseFormat;
/**
*
* @author Adrian Cole
*/
public enum ApiType {
BLOBSTORE, COMPUTE, LOADBALANCER, TABLE, QUEUE, MONITOR, UNRECOGNIZED;
@Override
public String toString() {
return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, name());
}
public static ApiType fromValue(String type) {
checkNotEmpty(type, "type must be defined");
try {
return valueOf(CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, type));
} catch (IllegalArgumentException e) {
return UNRECOGNIZED;
}
}
}

View File

@ -0,0 +1,139 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.apis;
import static com.google.common.collect.Iterables.filter;
import static com.google.common.collect.Iterables.find;
import java.util.NoSuchElementException;
import java.util.ServiceLoader;
/**
* The Apis class provides static methods for accessing apis.
*
* @author Jeremy Whitlock <jwhitlock@apache.org>
*/
public class Apis {
/**
* Returns the apis located on the classpath via
* {@link java.util.ServiceLoader}.
*
* @return all available apis loaded from classpath via ServiceLoader
*/
private static Iterable<ApiMetadata> fromServiceLoader() {
return ServiceLoader.load(ApiMetadata.class);
}
/**
* Returns all available apis.
*
* @return all available apis
*/
public static Iterable<ApiMetadata> all() {
return fromServiceLoader();
}
/**
* Returns the first api with the provided id
*
* @param id
* the id of the api to return
*
* @return the api with the given id
*
* @throws NoSuchElementException
* whenever there are no apis with the provided id
*/
public static ApiMetadata withId(String id) throws NoSuchElementException {
return find(all(), ApiPredicates.id(id));
}
/**
* Returns the apis that are of type
* {@link org.jclouds.apis.ApiMetadata#BLOBSTORE}.
*
* @return the blobstore apis
*/
public static Iterable<ApiMetadata> allBlobStore() {
return filter(all(), ApiPredicates.type(ApiType.BLOBSTORE));
}
/**
* Returns the apis that are of type
* {@link org.jclouds.apis.ApiMetadata#COMPUTE}.
*
* @return the compute service apis
*/
public static Iterable<ApiMetadata> allCompute() {
return filter(all(), ApiPredicates.type(ApiType.COMPUTE));
}
/**
* Returns the apis that are of type
* {@link org.jclouds.apis.ApiMetadata#QUEUE}.
*
* @return the queue service apis
*/
public static Iterable<ApiMetadata> allQueue() {
return filter(all(), ApiPredicates.type(ApiType.QUEUE));
}
/**
* Returns the apis that are of type
* {@link org.jclouds.apis.ApiMetadata#TABLE}.
*
* @return the table service apis
*/
public static Iterable<ApiMetadata> allTable() {
return filter(all(), ApiPredicates.type(ApiType.TABLE));
}
/**
* Returns the apis that are of type
* {@link org.jclouds.apis.ApiMetadata#LOADBALANCER}.
*
* @return the load balancer service apis
*/
public static Iterable<ApiMetadata> allLoadBalancer() {
return filter(all(), ApiPredicates.type(ApiType.LOADBALANCER));
}
/**
* Returns the apis that are of type
* {@link org.jclouds.apis.ApiMetadata#MONITOR}.
*
* @return the load balancer service apis
*/
public static Iterable<ApiMetadata> allMonitor() {
return filter(all(), ApiPredicates.type(ApiType.MONITOR));
}
/**
* Returns the apis that are of the provided type.
*
* @param type
* the type to apis to return
*
* @return the apis of the provided type
*/
public static Iterable<ApiMetadata> ofType(ApiType type) {
return filter(all(), ApiPredicates.type(type));
}
}

View File

@ -0,0 +1,211 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.apis;
import static com.google.common.base.Objects.equal;
import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI;
import org.jclouds.javax.annotation.Nullable;
import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper;
/**
* The BaseApiMetadata class is an abstraction of {@link ApiMetadata} to be
* extended by those implementing ApiMetadata.
*
* (Note: This class must be abstract to allow {@link java.util.ServiceLoader}
* to work properly.
*
* @author Jeremy Whitlock <jwhitlock@apache.org>, Adrian Cole
*/
public abstract class BaseApiMetadata implements ApiMetadata {
public static abstract class Builder<B extends Builder<B>> implements ApiMetadata.Builder<B> {
protected String id;
protected String name;
protected ApiType type;
protected String identityName;
protected String credentialName;
protected URI documentation;
@SuppressWarnings("unchecked")
protected B self() {
return (B) this;
}
/**
* {@inheritDoc}
*/
@Override
public B id(String id) {
this.id = checkNotNull(id, "id");
return self();
}
/**
* {@inheritDoc}
*/
@Override
public B name(String name) {
this.name = checkNotNull(name, "name");
return self();
}
/**
* {@inheritDoc}
*/
@Override
public B type(ApiType type) {
this.type = checkNotNull(type, "type");
return self();
}
/**
* {@inheritDoc}
*/
@Override
public B identityName(String identityName) {
this.identityName = checkNotNull(identityName, "identityName");
return self();
}
/**
* {@inheritDoc}
*/
@Override
public B credentialName(@Nullable String credentialName) {
this.credentialName = credentialName;
return self();
}
/**
* {@inheritDoc}
*/
@Override
public B documentation(URI documentation) {
this.documentation = checkNotNull(documentation, "documentation");
return self();
}
public B fromApiMetadata(ApiMetadata in) {
return id(in.getId()).type(in.getType()).name(in.getName()).identityName(in.getIdentityName())
.credentialName(in.getCredentialName());
}
}
protected final String id;
protected final String name;
protected final ApiType type;
protected final String identityName;
protected final String credentialName;
protected final URI documentation;
protected BaseApiMetadata(Builder<?> builder) {
this.id = builder.id;
this.name = builder.name;
this.type = builder.type;
this.identityName = builder.identityName;
this.credentialName = builder.credentialName;
this.documentation = builder.documentation;
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
// subclass equivalence is ok, since we don't know the classloader
// we'll get things from
if (o == null || !(o instanceof ApiMetadata))
return false;
ApiMetadata that = ApiMetadata.class.cast(o);
return equal(this.getId(), that.getId()) && equal(this.getName(), that.getName())
&& equal(this.getType(), that.getType()) && equal(this.getIdentityName(), that.getIdentityName())
&& equal(this.getCredentialName(), that.getCredentialName())
&& equal(this.getDocumentation(), that.getDocumentation());
}
@Override
public int hashCode() {
return Objects
.hashCode(getId(), getName(), getType(), getIdentityName(), getCredentialName(), getDocumentation());
}
@Override
public String toString() {
return string().toString();
}
protected ToStringHelper string() {
return Objects.toStringHelper("").add("id", getId()).add("name", getName()).add("type", getType())
.add("identityName", getIdentityName()).add("credentialName", getCredentialName())
.add("documentation", getDocumentation());
}
/**
* {@inheritDoc}
*/
@Override
public String getId() {
return id;
}
/**
* {@inheritDoc}
*/
@Override
public String getName() {
return name;
}
/**
* {@inheritDoc}
*/
@Override
public ApiType getType() {
return type;
}
/**
* {@inheritDoc}
*/
@Override
public String getIdentityName() {
return identityName;
}
/**
* {@inheritDoc}
*/
@Override
public String getCredentialName() {
return credentialName;
}
/**
* {@inheritDoc}
*/
@Override
public URI getDocumentation() {
return documentation;
}
}

View File

@ -18,151 +18,289 @@
*/ */
package org.jclouds.providers; package org.jclouds.providers;
import static com.google.common.base.Objects.equal;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.Iterables.addAll;
import static com.google.common.collect.Sets.newLinkedHashSet;
import java.net.URI; import java.net.URI;
import java.util.Set; import java.util.Set;
import org.jclouds.apis.ApiMetadata;
import org.jclouds.javax.annotation.Nullable;
import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
/** /**
* The BaseProviderMetadata class is an abstraction of {@link ProviderMetadata} to be extended by * The BaseProviderMetadata class is an abstraction of {@link ProviderMetadata}
* those implementing ProviderMetadata. * to be extended by those implementing ProviderMetadata.
* *
* (Note: This class must be abstract to allow {@link java.util.ServiceLoader} to work properly. * (Note: This class must be abstract to allow {@link java.util.ServiceLoader}
* to work properly.
* *
* @author Jeremy Whitlock <jwhitlock@apache.org> * @author Adrian Cole
*/ */
public abstract class BaseProviderMetadata implements ProviderMetadata { public abstract class BaseProviderMetadata implements ProviderMetadata {
/** public static abstract class Builder<B extends Builder<B>> implements ProviderMetadata.Builder<B> {
* @see java.lang.Object#hashCode() protected String id;
*/ protected String name;
@Override protected ApiMetadata api;
public int hashCode() { protected URI console;
final int prime = 31; protected URI homepage;
int result = 1; protected Set<String> linkedServices = newLinkedHashSet();
URI console = getConsole(); protected Set<String> iso3166Codes = newLinkedHashSet();
URI homepage = getHomepage();
URI docs = getApiDocumentation();
String id = getId();
String name = getName();
String identityName = getIdentityName();
String credentialName = getCredentialName();
String type = getType();
Set<String> linkedServices = getLinkedServices();
Set<String> iso3166Codes = getIso3166Codes();
result = prime * result + ((console == null) ? 0 : console.hashCode()); @SuppressWarnings("unchecked")
result = prime * result + ((homepage == null) ? 0 : homepage.hashCode()); protected B self() {
result = prime * result + ((docs == null) ? 0 : docs.hashCode()); return (B) this;
result = prime * result + ((id == null) ? 0 : id.hashCode()); }
result = prime * result + ((name == null) ? 0 : name.hashCode());
result = prime * result + ((identityName == null) ? 0 : identityName.hashCode());
result = prime * result + ((credentialName == null) ? 0 : credentialName.hashCode());
result = prime * result + ((type == null) ? 0 : type.hashCode());
result = prime * result + ((linkedServices == null) ? 0 : linkedServices.hashCode());
result = prime * result + ((iso3166Codes == null) ? 0 : iso3166Codes.hashCode());
return result; /**
* {@inheritDoc}
*/
@Override
public B id(String id) {
this.id = checkNotNull(id, "id");
return linkedService(id);
}
/**
* {@inheritDoc}
*/
@Override
public B name(String name) {
this.name = checkNotNull(name, "name");
return self();
}
/**
* {@inheritDoc}
*/
@Override
public B api(ApiMetadata api) {
this.api = checkNotNull(api, "api");
return self();
}
/**
* {@inheritDoc}
*/
@Override
public B console(@Nullable URI console) {
this.console = console;
return self();
}
/**
* {@inheritDoc}
*/
@Override
public B homepage(URI homepage) {
this.homepage = homepage;
return self();
}
/**
* {@inheritDoc}
*/
@Override
public B linkedServices(Iterable<String> linkedServices) {
addAll(this.linkedServices, checkNotNull(linkedServices, "linkedServices"));
return self();
}
/**
* {@inheritDoc}
*/
@Override
public B linkedServices(String... linkedServices) {
return linkedServices(ImmutableSet.copyOf(checkNotNull(linkedServices, "linkedServices")));
}
/**
* {@inheritDoc}
*/
@Override
public B linkedService(String linkedService) {
this.linkedServices.add(checkNotNull(linkedService, "linkedService"));
return self();
}
/**
* {@inheritDoc}
*/
@Override
public B iso3166Codes(Iterable<String> iso3166Codes) {
addAll(this.iso3166Codes, checkNotNull(iso3166Codes, "iso3166Codes"));
return self();
}
/**
* {@inheritDoc}
*/
@Override
public B iso3166Codes(String... iso3166Codes) {
return iso3166Codes(ImmutableSet.copyOf(checkNotNull(iso3166Codes, "iso3166Codes")));
}
/**
* {@inheritDoc}
*/
@Override
public B iso3166Code(String iso3166Code) {
this.iso3166Codes.add(checkNotNull(iso3166Code, "iso3166Code"));
return self();
}
/**
* {@inheritDoc}
*/
@Override
public B fromProviderMetadata(ProviderMetadata in) {
return id(in.getId()).name(in.getName()).api(in.getApi()).console(in.getConsole()).homepage(in.getHomepage())
.linkedServices(in.getLinkedServices()).iso3166Codes(in.getIso3166Codes());
}
}
protected final String id;
protected final String name;
protected final ApiMetadata api;
protected final URI homepage;
protected final URI console;
protected final Set<String> linkedServices;
protected final Set<String> iso3166Codes;
protected BaseProviderMetadata(Builder<?> builder) {
this.id = builder.id;
this.name = builder.name;
this.api = builder.api;
this.console = builder.console;
this.homepage = builder.homepage;
this.linkedServices = ImmutableSet.copyOf(builder.linkedServices);
this.iso3166Codes = ImmutableSet.copyOf(builder.iso3166Codes);
} }
/**
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object o) {
URI tConsole = getConsole(); if (this == o)
URI tHomepage = getHomepage();
URI tDocs = getApiDocumentation();
String tId = getId();
String tName = getName();
String tIdentityName = getIdentityName();
String tCredentialName = getCredentialName();
String tType = getType();
Set<String> tLinkedServices = getLinkedServices();
Set<String> tIso3166Codes = getIso3166Codes();
if (this == obj)
return true; return true;
if (obj == null) // subclass equivalence is ok, since we don't know the classloader
return false; // we'll get things from
if (getClass() != obj.getClass()) if (o == null || !(o instanceof ProviderMetadata))
return false; return false;
ProviderMetadata that = ProviderMetadata.class.cast(o);
return equal(this.getId(), that.getId()) && equal(this.getName(), that.getName())
&& equal(this.getApi(), that.getApi()) && equal(this.getConsole(), that.getConsole())
&& equal(this.getHomepage(), that.getHomepage())
&& equal(this.getLinkedServices(), that.getLinkedServices())
&& equal(this.getIso3166Codes(), that.getIso3166Codes());
}
ProviderMetadata other = (ProviderMetadata) obj; @Override
URI oConsole = other.getConsole(); public int hashCode() {
URI oHomepage = other.getHomepage(); return Objects.hashCode(getId(), getName(), getApi(), getConsole(), getHomepage(), getLinkedServices(),
URI oDocs = other.getApiDocumentation(); getIso3166Codes());
String oId = other.getId();
String oName = other.getName();
String oIdentityName = other.getIdentityName();
String oCredentialName = other.getCredentialName();
String oType = other.getType();
Set<String> oLinkedServices = other.getLinkedServices();
Set<String> oIso3166Codes = other.getIso3166Codes();
if (tConsole == null) {
if (oConsole != null)
return false;
} else if (!tConsole.equals(oConsole))
return false;
if (tDocs == null) {
if (oDocs != null)
return false;
} else if (!tDocs.equals(oDocs))
return false;
if (tHomepage == null) {
if (oHomepage != null)
return false;
} else if (!tHomepage.equals(oHomepage))
return false;
if (tId == null) {
if (oId != null)
return false;
} else if (!tId.equals(oId))
return false;
if (tName == null) {
if (oName != null)
return false;
} else if (!tName.equals(oName))
return false;
if (tIdentityName == null) {
if (oIdentityName != null)
return false;
} else if (!tIdentityName.equals(oIdentityName))
return false;
if (tCredentialName == null) {
if (oCredentialName != null)
return false;
} else if (!tCredentialName.equals(oCredentialName))
return false;
if (tType == null) {
if (oType != null)
return false;
} else if (!tType.equals(oType))
return false;
if (tLinkedServices == null) {
if (oLinkedServices != null)
return false;
} else if (!tLinkedServices.equals(oLinkedServices))
return false;
if (tIso3166Codes == null) {
if (oIso3166Codes != null)
return false;
} else if (!tIso3166Codes.equals(oIso3166Codes))
return false;
return true;
} }
@Override @Override
public String toString() { public String toString() {
return "[id=" + getId() + ", type=" + getType() + ", name=" + getName() + ", identityName=" + getIdentityName() return string().toString();
+ ", credentialName=" + getCredentialName() + ", homePage=" + getHomepage() + ", console="
+ getConsole() + ", apiDocs=" + getApiDocumentation() + ", linkedServices=" + getLinkedServices() +
", iso3166Codes=" + getIso3166Codes() + "]";
} }
public ToStringHelper string() {
return Objects.toStringHelper("").add("id", getId()).add("name", getName()).add("api", getApi())
.add("console", getConsole()).add("homepage", getHomepage()).add("linkedServices", getLinkedServices())
.add("iso3166Codes", getIso3166Codes());
}
/**
* {@inheritDoc}
*/
@Override
public String getId() {
return id;
}
/**
* {@inheritDoc}
*/
@Override
public String getName() {
return name;
}
/**
* {@inheritDoc}
*/
@Override
public ApiMetadata getApi() {
return api;
}
/**
* {@inheritDoc}
*/
@Override
public URI getConsole() {
return console;
}
/**
* {@inheritDoc}
*/
@Override
public URI getHomepage() {
return homepage;
}
/**
* {@inheritDoc}
*/
@Override @Override
public Set<String> getLinkedServices() { public Set<String> getLinkedServices() {
return ImmutableSet.of(getId()); return linkedServices;
}
/**
* {@inheritDoc}
*/
@Override
public Set<String> getIso3166Codes() {
return iso3166Codes;
}
/**
* {@inheritDoc}
*/
@Override
public String getType() {
return getApi().getType().toString();
}
/**
* {@inheritDoc}
*/
@Override
public String getIdentityName() {
return getApi().getIdentityName();
}
/**
* {@inheritDoc}
*/
@Override
public String getCredentialName() {
return getApi().getCredentialName();
}
/**
* {@inheritDoc}
*/
@Override
public URI getApiDocumentation() {
return getApi().getDocumentation();
} }
} }

View File

@ -21,35 +21,125 @@ package org.jclouds.providers;
import java.net.URI; import java.net.URI;
import java.util.Set; import java.util.Set;
import org.jclouds.apis.ApiMetadata;
import org.jclouds.javax.annotation.Nullable; import org.jclouds.javax.annotation.Nullable;
/** /**
* The ProviderMetadata interface allows jclouds to provide a plugin framework for gathering cloud * The ProviderMetadata interface allows jclouds to provide a plugin framework
* provider metadata. * for gathering cloud provider metadata.
* *
* @author Jeremy Whitlock <jwhitlock@apache.org> * @author Jeremy Whitlock <jwhitlock@apache.org>
*/ */
public interface ProviderMetadata { public interface ProviderMetadata {
/**
* @see ApiMetadata#BLOBSTORE_TYPE
*/
@Deprecated
public static final String BLOBSTORE_TYPE = "blobstore"; public static final String BLOBSTORE_TYPE = "blobstore";
/**
* @see ApiMetadata#COMPUTE_TYPE
*/
@Deprecated
public static final String COMPUTE_TYPE = "compute"; public static final String COMPUTE_TYPE = "compute";
/**
* @see ApiMetadata#LOADBALANCER_TYPE
*/
@Deprecated
public static final String LOADBALANCER_TYPE = "loadbalancer"; public static final String LOADBALANCER_TYPE = "loadbalancer";
/**
* @see ApiMetadata#TABLE_TYPE
*/
@Deprecated
public static final String TABLE_TYPE = "table"; public static final String TABLE_TYPE = "table";
/**
* @see ApiMetadata#QUEUE_TYPE
*/
@Deprecated
public static final String QUEUE_TYPE = "queue"; public static final String QUEUE_TYPE = "queue";
/**
* @see ApiMetadata#MONITOR_TYPE
*/
@Deprecated
public static final String MONITOR_TYPE = "monitor"; public static final String MONITOR_TYPE = "monitor";
/**
*
* @author Adrian Cole
* @since 1.5
*/
public static interface Builder<B extends Builder<B>> {
/**
* @see ProviderMetadata#getId()
*/
B id(String id);
/**
* @see ProviderMetadata#getName()
*/
B name(String name);
/**
* @see ProviderMetadata#getApi()
*/
B api(ApiMetadata api);
/**
* @see ProviderMetadata#getConsole()
*/
B console(@Nullable URI console);
/**
* @see ProviderMetadata#getHomepage()
*/
B homepage(@Nullable URI homepage);
/**
* @see ProviderMetadata#getLinkedServices()
*/
B linkedServices(Iterable<String> linkedServices);
/**
* @see ProviderMetadata#getLinkedServices()
*/
B linkedServices(String... linkedServices);
/**
* @see ProviderMetadata#getLinkedServices()
*/
B linkedService(String linkedService);
/**
* @see ProviderMetadata#getIso3166Code()
*/
B iso3166Codes(Iterable<String> iso3166Codes);
/**
* @see ProviderMetadata#getIso3166Code()
*/
B iso3166Codes(String... iso3166Codes);
/**
* @see ProviderMetadata#getIso3166Code()
*/
B iso3166Code(String iso3166Code);
ProviderMetadata build();
B fromProviderMetadata(ProviderMetadata in);
}
/**
* @see Builder
* @since 1.5
*/
Builder<?> toBuilder();
/** /**
* *
* @return the provider's unique identifier * @return the provider's unique identifier
*/ */
public String getId(); public String getId();
/**
*
* @return the provider's type
*/
public String getType();
/** /**
* *
* @return the name (display name) of the provider * @return the name (display name) of the provider
@ -58,18 +148,49 @@ public interface ProviderMetadata {
/** /**
* *
* @return the name (display name) of an identity on this provider (ex. user, email, account, * @see #getApi()
* apikey) * @see ApiMetadata#getType
*/ */
@Deprecated
public String getType();
/**
*
* @return the provider's api
* @since 1.5
*/
public ApiMetadata getApi();
/**
*
* @see #getApi()
* @see ApiMetadata#getIdentityName
*/
@Deprecated
public String getIdentityName(); public String getIdentityName();
/** /**
* *
* @return the name (display name) of a credential on this provider, or null if there is none * @see #getApi()
* (ex. password, secret, rsaKey) * @see ApiMetadata#getCredentialName
*/
@Deprecated
public String getCredentialName();
/**
*
* @see #getApi()
* @see ApiMetadata#getDocumentation
*/
@Deprecated
public URI getApiDocumentation();
/**
*
* @return the url for the provider's console, or null if one doesn't exist
*/ */
@Nullable @Nullable
public String getCredentialName(); public URI getConsole();
/** /**
* *
@ -77,18 +198,6 @@ public interface ProviderMetadata {
*/ */
public URI getHomepage(); public URI getHomepage();
/**
*
* @return the url for the provider's console
*/
public URI getConsole();
/**
*
* @return the url for the API documentation related to this service
*/
public URI getApiDocumentation();
/** /**
* *
* @return all known services linked to the same account on this provider * @return all known services linked to the same account on this provider

View File

@ -18,6 +18,8 @@
*/ */
package org.jclouds.providers; package org.jclouds.providers;
import org.jclouds.apis.ApiMetadata;
import org.jclouds.apis.ApiType;
import org.jclouds.util.Preconditions2; import org.jclouds.util.Preconditions2;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
@ -77,15 +79,15 @@ public class ProviderPredicates {
* *
* @return the providers with the given type * @return the providers with the given type
*/ */
public static Predicate<ProviderMetadata> type(final String type) { public static Predicate<ProviderMetadata> type(final ApiType type) {
Preconditions2.checkNotEmpty(type, "type must be defined"); Preconditions.checkNotNull(type, "type must be defined");
return new Predicate<ProviderMetadata>() { return new Predicate<ProviderMetadata>() {
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
public boolean apply(ProviderMetadata providerMetadata) { public boolean apply(ProviderMetadata providerMetadata) {
return providerMetadata.getType().equals(type); return providerMetadata.getApi().getType().equals(type);
} }
/** /**
@ -99,10 +101,19 @@ public class ProviderPredicates {
} }
/** /**
* Returns the providers that are bound to the same location as the given ISO 3166 code. * @see #type(ApiMetadata)
*/
@Deprecated
public static Predicate<ProviderMetadata> type(final String type) {
return type(ApiType.fromValue(type));
}
/**
* Returns the providers that are bound to the same location as the given ISO
* 3166 code.
* *
* @param isoCode * @param isoCode
* the ISO 3166 code to filter providers by * the ISO 3166 code to filter providers by
* *
* @return the providers with the given ISO 3166 code * @return the providers with the given ISO 3166 code
*/ */
@ -129,10 +140,11 @@ public class ProviderPredicates {
} }
/** /**
* Return all providers that have at least one ISO 3166 code in common with the given provider metadata. * Return all providers that have at least one ISO 3166 code in common with
* the given provider metadata.
* *
* @param refProviderMetadata * @param refProviderMetadata
* the provider metadata to use to filter providers by * the provider metadata to use to filter providers by
* *
* @return the providers that have at least one ISO 3166 code in common * @return the providers that have at least one ISO 3166 code in common
*/ */
@ -146,10 +158,11 @@ public class ProviderPredicates {
@Override @Override
public boolean apply(ProviderMetadata providerMetadata) { public boolean apply(ProviderMetadata providerMetadata) {
for (String refIso3166Code : refProviderMetadata.getIso3166Codes()) { for (String refIso3166Code : refProviderMetadata.getIso3166Codes()) {
// Return only if the potential provider contains the same ISO 3166 code and the provider and // Return only if the potential provider contains the same ISO
// 3166 code and the provider and
// reference provider are not the same. // reference provider are not the same.
if (providerContainsIso3166Code(providerMetadata, refIso3166Code) && if (providerContainsIso3166Code(providerMetadata, refIso3166Code)
!refProviderMetadata.equals(providerMetadata)) { && !refProviderMetadata.equals(providerMetadata)) {
return true; return true;
} }
} }
@ -167,19 +180,20 @@ public class ProviderPredicates {
} }
/** /**
* Returns whether or not the provided provider contains the ISO 3166 code provider or is within the same * Returns whether or not the provided provider contains the ISO 3166 code
* "global" region, like "US" would contain "US-*". * provider or is within the same "global" region, like "US" would contain
* "US-*".
* *
* @param providerMetadata * @param providerMetadata
* the provider metadata to search * the provider metadata to search
* @param iso3166Code * @param iso3166Code
* the ISO 3166 code to search the provider metadata for * the ISO 3166 code to search the provider metadata for
* *
* @return the result * @return the result
*/ */
private static boolean providerContainsIso3166Code(ProviderMetadata providerMetadata, String iso3166Code) { private static boolean providerContainsIso3166Code(ProviderMetadata providerMetadata, String iso3166Code) {
for (String availCode : providerMetadata.getIso3166Codes()) { for (String availCode : providerMetadata.getIso3166Codes()) {
if(iso3166Code.indexOf('-') == -1) { if (iso3166Code.indexOf('-') == -1) {
if (availCode.startsWith(iso3166Code + "-")) { if (availCode.startsWith(iso3166Code + "-")) {
return true; return true;
} }
@ -190,4 +204,33 @@ public class ProviderPredicates {
return false; return false;
} }
/**
* Returns all providers with the given api.
*
* @param type
* the type of the provider to return
*
* @return the providers with the given api
*/
public static Predicate<ProviderMetadata> api(final ApiMetadata api) {
Preconditions.checkNotNull(api, "api must be defined");
return new Predicate<ProviderMetadata>() {
/**
* {@inheritDoc}
*/
@Override
public boolean apply(ProviderMetadata providerMetadata) {
return providerMetadata.getApi().equals(api);
}
/**
* {@inheritDoc}
*/
@Override
public String toString() {
return "api(" + api + ")";
}
};
}
} }

View File

@ -24,6 +24,9 @@ import static com.google.common.collect.Iterables.find;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
import java.util.ServiceLoader; import java.util.ServiceLoader;
import org.jclouds.apis.ApiMetadata;
import org.jclouds.apis.ApiType;
import com.google.common.base.Predicates; import com.google.common.base.Predicates;
/** /**
@ -34,7 +37,8 @@ import com.google.common.base.Predicates;
public class Providers { public class Providers {
/** /**
* Returns the providers located on the classpath via {@link java.util.ServiceLoader}. * Returns the providers located on the classpath via
* {@link java.util.ServiceLoader}.
* *
* @return all available providers loaded from classpath via ServiceLoader * @return all available providers loaded from classpath via ServiceLoader
*/ */
@ -68,52 +72,52 @@ public class Providers {
/** /**
* Returns the providers that are of type * Returns the providers that are of type
* {@link org.jclouds.providers.ProviderMetadata#BLOBSTORE_TYPE}. * {@link org.jclouds.providers.ProviderMetadata#BLOBSTORE}.
* *
* @return the blobstore providers * @return the blobstore providers
*/ */
public static Iterable<ProviderMetadata> allBlobStore() { public static Iterable<ProviderMetadata> allBlobStore() {
return filter(all(), ProviderPredicates.type(ProviderMetadata.BLOBSTORE_TYPE)); return filter(all(), ProviderPredicates.type(ApiType.BLOBSTORE));
} }
/** /**
* Returns the providers that are of type * Returns the providers that are of type
* {@link org.jclouds.providers.ProviderMetadata#COMPUTE_TYPE}. * {@link org.jclouds.providers.ProviderMetadata#COMPUTE}.
* *
* @return the compute service providers * @return the compute service providers
*/ */
public static Iterable<ProviderMetadata> allCompute() { public static Iterable<ProviderMetadata> allCompute() {
return filter(all(), ProviderPredicates.type(ProviderMetadata.COMPUTE_TYPE)); return filter(all(), ProviderPredicates.type(ApiType.COMPUTE));
} }
/** /**
* Returns the providers that are of type * Returns the providers that are of type
* {@link org.jclouds.providers.ProviderMetadata#QUEUE_TYPE}. * {@link org.jclouds.providers.ProviderMetadata#QUEUE}.
* *
* @return the queue service providers * @return the queue service providers
*/ */
public static Iterable<ProviderMetadata> allQueue() { public static Iterable<ProviderMetadata> allQueue() {
return filter(all(), ProviderPredicates.type(ProviderMetadata.QUEUE_TYPE)); return filter(all(), ProviderPredicates.type(ApiType.QUEUE));
} }
/** /**
* Returns the providers that are of type * Returns the providers that are of type
* {@link org.jclouds.providers.ProviderMetadata#TABLE_TYPE}. * {@link org.jclouds.providers.ProviderMetadata#TABLE}.
* *
* @return the table service providers * @return the table service providers
*/ */
public static Iterable<ProviderMetadata> allTable() { public static Iterable<ProviderMetadata> allTable() {
return filter(all(), ProviderPredicates.type(ProviderMetadata.TABLE_TYPE)); return filter(all(), ProviderPredicates.type(ApiType.TABLE));
} }
/** /**
* Returns the providers that are of type * Returns the providers that are of type
* {@link org.jclouds.providers.ProviderMetadata#LOADBALANCER_TYPE}. * {@link org.jclouds.providers.ProviderMetadata#LOADBALANCER}.
* *
* @return the load balancer service providers * @return the load balancer service providers
*/ */
public static Iterable<ProviderMetadata> allLoadBalancer() { public static Iterable<ProviderMetadata> allLoadBalancer() {
return filter(all(), ProviderPredicates.type(ProviderMetadata.LOADBALANCER_TYPE)); return filter(all(), ProviderPredicates.type(ApiType.LOADBALANCER));
} }
/** /**
@ -124,15 +128,36 @@ public class Providers {
* *
* @return the providers of the provided type * @return the providers of the provided type
*/ */
public static Iterable<ProviderMetadata> ofType(String type) { public static Iterable<ProviderMetadata> ofType(ApiType type) {
return filter(all(), ProviderPredicates.type(type)); return filter(all(), ProviderPredicates.type(type));
} }
/** /**
* Returns the providers that are bound to the same location as the given ISO 3166 code regardless of type. * Returns the providers that are of the provided api.
*
* @param api
* the api to providers to return
*
* @return the providers of the provided api
*/
public static Iterable<ProviderMetadata> ofApi(ApiMetadata api) {
return filter(all(), ProviderPredicates.api(api));
}
/**
* @see #ofType(ApiMetadata)
*/
@Deprecated
public static Iterable<ProviderMetadata> ofType(String type) {
return ofType(ApiType.fromValue(type));
}
/**
* Returns the providers that are bound to the same location as the given ISO
* 3166 code regardless of type.
* *
* @param isoCode * @param isoCode
* the ISO 3166 code to filter providers by * the ISO 3166 code to filter providers by
* *
* @return the providers bound by the given ISO 3166 code * @return the providers bound by the given ISO 3166 code
*/ */
@ -141,25 +166,36 @@ public class Providers {
} }
/** /**
* Returns the providers that are bound to the same location as the given ISO 3166 code and of the given type. * Returns the providers that are bound to the same location as the given ISO
* 3166 code and of the given type.
* *
* @param iso3166Code * @param iso3166Code
* the ISO 3166 code to filter providers by * the ISO 3166 code to filter providers by
* @param type * @param type
* the type to filter providers by * the type to filter providers by
* *
* @return the providers bound by the given ISO 3166 code and of the proper type * @return the providers bound by the given ISO 3166 code and of the proper
* type
*/ */
public static Iterable<ProviderMetadata> boundedByIso3166Code(String iso3166Code, String type) { public static Iterable<ProviderMetadata> boundedByIso3166Code(String iso3166Code, ApiType type) {
return filter(all(), Predicates.and(ProviderPredicates.boundedByIso3166Code(iso3166Code), return filter(all(),
ProviderPredicates.type(type))); Predicates.and(ProviderPredicates.boundedByIso3166Code(iso3166Code), ProviderPredicates.type(type)));
} }
/** /**
* Returns the providers that have at least one common ISO 3166 code in common regardless of type. * @see #boundedByIso3166Code(String iso3166Code, ApiType)
*/
@Deprecated
public static Iterable<ProviderMetadata> boundedByIso3166Code(String iso3166Code, String type) {
return boundedByIso3166Code(iso3166Code, ApiType.fromValue(type));
}
/**
* Returns the providers that have at least one common ISO 3166 code in
* common regardless of type.
* *
* @param providerMetadata * @param providerMetadata
* the provider metadata to use to filter providers by * the provider metadata to use to filter providers by
* *
* @return the providers that share at least one common ISO 3166 code * @return the providers that share at least one common ISO 3166 code
*/ */
@ -168,17 +204,28 @@ public class Providers {
} }
/** /**
* Returns the providers that have at least one common ISO 3166 code and are of the given type. * Returns the providers that have at least one common ISO 3166 code and are
* of the given type.
* *
* @param providerMetadata * @param providerMetadata
* the provider metadata to use to filter providers by * the provider metadata to use to filter providers by
* @param type * @param type
* the type to filter providers by * the type to filter providers by
* *
* @return the providers that share at least one common ISO 3166 code and of the given type * @return the providers that share at least one common ISO 3166 code and of
* the given type
*/ */
public static Iterable<ProviderMetadata> collocatedWith(ProviderMetadata providerMetadata, String type) { public static Iterable<ProviderMetadata> collocatedWith(ProviderMetadata providerMetadata, ApiType type) {
return filter(all(), Predicates.and(ProviderPredicates.intersectingIso3166Code(providerMetadata), return filter(all(),
ProviderPredicates.type(type))); Predicates.and(ProviderPredicates.intersectingIso3166Code(providerMetadata), ProviderPredicates.type(type)));
} }
/**
* @see #collocatedWith(ProviderMetadata iso3166Code, ApiType)
*/
@Deprecated
public static Iterable<ProviderMetadata> collocatedWith(ProviderMetadata providerMetadata, String type) {
return collocatedWith(providerMetadata, ApiType.fromValue(type));
}
} }

View File

@ -0,0 +1,94 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.apis;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.fail;
import java.util.NoSuchElementException;
import org.testng.annotations.Test;
/**
* The ApisTest tests the org.jclouds.apis.Apis class.
*
* @author Jeremy Whitlock <jwhitlock@apache.org>
*/
@Test(groups = "unit", testName = "ApisTest")
public class ApisTest {
private final ApiMetadata testBlobstoreApi = new JcloudsTestBlobStoreApiMetadata();
private final ApiMetadata testComputeApi = new JcloudsTestComputeApiMetadata();
private final ApiMetadata testYetAnotherComputeApi = new JcloudsTestYetAnotherComputeApiMetadata();
@Test
public void testWithId() {
ApiMetadata apiMetadata;
try {
apiMetadata = Apis.withId("fake-id");
fail("Looking for a api with an id that doesn't exist should " + "throw an exceptoin.");
} catch (NoSuchElementException nsee) {
; // Expected
}
apiMetadata = Apis.withId(testBlobstoreApi.getId());
assertEquals(testBlobstoreApi, apiMetadata);
}
@Test
public void testOfType() {
Iterable<ApiMetadata> apisMetadata = Apis.ofType(ApiType.BLOBSTORE);
for (ApiMetadata apiMetadata : apisMetadata) {
assertEquals(testBlobstoreApi, apiMetadata);
}
apisMetadata = Apis.ofType(ApiType.COMPUTE);
for (ApiMetadata apiMetadata : apisMetadata) {
if (apiMetadata.getName().equals(testComputeApi.getName())) {
assertEquals(testComputeApi, apiMetadata);
} else {
assertEquals(testYetAnotherComputeApi, apiMetadata);
}
}
apisMetadata = Apis.ofType(ApiType.UNRECOGNIZED);
assertEquals(false, apisMetadata.iterator().hasNext());
}
@Test
public void testAll() {
Iterable<ApiMetadata> apisMetadata = Apis.all();
for (ApiMetadata apiMetadata : apisMetadata) {
if (apiMetadata.getName().equals(testBlobstoreApi.getName())) {
assertEquals(testBlobstoreApi, apiMetadata);
} else if (apiMetadata.getName().equals(testComputeApi.getName())) {
assertEquals(testComputeApi, apiMetadata);
} else {
assertEquals(testYetAnotherComputeApi, apiMetadata);
}
}
}
}

View File

@ -0,0 +1,62 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.apis;
import static org.testng.Assert.assertEquals;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableSet;
/**
*
* @author Jeremy Whitlock <jwhitlock@apache.org>
*/
@Test(groups = "unit")
public abstract class BaseApiMetadataTest {
private final ApiMetadata toTest;
private final ApiType expectedType;
public BaseApiMetadataTest(ApiMetadata toTest, ApiType expectedType) {
this.toTest = toTest;
this.expectedType = expectedType;
}
@Test
public void testWithId() {
ApiMetadata apiMetadata = Apis.withId(toTest.getId());
assertEquals(toTest, apiMetadata);
}
// it is ok to have multiple services in the same classpath (ex. ec2 vs elb)
@Test
public void testOfTypeContains() {
ImmutableSet<ApiMetadata> ofType = ImmutableSet.copyOf(Apis.ofType(expectedType));
assert ofType.contains(toTest) : String.format("%s not found in %s", toTest, ofType);
}
@Test
public void testAllContains() {
ImmutableSet<ApiMetadata> all = ImmutableSet.copyOf(Apis.all());
assert all.contains(toTest) : String.format("%s not found in %s", toTest, all);
}
}

View File

@ -0,0 +1,63 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.apis;
import java.net.URI;
/**
* Implementation of @ link org.jclouds.types.ApiMetadata} for testing.
*
* @author Jeremy Whitlock <jwhitlock@apache.org>, Adrian Cole
*/
public class JcloudsTestBlobStoreApiMetadata extends BaseApiMetadata {
public JcloudsTestBlobStoreApiMetadata() {
this(builder()
.id("test-blobstore-api")
.type(ApiType.BLOBSTORE)
.name("Test Blobstore Api")
.identityName("user")
.credentialName("password")
.documentation(URI.create("http://jclouds.org/documentation")));
}
// below are so that we can reuse builders, toString, hashCode, etc.
// we have to set concrete classes here, as our base class cannot be
// concrete due to serviceLoader
protected JcloudsTestBlobStoreApiMetadata(ConcreteBuilder builder) {
super(builder);
}
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
@Override
public JcloudsTestBlobStoreApiMetadata build() {
return new JcloudsTestBlobStoreApiMetadata(this);
}
}
public static ConcreteBuilder builder() {
return new ConcreteBuilder();
}
@Override
public ConcreteBuilder toBuilder() {
return builder().fromApiMetadata(this);
}
}

View File

@ -0,0 +1,63 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.apis;
import java.net.URI;
/**
* Implementation of @ link org.jclouds.types.ApiMetadata} for testing.
*
* @author Jeremy Whitlock <jwhitlock@apache.org>, Adrian Cole
*/
public class JcloudsTestComputeApiMetadata extends BaseApiMetadata {
public JcloudsTestComputeApiMetadata() {
this(builder()
.id("test-compute-api")
.type(ApiType.COMPUTE)
.name("Test Compute Api")
.identityName("user")
.credentialName("password")
.documentation(URI.create("http://jclouds.org/documentation")));
}
// below are so that we can reuse builders, toString, hashCode, etc.
// we have to set concrete classes here, as our base class cannot be
// concrete due to serviceLoader
protected JcloudsTestComputeApiMetadata(ConcreteBuilder builder) {
super(builder);
}
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
@Override
public JcloudsTestComputeApiMetadata build() {
return new JcloudsTestComputeApiMetadata(this);
}
}
public static ConcreteBuilder builder() {
return new ConcreteBuilder();
}
@Override
public ConcreteBuilder toBuilder() {
return builder().fromApiMetadata(this);
}
}

View File

@ -0,0 +1,64 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.apis;
import java.net.URI;
/**
* Implementation of @ link org.jclouds.types.ApiMetadata} for testing.
*
* @author Jeremy Whitlock <jwhitlock@apache.org>
*/
public class JcloudsTestYetAnotherComputeApiMetadata extends BaseApiMetadata {
public JcloudsTestYetAnotherComputeApiMetadata() {
this(builder()
.id("test-yet-another-compute-api")
.type(ApiType.COMPUTE)
.name("Test Yet Another Compute Api")
.identityName("user")
.credentialName("password")
.documentation(URI.create("http://jclouds.org/documentation")));
}
// below are so that we can reuse builders, toString, hashCode, etc.
// we have to set concrete classes here, as our base class cannot be
// concrete due to serviceLoader
protected JcloudsTestYetAnotherComputeApiMetadata(ConcreteBuilder builder) {
super(builder);
}
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
@Override
public JcloudsTestYetAnotherComputeApiMetadata build() {
return new JcloudsTestYetAnotherComputeApiMetadata(this);
}
}
public static ConcreteBuilder builder() {
return new ConcreteBuilder();
}
@Override
public ConcreteBuilder toBuilder() {
return builder().fromApiMetadata(this);
}
}

View File

@ -18,10 +18,13 @@
*/ */
package org.jclouds.providers; package org.jclouds.providers;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import java.util.Set; import java.util.logging.Logger;
import org.jclouds.apis.ApiMetadata;
import org.jclouds.apis.ApiType;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
@ -33,15 +36,15 @@ import com.google.common.collect.Iterables;
*/ */
@Test(groups = "unit") @Test(groups = "unit")
public abstract class BaseProviderMetadataTest { public abstract class BaseProviderMetadataTest {
protected Set<String> allTypes = ImmutableSet.of(ProviderMetadata.BLOBSTORE_TYPE, ProviderMetadata.COMPUTE_TYPE,
ProviderMetadata.LOADBALANCER_TYPE, ProviderMetadata.QUEUE_TYPE, ProviderMetadata.TABLE_TYPE);
private final ProviderMetadata toTest; private final ProviderMetadata toTest;
private final String expectedType; private final ApiType expectedType;
private final ApiMetadata expectedApi;
public BaseProviderMetadataTest(ProviderMetadata toTest, String expectedType) { public BaseProviderMetadataTest(ProviderMetadata toTest, ApiMetadata expectedApi) {
this.toTest = toTest; this.toTest = checkNotNull(toTest, "toTest must be defined");
this.expectedType = expectedType; this.expectedApi = checkNotNull(expectedApi, "expectedApi must be defined");
this.expectedType = expectedApi.getType();
} }
@Test @Test
@ -52,6 +55,14 @@ public abstract class BaseProviderMetadataTest {
assert providerMetadata.getLinkedServices().contains(toTest.getId()); assert providerMetadata.getLinkedServices().contains(toTest.getId());
} }
@Test
public void testOfApiContains() {
if (expectedApi == null)
Logger.getAnonymousLogger().warning("please update your test class");
ImmutableSet<ProviderMetadata> ofApi = ImmutableSet.copyOf(Providers.ofApi(expectedApi));
assert ofApi.contains(toTest) : String.format("%s not found in %s", toTest, ofApi);
}
// it is ok to have multiple services in the same classpath (ex. ec2 vs elb) // it is ok to have multiple services in the same classpath (ex. ec2 vs elb)
@Test @Test
public void testOfTypeContains() { public void testOfTypeContains() {

View File

@ -19,7 +19,8 @@
package org.jclouds.providers; package org.jclouds.providers;
import java.net.URI; import java.net.URI;
import java.util.Set;
import org.jclouds.apis.JcloudsTestBlobStoreApiMetadata;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
@ -30,76 +31,36 @@ import com.google.common.collect.ImmutableSet;
*/ */
public class JcloudsTestBlobStoreProviderMetadata extends BaseProviderMetadata { public class JcloudsTestBlobStoreProviderMetadata extends BaseProviderMetadata {
/** public JcloudsTestBlobStoreProviderMetadata() {
* {@inheritDoc} this(builder()
*/ .api(new JcloudsTestBlobStoreApiMetadata())
@Override .id("test-blobstore-api")
public String getId() { .name("Test Blobstore Provider")
return "test-blobstore-provider"; .homepage(URI.create("http://jclouds.org"))
.console(URI.create("http://jclouds.org/console"))
.iso3166Codes(ImmutableSet.of("US-VA", "US-CA", "US-FL")));
} }
/** // below are so that we can reuse builders, toString, hashCode, etc.
* {@inheritDoc} // we have to set concrete classes here, as our base class cannot be
*/ // concrete due to serviceLoader
@Override protected JcloudsTestBlobStoreProviderMetadata(ConcreteBuilder builder) {
public String getType() { super(builder);
return ProviderMetadata.BLOBSTORE_TYPE;
} }
/** private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
* {@inheritDoc}
*/ @Override
@Override public JcloudsTestBlobStoreProviderMetadata build() {
public String getName() { return new JcloudsTestBlobStoreProviderMetadata(this);
return "Test Blobstore Provider"; }
} }
/** public static ConcreteBuilder builder() {
* {@inheritDoc} return new ConcreteBuilder();
*/
@Override
public String getCredentialName() {
return "user";
} }
/** public ConcreteBuilder toBuilder() {
* {@inheritDoc} return builder().fromProviderMetadata(this);
*/
@Override
public String getIdentityName() {
return "password";
} }
/**
* {@inheritDoc}
*/
@Override
public URI getHomepage() {
return URI.create("http://jclouds.org");
}
/**
* {@inheritDoc}
*/
@Override
public URI getConsole() {
return URI.create("http://jclouds.org/console");
}
/**
* {@inheritDoc}
*/
@Override
public URI getApiDocumentation() {
return URI.create("http://jclouds.org/documentation");
}
/**
* {@inheritDoc}
*/
@Override
public Set<String> getIso3166Codes() {
return ImmutableSet.of("US-VA", "US-CA", "US-FL");
}
} }

View File

@ -19,7 +19,8 @@
package org.jclouds.providers; package org.jclouds.providers;
import java.net.URI; import java.net.URI;
import java.util.Set;
import org.jclouds.apis.JcloudsTestComputeApiMetadata;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
@ -30,76 +31,36 @@ import com.google.common.collect.ImmutableSet;
*/ */
public class JcloudsTestComputeProviderMetadata extends BaseProviderMetadata { public class JcloudsTestComputeProviderMetadata extends BaseProviderMetadata {
/** public JcloudsTestComputeProviderMetadata() {
* {@ see org.jclouds.types.ProviderMetadata#getId()} this(builder()
*/ .api(new JcloudsTestComputeApiMetadata())
@Override .id("test-compute-api")
public String getId() { .name("Test Compute Provider")
return "test-compute-provider"; .homepage(URI.create("http://jclouds.org"))
.console(URI.create("http://jclouds.org/console"))
.iso3166Codes(ImmutableSet.of("US-VA", "US-CA")));
} }
/** // below are so that we can reuse builders, toString, hashCode, etc.
* {@ see org.jclouds.types.ProviderMetadata#getType()} // we have to set concrete classes here, as our base class cannot be
*/ // concrete due to serviceLoader
@Override protected JcloudsTestComputeProviderMetadata(ConcreteBuilder builder) {
public String getType() { super(builder);
return ProviderMetadata.COMPUTE_TYPE;
} }
/** private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
* {@ see org.jclouds.types.ProviderMetadata#getName()}
*/ @Override
@Override public JcloudsTestComputeProviderMetadata build() {
public String getName() { return new JcloudsTestComputeProviderMetadata(this);
return "Test Compute Provider"; }
} }
/** public static ConcreteBuilder builder() {
* {@inheritDoc} return new ConcreteBuilder();
*/
@Override
public String getCredentialName() {
return "user";
} }
/** public ConcreteBuilder toBuilder() {
* {@inheritDoc} return builder().fromProviderMetadata(this);
*/
@Override
public String getIdentityName() {
return "password";
} }
/**
* {@ see org.jclouds.types.ProviderMetadata#getHomepage()}
*/
@Override
public URI getHomepage() {
return URI.create("http://jclouds.org");
}
/**
* {@ see org.jclouds.types.ProviderMetadata#getConsole()}
*/
@Override
public URI getConsole() {
return URI.create("http://jclouds.org/console");
}
/**
* {@inheritDoc}
*/
@Override
public URI getApiDocumentation() {
return URI.create("http://jclouds.org/documentation");
}
/**
* {@inheritDoc}
*/
@Override
public Set<String> getIso3166Codes() {
return ImmutableSet.of("US-VA", "US-CA");
}
} }

View File

@ -19,7 +19,8 @@
package org.jclouds.providers; package org.jclouds.providers;
import java.net.URI; import java.net.URI;
import java.util.Set;
import org.jclouds.apis.JcloudsTestComputeApiMetadata;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
@ -30,76 +31,36 @@ import com.google.common.collect.ImmutableSet;
*/ */
public class JcloudsTestYetAnotherComputeProviderMetadata extends BaseProviderMetadata { public class JcloudsTestYetAnotherComputeProviderMetadata extends BaseProviderMetadata {
/** public JcloudsTestYetAnotherComputeProviderMetadata() {
* {@ see org.jclouds.types.ProviderMetadata#getId()} this(builder()
*/ .api(new JcloudsTestComputeApiMetadata())
@Override .id("test-yet-another-compute-provider")
public String getId() { .name("Test Yet Another Compute Provider")
return "test-yet-another-compute-provider"; .homepage(URI.create("http://jclouds.org"))
.console(URI.create("http://jclouds.org/console"))
.iso3166Codes(ImmutableSet.of("JP-13")));
} }
/** // below are so that we can reuse builders, toString, hashCode, etc.
* {@ see org.jclouds.types.ProviderMetadata#getType()} // we have to set concrete classes here, as our base class cannot be
*/ // concrete due to serviceLoader
@Override protected JcloudsTestYetAnotherComputeProviderMetadata(ConcreteBuilder builder) {
public String getType() { super(builder);
return ProviderMetadata.COMPUTE_TYPE;
} }
/** private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
* {@ see org.jclouds.types.ProviderMetadata#getName()}
*/ @Override
@Override public JcloudsTestYetAnotherComputeProviderMetadata build() {
public String getName() { return new JcloudsTestYetAnotherComputeProviderMetadata(this);
return "Test Yet Another Compute Provider"; }
} }
/** public static ConcreteBuilder builder() {
* {@inheritDoc} return new ConcreteBuilder();
*/
@Override
public String getCredentialName() {
return "user";
} }
/** public ConcreteBuilder toBuilder() {
* {@inheritDoc} return builder().fromProviderMetadata(this);
*/
@Override
public String getIdentityName() {
return "password";
} }
/**
* {@ see org.jclouds.types.ProviderMetadata#getHomepage()}
*/
@Override
public URI getHomepage() {
return URI.create("http://jclouds.org");
}
/**
* {@ see org.jclouds.types.ProviderMetadata#getConsole()}
*/
@Override
public URI getConsole() {
return URI.create("http://jclouds.org/console");
}
/**
* {@inheritDoc}
*/
@Override
public URI getApiDocumentation() {
return URI.create("http://jclouds.org/documentation");
}
/**
* {@inheritDoc}
*/
@Override
public Set<String> getIso3166Codes() {
return ImmutableSet.of("JP-13");
}
} }

View File

@ -23,6 +23,7 @@ import static org.testng.Assert.fail;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
import org.jclouds.apis.ApiType;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
@ -32,7 +33,7 @@ import com.google.common.collect.Iterables;
* *
* @author Jeremy Whitlock <jwhitlock@apache.org> * @author Jeremy Whitlock <jwhitlock@apache.org>
*/ */
@Test( groups = "unit" ) @Test(groups = "unit", testName = "ProvidersTest")
public class ProvidersTest { public class ProvidersTest {
private final ProviderMetadata testBlobstoreProvider = new JcloudsTestBlobStoreProviderMetadata(); private final ProviderMetadata testBlobstoreProvider = new JcloudsTestBlobStoreProviderMetadata();
@ -45,8 +46,7 @@ public class ProvidersTest {
try { try {
providerMetadata = Providers.withId("fake-id"); providerMetadata = Providers.withId("fake-id");
fail("Looking for a provider with an id that doesn't exist should " + fail("Looking for a provider with an id that doesn't exist should " + "throw an exceptoin.");
"throw an exceptoin.");
} catch (NoSuchElementException nsee) { } catch (NoSuchElementException nsee) {
; // Expected ; // Expected
} }
@ -58,6 +58,30 @@ public class ProvidersTest {
@Test @Test
public void testOfType() { public void testOfType() {
Iterable<ProviderMetadata> providersMetadata = Providers.ofType(ApiType.BLOBSTORE);
for (ProviderMetadata providerMetadata : providersMetadata) {
assertEquals(testBlobstoreProvider, providerMetadata);
}
providersMetadata = Providers.ofType(ApiType.COMPUTE);
for (ProviderMetadata providerMetadata : providersMetadata) {
if (providerMetadata.getName().equals(testComputeProvider.getName())) {
assertEquals(testComputeProvider, providerMetadata);
} else {
assertEquals(testYetAnotherComputeProvider, providerMetadata);
}
}
providersMetadata = Providers.ofType(ApiType.UNRECOGNIZED);
assertEquals(false, providersMetadata.iterator().hasNext());
}
@Test
@Deprecated
public void testOfTypeDeprecated() {
Iterable<ProviderMetadata> providersMetadata = Providers.ofType(ProviderMetadata.BLOBSTORE_TYPE); Iterable<ProviderMetadata> providersMetadata = Providers.ofType(ProviderMetadata.BLOBSTORE_TYPE);
for (ProviderMetadata providerMetadata : providersMetadata) { for (ProviderMetadata providerMetadata : providersMetadata) {
@ -86,10 +110,10 @@ public class ProvidersTest {
for (ProviderMetadata providerMetadata : providersMetadata) { for (ProviderMetadata providerMetadata : providersMetadata) {
if (providerMetadata.getName().equals(testBlobstoreProvider.getName())) { if (providerMetadata.getName().equals(testBlobstoreProvider.getName())) {
assertEquals(testBlobstoreProvider, providerMetadata); assertEquals(testBlobstoreProvider, providerMetadata);
} else if (providerMetadata.getName().equals(testComputeProvider.getName())){ } else if (providerMetadata.getName().equals(testComputeProvider.getName())) {
assertEquals(testComputeProvider, providerMetadata); assertEquals(testComputeProvider, providerMetadata);
} else { } else {
assertEquals(testYetAnotherComputeProvider, providerMetadata); assertEquals(testYetAnotherComputeProvider, providerMetadata);
} }
} }
} }
@ -104,6 +128,44 @@ public class ProvidersTest {
assertEquals(Iterables.size(Providers.boundedByIso3166Code("JP")), 1); assertEquals(Iterables.size(Providers.boundedByIso3166Code("JP")), 1);
assertEquals(Iterables.size(Providers.boundedByIso3166Code("FAKE-CODE")), 0); assertEquals(Iterables.size(Providers.boundedByIso3166Code("FAKE-CODE")), 0);
// Test filtering by ISO 3166 code and type
assertEquals(Iterables.size(Providers.boundedByIso3166Code("US-CA", ApiType.BLOBSTORE)), 1);
assertEquals(Iterables.size(Providers.boundedByIso3166Code("US-CA", ApiType.COMPUTE)), 1);
assertEquals(Iterables.size(Providers.boundedByIso3166Code("US-FL", ApiType.BLOBSTORE)), 1);
assertEquals(Iterables.size(Providers.boundedByIso3166Code("US-FL", ApiType.COMPUTE)), 0);
assertEquals(Iterables.size(Providers.boundedByIso3166Code("US", ApiType.BLOBSTORE)), 1);
assertEquals(Iterables.size(Providers.boundedByIso3166Code("US", ApiType.COMPUTE)), 1);
assertEquals(Iterables.size(Providers.boundedByIso3166Code("FAKE-CODE", ApiType.BLOBSTORE)), 0);
assertEquals(Iterables.size(Providers.boundedByIso3166Code("FAKE-CODE", ApiType.COMPUTE)), 0);
}
@Test
public void testCollocatedWith() {
// Test filtering by collocation alone
assertEquals(Iterables.size(Providers.collocatedWith(testBlobstoreProvider)), 1);
assertEquals(Iterables.size(Providers.collocatedWith(testComputeProvider)), 1);
assertEquals(Iterables.size(Providers.collocatedWith(testYetAnotherComputeProvider)), 0);
// Test filtering by collocation and type
assertEquals(Iterables.size(Providers.collocatedWith(testBlobstoreProvider, ApiType.BLOBSTORE)), 0);
assertEquals(Iterables.size(Providers.collocatedWith(testBlobstoreProvider, ApiType.COMPUTE)), 1);
assertEquals(Iterables.size(Providers.collocatedWith(testComputeProvider, ApiType.COMPUTE)), 0);
assertEquals(Iterables.size(Providers.collocatedWith(testComputeProvider, ApiType.BLOBSTORE)), 1);
assertEquals(Iterables.size(Providers.collocatedWith(testYetAnotherComputeProvider, ApiType.COMPUTE)), 0);
assertEquals(Iterables.size(Providers.collocatedWith(testYetAnotherComputeProvider, ApiType.BLOBSTORE)), 0);
}
@Test
@Deprecated
public void testBoundedByIso3166CodeDeprecated() {
// Test filtering by ISO 3166 code alone
assertEquals(Iterables.size(Providers.boundedByIso3166Code("US-CA")), 2);
assertEquals(Iterables.size(Providers.boundedByIso3166Code("US-FL")), 1);
assertEquals(Iterables.size(Providers.boundedByIso3166Code("US")), 2);
assertEquals(Iterables.size(Providers.boundedByIso3166Code("JP-13")), 1);
assertEquals(Iterables.size(Providers.boundedByIso3166Code("JP")), 1);
assertEquals(Iterables.size(Providers.boundedByIso3166Code("FAKE-CODE")), 0);
// Test filtering by ISO 3166 code and type // Test filtering by ISO 3166 code and type
assertEquals(Iterables.size(Providers.boundedByIso3166Code("US-CA", ProviderMetadata.BLOBSTORE_TYPE)), 1); assertEquals(Iterables.size(Providers.boundedByIso3166Code("US-CA", ProviderMetadata.BLOBSTORE_TYPE)), 1);
assertEquals(Iterables.size(Providers.boundedByIso3166Code("US-CA", ProviderMetadata.COMPUTE_TYPE)), 1); assertEquals(Iterables.size(Providers.boundedByIso3166Code("US-CA", ProviderMetadata.COMPUTE_TYPE)), 1);
@ -116,7 +178,8 @@ public class ProvidersTest {
} }
@Test @Test
public void testCollocatedWith() { @Deprecated
public void testCollocatedWithDeprecated() {
// Test filtering by collocation alone // Test filtering by collocation alone
assertEquals(Iterables.size(Providers.collocatedWith(testBlobstoreProvider)), 1); assertEquals(Iterables.size(Providers.collocatedWith(testBlobstoreProvider)), 1);
assertEquals(Iterables.size(Providers.collocatedWith(testComputeProvider)), 1); assertEquals(Iterables.size(Providers.collocatedWith(testComputeProvider)), 1);
@ -127,9 +190,9 @@ public class ProvidersTest {
assertEquals(Iterables.size(Providers.collocatedWith(testBlobstoreProvider, ProviderMetadata.COMPUTE_TYPE)), 1); assertEquals(Iterables.size(Providers.collocatedWith(testBlobstoreProvider, ProviderMetadata.COMPUTE_TYPE)), 1);
assertEquals(Iterables.size(Providers.collocatedWith(testComputeProvider, ProviderMetadata.COMPUTE_TYPE)), 0); assertEquals(Iterables.size(Providers.collocatedWith(testComputeProvider, ProviderMetadata.COMPUTE_TYPE)), 0);
assertEquals(Iterables.size(Providers.collocatedWith(testComputeProvider, ProviderMetadata.BLOBSTORE_TYPE)), 1); assertEquals(Iterables.size(Providers.collocatedWith(testComputeProvider, ProviderMetadata.BLOBSTORE_TYPE)), 1);
assertEquals(Iterables.size(Providers.collocatedWith(testYetAnotherComputeProvider, assertEquals(
ProviderMetadata.COMPUTE_TYPE)), 0); Iterables.size(Providers.collocatedWith(testYetAnotherComputeProvider, ProviderMetadata.COMPUTE_TYPE)), 0);
assertEquals(Iterables.size(Providers.collocatedWith(testYetAnotherComputeProvider, assertEquals(
ProviderMetadata.BLOBSTORE_TYPE)), 0); Iterables.size(Providers.collocatedWith(testYetAnotherComputeProvider, ProviderMetadata.BLOBSTORE_TYPE)), 0);
} }
} }

View File

@ -0,0 +1,3 @@
org.jclouds.apis.JcloudsTestBlobStoreApiMetadata
org.jclouds.apis.JcloudsTestComputeApiMetadata
org.jclouds.apis.JcloudsTestYetAnotherComputeApiMetadata

View File

@ -19,12 +19,9 @@
package org.jclouds.aws.elb; package org.jclouds.aws.elb;
import java.net.URI; import java.net.URI;
import java.util.Set;
import org.jclouds.elb.ELBApiMetadata;
import org.jclouds.providers.BaseProviderMetadata; import org.jclouds.providers.BaseProviderMetadata;
import org.jclouds.providers.ProviderMetadata;
import com.google.common.collect.ImmutableSet;
/** /**
* Implementation of @ link org.jclouds.types.ProviderMetadata} for Amazon's Elastic Load Balancing * Implementation of @ link org.jclouds.types.ProviderMetadata} for Amazon's Elastic Load Balancing
@ -34,82 +31,38 @@ import com.google.common.collect.ImmutableSet;
*/ */
public class AWSELBProviderMetadata extends BaseProviderMetadata { public class AWSELBProviderMetadata extends BaseProviderMetadata {
/** public AWSELBProviderMetadata() {
* {@inheritDoc} this(builder()
*/ .id("aws-elb")
@Override .name("Amazon Elastic Load Balancing")
public String getId() { .api(new ELBApiMetadata())
return "aws-elb"; .homepage(URI.create("http://aws.amazon.com/elasticloadbalancing"))
.console(URI.create("https://console.aws.amazon.com/ec2/home"))
.linkedServices("aws-ec2","aws-elb", "aws-elb", "aws-s3", "aws-simpledb")
.iso3166Codes("US-VA", "US-CA", "BR-SP", "US-OR", "IE", "SG", "JP-13"));
} }
/** // below are so that we can reuse builders, toString, hashCode, etc.
* {@inheritDoc} // we have to set concrete classes here, as our base class cannot be
*/ // concrete due to serviceLoader
@Override protected AWSELBProviderMetadata(ConcreteBuilder builder) {
public String getType() { super(builder);
return ProviderMetadata.LOADBALANCER_TYPE;
} }
/** private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
* {@inheritDoc}
*/ @Override
@Override public AWSELBProviderMetadata build() {
public String getName() { return new AWSELBProviderMetadata(this);
return "Amazon Elastic Load Balancing"; }
} }
/** public static ConcreteBuilder builder() {
* {@inheritDoc} return new ConcreteBuilder();
*/
@Override
public String getIdentityName() {
return "Access Key ID";
} }
/** public ConcreteBuilder toBuilder() {
* {@inheritDoc} return builder().fromProviderMetadata(this);
*/
@Override
public String getCredentialName() {
return "Secret Access Key";
} }
/**
* {@inheritDoc}
*/
@Override
public URI getHomepage() {
return URI.create("http://aws.amazon.com/elasticloadbalancing");
}
/**
* {@inheritDoc}
*/
@Override
public URI getConsole() {
return URI.create("https://console.aws.amazon.com/ec2/home");
}
/**
* {@inheritDoc}
*/
@Override
public URI getApiDocumentation() {
return URI.create("http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/APIReference");
}
/**
* {@inheritDoc}
*/
@Override
public Set<String> getLinkedServices() {
return ImmutableSet.of("aws-s3", "aws-ec2", "aws-elb", "aws-simpledb");
}
/**
* {@inheritDoc}
*/
@Override
public Set<String> getIso3166Codes() {
return ImmutableSet.of("US-VA", "US-CA", "US-OR", "BR-SP", "IE", "SG", "JP-13");
}
} }

View File

@ -18,8 +18,8 @@
*/ */
package org.jclouds.aws.elb; package org.jclouds.aws.elb;
import org.jclouds.elb.ELBApiMetadata;
import org.jclouds.providers.BaseProviderMetadataTest; import org.jclouds.providers.BaseProviderMetadataTest;
import org.jclouds.providers.ProviderMetadata;
import org.testng.annotations.Test; import org.testng.annotations.Test;
/** /**
@ -31,6 +31,6 @@ import org.testng.annotations.Test;
public class AWSELBProviderTest extends BaseProviderMetadataTest { public class AWSELBProviderTest extends BaseProviderMetadataTest {
public AWSELBProviderTest() { public AWSELBProviderTest() {
super(new AWSELBProviderMetadata(), ProviderMetadata.LOADBALANCER_TYPE); super(new AWSELBProviderMetadata(), new ELBApiMetadata());
} }
} }

View File

@ -0,0 +1,67 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.elb;
import java.net.URI;
import org.jclouds.apis.ApiMetadata;
import org.jclouds.apis.ApiType;
import org.jclouds.apis.BaseApiMetadata;
/**
* Implementation of {@link ApiMetadata} for Amazon's Elastic Load Balancing api.
*
* @author Adrian Cole
*/
public class ELBApiMetadata extends BaseApiMetadata {
public ELBApiMetadata() {
this(builder()
.id("elb")
.type(ApiType.LOADBALANCER)
.name("Amazon Elastic Load Balancing Api")
.identityName("Access Key ID")
.credentialName("Secret Access Key")
.documentation(URI.create("http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/APIReference")));
}
// below are so that we can reuse builders, toString, hashCode, etc.
// we have to set concrete classes here, as our base class cannot be
// concrete due to serviceLoader
protected ELBApiMetadata(ConcreteBuilder builder) {
super(builder);
}
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
@Override
public ELBApiMetadata build() {
return new ELBApiMetadata(this);
}
}
public static ConcreteBuilder builder() {
return new ConcreteBuilder();
}
@Override
public ConcreteBuilder toBuilder() {
return builder().fromApiMetadata(this);
}
}

View File

@ -0,0 +1 @@
org.jclouds.elb.ELBApiMetadata

View File

@ -0,0 +1,35 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.elb;
import org.jclouds.apis.ApiType;
import org.jclouds.apis.BaseApiMetadataTest;
import org.testng.annotations.Test;
/**
*
* @author Adrian Cole
*/
@Test(groups = "unit", testName = "ELBApiMetadataTest")
public class ELBApiMetadataTest extends BaseApiMetadataTest {
public ELBApiMetadataTest() {
super(new ELBApiMetadata(), ApiType.LOADBALANCER);
}
}

View File

@ -0,0 +1,68 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.glesys;
import java.net.URI;
import org.jclouds.apis.ApiMetadata;
import org.jclouds.apis.ApiType;
import org.jclouds.apis.BaseApiMetadata;
/**
* Implementation of {@link ApiMetadata} for GleSYS API
*
* @author Adrian Cole
*/
public class GleSYSApiMetadata extends BaseApiMetadata {
public GleSYSApiMetadata() {
this(builder()
.id("glesys")
.type(ApiType.COMPUTE)
.name("GleSYS API")
.identityName("Username")
.credentialName("API Key")
.documentation(URI.create("https://customer.glesys.com/api.php")));
}
// below are so that we can reuse builders, toString, hashCode, etc.
// we have to set concrete classes here, as our base class cannot be
// concrete due to serviceLoader
protected GleSYSApiMetadata(Builder<?> builder) {
super(builder);
}
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
@Override
public GleSYSApiMetadata build() {
return new GleSYSApiMetadata(this);
}
}
public static ConcreteBuilder builder() {
return new ConcreteBuilder();
}
@Override
public ConcreteBuilder toBuilder() {
return builder().fromApiMetadata(this);
}
}

View File

@ -19,97 +19,47 @@
package org.jclouds.glesys; package org.jclouds.glesys;
import java.net.URI; import java.net.URI;
import java.util.Set;
import org.jclouds.providers.BaseProviderMetadata; import org.jclouds.providers.BaseProviderMetadata;
import org.jclouds.providers.ProviderMetadata;
import com.google.common.collect.ImmutableSet;
/** /**
* Implementation of {@ link org.jclouds.types.ProviderMetadata} for GleSYS. * Implementation of {@link org.jclouds.types.ProviderMetadata} for GleSYS.
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
public class GleSYSProviderMetadata extends BaseProviderMetadata { public class GleSYSProviderMetadata extends BaseProviderMetadata {
/** public GleSYSProviderMetadata() {
* {@inheritDoc} this(builder()
*/ .id("glesys")
@Override .name("GleSYS")
public String getId() { .api(new GleSYSApiMetadata())
return "glesys"; .homepage(URI.create("http://www.glesys.com"))
.console(URI.create("https://customer.glesys.com/cloud.php"))
.iso3166Codes("NL-NH","SE-N","US-NY","SE-AB"));
} }
/** // below are so that we can reuse builders, toString, hashCode, etc.
* {@inheritDoc} // we have to set concrete classes here, as our base class cannot be
*/ // concrete due to serviceLoader
@Override protected GleSYSProviderMetadata(ConcreteBuilder builder) {
public String getType() { super(builder);
return ProviderMetadata.COMPUTE_TYPE;
} }
/** private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
* {@inheritDoc}
*/ @Override
@Override public GleSYSProviderMetadata build() {
public String getName() { return new GleSYSProviderMetadata(this);
return "GleSYS"; }
} }
/** public static ConcreteBuilder builder() {
* {@inheritDoc} return new ConcreteBuilder();
*/
@Override
public String getIdentityName() {
return "Username";
} }
/** public ConcreteBuilder toBuilder() {
* {@inheritDoc} return builder().fromProviderMetadata(this);
*/
@Override
public String getCredentialName() {
return "API Key";
}
/**
* {@inheritDoc}
*/
@Override
public URI getHomepage() {
return URI.create("http://www.glesys.com");
}
/**
* {@inheritDoc}
*/
@Override
public URI getConsole() {
return URI.create("https://customer.glesys.com/cloud.php");
}
/**
* {@inheritDoc}
*/
@Override
public URI getApiDocumentation() {
return URI.create("https://customer.glesys.com/api.php");
}
/**
* {@inheritDoc}
*/
@Override
public Set<String> getLinkedServices() {
return ImmutableSet.of("glesys");
}
/**
* {@inheritDoc}
*/
@Override
public Set<String> getIso3166Codes() {
return ImmutableSet.of("NL-NH","SE-N","US-NY","SE-AB");
} }
} }

View File

@ -19,7 +19,6 @@
package org.jclouds.glesys; package org.jclouds.glesys;
import org.jclouds.providers.BaseProviderMetadataTest; import org.jclouds.providers.BaseProviderMetadataTest;
import org.jclouds.providers.ProviderMetadata;
import org.testng.annotations.Test; import org.testng.annotations.Test;
/** /**
@ -30,6 +29,6 @@ import org.testng.annotations.Test;
public class GleSYSProviderTest extends BaseProviderMetadataTest { public class GleSYSProviderTest extends BaseProviderMetadataTest {
public GleSYSProviderTest() { public GleSYSProviderTest() {
super(new GleSYSProviderMetadata(), ProviderMetadata.COMPUTE_TYPE); super(new GleSYSProviderMetadata(), new GleSYSApiMetadata());
} }
} }

View File

@ -0,0 +1,50 @@
package org.jclouds.savvis.vpdc;
import java.net.URI;
import org.jclouds.apis.ApiMetadata;
import org.jclouds.apis.ApiType;
import org.jclouds.apis.BaseApiMetadata;
/**
* Implementation of {@link ApiMetadata} for the Savvis Symphony VPDC API
*
* @author Adrian Cole
*/
public class SavvisSymphonyVPDCApiMetadata extends BaseApiMetadata {
public SavvisSymphonyVPDCApiMetadata() {
this(builder()
.id("savvis-symphonyvpdc")
.type(ApiType.COMPUTE)
.name("Savvis Symphony VPDC API")
.identityName("Username")
.credentialName("Password")
.documentation(URI.create("https://api.savvis.net/doc/spec/api/index.html")));
}
// below are so that we can reuse builders, toString, hashCode, etc.
// we have to set concrete classes here, as our base class cannot be
// concrete due to serviceLoader
protected SavvisSymphonyVPDCApiMetadata(Builder<?> builder) {
super(builder);
}
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
@Override
public SavvisSymphonyVPDCApiMetadata build() {
return new SavvisSymphonyVPDCApiMetadata(this);
}
}
public static ConcreteBuilder builder() {
return new ConcreteBuilder();
}
@Override
public ConcreteBuilder toBuilder() {
return builder().fromApiMetadata(this);
}
}

View File

@ -18,13 +18,9 @@
*/ */
package org.jclouds.savvis.vpdc; package org.jclouds.savvis.vpdc;
import com.google.common.collect.ImmutableSet;
import java.net.URI; import java.net.URI;
import java.util.Set;
import org.jclouds.providers.BaseProviderMetadata; import org.jclouds.providers.BaseProviderMetadata;
import org.jclouds.providers.ProviderMetadata;
/** /**
* Implementation of {@link org.jclouds.types.ProviderMetadata} for Savvis Symphony VPDC services. * Implementation of {@link org.jclouds.types.ProviderMetadata} for Savvis Symphony VPDC services.
@ -32,110 +28,72 @@ import org.jclouds.providers.ProviderMetadata;
* @author Kedar Dave * @author Kedar Dave
*/ */
public class SavvisSymphonyVPDCProviderMetadata extends BaseProviderMetadata { public class SavvisSymphonyVPDCProviderMetadata extends BaseProviderMetadata {
public SavvisSymphonyVPDCProviderMetadata() {
/** this(builder()
* {@inheritDoc} .id("savvis-symphonyvpdc")
*/ .name("Savvis Symphony VPDC")
@Override .api(new SavvisSymphonyVPDCApiMetadata())
public String getId() { .homepage(URI.create("https://api.savvis.net/doc/spec/api/index.html"))
return "savvis-symphonyvpdc"; .console(URI.create("https://www.savvisstation.com"))
} /**
/**
* {@inheritDoc}
*/
@Override
public String getType() {
return ProviderMetadata.COMPUTE_TYPE;
}
/**
* {@inheritDoc}
*/
@Override
public String getName() {
return "Savvis Symphony VPDC";
}
/**
* {@inheritDoc}
*/
@Override
public String getIdentityName() {
return "username";
}
/**
* {@inheritDoc}
*/
@Override
public String getCredentialName() {
return "password";
}
/**
* {@inheritDoc}
*/
@Override
public URI getHomepage() {
return URI.create("http://www.savvis.com/en-US/infrastructure-services/Cloud/Pages/SavvisSymphonyVPDC.aspx");
}
/**
* {@inheritDoc}
*/
@Override
public URI getConsole() {
return URI.create("https://www.savvisstation.com");
}
/**
* {@inheritDoc}
*/
@Override
public URI getApiDocumentation() {
return URI.create("https://api.savvis.net/doc/spec/api/index.html");
}
/**
* {@inheritDoc} * {@inheritDoc}
* list of data centers from savvisstation colocation guide * list of data centers from savvisstation colocation guide
* https://www.savvisstation.com/DocumentViewer?GUID=a95f0387-cbfe-43eb-b25b-4f2b0f68498f&sessionid=SavvisCCC%3ac9a8984b9655b01916be587e5204b2cf * https://www.savvisstation.com/DocumentViewer?GUID=a95f0387-cbfe-43eb-b25b-4f2b0f68498f&sessionid=SavvisCCC%3ac9a8984b9655b01916be587e5204b2cf
* Once we have confirmation from Savvis as to what data centers are used for vpdc deployments, * Once we have confirmation from Savvis as to what data centers are used for vpdc deployments,
* iso codes for those will be entered here * iso codes for those will be entered here
* *
* City Code * City Code
* Lithia Springs, GA AT1 * Lithia Springs, GA AT1
* Waltham, MA BO1 * Waltham, MA BO1
* Waltham, MA BO2 * Waltham, MA BO2
* Waltham, MA B03 * Waltham, MA B03
* Elk Grove Village, IL CH3 * Elk Grove Village, IL CH3
* Chicago, IL CH4 * Chicago, IL CH4
* Sterling, VA DC2 * Sterling, VA DC2
* Sterling, VA DC3 * Sterling, VA DC3
* Sterling, VA DC4 Phase I * Sterling, VA DC4 Phase I
* Sterling, VA DC4 Phase II * Sterling, VA DC4 Phase II
* Fort Worth, TX DL1 * Fort Worth, TX DL1
* Fort Worth, TX DL2 * Fort Worth, TX DL2
* El Segundo, CA LA1 * El Segundo, CA LA1
* Jersey City, NJ NJ1 * Jersey City, NJ NJ1
* Weehawken, NJ NJ2 * Weehawken, NJ NJ2
* Piscataway, NJ NJ3 * Piscataway, NJ NJ3
* Piscataway, NJ 2nd floor NJ3 * Piscataway, NJ 2nd floor NJ3
* Weehawken, NJ NJ2X * Weehawken, NJ NJ2X
* Irvine, CA OC2 * Irvine, CA OC2
* Santa Clara, CA SC4 * Santa Clara, CA SC4
* Santa Clara, CA SC5 * Santa Clara, CA SC5
* Santa Clara, CA SC8 * Santa Clara, CA SC8
* Santa Clara, CA SC9 * Santa Clara, CA SC9
* Tukwila, WA 1st floor SE2 * Tukwila, WA 1st floor SE2
* Montreal, Canada MR1 * Montreal, Canada MR1
* Toronto, Canada TR1 * Toronto, Canada TR1
* Vancouver, Canada VC1 * Vancouver, Canada VC1
*/ */
@Override .iso3166Codes("US", "CA"));
public Set<String> getIso3166Codes() {
return ImmutableSet.of("");
} }
// below are so that we can reuse builders, toString, hashCode, etc.
// we have to set concrete classes here, as our base class cannot be
// concrete due to serviceLoader
protected SavvisSymphonyVPDCProviderMetadata(ConcreteBuilder builder) {
super(builder);
}
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
@Override
public SavvisSymphonyVPDCProviderMetadata build() {
return new SavvisSymphonyVPDCProviderMetadata(this);
}
}
public static ConcreteBuilder builder() {
return new ConcreteBuilder();
}
public ConcreteBuilder toBuilder() {
return builder().fromProviderMetadata(this);
}
} }

Some files were not shown because too many files have changed in this diff Show More