Skip to content

qingcloud-cps-robot/qingcloud-sdk-java

 
 

Repository files navigation

QingCloud SDK for Java

The official QingCloud SDK for the Java programming language.

Getting Started

Preparation

Before your start, please login to QingCloud Console to create a pair of QingCloud API AccessKey.

API AccessKey Example:

qy_access_key_id: QYACCESSKEYIDEXAMPLE
qy_secret_access_key: SECRETACCESSKEY

Installation

Add below dependency in your pom file

<dependency>
    <groupId>com.qingcloud</groupId>
    <artifactId>qingcloud-sdk-java</artifactId>
    <version>1.2.2</version>
</dependency>

For more information, please refer to maven page

Usage

Now you are ready to code. You can read the detailed guides in the list below to have a clear understanding.

Quick start code example

public class InstanceTest {
    private static Logger logger = LoggerFactory.getLogger(InstanceTest.class);

    @Test
    public void testDescribeInstances() {
        EnvContext context = new EnvContext("ACCESS_KEY_ID_EXAMPLE", "SECRET_ACCESS_KEY_EXAMPLE");
        context.setProtocol("https");
        context.setHost("api.qingcloud.com");
        context.setPort("443");
        context.setZone("pek3b");
        context.setApiLang("zh-cn"); // optional, set return message i18n, default to us-en
        InstanceService service = new InstanceService(context);

        InstanceService.DescribeInstancesInput input = new InstanceService.DescribeInstancesInput();
        input.setLimit(1);

        try {
            InstanceService.DescribeInstancesOutput output = service.describeInstances(input);
            for (Types.InstanceModel model : output.getInstanceSet()) {
                System.out.println("==================");
                System.out.println(model.getInstanceID());
                System.out.println(model.getInstanceName());
                System.out.println(model.getImage().getImageID());
                for (Types.NICVxNetModel vxNetModel : model.getVxNets()) {
                    System.out.println("==================");
                    System.out.println(vxNetModel.getVxNetID());
                    System.out.println(vxNetModel.getVxNetType());
                }
            }
        } catch (QCException e) {
            e.printStackTrace();
        }
    }
}

Checkout our releases and change logs for information about the latest features, bug fixes and new ideas.

Reference Documentations

Contributing

This repository was automatically generated, please contribute to Snips instead.

LICENSE

The Apache License (Version 2.0, January 2004).

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 100.0%