| 1 | /* |
| 2 | * Licensed to the Apache Software Foundation (ASF) under one or more |
| 3 | * contributor license agreements. See the NOTICE file distributed with |
| 4 | * this work for additional information regarding copyright ownership. |
| 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 |
| 6 | * (the "License"); you may not use this file except in compliance with |
| 7 | * the License. You may obtain a copy of the License at |
| 8 | * |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | * |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
| 16 | */ |
| 17 | package org.jclouds.glesys; |
| 18 | |
| 19 | import static org.jclouds.reflect.Reflection2.typeToken; |
| 20 | |
| 21 | import java.net.URI; |
| 22 | import java.util.Properties; |
| 23 | |
| 24 | import org.jclouds.apis.ApiMetadata; |
| 25 | import org.jclouds.compute.ComputeServiceContext; |
| 26 | import org.jclouds.glesys.compute.config.GleSYSComputeServiceContextModule; |
| 27 | import org.jclouds.glesys.config.GleSYSRestClientModule; |
| 28 | import org.jclouds.rest.internal.BaseRestApiMetadata; |
| 29 | |
| 30 | import com.google.common.collect.ImmutableSet; |
| 31 | import com.google.common.reflect.TypeToken; |
| 32 | import com.google.inject.Module; |
| 33 | |
| 34 | /** |
| 35 | * Implementation of {@link ApiMetadata} for API |
| 36 | * |
| 37 | * @author Adrian Cole |
| 38 | */ |
| 39 | public class GleSYSApiMetadata extends BaseRestApiMetadata { |
| 40 | |
| 41 | /** |
| 42 | * @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(GleSYSApi.class)} as |
| 43 | * {@link GleSYSAsyncApi} interface will be removed in jclouds 1.7. |
| 44 | */ |
| 45 | @Deprecated |
| 46 | public static final TypeToken<org.jclouds.rest.RestContext<GleSYSApi, GleSYSAsyncApi>> CONTEXT_TOKEN = new TypeToken<org.jclouds.rest.RestContext<GleSYSApi, GleSYSAsyncApi>>() { |
| 47 | private static final long serialVersionUID = 1L; |
| 48 | }; |
| 49 | |
| 50 | @Override |
| 51 | public Builder toBuilder() { |
| 52 | return new Builder().fromApiMetadata(this); |
| 53 | } |
| 54 | |
| 55 | public GleSYSApiMetadata() { |
| 56 | this(new Builder()); |
| 57 | } |
| 58 | |
| 59 | protected GleSYSApiMetadata(Builder builder) { |
| 60 | super(builder); |
| 61 | } |
| 62 | |
| 63 | public static Properties defaultProperties() { |
| 64 | Properties properties = BaseRestApiMetadata.defaultProperties(); |
| 65 | properties.setProperty("jclouds.ssh.max-retries", "5"); |
| 66 | properties.setProperty("jclouds.ssh.retry-auth", "true"); |
| 67 | return properties; |
| 68 | } |
| 69 | |
| 70 | public static class Builder extends BaseRestApiMetadata.Builder<Builder> { |
| 71 | |
| 72 | @SuppressWarnings("deprecation") |
| 73 | protected Builder() { |
| 74 | super(GleSYSApi.class, GleSYSAsyncApi.class); |
| 75 | id("glesys") |
| 76 | .name("GleSYS API") |
| 77 | .identityName("Username") |
| 78 | .credentialName("API Key") |
| 79 | .documentation(URI.create("https://customer.glesys.com/api.php")) |
| 80 | .version("1") |
| 81 | .buildVersion("3.5.0") |
| 82 | .defaultEndpoint("https://api.glesys.com") |
| 83 | .defaultProperties(GleSYSApiMetadata.defaultProperties()) |
| 84 | .view(typeToken(ComputeServiceContext.class)) |
| 85 | .defaultModules(ImmutableSet.<Class<? extends Module>>of(GleSYSComputeServiceContextModule.class, GleSYSRestClientModule.class)); |
| 86 | } |
| 87 | |
| 88 | @Override |
| 89 | public GleSYSApiMetadata build() { |
| 90 | return new GleSYSApiMetadata(this); |
| 91 | } |
| 92 | |
| 93 | @Override |
| 94 | protected Builder self() { |
| 95 | return this; |
| 96 | } |
| 97 | } |
| 98 | } |