更新证书_证书API列表_API参考_开发指南_CodePipeline

阿里云产品文档 xtyly 4年前 (2016-11-09) 4次浏览 已收录 0个评论

描述说明:在Codepipeline中更新用户证书。请求信息请求行 RequestLine

  1. POST /credential/update HTTP/1.1

请求行参数 URI Param

名称 类型 是否必须 描述 CredentialType String 是 证书类型 CredentialId String 是 证书Id JsonContent String 是 证书内容

返回信息返回行 ResponseLine

  1. HTTP/1.1 200 OK

返回码 HTTP Status Code

Status Code 描述 204 No Content 401 Authentication failed 403 The request was valid, but the server is refusing action. The user might not have the necessary permissions for a resource, or may need an account of some sort. 500 Internal Error

返回体 ResponseBody

  1. {
  2. "RequestId": "string"
  3. }

返回体解释无证书类型及内容说明1. 用户名和密码 类型证书 示例:
CredentialType:UsernamePasswordCredentials
JsonContent:

  1. {
  2. "password": "demo-password-update",
  3. "description": "update a demo username password credential",
  4. "id": "demo-id",
  5. "username": "demo-username-update"
  6. }

JsonContent中各个字段的说明:

字段 是否必填 错误异常 username 是 args username required password 是 args password required id 是 args id required description 否,如果为空则默认使用id的值设置

Java 代码示例

  1. Map map = new HashMap();
  2. map.put("username", "demo-username-update");
  3. map.put("password", "demo-password-update");
  4. map.put("id", "demo-id");
  5. map.put("description", "update a demo username password credential");
  6. String jsonStr = JSON.toJSONString(map);
  7. UpdateCredentialRequest updateCredentialRequest = new UpdateCredentialRequest();
  8. try {
  9. updateCredentialRequest.setAcceptFormat(FormatType.JSON);
  10. updateCredentialRequest.setCredentialType("UsernamePasswordCredentials");
  11. updateCredentialRequest.setCredentialId("demo-id");
  12. updateCredentialRequest.setJsonContent(jsonStr);
  13. UpdateCredentialResponse updateCredentialResponse = client.getAcsResponse(updateCredentialRequest);
  14. System.out.println(updateCredentialResponse.getRequestId());
  15. } catch (Exception e) {
  16. e.printStackTrace();;
  17. }

2. registry授权 类型证书 示例
CredentialType:DockerRegistryCredentials
JsonContent:

  1. {
  2. "password": "demo-registry-password-update",
  3. "description": "update a demo registry credential",
  4. "id": "demo-registry-id",
  5. "email": "demo@demo.com",
  6. "username": "demo-registry-username-update"
  7. }

JsonContent中各个字段的说明:

字段 是否必填 错误异常 username 是 args username required password 是 args password required id 是 args id required email 否 description 否,如果为空则默认使用id的值设置

Java 代码示例:

  1. Map<String, String> map = new HashMap<String, String>();
  2. map.put("username", "demo-registry-username-update");
  3. map.put("password", "demo-registry-password-update");
  4. map.put("email", "demo@demo.com");
  5. map.put("id", "demo-registry-id");
  6. map.put("description", "update a demo registry credential");
  7. String jsonStr = JSON.toJSONString(map);
  8. UpdateCredentialRequest updateCredentialRequest = new UpdateCredentialRequest();
  9. try {
  10. updateCredentialRequest.setAcceptFormat(FormatType.JSON);
  11. updateCredentialRequest.setCredentialType("DockerRegistryCredentials");
  12. updateCredentialRequest.setCredentialId("demo-registry-id");
  13. updateCredentialRequest.setJsonContent(jsonStr);
  14. UpdateCredentialResponse updateCredentialResponse = client.getAcsResponse(updateCredentialRequest);
  15. System.out.println(updateCredentialResponse.getRequestId());
  16. } catch (Exception e) {
  17. e.printStackTrace();;
  18. }

