Module: JPSClient::API::AndroidJks

Included in:
Client
Defined in:
lib/jpsclient/api/android_jks.rb

Overview

Android JKS 证书相关 API 处理 /api/android_jks/* 路径的所有接口

支持的功能:

  • 创建 JKS 证书(异步)

  • 更新 JKS 证书信息

  • 删除 JKS 证书

  • 获取 JKS 证书列表

  • 获取 JKS 证书详情

  • 重命名 JKS 证书(异步)

  • APK 重签名(异步)

Instance Method Summary collapse

Instance Method Details

#create_android_jks(alias_name:, bundle_id:, store_password: nil, key_password: nil, validity: nil, distinguished_name: nil, google_account: nil, project_id: nil, remark: nil) ⇒ Hash

创建 Android JKS 证书(异步接口)

Parameters:

  • alias_name (String)

    证书别名(必填)

  • store_password (String) (defaults to: nil)

    keystore 密码,为空则自动生成

  • key_password (String) (defaults to: nil)

    key 密码,为空则与 store_password 一致

  • validity (Integer) (defaults to: nil)

    有效期(天),默认 36500

  • distinguished_name (Hash) (defaults to: nil)

    DN 信息,如 “xxx”, O: “xxx”

  • bundle_id (String)

    包名(必填)

  • google_account (String) (defaults to: nil)

    Google 开发者账号

  • project_id (String) (defaults to: nil)

    关联项目 ID

  • remark (String) (defaults to: nil)

    备注

Returns:

  • (Hash)

    API 响应(异步任务)

Raises:



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/jpsclient/api/android_jks.rb', line 28

def create_android_jks(alias_name:, bundle_id:, store_password: nil, key_password: nil, validity: nil,
                       distinguished_name: nil, google_account: nil,
                       project_id: nil, remark: nil)
  config = @request_config && @request_config["android_jks_create"]
  raise JPSClient::ExceptionError, "Missing config for android_jks_create" unless config && config["url"]
  path = config["url"]

  body_params = { aliasName: alias_name, bundleId: bundle_id }
  body_params[:storePassword] = store_password if store_password
  body_params[:keyPassword] = key_password if key_password
  body_params[:validity] = validity if validity
  body_params[:distinguishedName] = distinguished_name if distinguished_name
  body_params[:googleAccount] =  if 
  body_params[:projectId] = project_id if project_id
  body_params[:remark] = remark if remark

  return request_with_auth(:post, path, body: body_params)
end

#delete_android_jks(id:) ⇒ Hash

删除 Android JKS 证书

Parameters:

  • id (String)

    JKS ID(必填)

Returns:

  • (Hash)

    API 响应

Raises:



73
74
75
76
77
78
79
80
81
# File 'lib/jpsclient/api/android_jks.rb', line 73

def delete_android_jks(id:)
  config = @request_config && @request_config["android_jks_delete"]
  raise JPSClient::ExceptionError, "Missing config for android_jks_delete" unless config && config["url"]
  path = config["url"]

  body_params = { id: id }

  return request_with_auth(:post, path, body: body_params)
end

#get_android_jks_detail(bundle_id:) ⇒ Hash

获取 Android JKS 证书详情

Parameters:

  • bundle_id (String)

    包名(必填)

Returns:

  • (Hash)

    API 响应,data 包含 id、aliasName、bundleId、jksFileUrl、storePassword、keyPassword

Raises:



108
109
110
111
112
113
114
115
116
# File 'lib/jpsclient/api/android_jks.rb', line 108

def get_android_jks_detail(bundle_id:)
  config = @request_config && @request_config["android_jks_detail"]
  raise JPSClient::ExceptionError, "Missing config for android_jks_detail" unless config && config["url"]
  path = config["url"]

  get_params = { bundleId: bundle_id }

  return request_with_auth(:get, path, params: get_params)
end

#get_android_jks_list(page_no: 1, page_size: 20, alias_name: nil, google_account: nil, project_id: nil) ⇒ Hash

获取 Android JKS 证书列表

Parameters:

  • page_no (Integer) (defaults to: 1)

    当前页数(必填)

  • page_size (Integer) (defaults to: 20)

    每页记录数(必填)

  • alias_name (String) (defaults to: nil)

    证书别名(可选)

  • google_account (String) (defaults to: nil)

    Google 开发者账号(可选)

  • project_id (String) (defaults to: nil)

    关联项目 ID(可选)

Returns:

  • (Hash)

    API 响应,data 包含 list 数组和 total 总数

Raises:



91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/jpsclient/api/android_jks.rb', line 91

def get_android_jks_list(page_no: 1, page_size: 20, alias_name: nil, google_account: nil, project_id: nil)
  config = @request_config && @request_config["android_jks_list"]
  raise JPSClient::ExceptionError, "Missing config for android_jks_list" unless config && config["url"]
  path = config["url"]

  get_params = { pageNo: page_no, pageSize: page_size }
  get_params[:aliasName] = alias_name if alias_name
  get_params[:googleAccount] =  if 
  get_params[:projectId] = project_id if project_id

  return request_with_auth(:get, path, params: get_params)
end

#rename_android_jks(id:, new_alias:, new_store_password:) ⇒ Hash

重命名 Android JKS 证书(异步接口)

Parameters:

  • id (String)

    JKS 证书 ID(必填)

  • new_alias (String)

    新别名(必填)

  • new_store_password (String)

    新 storePassword(必填)

Returns:

  • (Hash)

    API 响应(异步任务)

Raises:



124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/jpsclient/api/android_jks.rb', line 124

def rename_android_jks(id:, new_alias:, new_store_password:)
  config = @request_config && @request_config["android_jks_rename"]
  raise JPSClient::ExceptionError, "Missing config for android_jks_rename" unless config && config["url"]
  path = config["url"]

  body_params = {
    id: id,
    newAlias: new_alias,
    newStorePassword: new_store_password
  }

  return request_with_auth(:post, path, body: body_params)
end

#rewrite_apk(input_s3_key:, output_s3_key:, new_package:, jks_id:, s3_bucket: nil, use_aapt2: nil, skip_verify: nil) ⇒ Hash

APK 重签名(异步接口)

Parameters:

  • input_s3_key (String)

    输入 APK 文件的 S3 Key(必填)

  • output_s3_key (String)

    输出 APK 文件的 S3 Key(必填)

  • new_package (String)

    新的包名(必填)

  • jks_id (String)

    JKS 证书 ID(必填)

  • s3_bucket (String) (defaults to: nil)

    S3 Bucket,默认 pgy-resource-new

  • use_aapt2 (Boolean) (defaults to: nil)

    是否使用 aapt2,默认 true

  • skip_verify (Boolean) (defaults to: nil)

    是否跳过签名验证,默认 false

Returns:

  • (Hash)

    API 响应(异步任务)

Raises:



148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# File 'lib/jpsclient/api/android_jks.rb', line 148

def rewrite_apk(input_s3_key:, output_s3_key:, new_package:, jks_id:,
                s3_bucket: nil, use_aapt2: nil, skip_verify: nil)
  config = @request_config && @request_config["android_jks_rewrite_apk"]
  raise JPSClient::ExceptionError, "Missing config for android_jks_rewrite_apk" unless config && config["url"]
  path = config["url"]

  body_params = {
    inputS3Key: input_s3_key,
    outputS3Key: output_s3_key,
    newPackage: new_package,
    jksId: jks_id
  }
  body_params[:s3Bucket] = s3_bucket if s3_bucket
  body_params[:useAapt2] = use_aapt2 unless use_aapt2.nil?
  body_params[:skipVerify] = skip_verify unless skip_verify.nil?

  return request_with_auth(:post, path, body: body_params)
end

#update_android_jks(id:, bundle_id: nil, google_account: nil, project_id: nil, remark: nil) ⇒ Hash

更新 Android JKS 证书信息

Parameters:

  • id (String)

    JKS ID(必填)

  • bundle_id (String) (defaults to: nil)

    包名

  • google_account (String) (defaults to: nil)

    Google 开发者账号

  • project_id (String) (defaults to: nil)

    关联项目 ID

  • remark (String) (defaults to: nil)

    备注

Returns:

  • (Hash)

    API 响应

Raises:



55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/jpsclient/api/android_jks.rb', line 55

def update_android_jks(id:, bundle_id: nil, google_account: nil, project_id: nil, remark: nil)
  config = @request_config && @request_config["android_jks_update"]
  raise JPSClient::ExceptionError, "Missing config for android_jks_update" unless config && config["url"]
  path = config["url"]

  body_params = { id: id }
  body_params[:bundleId] = bundle_id if bundle_id
  body_params[:googleAccount] =  if 
  body_params[:projectId] = project_id if project_id
  body_params[:remark] = remark if remark

  return request_with_auth(:post, path, body: body_params)
end