Skip to content

Commit

Permalink
feat(tencentcloud): Add tencentcloud models, descriptions and abstrac…
Browse files Browse the repository at this point in the history
…t agents (#4603)
  • Loading branch information
shengyu committed Jun 1, 2020
1 parent 9eb972b commit 013d74e
Show file tree
Hide file tree
Showing 47 changed files with 2,995 additions and 5 deletions.
17 changes: 15 additions & 2 deletions clouddriver-tencentcloud/clouddriver-tencentcloud.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,30 @@ dependencies {
implementation project(":clouddriver-security")

compileOnly "org.projectlombok:lombok"
testCompile "org.projectlombok:lombok"
annotationProcessor "org.projectlombok:lombok"
testAnnotationProcessor "org.projectlombok:lombok"

implementation "com.google.guava:guava"
implementation "com.netflix.frigga:frigga"
implementation "com.netflix.spectator:spectator-api"
implementation "com.netflix.spinnaker.fiat:fiat-api:$fiatVersion"
implementation "com.netflix.spinnaker.fiat:fiat-core:$fiatVersion"
implementation "com.netflix.spinnaker.kork:kork-exceptions"
implementation "com.netflix.spinnaker.moniker:moniker"
implementation "org.springframework.boot:spring-boot-starter-web"
implementation "com.netflix.spinnaker.kork:kork-core"
implementation "com.netflix.spinnaker.kork:kork-exceptions"
implementation "com.netflix.spinnaker.kork:kork-security"
implementation "org.springframework.boot:spring-boot-actuator"
implementation "org.springframework.boot:spring-boot-starter-web"
implementation "com.google.guava:guava"
implementation "com.tencentcloudapi:tencentcloud-sdk-java:3.1.51"

testImplementation "cglib:cglib-nodep"
testImplementation "org.assertj:assertj-core"
testImplementation "org.junit.jupiter:junit-jupiter"
testImplementation "org.mockito:mockito-core"
testImplementation "org.objenesis:objenesis"
testImplementation "org.spockframework:spock-core"
testImplementation "org.spockframework:spock-spring"
testImplementation "org.springframework:spring-test"
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,22 @@ public class TencentCloudProvider implements CloudProvider {

public static final String ID = "tencentcloud";

final String id = ID;
final String displayName = "TencentCloud";
final Class<? extends Annotation> operationAnnotationType = TencentCloudOperation.class;

@Override
public String getId() {
return ID;
return id;
}

@Override
public String getDisplayName() {
return "TencentCloud";
return displayName;
}

@Override
public Class<? extends Annotation> getOperationAnnotationType() {
return TencentCloudOperation.class;
return operationAnnotationType;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*
* Copyright 2019 THL A29 Limited, a Tencent company.
*
* Licensed 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 com.netflix.spinnaker.clouddriver.tencentcloud.client;

import com.tencentcloudapi.common.Credential;
import com.tencentcloudapi.common.profile.ClientProfile;
import com.tencentcloudapi.common.profile.HttpProfile;
import java.time.Instant;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAccessor;
import java.util.Date;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public abstract class AbstractTencentCloudServiceClient {
public static final long MAX_QUERY_TIME = 1000;
public static final long DEFAULT_LIMIT = 100;
private Credential credential;
private HttpProfile httpProfile;
private ClientProfile clientProfile;

public abstract String getEndPoint();

public AbstractTencentCloudServiceClient(String secretId, String secretKey) {
credential = new Credential(secretId, secretKey);
httpProfile = new HttpProfile();
httpProfile.setEndpoint(getEndPoint());
clientProfile = new ClientProfile();
clientProfile.setHttpProfile(httpProfile);
}

public static Date convertToIsoDateTime(String isoDateTime) {
try {
DateTimeFormatter timeFormatter = DateTimeFormatter.ISO_DATE_TIME;
TemporalAccessor accessor = timeFormatter.parse(isoDateTime);
return Date.from(Instant.from(accessor));
} catch (Exception e) {
log.warn("convert time error " + e.toString());
return null;
}
}

public Credential getCredential() {
return credential;
}

public void setCredential(Credential credential) {
this.credential = credential;
}

public HttpProfile getHttpProfile() {
return httpProfile;
}

public void setHttpProfile(HttpProfile httpProfile) {
this.httpProfile = httpProfile;
}

public ClientProfile getClientProfile() {
return clientProfile;
}

public void setClientProfile(ClientProfile clientProfile) {
this.clientProfile = clientProfile;
}
}
Loading

0 comments on commit 013d74e

Please sign in to comment.