全部产品
云市场

Tag操作

更新时间:2018-10-19 09:00:28

创建Tag

删除Tag

获取Tag

创建Tag

  1. public void testCreatTag() {
  2. // 如果是除杭州region外的其它region(如新加坡、澳洲Region),需要将下面的"cn-hangzhou"替换为"ap-southeast-1"、或"ap-southeast-2"。
  3. IAcsClient client = IAcsClientUtil.getiAcsClient();
  4. CreateTagRequest request = new CreateTagRequest();
  5. try {
  6. request.setTagName("testtag123567");
  7. CreateTagResponse httpResponse = client.getAcsResponse(request);
  8. System.out.println("------testCreatTag------" + JSON.toJSONString(httpResponse));
  9. } catch (ServerException e) {
  10. e.printStackTrace();
  11. } catch (ClientException e) {
  12. e.printStackTrace();
  13. }
  14. }

删除Tag

  1. public void testDeleteTag() {
  2. // 如果是除杭州region外的其它region(如新加坡、澳洲Region),需要将下面的"cn-hangzhou"替换为"ap-southeast-1"、或"ap-southeast-2"。
  3. IAcsClient client = IAcsClientUtil.getiAcsClient();
  4. DeleteTagRequest request = new DeleteTagRequest();
  5. try {
  6. request.setTagId(24911);
  7. DeleteTagResponse httpResponse = client.getAcsResponse(request);
  8. System.out.println("------testDeleteTag------" + JSON.toJSONString(httpResponse));
  9. } catch (ServerException e) {
  10. e.printStackTrace();
  11. } catch (ClientException e) {
  12. e.printStackTrace();
  13. }
  14. }

获取Tag

  1. public void testQueryTagByParam() {
  2. IAcsClient client = IAcsClientUtil.getiAcsClient();
  3. QueryTagByParamRequest request = new QueryTagByParamRequest();
  4. try {
  5. request.setKeyWord("testtag1235");
  6. QueryTagByParamResponse httpResponse = client.getAcsResponse(request);
  7. System.out.println("------testQueryTagByParam------" + JSON.toJSONString(httpResponse));
  8. } catch (ServerException e) {
  9. e.printStackTrace();
  10. } catch (ClientException e) {
  11. e.printStackTrace();
  12. }
  13. }