Skip to content

Commit 4458a00

Browse files
Tanc009oulinbao
authored andcommitted
add core sdk (#1)
add java sdk and readme
1 parent d23bd0e commit 4458a00

841 files changed

Lines changed: 88082 additions & 1 deletion

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 77 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,77 @@
1-
# jdcloud-sdk-java
1+
2+
# 简介 #
3+
欢迎使用京东云开发者Java工具套件(Java SDK)。使用京东云Java SDK,您无需复杂编程就可以访问京东云提供的各种服务。
4+
5+
为了方便您理解SDK中的一些概念和参数的含义,使用SDK前建议您先查看[OpenAPI使用入门](http://www.jdcloud.com/help/detail/355/isCatalog/0)。要了解每个API的具体参数和含义,请参考程序注释或参考OpenAPI&SDK下具体产品线的API文档。
6+
7+
# 环境准备 #
8+
1. 京东云Java SDK适用于jdk7及以上版本。
9+
2. 在开始调用京东云open API之前,需提前在京东云用户中心账户管理下的[AccessKey管理页面](https://uc.jdcloud.com/accesskey/index)申请accesskey和secretKey密钥对(简称AK/SK)。AK/SK信息请妥善保管,如果遗失可能会造成非法用户使用此信息操作您在云上的资源,给你造成数据和财产损失。
10+
11+
# SDK使用方法 #
12+
如果您使用Apache Maven来管理Java项目,只需在项目的pom.xml文件加入相应的依赖项即可,如下所示:
13+
14+
<dependency>
15+
<groupId>com.jdcloud.sdk</groupId>
16+
<artifactId>core</artifactId>
17+
<version>1.0.0</version>
18+
</dependency>
19+
<!-- 对应产品线的SDK -->
20+
<dependency>
21+
<groupId>com.jdcloud.sdk</groupId>
22+
<artifactId>vm</artifactId>
23+
<version>0.6.0</version>
24+
</dependency>
25+
26+
您还可以下载sdk源代码自行使用。
27+
28+
SDK使用中的任何问题,欢迎您在Issues页面交流。
29+
30+
**注意:京东云并没有提供其他下载方式,请务必使用上述官方下载方式!**
31+
32+
# 调用SDK #
33+
Java SDK的调用主要分为4步:
34+
35+
1. 设置accessKey和secretKey
36+
37+
2. 创建Client
38+
39+
3. 设置请求参数
40+
41+
4. 执行请求得到响应
42+
43+
以下是查询单个云主机实例详情的调用示例
44+
import com.jdcloud.sdk.auth.CredentialsProvider;
45+
import com.jdcloud.sdk.auth.StaticCredentialsProvider;
46+
import com.jdcloud.sdk.http.HttpRequestConfig;
47+
import com.jdcloud.sdk.http.Protocol;
48+
import com.jdcloud.sdk.service.vm.client.VmClient;
49+
import com.jdcloud.sdk.service.vm.model.*;
50+
51+
public class VmClientExample {
52+
53+
public static void main(String[] args) {
54+
//1. 设置accessKey和secretKey
55+
String accessKeyId = "{accessKey}";
56+
String secretAccessKey = "{secretKey}";
57+
CredentialsProvider credentialsProvider = new StaticCredentialsProvider(accessKeyId, secretAccessKey);
58+
59+
//2. 创建XXXClient
60+
VmClient vmClient = VmClient.builder()
61+
.credentialsProvider(credentialsProvider)
62+
.httpRequestConfig(new HttpRequestConfig.Builder().protocol(Protocol.HTTPS).build()) //默认为HTTPS
63+
.build();
64+
65+
//3. 设置请求参数
66+
DescribeInstanceRequest request = new DescribeInstanceRequest();
67+
request.regionId("cn-north-1");
68+
request.instanceId("i-c0se9uju");
69+
70+
//4. 执行请求
71+
DescribeInstanceResponse response = vmClient.describeInstance(request);
72+
73+
//5. 处理响应
74+
System.out.println(new Gson().toJson(response));
75+
76+
}
77+
}

charge/ChangeLog.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2018-03-31 version: 0.2.0
2+
1. 待补充
3+
4+
2018-01-31 version: 0.1.0
5+
1. 初始版本

charge/charge.iml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
3+
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="false">
4+
<output url="file://$MODULE_DIR$/target/classes" />
5+
<output-test url="file://$MODULE_DIR$/target/test-classes" />
6+
<content url="file://$MODULE_DIR$">
7+
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
8+
<excludeFolder url="file://$MODULE_DIR$/target" />
9+
</content>
10+
<orderEntry type="inheritedJdk" />
11+
<orderEntry type="sourceFolder" forTests="false" />
12+
<orderEntry type="module" module-name="core" />
13+
<orderEntry type="library" name="Maven: com.google.http-client:google-http-client:1.22.0" level="project" />
14+
<orderEntry type="library" name="Maven: com.google.code.findbugs:jsr305:1.3.9" level="project" />
15+
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpclient:4.0.1" level="project" />
16+
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore:4.0.1" level="project" />
17+
<orderEntry type="library" name="Maven: commons-logging:commons-logging:1.1.1" level="project" />
18+
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.3" level="project" />
19+
<orderEntry type="library" name="Maven: com.google.http-client:google-http-client-gson:1.22.0" level="project" />
20+
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.1" level="project" />
21+
<orderEntry type="library" name="Maven: joda-time:joda-time:2.9.3" level="project" />
22+
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.5" level="project" />
23+
</component>
24+
</module>

charge/pom.xml

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
<?xml version="1.0"?>
2+
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
3+
xmlns="http://maven.apache.org/POM/4.0.0"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
5+
<modelVersion>4.0.0</modelVersion>
6+
<groupId>com.jdcloud.sdk</groupId>
7+
<artifactId>charge</artifactId>
8+
<version>0.2.0</version>
9+
<packaging>jar</packaging>
10+
<name>charge</name>
11+
<url>http://www.jdcloud.com</url>
12+
<description>JDCLOUD Open API SDK for Java</description>
13+
14+
<properties>
15+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
16+
</properties>
17+
18+
<distributionManagement>
19+
<snapshotRepository>
20+
<id>ossrh</id>
21+
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
22+
</snapshotRepository>
23+
<repository>
24+
<id>ossrh</id>
25+
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
26+
</repository>
27+
</distributionManagement>
28+
29+
<licenses>
30+
<license>
31+
<name></name>
32+
<url></url>
33+
<distribution></distribution>
34+
</license>
35+
</licenses>
36+
<scm>
37+
<url>https://github.com/jdcloud-api/jdcloud-sdk-java</url>
38+
<connection>https://github.com/jdcloud-api/jdcloud-sdk-java.git</connection>
39+
</scm>
40+
<developers>
41+
<developer>
42+
<id>jdcloud developers</id>
43+
<name>JDCLOUD SDK</name>
44+
<email>jdcloud-api@jd.com</email>
45+
</developer>
46+
</developers>
47+
48+
<dependencies>
49+
<dependency>
50+
<groupId>com.jdcloud.sdk</groupId>
51+
<artifactId>core</artifactId>
52+
<version>1.0.0</version>
53+
</dependency>
54+
</dependencies>
55+
56+
<build>
57+
<plugins>
58+
<plugin>
59+
<groupId>org.sonatype.plugins</groupId>
60+
<artifactId>nexus-staging-maven-plugin</artifactId>
61+
<version>1.6.3</version>
62+
<extensions>true</extensions>
63+
<configuration>
64+
<serverId>ossrh</serverId>
65+
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
66+
<autoReleaseAfterClose>true</autoReleaseAfterClose>
67+
</configuration>
68+
</plugin>
69+
<plugin>
70+
<groupId>org.apache.maven.plugins</groupId>
71+
<artifactId>maven-compiler-plugin</artifactId>
72+
<configuration>
73+
<source>1.7</source>
74+
<target>1.7</target>
75+
<encoding>UTF-8</encoding>
76+
</configuration>
77+
</plugin>
78+
<plugin>
79+
<groupId>org.apache.maven.plugins</groupId>
80+
<artifactId>maven-source-plugin</artifactId>
81+
<version>2.2.1</version>
82+
<executions>
83+
<execution>
84+
<id>attach-sources</id>
85+
<goals>
86+
<goal>jar-no-fork</goal>
87+
</goals>
88+
</execution>
89+
</executions>
90+
</plugin>
91+
<plugin>
92+
<groupId>org.apache.maven.plugins</groupId>
93+
<artifactId>maven-javadoc-plugin</artifactId>
94+
<version>2.9.1</version>
95+
<executions>
96+
<execution>
97+
<id>attach-javadocs</id>
98+
<goals>
99+
<goal>jar</goal>
100+
</goals>
101+
</execution>
102+
</executions>
103+
</plugin>
104+
<plugin>
105+
<groupId>org.apache.maven.plugins</groupId>
106+
<artifactId>maven-gpg-plugin</artifactId>
107+
<version>1.5</version>
108+
<executions>
109+
<execution>
110+
<id>sign-artifacts</id>
111+
<phase>verify</phase>
112+
<goals>
113+
<goal>sign</goal>
114+
</goals>
115+
</execution>
116+
</executions>
117+
</plugin>
118+
</plugins>
119+
</build>
120+
</project>

0 commit comments

Comments
 (0)