3. Docker授权 类型证书 示例:
CredentialType:DockerServerCredentials
JsonContent:

  1. {
  2. "clientCertificate": "demo-docker-clientCertificateContent-update",
  3. "clientKey": "demo-docker-clientKeyContent-update",
  4. "serverCaCertificate": "demo-docker-serverCaCertificateContent-update",
  5. "description": "update a demo docker credential",
  6. "id": "demo-docker-id"
  7. }

JsonContent中各个字段的说明:

字段 是否必填 错误异常 clientKey 是 args clientKey required clientCertificate 是 args clientCertificate required serverCaCertificate 是 args serverCaCertificate required id 是 args id required description 否,如果为空则默认使用id的值设置

Java 代码示例:

  1. Map map = new HashMap();
  2. map.put("clientKey", "demo-docker-clientKeyContent-update");
  3. map.put("clientCertificate", "demo-docker-clientCertificateContent-update");
  4. map.put("serverCaCertificate", "demo-docker-serverCaCertificateContent-update");
  5. map.put("id", "demo-docker-id");
  6. map.put("description", "update a demo docker credential");
  7. String jsonStr = JSON.toJSONString(map);
  8. System.out.println(jsonStr);
  9. UpdateCredentialRequest updateCredentialRequest = new UpdateCredentialRequest();
  10. try {
  11. updateCredentialRequest.setAcceptFormat(FormatType.JSON);
  12. updateCredentialRequest.setCredentialType("DockerServerCredentials");
  13. updateCredentialRequest.setCredentialId("demo-docker-id");
  14. updateCredentialRequest.setJsonContent(jsonStr);
  15. UpdateCredentialResponse updateCredentialResponse = client.getAcsResponse(updateCredentialRequest);
  16. System.out.println(updateCredentialResponse.getRequestId());
  17. } catch (Exception e) {
  18. e.printStackTrace();;
  19. }

4. SSH用户名和私钥 类型证书 示例:
CredentialType:SSHCredentials
JsonContent:

  1. {
  2. "privateKeySource": {
  3. "privateKey": "demo-ssh-privateKeyContent-update"
  4. },
  5. "description": "update a demo ssh credential",
  6. "passphrase": "demo-ssh-passphrase-update",
  7. "id": "demo-ssh-id",
  8. "username": "demo-ssh-username-update"
  9. }

JsonContent中各个字段的说明:

字段 是否必填 错误异常 privateKey 是 args privateKey required username 否,默认为jetty passphrase 否 id 是 args id required privateKeySource 是 args privateKeySource required description 否,如果为空则默认使用id的值设置

Java 代码示例:

  1. Map outermap = new HashMap();
  2. Map innerMap = new HashMap();
  3. innerMap.put("privateKey", "demo-ssh-privateKeyContent-update");
  4. outermap.put("username", "demo-ssh-username-update");
  5. outermap.put("passphrase", "demo-ssh-passphrase-update");
  6. outermap.put("id", "demo-ssh-id");
  7. outermap.put("description", "update a demo ssh credential");
  8. outermap.put("privateKeySource", innerMap);
  9. String jsonStr = JSON.toJSONString(outermap);
  10. System.out.println(jsonStr);
  11. UpdateCredentialRequest updateCredentialRequest = new UpdateCredentialRequest();
  12. try {
  13. updateCredentialRequest.setAcceptFormat(FormatType.JSON);
  14. updateCredentialRequest.setCredentialType("SSHCredentials");
  15. updateCredentialRequest.setCredentialId("demo-ssh-id");
  16. updateCredentialRequest.setJsonContent(jsonStr);
  17. UpdateCredentialResponse updateCredentialResponse = client.getAcsResponse(updateCredentialRequest);
  18. System.out.println(updateCredentialResponse.getRequestId());
  19. } catch (Exception e) {
  20. e.printStackTrace();;
  21. }

更新证书_证书API列表_API参考_开发指南_CodePipeline


阿里云百科网 , 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:更新证书_证书API列表_API参考_开发指南_CodePipeline
喜欢 (0)
[sp91@qq.com]
分享 (0)
发表我的评论
取消评论
表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址