fastlane-plugin-airwatch_workspaceone 1.0.2 → 2.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1c62f69f944ca9c95d087f4b1f0dc1a284779120e2756457735126a8a8972de4
4
- data.tar.gz: 5727e93a347e01cb6ce22f9eb2a41b6871fd8a100c89484010c87033330d7d00
3
+ metadata.gz: 191673d04c6aea52b229a49d1b45af155ea14d31b2bfe091f4c57d479bbe66be
4
+ data.tar.gz: c0c51a6ade8f56fd4c64181c33bb2ed8f8a6a8a1beb1ec71f87eecd86e89a458
5
5
  SHA512:
6
- metadata.gz: b62070708b3489f3400aabbff7a47cb127333711b5ae716e6c66ed93a5aa37352d94769447804639a2f419ac2c7f62fd23f2a8c4d29991b5f14da8c7348eacb3
7
- data.tar.gz: 3ad00a3d6948f338fba6cf62ea62d63218f07874776129807dafb3399020c1517411fb163f9d6a5c891bc04c1659c4dc022a4b8200396f18c6be341254eafcbc
6
+ metadata.gz: b7448ef957bb1739cffb4a7dd1f32277356c8de22823f4daf2bcd8bd93a81782a722f96f79b6fb420928ba71d29acaca80a720169dc11eb3de1dfb160202fc02
7
+ data.tar.gz: 85c7e7714b8be62745595c97d363a3eafe2f041d37d1110d6888cd863c95977517bb4890824b63ef6bc985dce41d66e9a9ace6c8f31a83228c60d03b6c680be2
data/README.md CHANGED
@@ -12,28 +12,61 @@ fastlane add_plugin airwatch_workspaceone
12
12
 
13
13
  ## About airwatch_workspaceone
14
14
 
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.
16
-
17
- This plugin features two actions :-
18
- 1. deploy_build - To upload an iOS ipa OR Android APK to AirWatch/WorkspaceOne console.
19
- 2. retire_previous_versions - To retire all active versions of the application on the AirWatch console except the latest version.
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
+
17
+ This plugin features following actions :-
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
+ 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
+ 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
+ 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
+ 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. 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
+ 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.
20
26
 
21
27
  ## Available options
22
28
 
23
29
  To check for available options, run
24
30
 
25
31
  ```bash
26
- fastlane action deploy_app
32
+ fastlane action deploy_build
27
33
  ```
28
- and
29
-
30
34
  ```bash
31
35
  fastlane action retire_previous_versions
32
36
  ```
33
-
37
+ ```bash
38
+ fastlane action delete_previous_versions
39
+ ```
40
+ ```bash
41
+ fastlane action retire_specific_version
42
+ ```
43
+ ```bash
44
+ fastlane action delete_specific_version
45
+ ```
46
+ ```bash
47
+ fastlane action add_or_update_assignments
48
+ ```
49
+ ```bash
50
+ fastlane action unretire_all_versions
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.
34
56
  ## Example
35
57
 
36
- Check out the [example `Fastfile`](fastlane/Fastfile) to see how to use this plugin.
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
+ ```
37
70
 
38
71
  ## Run tests for this plugin
39
72
 
