fastlane-plugin-airwatch_workspaceone 2.0.0 → 2.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +19 -4
- data/lib/fastlane/plugin/airwatch_workspaceone/actions/add_or_update_assignments_action.rb +16 -37
- data/lib/fastlane/plugin/airwatch_workspaceone/actions/delete_previous_versions_action.rb +28 -61
- data/lib/fastlane/plugin/airwatch_workspaceone/actions/delete_specific_version_action.rb +22 -68
- data/lib/fastlane/plugin/airwatch_workspaceone/actions/deploy_build_action.rb +74 -17
- data/lib/fastlane/plugin/airwatch_workspaceone/actions/latest_version_action.rb +182 -0
- data/lib/fastlane/plugin/airwatch_workspaceone/actions/retire_previous_versions_action.rb +21 -74
- data/lib/fastlane/plugin/airwatch_workspaceone/actions/retire_specific_version_action.rb +20 -73
- data/lib/fastlane/plugin/airwatch_workspaceone/actions/unretire_all_versions.rb +20 -73
- data/lib/fastlane/plugin/airwatch_workspaceone/actions/unretire_specific_version_action.rb +164 -0
- data/lib/fastlane/plugin/airwatch_workspaceone/helper/airwatch_workspaceone_helper.rb +130 -1
- data/lib/fastlane/plugin/airwatch_workspaceone/version.rb +1 -1
- metadata +9 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 23a24e8e7abab45317fbb762787db007bc81cc11c36bda46c5b17b26cd949b56
|
4
|
+
data.tar.gz: 002cc296d31c9bdc141b8325ab887761294142dcef9d61ccf9286faa43bf1ff8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d42673b8e6596baf6ac3ee2830bb63078a345d9789690bb9c4b15721ebf08567004b4f8c322139d7039bd64f396318d702e91e80cde84ea6187855f990f189a
|
7
|
+
data.tar.gz: dcd4263e484eccbd0aeed3dbee8cac11ff8429b2b6abbd535e246ffa580a5da817bad3ed904ae69b1a5cc215f3854e5397643bacbf4c85c6bb89869e7e901792
|
data/README.md
CHANGED
@@ -15,13 +15,14 @@ fastlane add_plugin airwatch_workspaceone
|
|
15
15
|
The main purpose of this plugin is to upload an IPA or an APK file to an AirWatch or Workspace ONE enterprise instance/console. For Android, the plugin works only with legacy AirWatch console and not with Workspace ONE console.
|
16
16
|
|
17
17
|
This plugin features following actions :-
|
18
|
-
1. deploy_build -
|
18
|
+
1. deploy_build - The main purpose of this action is to upload an IPA or an APK file to an AirWatch or Workspace ONE enterprise console.
|
19
19
|
2. retire_previous_versions - The main purpose of this action is to retire previous active versions of an application. This action takes a string parameter where you can specify the number of latest versions to keep if you do not want to retire all the previous active versions.
|
20
20
|
3. delete_previous_versions - The main purpose of this action is to delete versions of an application. This action takes a string parameter where you can specify the number of latest versions to keep if you do not want to delete all the versions.
|
21
21
|
4. retire_specific_version - The main purpose of this action is to retire a specific version of an application. This action takes a string parameter where you can specify the version number to retire.
|
22
22
|
5. delete_specific_version - The main purpose of this action is to delete a specific version of an application. This action takes a string parameter where you can specify the version number to delete.
|
23
|
-
6.
|
23
|
+
6. add_or_update_assignments - The main purpose of this action is to add a new smart group assignment to an application or to update an existing smart group assignment of an application with a given dictionary of deployment/assignment parameters. If a smart group name is provided which does not exist yet on Console, assignment for that smart group is ignored.
|
24
24
|
7. unretire_all_versions - The main purpose of this action is to unretire all retired versions of an application.
|
25
|
+
8. unretire_specific_version - The main purpose of this action is to unretire a specific version of an application. This action takes a string parameter where you can specify the version number to unretire.
|
25
26
|
|
26
27
|
## Available options
|
27
28
|
|
@@ -48,10 +49,24 @@ fastlane action add_or_update_assignments
|
|
48
49
|
```bash
|
49
50
|
fastlane action unretire_all_versions
|
50
51
|
```
|
51
|
-
|
52
|
+
```bash
|
53
|
+
fastlane action unretire_specific_version
|
54
|
+
```
|
55
|
+
Please do not append /API/ at the end of host_url option in any of the actions; you should pass something like - https://asxxx.awmdm.com. Thanks to [Willie Stewart](https://github.com/wstewartii) for facing an [issue](https://github.com/letsbondiway/fastlane-plugin-airwatch_workspaceone/issues/2) because of this due to which this gets documented.
|
52
56
|
## Example
|
53
57
|
|
54
|
-
Check out the [example `Fastfile`](fastlane/Fastfile) to see
|
58
|
+
Check out the [example `Fastfile`](fastlane/Fastfile) to see example lanes.
|
59
|
+
|
60
|
+
To make use of this plugin, run one of the lanes using the following command -
|
61
|
+
|
62
|
+
```bash
|
63
|
+
bundle exec fastlane lane_name
|
64
|
+
```
|
65
|
+
If you are using .env files (please find sample - .env.development at the same folder where Fastfile is located), please specify using --env parameter
|
66
|
+
|
67
|
+
```bash
|
68
|
+
bundle exec fastlane lane_name --env development
|
69
|
+
```
|
55
70
|
|
56
71
|
## Run tests for this plugin
|
57
72
|
|
@@ -5,7 +5,6 @@ module Fastlane
|
|
5
5
|
module Actions
|
6
6
|
class AddOrUpdateAssignmentsAction < Action
|
7
7
|
|
8
|
-
APP_VERSIONS_LIST_SUFFIX = "/API/mam/apps/search?bundleid=%s"
|
9
8
|
ADD_UPDATE_ASSIGNMENT_SUFFIX = "/API/mam/apps/internal/%d/assignments"
|
10
9
|
SEARCH_SMART_GROUP_SUFFIX = "/API/mdm/smartgroups/search?name=%s&organizationgroupid=%d"
|
11
10
|
|
@@ -103,8 +102,8 @@ module Fastlane
|
|
103
102
|
|
104
103
|
def self.find_app_smart_groups(app_identifier)
|
105
104
|
# get the list of apps
|
106
|
-
|
107
|
-
app_versions =
|
105
|
+
apps = Helper::AirwatchWorkspaceoneHelper.list_app_versions(app_identifier, $host_url, $aw_tenant_code, $b64_encoded_auth, $org_group_id, debug)
|
106
|
+
app_versions = apps['Application']
|
108
107
|
|
109
108
|
if app_versions.count <= 0
|
110
109
|
UI.user_error!("No app found on the console having bundle identifier: %s" % [app_identifier])
|
@@ -112,41 +111,21 @@ module Fastlane
|
|
112
111
|
exit
|
113
112
|
end
|
114
113
|
|
114
|
+
app_versions.sort_by! { |app_version| app_version["Id"]["Value"] }
|
115
115
|
latest_app_version = app_versions.last
|
116
116
|
$app_id_int = latest_app_version['Id']['Value']
|
117
117
|
app_smart_groups = latest_app_version['SmartGroups']
|
118
118
|
return app_smart_groups
|
119
119
|
end
|
120
120
|
|
121
|
-
def self.list_app_versions(app_identifier)
|
122
|
-
require 'rest-client'
|
123
|
-
require 'json'
|
124
|
-
|
125
|
-
response = RestClient.get($host_url + APP_VERSIONS_LIST_SUFFIX % [app_identifier], {accept: :json, 'aw-tenant-code': $aw_tenant_code, 'Authorization': "Basic " + $b64_encoded_auth})
|
126
|
-
|
127
|
-
if debug
|
128
|
-
UI.message("Response code: %d" % [response.code])
|
129
|
-
UI.message("Response body:")
|
130
|
-
UI.message(response.body)
|
131
|
-
end
|
132
|
-
|
133
|
-
if response.code != 200
|
134
|
-
UI.user_error!("There was an error in finding app versions. One possible reason is that an app with the bundle identifier given does not exist on Console.")
|
135
|
-
exit
|
136
|
-
end
|
137
|
-
|
138
|
-
json = JSON.parse(response.body)
|
139
|
-
return json
|
140
|
-
end
|
141
|
-
|
142
121
|
def self.find_smart_group_id(smart_group_name)
|
143
|
-
|
122
|
+
smart_groups = fetch_smart_group_details(smart_group_name)
|
144
123
|
smart_group_id = -1
|
145
|
-
if
|
124
|
+
if smart_groups.empty?
|
146
125
|
return smart_group_id
|
147
126
|
end
|
148
127
|
|
149
|
-
|
128
|
+
smart_groups['SmartGroups'].each do |smart_group|
|
150
129
|
smart_group_id = smart_group['SmartGroupID']
|
151
130
|
end
|
152
131
|
|
@@ -221,29 +200,29 @@ module Fastlane
|
|
221
200
|
[
|
222
201
|
FastlaneCore::ConfigItem.new(key: :host_url,
|
223
202
|
env_name: "AIRWATCH_HOST_API_URL",
|
224
|
-
description: "Host API URL of the AirWatch instance",
|
203
|
+
description: "Host API URL of the AirWatch/Workspace ONE instance without /API/ at the end",
|
225
204
|
optional: false,
|
226
205
|
type: String,
|
227
206
|
verify_block: proc do |value|
|
228
|
-
UI.user_error!("No AirWatch Host API URl given.") unless value and !value.empty?
|
207
|
+
UI.user_error!("No AirWatch/Workspace ONE Host API URl given, pass using `host_url: 'https://yourhost.com'`") unless value and !value.empty?
|
229
208
|
end),
|
230
209
|
|
231
210
|
FastlaneCore::ConfigItem.new(key: :aw_tenant_code,
|
232
211
|
env_name: "AIRWATCH_API_KEY",
|
233
|
-
description: "API key or the tenant code to access AirWatch Rest APIs",
|
212
|
+
description: "API key or the tenant code to access AirWatch/Workspace ONE Rest APIs",
|
234
213
|
optional: false,
|
235
214
|
type: String,
|
236
215
|
verify_block: proc do |value|
|
237
|
-
UI.user_error!("Api tenant code header is missing
|
216
|
+
UI.user_error!("Api tenant code header is missing, pass using `aw_tenant_code: 'yourapikey'`") unless value and !value.empty?
|
238
217
|
end),
|
239
218
|
|
240
219
|
FastlaneCore::ConfigItem.new(key: :b64_encoded_auth,
|
241
220
|
env_name: "AIRWATCH_BASE64_ENCODED_BASIC_AUTH_STRING",
|
242
|
-
description: "The base64 encoded Basic Auth string generated by authorizing username and password to the AirWatch instance",
|
221
|
+
description: "The base64 encoded Basic Auth string generated by authorizing username and password to the AirWatch/Workspace ONE instance",
|
243
222
|
optional: false,
|
244
223
|
type: String,
|
245
224
|
verify_block: proc do |value|
|
246
|
-
UI.user_error!("The authorization header is empty or the scheme is not basic") unless value and !value.empty?
|
225
|
+
UI.user_error!("The authorization header is empty or the scheme is not basic, pass using `b64_encoded_auth: 'yourb64encodedauthstring'`") unless value and !value.empty?
|
247
226
|
end),
|
248
227
|
|
249
228
|
FastlaneCore::ConfigItem.new(key: :org_group_id,
|
@@ -252,7 +231,7 @@ module Fastlane
|
|
252
231
|
optional: false,
|
253
232
|
type: String,
|
254
233
|
verify_block: proc do |value|
|
255
|
-
UI.user_error!("No Organization Group ID integer given, pass using `org_group_id:
|
234
|
+
UI.user_error!("No Organization Group ID integer given, pass using `org_group_id: 'yourorggrpintid'`") unless value and !value.empty?
|
256
235
|
end),
|
257
236
|
|
258
237
|
FastlaneCore::ConfigItem.new(key: :app_identifier,
|
@@ -266,11 +245,11 @@ module Fastlane
|
|
266
245
|
|
267
246
|
FastlaneCore::ConfigItem.new(key: :smart_groups_to_assign,
|
268
247
|
env_name: "AIRWATCH_SMART_GROUPS_TO_ASSIGN",
|
269
|
-
description: "
|
248
|
+
description: "Names of the smart groups to assign the app to",
|
270
249
|
optional: false,
|
271
250
|
type: Array,
|
272
251
|
verify_block: proc do |value|
|
273
|
-
UI.user_error!("No smart group given, pass using `
|
252
|
+
UI.user_error!("No smart group names given, pass using `smart_groups_to_assign: ['yoursmartgrp1', 'yoursmartgroup2']` or `smart_groups_to_assign: 'yoursmartgrp1'`") unless value and !value.empty?
|
274
253
|
end),
|
275
254
|
|
276
255
|
FastlaneCore::ConfigItem.new(key: :assignment_parameters,
|
@@ -279,7 +258,7 @@ module Fastlane
|
|
279
258
|
optional: false,
|
280
259
|
is_string: false,
|
281
260
|
verify_block: proc do |value|
|
282
|
-
UI.user_error!("No
|
261
|
+
UI.user_error!("No smart group assignment parameters given, pass using `assignment_parameters: '{key1: value1, key2: value2}'`") unless value and !value.empty?
|
283
262
|
end),
|
284
263
|
|
285
264
|
FastlaneCore::ConfigItem.new(key: :debug,
|
@@ -5,9 +5,6 @@ module Fastlane
|
|
5
5
|
module Actions
|
6
6
|
class DeletePreviousVersionsAction < Action
|
7
7
|
|
8
|
-
APP_VERSIONS_LIST_SUFFIX = "/API/mam/apps/search?bundleid=%s"
|
9
|
-
INTERNAL_APP_DELETE_SUFFIX = "/API/mam/apps/internal/%d"
|
10
|
-
|
11
8
|
$is_debug = false
|
12
9
|
|
13
10
|
def self.run(params)
|
@@ -23,6 +20,7 @@ module Fastlane
|
|
23
20
|
UI.message(" host_url: #{params[:host_url]}")
|
24
21
|
UI.message(" aw_tenant_code: #{params[:aw_tenant_code]}")
|
25
22
|
UI.message(" b64_encoded_auth: #{params[:b64_encoded_auth]}")
|
23
|
+
UI.message(" organization_group_id: #{params[:org_group_id]}")
|
26
24
|
UI.message(" app_identifier: #{params[:app_identifier]}")
|
27
25
|
UI.message(" keep_latest_versions_count: #{params[:keep_latest_versions_count]}")
|
28
26
|
end
|
@@ -30,6 +28,7 @@ module Fastlane
|
|
30
28
|
$host_url = params[:host_url]
|
31
29
|
$aw_tenant_code = params[:aw_tenant_code]
|
32
30
|
$b64_encoded_auth = params[:b64_encoded_auth]
|
31
|
+
$org_group_id = params[:org_group_id]
|
33
32
|
app_identifier = params[:app_identifier]
|
34
33
|
keep_latest_versions_count = params[:keep_latest_versions_count]
|
35
34
|
|
@@ -38,7 +37,7 @@ module Fastlane
|
|
38
37
|
UI.message("1. Finding app versions")
|
39
38
|
UI.message("-----------------------")
|
40
39
|
|
41
|
-
app_versions =
|
40
|
+
app_versions = find_app_versions(app_identifier)
|
42
41
|
UI.success("Found %d app version(s)" % [app_versions.count])
|
43
42
|
UI.success("Version number(s): %s" % [app_versions.map {|app_version| app_version.values[1]}])
|
44
43
|
|
@@ -55,77 +54,36 @@ module Fastlane
|
|
55
54
|
app_versions.pop(keep_latest_versions_count_int)
|
56
55
|
UI.important("Version number(s) to delete: %s" % [app_versions.map {|app_version| app_version.values[1]}])
|
57
56
|
app_versions.each do |app_version|
|
58
|
-
delete_app(app_version)
|
57
|
+
Helper::AirwatchWorkspaceoneHelper.delete_app(app_version, $host_url, $aw_tenant_code, $b64_encoded_auth, debug)
|
59
58
|
end
|
60
59
|
UI.success("Version(s) %s successfully deleted." % [app_versions.map {|app_version| app_version.values[1]}])
|
61
60
|
end
|
62
61
|
end
|
63
62
|
|
64
|
-
def self.
|
63
|
+
def self.find_app_versions(app_identifier)
|
65
64
|
# get the list of apps
|
66
|
-
|
65
|
+
apps = Helper::AirwatchWorkspaceoneHelper.list_app_versions(app_identifier, $host_url, $aw_tenant_code, $b64_encoded_auth, $org_group_id, debug)
|
67
66
|
app_versions = Array.new
|
68
67
|
active_app_versions = Array.new
|
69
68
|
retired_app_versions = Array.new
|
70
69
|
|
71
|
-
|
70
|
+
apps['Application'].each do |app|
|
72
71
|
if app['Status'] == "Active"
|
73
|
-
active_app_version =
|
74
|
-
active_app_version['Id'] = app['Id']['Value']
|
75
|
-
active_app_version['Version'] = app['AppVersion']
|
72
|
+
active_app_version = Helper::AirwatchWorkspaceoneHelper.construct_app_version(app)
|
76
73
|
active_app_versions << active_app_version
|
77
74
|
elsif app["Status"] == "Retired"
|
78
|
-
retired_app_version =
|
79
|
-
retired_app_version['Id'] = app['Id']['Value']
|
80
|
-
retired_app_version['Version'] = app['AppVersion']
|
75
|
+
retired_app_version = Helper::AirwatchWorkspaceoneHelper.construct_app_version(app)
|
81
76
|
retired_app_versions << retired_app_version
|
82
77
|
end
|
83
78
|
end
|
84
79
|
|
80
|
+
retired_app_versions.sort_by! { |app_version| app_version["Id"] }
|
81
|
+
active_app_versions.sort_by! { |app_version| app_version["Id"] }
|
85
82
|
app_versions.push(*retired_app_versions)
|
86
83
|
app_versions.push(*active_app_versions)
|
87
84
|
return app_versions
|
88
85
|
end
|
89
86
|
|
90
|
-
def self.list_app_versions(app_identifier)
|
91
|
-
require 'rest-client'
|
92
|
-
require 'json'
|
93
|
-
|
94
|
-
response = RestClient.get($host_url + APP_VERSIONS_LIST_SUFFIX % [app_identifier], {accept: :json, 'aw-tenant-code': $aw_tenant_code, 'Authorization': "Basic " + $b64_encoded_auth})
|
95
|
-
|
96
|
-
if debug
|
97
|
-
UI.message("Response code: %d" % [response.code])
|
98
|
-
UI.message("Response body:")
|
99
|
-
UI.message(response.body)
|
100
|
-
end
|
101
|
-
|
102
|
-
if response.code != 200
|
103
|
-
UI.user_error!("There was an error in finding app versions. One possible reason is that an app with the bundle identifier given does not exist on Console.")
|
104
|
-
exit
|
105
|
-
end
|
106
|
-
|
107
|
-
json = JSON.parse(response.body)
|
108
|
-
return json
|
109
|
-
end
|
110
|
-
|
111
|
-
def self.delete_app(app_version)
|
112
|
-
require 'rest-client'
|
113
|
-
require 'json'
|
114
|
-
|
115
|
-
UI.message("Starting to delete app version: %s" % [app_version['Version']])
|
116
|
-
response = RestClient.delete($host_url + INTERNAL_APP_DELETE_SUFFIX % [app_version['Id']], {accept: :json, 'aw-tenant-code': $aw_tenant_code, 'Authorization': "Basic " + $b64_encoded_auth})
|
117
|
-
|
118
|
-
if debug
|
119
|
-
UI.message("Response code: %d" % [response.code])
|
120
|
-
end
|
121
|
-
|
122
|
-
if response.code == 204
|
123
|
-
UI.message("Successfully deleted app version: %s" % [app_version['Version']])
|
124
|
-
else
|
125
|
-
UI.message("Failed to delete app version: %s" % [app_version['Version']])
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
87
|
def self.description
|
130
88
|
"The main purpose of this action is to delete versions of an application. This action takes a string parameter where you can specify the number of latest versions to keep if you do not want to delete all the versions."
|
131
89
|
end
|
@@ -140,36 +98,45 @@ module Fastlane
|
|
140
98
|
|
141
99
|
def self.details
|
142
100
|
# Optional:
|
143
|
-
"delete_previous_versions - To delete versions of an application on the AirWatch console."
|
101
|
+
"delete_previous_versions - To delete versions of an application on the AirWatch/Workspace ONE console."
|
144
102
|
end
|
145
103
|
|
146
104
|
def self.available_options
|
147
105
|
[
|
148
106
|
FastlaneCore::ConfigItem.new(key: :host_url,
|
149
107
|
env_name: "AIRWATCH_HOST_API_URL",
|
150
|
-
description: "Host API URL of the AirWatch instance",
|
108
|
+
description: "Host API URL of the AirWatch/Workspace ONE instance without /API/ at the end",
|
151
109
|
optional: false,
|
152
110
|
type: String,
|
153
111
|
verify_block: proc do |value|
|
154
|
-
UI.user_error!("No AirWatch Host API URl given.") unless value and !value.empty?
|
112
|
+
UI.user_error!("No AirWatch/Workspace ONE Host API URl given, pass using `host_url: 'https://yourhost.com'`") unless value and !value.empty?
|
155
113
|
end),
|
156
114
|
|
157
115
|
FastlaneCore::ConfigItem.new(key: :aw_tenant_code,
|
158
116
|
env_name: "AIRWATCH_API_KEY",
|
159
|
-
description: "API key to access AirWatch Rest APIs",
|
117
|
+
description: "API key or the tenant code to access AirWatch/Workspace ONE Rest APIs",
|
160
118
|
optional: false,
|
161
119
|
type: String,
|
162
120
|
verify_block: proc do |value|
|
163
|
-
UI.user_error!("Api tenant code header is missing
|
121
|
+
UI.user_error!("Api tenant code header is missing, pass using `aw_tenant_code: 'yourapikey'`") unless value and !value.empty?
|
164
122
|
end),
|
165
123
|
|
166
124
|
FastlaneCore::ConfigItem.new(key: :b64_encoded_auth,
|
167
125
|
env_name: "AIRWATCH_BASE64_ENCODED_BASIC_AUTH_STRING",
|
168
|
-
description: "The base64 encoded Basic Auth string generated by authorizing username and password to the AirWatch instance",
|
126
|
+
description: "The base64 encoded Basic Auth string generated by authorizing username and password to the AirWatch/Workspace ONE instance",
|
127
|
+
optional: false,
|
128
|
+
type: String,
|
129
|
+
verify_block: proc do |value|
|
130
|
+
UI.user_error!("The authorization header is empty or the scheme is not basic, pass using `b64_encoded_auth: 'yourb64encodedauthstring'`") unless value and !value.empty?
|
131
|
+
end),
|
132
|
+
|
133
|
+
FastlaneCore::ConfigItem.new(key: :org_group_id,
|
134
|
+
env_name: "AIRWATCH_ORGANIZATION_GROUP_ID",
|
135
|
+
description: "Organization Group ID integer identifying the customer or container",
|
169
136
|
optional: false,
|
170
137
|
type: String,
|
171
138
|
verify_block: proc do |value|
|
172
|
-
UI.user_error!("
|
139
|
+
UI.user_error!("No Organization Group ID integer given, pass using `org_group_id: 'yourorggrpintid'`") unless value and !value.empty?
|
173
140
|
end),
|
174
141
|
|
175
142
|
FastlaneCore::ConfigItem.new(key: :app_identifier,
|
@@ -188,7 +155,7 @@ module Fastlane
|
|
188
155
|
type: String,
|
189
156
|
default_value: "0",
|
190
157
|
verify_block: proc do |value|
|
191
|
-
UI.user_error!("The number of latest versions to keep can not be negative") unless value.to_i >= 0
|
158
|
+
UI.user_error!("The number of latest versions to keep can not be negative, pass using `keep_latest_versions_count: 'count'`") unless value.to_i >= 0
|
192
159
|
end),
|
193
160
|
|
194
161
|
FastlaneCore::ConfigItem.new(key: :debug,
|
@@ -3,10 +3,7 @@ require_relative '../helper/airwatch_workspaceone_helper'
|
|
3
3
|
|
4
4
|
module Fastlane
|
5
5
|
module Actions
|
6
|
-
class DeleteSpecificVersionAction < Action
|
7
|
-
|
8
|
-
APP_VERSIONS_LIST_SUFFIX = "/API/mam/apps/search?bundleid=%s"
|
9
|
-
INTERNAL_APP_DELETE_SUFFIX = "/API/mam/apps/internal/%d"
|
6
|
+
class DeleteSpecificVersionAction < Action
|
10
7
|
|
11
8
|
$is_debug = false
|
12
9
|
|
@@ -23,6 +20,7 @@ module Fastlane
|
|
23
20
|
UI.message(" host_url: #{params[:host_url]}")
|
24
21
|
UI.message(" aw_tenant_code: #{params[:aw_tenant_code]}")
|
25
22
|
UI.message(" b64_encoded_auth: #{params[:b64_encoded_auth]}")
|
23
|
+
UI.message(" organization_group_id: #{params[:org_group_id]}")
|
26
24
|
UI.message(" app_identifier: #{params[:app_identifier]}")
|
27
25
|
UI.message(" version_number: #{params[:version_number]}")
|
28
26
|
end
|
@@ -30,6 +28,7 @@ module Fastlane
|
|
30
28
|
$host_url = params[:host_url]
|
31
29
|
$aw_tenant_code = params[:aw_tenant_code]
|
32
30
|
$b64_encoded_auth = params[:b64_encoded_auth]
|
31
|
+
$org_group_id = params[:org_group_id]
|
33
32
|
app_identifier = params[:app_identifier]
|
34
33
|
version_number = params[:version_number]
|
35
34
|
|
@@ -38,7 +37,7 @@ module Fastlane
|
|
38
37
|
UI.message("1. Finding app versions")
|
39
38
|
UI.message("-----------------------")
|
40
39
|
|
41
|
-
app_versions =
|
40
|
+
app_versions = Helper::AirwatchWorkspaceoneHelper.find_app_versions(app_identifier, 'None', $host_url, $aw_tenant_code, $b64_encoded_auth, $org_group_id, debug)
|
42
41
|
app_version_numbers = app_versions.map {|app_version| app_version.values[1]}
|
43
42
|
UI.success("Found %d app version(s)" % [app_versions.count])
|
44
43
|
UI.success("Version number(s): %s" % [app_version_numbers])
|
@@ -51,7 +50,7 @@ module Fastlane
|
|
51
50
|
if app_version_numbers.include? version_number
|
52
51
|
version_index = app_version_numbers.index(version_number)
|
53
52
|
app_version_to_delete = app_versions[version_index]
|
54
|
-
delete_app(app_version_to_delete)
|
53
|
+
Helper::AirwatchWorkspaceoneHelper.delete_app(app_version_to_delete, $host_url, $aw_tenant_code, $b64_encoded_auth, debug)
|
55
54
|
else
|
56
55
|
UI.user_error!("A version with the given version number: %s does not exist on the console for this application or is already deleted." % [version_number])
|
57
56
|
end
|
@@ -59,60 +58,6 @@ module Fastlane
|
|
59
58
|
UI.success("Version %s successfully deleted" % [version_number])
|
60
59
|
end
|
61
60
|
|
62
|
-
def self.find_app(app_identifier)
|
63
|
-
# get the list of apps
|
64
|
-
data = list_app_versions(app_identifier)
|
65
|
-
app_versions = Array.new
|
66
|
-
|
67
|
-
data['Application'].each do |app|
|
68
|
-
app_version = Hash.new
|
69
|
-
app_version['Id'] = app['Id']['Value']
|
70
|
-
app_version['Version'] = app['AppVersion']
|
71
|
-
app_versions << app_version
|
72
|
-
end
|
73
|
-
|
74
|
-
return app_versions
|
75
|
-
end
|
76
|
-
|
77
|
-
def self.list_app_versions(app_identifier)
|
78
|
-
require 'rest-client'
|
79
|
-
require 'json'
|
80
|
-
|
81
|
-
response = RestClient.get($host_url + APP_VERSIONS_LIST_SUFFIX % [app_identifier], {accept: :json, 'aw-tenant-code': $aw_tenant_code, 'Authorization': "Basic " + $b64_encoded_auth})
|
82
|
-
|
83
|
-
if debug
|
84
|
-
UI.message("Response code: %d" % [response.code])
|
85
|
-
UI.message("Response body:")
|
86
|
-
UI.message(response.body)
|
87
|
-
end
|
88
|
-
|
89
|
-
if response.code != 200
|
90
|
-
UI.user_error!("There was an error in finding app versions. One possible reason is that an app with the bundle identifier given does not exist on Console.")
|
91
|
-
exit
|
92
|
-
end
|
93
|
-
|
94
|
-
json = JSON.parse(response.body)
|
95
|
-
return json
|
96
|
-
end
|
97
|
-
|
98
|
-
def self.delete_app(app_version)
|
99
|
-
require 'rest-client'
|
100
|
-
require 'json'
|
101
|
-
|
102
|
-
UI.message("Starting to delete app version: %s" % [app_version['Version']])
|
103
|
-
response = RestClient.delete($host_url + INTERNAL_APP_DELETE_SUFFIX % [app_version['Id']], {accept: :json, 'aw-tenant-code': $aw_tenant_code, 'Authorization': "Basic " + $b64_encoded_auth})
|
104
|
-
|
105
|
-
if debug
|
106
|
-
UI.message("Response code: %d" % [response.code])
|
107
|
-
end
|
108
|
-
|
109
|
-
if response.code == 204
|
110
|
-
UI.message("Successfully deleted app version: %s" % [app_version['Version']])
|
111
|
-
else
|
112
|
-
UI.message("Failed to delete app version: %s" % [app_version['Version']])
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
61
|
def self.description
|
117
62
|
"The main purpose of this action is to delete a specific version of an application. This action takes a string parameter where you can specify the version number to delete."
|
118
63
|
end
|
@@ -127,36 +72,45 @@ module Fastlane
|
|
127
72
|
|
128
73
|
def self.details
|
129
74
|
# Optional:
|
130
|
-
"delete_specific_version - To delete specific version of an application on the AirWatch console."
|
75
|
+
"delete_specific_version - To delete specific version of an application on the AirWatch/Workspace ONE console."
|
131
76
|
end
|
132
77
|
|
133
78
|
def self.available_options
|
134
79
|
[
|
135
80
|
FastlaneCore::ConfigItem.new(key: :host_url,
|
136
81
|
env_name: "AIRWATCH_HOST_API_URL",
|
137
|
-
description: "Host API URL of the AirWatch instance",
|
82
|
+
description: "Host API URL of the AirWatch/Workspace ONE instance without /API/ at the end",
|
138
83
|
optional: false,
|
139
84
|
type: String,
|
140
85
|
verify_block: proc do |value|
|
141
|
-
UI.user_error!("No AirWatch Host API URl given.") unless value and !value.empty?
|
86
|
+
UI.user_error!("No AirWatch/Workspace ONE Host API URl given, pass using `host_url: 'https://yourhost.com'`") unless value and !value.empty?
|
142
87
|
end),
|
143
88
|
|
144
89
|
FastlaneCore::ConfigItem.new(key: :aw_tenant_code,
|
145
90
|
env_name: "AIRWATCH_API_KEY",
|
146
|
-
description: "API key to access AirWatch Rest APIs",
|
91
|
+
description: "API key or the tenant code to access AirWatch/Workspace ONE Rest APIs",
|
147
92
|
optional: false,
|
148
93
|
type: String,
|
149
94
|
verify_block: proc do |value|
|
150
|
-
UI.user_error!("Api tenant code header is missing
|
95
|
+
UI.user_error!("Api tenant code header is missing, pass using `aw_tenant_code: 'yourapikey'`") unless value and !value.empty?
|
151
96
|
end),
|
152
97
|
|
153
98
|
FastlaneCore::ConfigItem.new(key: :b64_encoded_auth,
|
154
99
|
env_name: "AIRWATCH_BASE64_ENCODED_BASIC_AUTH_STRING",
|
155
|
-
description: "The base64 encoded Basic Auth string generated by authorizing username and password to the AirWatch instance",
|
100
|
+
description: "The base64 encoded Basic Auth string generated by authorizing username and password to the AirWatch/Workspace ONE instance",
|
101
|
+
optional: false,
|
102
|
+
type: String,
|
103
|
+
verify_block: proc do |value|
|
104
|
+
UI.user_error!("The authorization header is empty or the scheme is not basic, pass using `b64_encoded_auth: 'yourb64encodedauthstring'`") unless value and !value.empty?
|
105
|
+
end),
|
106
|
+
|
107
|
+
FastlaneCore::ConfigItem.new(key: :org_group_id,
|
108
|
+
env_name: "AIRWATCH_ORGANIZATION_GROUP_ID",
|
109
|
+
description: "Organization Group ID integer identifying the customer or container",
|
156
110
|
optional: false,
|
157
111
|
type: String,
|
158
112
|
verify_block: proc do |value|
|
159
|
-
UI.user_error!("
|
113
|
+
UI.user_error!("No Organization Group ID integer given, pass using `org_group_id: 'yourorggrpintid'`") unless value and !value.empty?
|
160
114
|
end),
|
161
115
|
|
162
116
|
FastlaneCore::ConfigItem.new(key: :app_identifier,
|
@@ -170,7 +124,7 @@ module Fastlane
|
|
170
124
|
|
171
125
|
FastlaneCore::ConfigItem.new(key: :version_number,
|
172
126
|
env_name: "AIRWATCH_VERSION_NUMBER",
|
173
|
-
description: "Version number of the application to
|
127
|
+
description: "Version number of the application to delete",
|
174
128
|
optional: false,
|
175
129
|
type: String,
|
176
130
|
verify_block: proc do |value|
|