@@ -0,0 +1,311 @@
1
+ require 'fastlane/action'
2
+ require_relative '../helper/airwatch_workspaceone_helper'
3
+
4
+ module Fastlane
5
+ module Actions
6
+ class AddOrUpdateAssignmentsAction < Action
7
+
8
+ APP_VERSIONS_LIST_SUFFIX = "/API/mam/apps/search?applicationtype=Internal&bundleid=%s"
9
+ ADD_UPDATE_ASSIGNMENT_SUFFIX = "/API/mam/apps/internal/%d/assignments"
10
+ SEARCH_SMART_GROUP_SUFFIX = "/API/mdm/smartgroups/search?name=%s&organizationgroupid=%d"
11
+
12
+ $is_debug = false
13
+ $app_id_int
14
+
15
+ def self.run(params)
16
+ UI.message("The airwatch_workspaceone plugin is working!")
17
+
18
+ # check if debug is enabled
19
+ $is_debug = params[:debug]
20
+
21
+ if debug
22
+ UI.message("----------------------------------------------")
23
+ UI.message("AddOrUpdateAssignmentsAction debug information")
24
+ UI.message("----------------------------------------------")
25
+ UI.message(" host_url: #{params[:host_url]}")
26
+ UI.message(" aw_tenant_code: #{params[:aw_tenant_code]}")
27
+ UI.message(" b64_encoded_auth: #{params[:b64_encoded_auth]}")
28
+ UI.message(" organization_group_id: #{params[:org_group_id]}")
29
+ UI.message(" app_identifier: #{params[:app_identifier]}")
30
+ UI.message(" smart_groups_to_assign: #{params[:smart_groups_to_assign]}")
31
+ UI.message(" assignment_parameters: #{params[:assignment_parameters]}")
32
+ end
33
+
34
+ $host_url = params[:host_url]
35
+ $aw_tenant_code = params[:aw_tenant_code]
36
+ $b64_encoded_auth = params[:b64_encoded_auth]
37
+ $org_group_id = params[:org_group_id]
38
+ app_identifier = params[:app_identifier]
39
+ smart_groups_to_assign = params[:smart_groups_to_assign]
40
+ assignment_parameters = params[:assignment_parameters]
41
+
42
+ # step 1: find app
43
+ UI.message("-----------------------------")
44
+ UI.message("1. Finding app's smart groups")
45
+ UI.message("-----------------------------")
46
+
47
+ app_smart_groups = find_app_smart_groups(app_identifier)
48
+ UI.success("Found %d smart group(s) assigned to the app." % [app_smart_groups.count])
49
+ UI.success("Smart Group(s): %s" % [app_smart_groups.map {|smart_group| smart_group.values[1]}])
50
+
51
+ # step 2: separate smart groups into need to add and need to update
52
+ UI.message("-----------------------------------------------")
53
+ UI.message("2. Separating smart groups to add and to update")
54
+ UI.message("-----------------------------------------------")
55
+
56
+ update_smart_group_ids = Array.new
57
+ update_smart_group_names = Array.new
58
+ add_smart_group_ids = Array.new
59
+ add_smart_group_names = Array.new
60
+
61
+ smart_groups_to_assign.each do |smart_group|
62
+ UI.message("Fetching details for %s smart group" % [smart_group])
63
+ smart_group_id = find_smart_group_id(smart_group)
64
+ if smart_group_id == -1
65
+ UI.important("Could not find smart group named %s in the given organization group. Skipping this smart group assignment." % [smart_group])
66
+ else
67
+ if app_smart_groups.map {|smart_group| smart_group.values[0]}.include? smart_group_id
68
+ UI.message("Assignment to the smart group %s needs to be updated" % [smart_group])
69
+ update_smart_group_ids << smart_group_id
70
+ update_smart_group_names << smart_group
71
+ else
72
+ UI.message("Assignment to the smart group %s needs to be added" % [smart_group])
73
+ add_smart_group_ids << smart_group_id
74
+ add_smart_group_names << smart_group
75
+ end
76
+ end
77
+ end
78
+
79
+ # step 3: update smart group assignments
80
+ UI.message("--------------------------------------------")
81
+ UI.message("3. Updating existing smart group assignments")
82
+ UI.message("--------------------------------------------")
83
+
84
+ if update_smart_group_ids.count <= 0
85
+ UI.success("No existing smart groups assignment needs to be updated")
86
+ else
87
+ add_update_smart_group_assignment(update_smart_group_ids, assignment_parameters, true)
88
+ UI.success("Assignment for smart group(s): %s successfully updated" % [update_smart_group_names])
89
+ end
90
+
91
+ # step 4: add smart group assignments
92
+ UI.message("-------------------------------------")
93
+ UI.message("4. Adding new smart group assignments")
94
+ UI.message("-------------------------------------")
95
+
96
+ if add_smart_group_ids.count <= 0
97
+ UI.success("No new groups assignment needs to be added")
98
+ else
99
+ add_update_smart_group_assignment(add_smart_group_ids, assignment_parameters, false)
100
+ UI.success("Assignment for smart group(s): %s successfully added" % [add_smart_group_names])
101
+ end
102
+ end
103
+
104
+ def self.find_app_smart_groups(app_identifier)
105
+ # get the list of apps
106
+ data = list_app_versions(app_identifier)
107
+ app_versions = data['Application']
108
+
109
+ if app_versions.count <= 0
110
+ UI.user_error!("No app found on the console having bundle identifier: %s" % [app_identifier])
111
+ UI.user_error!("Please provide an existing app identifier")
112
+ exit
113
+ end
114
+
115
+ app_versions.sort_by! { |app_version| app_version["Id"]["Value"] }
116
+ latest_app_version = app_versions.last
117
+ $app_id_int = latest_app_version['Id']['Value']
118
+ app_smart_groups = latest_app_version['SmartGroups']
119
+ return app_smart_groups
120
+ end
121
+
122
+ def self.list_app_versions(app_identifier)
123
+ require 'rest-client'
124
+ require 'json'
125
+
126
+ response = RestClient.get($host_url + APP_VERSIONS_LIST_SUFFIX % [app_identifier], {accept: :json, 'aw-tenant-code': $aw_tenant_code, 'Authorization': "Basic " + $b64_encoded_auth})
127
+
128
+ if debug
129
+ UI.message("Response code: %d" % [response.code])
130
+ UI.message("Response body:")
131
+ UI.message(response.body)
132
+ end
133
+
134
+ if response.code != 200
135
+ 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.")
136
+ exit
137
+ end
138
+
139
+ json = JSON.parse(response.body)
140
+ return json
141
+ end
142
+
143
+ def self.find_smart_group_id(smart_group_name)
144
+ data = fetch_smart_group_details(smart_group_name)
145
+ smart_group_id = -1
146
+ if data.empty?
147
+ return smart_group_id
148
+ end
149
+
150
+ data['SmartGroups'].each do |smart_group|
151
+ smart_group_id = smart_group['SmartGroupID']
152
+ end
153
+
154
+ return smart_group_id
155
+ end
156
+
157
+ def self.fetch_smart_group_details(smart_group_name)
158
+ require 'rest-client'
159
+ require 'json'
160
+
161
+ response = RestClient.get($host_url + SEARCH_SMART_GROUP_SUFFIX % [smart_group_name, $org_group_id], {accept: :json, 'aw-tenant-code': $aw_tenant_code, 'Authorization': "Basic " + $b64_encoded_auth})
162
+
163
+ if debug
164
+ UI.message("Response code: %d" % [response.code])
165
+ UI.message("Response body:")
166
+ UI.message(response.body)
167
+ end
168
+
169
+ if response.code != 200
170
+ return Hash.new
171
+ end
172
+
173
+ json = JSON.parse(response.body)
174
+ return json
175
+ end
176
+
177
+ def self.add_update_smart_group_assignment(smart_group_ids, assignment_parameters, update)
178
+ require 'rest-client'
179
+ require 'json'
180
+
181
+ body = {
182
+ "SmartGroupIds" => smart_group_ids,
183
+ "DeploymentParameters" => assignment_parameters
184
+ }
185
+
186
+ if debug
187
+ UI.message("Deploy Request JSON:")
188
+ UI.message(body.to_json)
189
+ end
190
+
191
+ if update
192
+ response = RestClient.put($host_url + ADD_UPDATE_ASSIGNMENT_SUFFIX % [$app_id_int], body.to_json, {content_type: :json, accept: :json, 'aw-tenant-code': $aw_tenant_code, 'Authorization': "Basic " + $b64_encoded_auth})
193
+ else
194
+ response = RestClient.post($host_url + ADD_UPDATE_ASSIGNMENT_SUFFIX % [$app_id_int], body.to_json, {content_type: :json, accept: :json, 'aw-tenant-code': $aw_tenant_code, 'Authorization': "Basic " + $b64_encoded_auth})
195
+ end
196
+
197
+ if debug
198
+ UI.message("Response code: %d" % [response.code])
199
+ UI.message("Response body:")
200
+ UI.message(response.body)
201
+ end
202
+ end
203
+
204
+ def self.description
205
+ "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."
206
+ end
207
+
208
+ def self.authors
209
+ ["Ram Awadhesh Sharan"]
210
+ end
211
+
212
+ def self.return_value
213
+ # If your method provides a return value, you can describe here what it does
214
+ end
215
+
216
+ def self.details
217
+ # Optional:
218
+ "add_or_update_assignments - To add or update smart group assignments with given deployment parameters."
219
+ end
220
+
221
+ def self.available_options
222
+ [
223
+ FastlaneCore::ConfigItem.new(key: :host_url,
224
+ env_name: "AIRWATCH_HOST_API_URL",
225
+ description: "Host API URL of the AirWatch/Workspace ONE instance without /API/ at the end",
226
+ optional: false,
227
+ type: String,
228
+ verify_block: proc do |value|
229
+ UI.user_error!("No AirWatch/Workspace ONE Host API URl given, pass using `host_url: 'https://yourhost.com'`") unless value and !value.empty?
230
+ end),
231
+
232
+ FastlaneCore::ConfigItem.new(key: :aw_tenant_code,
233
+ env_name: "AIRWATCH_API_KEY",
234
+ description: "API key or the tenant code to access AirWatch/Workspace ONE Rest APIs",
235
+ optional: false,
236
+ type: String,
237
+ verify_block: proc do |value|
238
+ UI.user_error!("Api tenant code header is missing, pass using `aw_tenant_code: 'yourapikey'`") unless value and !value.empty?
239
+ end),
240
+
241
+ FastlaneCore::ConfigItem.new(key: :b64_encoded_auth,
242
+ env_name: "AIRWATCH_BASE64_ENCODED_BASIC_AUTH_STRING",
243
+ description: "The base64 encoded Basic Auth string generated by authorizing username and password to the AirWatch/Workspace ONE instance",
244
+ optional: false,
245
+ type: String,
246
+ verify_block: proc do |value|
247
+ 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?
248
+ end),
249
+
250
+ FastlaneCore::ConfigItem.new(key: :org_group_id,
251
+ env_name: "AIRWATCH_ORGANIZATION_GROUP_ID",
252
+ description: "Organization Group ID integer identifying the customer or container",
253
+ optional: false,
254
+ type: String,
255
+ verify_block: proc do |value|
256
+ UI.user_error!("No Organization Group ID integer given, pass using `org_group_id: 'yourorggrpintid'`") unless value and !value.empty?
257
+ end),
258
+
259
+ FastlaneCore::ConfigItem.new(key: :app_identifier,
260
+ env_name: "APP_IDENTIFIER",
261
+ description: "Bundle identifier of your app",
262
+ optional: false,
263
+ type: String,
264
+ verify_block: proc do |value|
265
+ UI.user_error!("No app identifier given, pass using `app_identifier: 'com.example.app'`") unless value and !value.empty?
266
+ end),
267
+
268
+ FastlaneCore::ConfigItem.new(key: :smart_groups_to_assign,
269
+ env_name: "AIRWATCH_SMART_GROUPS_TO_ASSIGN",
270
+ description: "Names of the smart groups to assign the app to",
271
+ optional: false,
272
+ type: Array,
273
+ verify_block: proc do |value|
274
+ 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?
275
+ end),
276
+
277
+ FastlaneCore::ConfigItem.new(key: :assignment_parameters,
278
+ env_name: "AIRWATCH_ASSIGNMENT_PARAMETERS",
279
+ description: "Deployment parameters for the smart group assignment",
280
+ optional: false,
281
+ is_string: false,
282
+ verify_block: proc do |value|
283
+ UI.user_error!("No smart group assignment parameters given, pass using `assignment_parameters: '{key1: value1, key2: value2}'`") unless value and !value.empty?
284
+ end),
285
+
286
+ FastlaneCore::ConfigItem.new(key: :debug,
287
+ env_name: "AIRWATCH_DEBUG",
288
+ description: "Debug flag, set to true to show extended output. default: false",
289
+ optional: true,
290
+ is_string: false,
291
+ default_value: false)
292
+ ]
293
+ end
294
+
295
+ def self.is_supported?(platform)
296
+ # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
297
+ # See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
298
+ #
299
+ [:ios, :android].include?(platform)
300
+ true
301
+ end
302
+
303
+ # helpers
304
+
305
+ def self.debug
306
+ $is_debug
307
+ end
308
+
309
+ end
310
+ end
311
+ end
@@ -0,0 +1,221 @@
1
+ require 'fastlane/action'
2
+ require_relative '../helper/airwatch_workspaceone_helper'
3
+
4
+ module Fastlane
5
+ module Actions
6
+ class DeletePreviousVersionsAction < Action
7
+
8
+ APP_VERSIONS_LIST_SUFFIX = "/API/mam/apps/search?applicationtype=Internal&bundleid=%s"
9
+ INTERNAL_APP_DELETE_SUFFIX = "/API/mam/apps/internal/%d"
10
+
11
+ $is_debug = false
12
+
13
+ def self.run(params)
14
+ UI.message("The airwatch_workspaceone plugin is working!")
15
+
16
+ # check if debug is enabled
17
+ $is_debug = params[:debug]
18
+
19
+ if debug
20
+ UI.message("----------------------------------------------")
21
+ UI.message("DeletePreviousVersionsAction debug information")
22
+ UI.message("----------------------------------------------")
23
+ UI.message(" host_url: #{params[:host_url]}")
24
+ UI.message(" aw_tenant_code: #{params[:aw_tenant_code]}")
25
+ UI.message(" b64_encoded_auth: #{params[:b64_encoded_auth]}")
26
+ UI.message(" app_identifier: #{params[:app_identifier]}")
27
+ UI.message(" keep_latest_versions_count: #{params[:keep_latest_versions_count]}")
28
+ end
29
+
30
+ $host_url = params[:host_url]
31
+ $aw_tenant_code = params[:aw_tenant_code]
32
+ $b64_encoded_auth = params[:b64_encoded_auth]
33
+ app_identifier = params[:app_identifier]
34
+ keep_latest_versions_count = params[:keep_latest_versions_count]
35
+
36
+ # step 1: find app
37
+ UI.message("-----------------------")
38
+ UI.message("1. Finding app versions")
39
+ UI.message("-----------------------")
40
+
41
+ app_versions = find_app(app_identifier)
42
+ UI.success("Found %d app version(s)" % [app_versions.count])
43
+ UI.success("Version number(s): %s" % [app_versions.map {|app_version| app_version.values[1]}])
44
+
45
+ # step 2: delete versions
46
+ UI.message("------------------------")
47
+ UI.message("2. Deleting app versions")
48
+ UI.message("------------------------")
49
+
50
+ keep_latest_versions_count_int = keep_latest_versions_count.to_i
51
+ if app_versions.count < keep_latest_versions_count_int
52
+ UI.important("Given number of latest versions to keep is greater than available number of versions on the store.")
53
+ UI.important("Will not delete any version.")
54
+ else
55
+ app_versions.pop(keep_latest_versions_count_int)
56
+ UI.important("Version number(s) to delete: %s" % [app_versions.map {|app_version| app_version.values[1]}])
57
+ app_versions.each do |app_version|
58
+ delete_app(app_version)
59
+ end
60
+ UI.success("Version(s) %s successfully deleted." % [app_versions.map {|app_version| app_version.values[1]}])
61
+ end
62
+ end
63
+
64
+ def self.find_app(app_identifier)
65
+ # get the list of apps
66
+ data = list_app_versions(app_identifier)
67
+ app_versions = Array.new
68
+ active_app_versions = Array.new
69
+ retired_app_versions = Array.new
70
+
71
+ data['Application'].each do |app|
72
+ if app['Status'] == "Active"
73
+ active_app_version = Hash.new
74
+ active_app_version['Id'] = app['Id']['Value']
75
+ active_app_version['Version'] = app['AppVersion']
76
+ active_app_versions << active_app_version
77
+ elsif app["Status"] == "Retired"
78
+ retired_app_version = Hash.new
79
+ retired_app_version['Id'] = app['Id']['Value']
80
+ retired_app_version['Version'] = app['AppVersion']
81
+ retired_app_versions << retired_app_version
82
+ end
83
+ end
84
+
85
+ retired_app_versions.sort_by! { |app_version| app_version["Id"] }
86
+ active_app_versions.sort_by! { |app_version| app_version["Id"] }
87
+ app_versions.push(*retired_app_versions)
88
+ app_versions.push(*active_app_versions)
89
+ return app_versions
90
+ end
91
+
92
+ def self.list_app_versions(app_identifier)
93
+ require 'rest-client'
94
+ require 'json'
95
+
96
+ response = RestClient.get($host_url + APP_VERSIONS_LIST_SUFFIX % [app_identifier], {accept: :json, 'aw-tenant-code': $aw_tenant_code, 'Authorization': "Basic " + $b64_encoded_auth})
97
+
98
+ if debug
99
+ UI.message("Response code: %d" % [response.code])
100
+ UI.message("Response body:")
101
+ UI.message(response.body)
102
+ end
103
+
104
+ if response.code != 200
105
+ 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.")
106
+ exit
107
+ end
108
+
109
+ json = JSON.parse(response.body)
110
+ return json
111
+ end
112
+
113
+ def self.delete_app(app_version)
114
+ require 'rest-client'
115
+ require 'json'
116
+
117
+ UI.message("Starting to delete app version: %s" % [app_version['Version']])
118
+ 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})
119
+
120
+ if debug
121
+ UI.message("Response code: %d" % [response.code])
122
+ end
123
+
124
+ if response.code == 204
125
+ UI.message("Successfully deleted app version: %s" % [app_version['Version']])
126
+ else
127
+ UI.message("Failed to delete app version: %s" % [app_version['Version']])
128
+ end
129
+ end
130
+
131
+ def self.description
132
+ "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."
133
+ end
134
+
135
+ def self.authors
136
+ ["Ram Awadhesh Sharan"]
137
+ end
138
+
139
+ def self.return_value
140
+ # If your method provides a return value, you can describe here what it does
141
+ end
142
+
143
+ def self.details
144
+ # Optional:
145
+ "delete_previous_versions - To delete versions of an application on the AirWatch/Workspace ONE console."
146
+ end
147
+
148
+ def self.available_options
149
+ [
150
+ FastlaneCore::ConfigItem.new(key: :host_url,
151
+ env_name: "AIRWATCH_HOST_API_URL",
152
+ description: "Host API URL of the AirWatch/Workspace ONE instance without /API/ at the end",
153
+ optional: false,
154
+ type: String,
155
+ verify_block: proc do |value|
156
+ UI.user_error!("No AirWatch/Workspace ONE Host API URl given, pass using `host_url: 'https://yourhost.com'`") unless value and !value.empty?
157
+ end),
158
+
159
+ FastlaneCore::ConfigItem.new(key: :aw_tenant_code,
160
+ env_name: "AIRWATCH_API_KEY",
161
+ description: "API key or the tenant code to access AirWatch/Workspace ONE Rest APIs",
162
+ optional: false,
163
+ type: String,
164
+ verify_block: proc do |value|
165
+ UI.user_error!("Api tenant code header is missing, pass using `aw_tenant_code: 'yourapikey'`") unless value and !value.empty?
166
+ end),
167
+
168
+ FastlaneCore::ConfigItem.new(key: :b64_encoded_auth,
169
+ env_name: "AIRWATCH_BASE64_ENCODED_BASIC_AUTH_STRING",
170
+ description: "The base64 encoded Basic Auth string generated by authorizing username and password to the AirWatch/Workspace ONE instance",
171
+ optional: false,
172
+ type: String,
173
+ verify_block: proc do |value|
174
+ 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?
175
+ end),
176
+
177
+ FastlaneCore::ConfigItem.new(key: :app_identifier,
178
+ env_name: "APP_IDENTIFIER",
179
+ description: "Bundle identifier of your app",
180
+ optional: false,
181
+ type: String,
182
+ verify_block: proc do |value|
183
+ UI.user_error!("No app identifier given, pass using `app_identifier: 'com.example.app'`") unless value and !value.empty?
184
+ end),
185
+
186
+ FastlaneCore::ConfigItem.new(key: :keep_latest_versions_count,
187
+ env_name: "AIRWATCH_KEEP_LATEST_VERSIONS_COUNT",
188
+ description: "Name of the application. default: 0",
189
+ optional: true,
190
+ type: String,
191
+ default_value: "0",
192
+ verify_block: proc do |value|
193
+ 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
194
+ end),
195
+
196
+ FastlaneCore::ConfigItem.new(key: :debug,
197
+ env_name: "AIRWATCH_DEBUG",
198
+ description: "Debug flag, set to true to show extended output. default: false",
199
+ optional: true,
200
+ is_string: false,
201
+ default_value: false)
202
+ ]
203
+ end
204
+
205
+ def self.is_supported?(platform)
206
+ # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
207
+ # See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
208
+
209
+ [:ios, :android].include?(platform)
210
+ true
211
+ end
212
+
213
+ # helpers
214
+
215
+ def self.debug
216
+ $is_debug
217
+ end
218
+
219
+ end
220
+ end
221
+ end