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.
@@ -0,0 +1,218 @@
1
+ require 'fastlane/action'
2
+ require_relative '../helper/airwatch_workspaceone_helper'
3
+
4
+ module Fastlane
5
+ module Actions
6
+ class UnretireSpecificVersionAction < Action
7
+
8
+ APP_VERSIONS_LIST_SUFFIX = "/API/mam/apps/search?applicationtype=Internal&bundleid=%s"
9
+ INTERNAL_APP_UNRETIRE_SUFFIX = "/API/mam/apps/internal/%d/unretire"
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("UnretireSpecificVersionAction 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(" version_number: #{params[:version_number]}")
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
+ version_number = params[:version_number]
35
+
36
+ # step 1: find app
37
+ UI.message("-------------------------------")
38
+ UI.message("1. Finding retired app versions")
39
+ UI.message("-------------------------------")
40
+
41
+ retired_app_versions = find_app(app_identifier)
42
+ if retired_app_versions.count <= 0
43
+ UI.important("No retired app versions found for application with bundle identifier given: %s" % [app_identifier])
44
+ return
45
+ end
46
+
47
+ retired_version_numbers = retired_app_versions.map {|retired_app_version| retired_app_version.values[1]}
48
+ UI.success("Found %d retired app version(s)" % [retired_app_versions.count])
49
+ UI.success("Version number(s): %s" % [retired_version_numbers])
50
+
51
+ # step 2: retire specific version
52
+ UI.message("----------------------------------")
53
+ UI.message("2. UnRetiring specific app version")
54
+ UI.message("----------------------------------")
55
+
56
+ if retired_version_numbers.include? version_number
57
+ version_index = retired_version_numbers.index(version_number)
58
+ app_version_to_unretire = retired_app_versions[version_index]
59
+ unretire_app(app_version_to_unretire)
60
+ else
61
+ UI.user_error!("A version with the given version number: %s does not exist on the console for this application or is already Active." % [version_number])
62
+ end
63
+
64
+ UI.success("Version %s successfully unretired" % [version_number])
65
+ end
66
+
67
+ def self.find_app(app_identifier)
68
+ # get the list of apps
69
+ data = list_app_versions(app_identifier)
70
+ retired_app_versions = Array.new
71
+
72
+ data['Application'].each do |app|
73
+ if app['Status'] == "Retired"
74
+ retired_app_version = Hash.new
75
+ retired_app_version['Id'] = app['Id']['Value']
76
+ retired_app_version['Version'] = app['AppVersion']
77
+ retired_app_versions << retired_app_version
78
+ end
79
+ end
80
+
81
+ retired_app_versions.sort_by! { |app_version| app_version["Id"] }
82
+ return retired_app_versions
83
+ end
84
+
85
+ def self.list_app_versions(app_identifier)
86
+ require 'rest-client'
87
+ require 'json'
88
+
89
+ response = RestClient.get($host_url + APP_VERSIONS_LIST_SUFFIX % [app_identifier], {accept: :json, 'aw-tenant-code': $aw_tenant_code, 'Authorization': "Basic " + $b64_encoded_auth})
90
+
91
+ if debug
92
+ UI.message("Response code: %d" % [response.code])
93
+ UI.message("Response body:")
94
+ UI.message(response.body)
95
+ end
96
+
97
+ if response.code != 200
98
+ 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.")
99
+ exit
100
+ end
101
+
102
+ json = JSON.parse(response.body)
103
+ return json
104
+ end
105
+
106
+ def self.unretire_app(app_version)
107
+ require 'rest-client'
108
+ require 'json'
109
+
110
+ body = {
111
+ "applicationid" => app_version['Id']
112
+ }
113
+
114
+ UI.message("Starting to unretire app version: %s" % [app_version['Version']])
115
+ response = RestClient.post($host_url + INTERNAL_APP_UNRETIRE_SUFFIX % [app_version['Id']], body.to_json, {accept: :json, 'aw-tenant-code': $aw_tenant_code, 'Authorization': "Basic " + $b64_encoded_auth})
116
+
117
+ if debug
118
+ UI.message("Response code: %d" % [response.code])
119
+ end
120
+
121
+ if response.code == 202
122
+ UI.message("Successfully unretired app version: %s" % [app_version['Version']])
123
+ else
124
+ json = JSON.parse(response.body)
125
+ UI.message("Failed to unretire app version: %s" % [app_version['Version']])
126
+ end
127
+ end
128
+
129
+ def self.description
130
+ "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."
131
+ end
132
+
133
+ def self.authors
134
+ ["Ram Awadhesh Sharan"]
135
+ end
136
+
137
+ def self.return_value
138
+ # If your method provides a return value, you can describe here what it does
139
+ end
140
+
141
+ def self.details
142
+ # Optional:
143
+ "unretire_specific_version - To unretire specific version of an application on the AirWatch/Workspace ONE console."
144
+ end
145
+
146
+ def self.available_options
147
+ [
148
+ FastlaneCore::ConfigItem.new(key: :host_url,
149
+ env_name: "AIRWATCH_HOST_API_URL",
150
+ description: "Host API URL of the AirWatch/Workspace ONE instance without /API/ at the end",
151
+ optional: false,
152
+ type: String,
153
+ verify_block: proc do |value|
154
+ UI.user_error!("No AirWatch/Workspace ONE Host API URl given, pass using `host_url: 'https://yourhost.com'`") unless value and !value.empty?
155
+ end),
156
+
157
+ FastlaneCore::ConfigItem.new(key: :aw_tenant_code,
158
+ env_name: "AIRWATCH_API_KEY",
159
+ description: "API key or the tenant code to access AirWatch/Workspace ONE Rest APIs",
160
+ optional: false,
161
+ type: String,
162
+ verify_block: proc do |value|
163
+ UI.user_error!("Api tenant code header is missing, pass using `aw_tenant_code: 'yourapikey'`") unless value and !value.empty?
164
+ end),
165
+
166
+ FastlaneCore::ConfigItem.new(key: :b64_encoded_auth,
167
+ 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/Workspace ONE instance",
169
+ optional: false,
170
+ type: String,
171
+ verify_block: proc do |value|
172
+ 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?
173
+ end),
174
+
175
+ FastlaneCore::ConfigItem.new(key: :app_identifier,
176
+ env_name: "APP_IDENTIFIER",
177
+ description: "Bundle identifier of your app",
178
+ optional: false,
179
+ type: String,
180
+ verify_block: proc do |value|
181
+ UI.user_error!("No app identifier given, pass using `app_identifier: 'com.example.app'`") unless value and !value.empty?
182
+ end),
183
+
184
+ FastlaneCore::ConfigItem.new(key: :version_number,
185
+ env_name: "AIRWATCH_VERSION_NUMBER",
186
+ description: "Version number of the application to unretire",
187
+ optional: false,
188
+ type: String,
189
+ verify_block: proc do |value|
190
+ UI.user_error!("No version number given, pass using `version_number: '1.0'`") unless value and !value.empty?
191
+ end),
192
+
193
+ FastlaneCore::ConfigItem.new(key: :debug,
194
+ env_name: "AIRWATCH_DEBUG",
195
+ description: "Debug flag, set to true to show extended output. default: false",
196
+ optional: true,
197
+ is_string: false,
198
+ default_value: false)
199
+ ]
200
+ end
201
+
202
+ def self.is_supported?(platform)
203
+ # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
204
+ # See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
205
+
206
+ [:ios, :android].include?(platform)
207
+ true
208
+ end
209
+
210
+ # helpers
211
+
212
+ def self.debug
213
+ $is_debug
214
+ end
215
+
216
+ end
217
+ end
218
+ end
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module AirwatchWorkspaceone
3
- VERSION = "1.0.2"
3
+ VERSION = "2.3.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-airwatch_workspaceone
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 2.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ram Awadhesh Sharan
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-30 00:00:00.000000000 Z
11
+ date: 2020-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -164,7 +164,7 @@ dependencies:
164
164
  - - ">="
165
165
  - !ruby/object:Gem::Version
166
166
  version: 2.123.0
167
- description:
167
+ description:
168
168
  email: ram.awadhesh1.618@gmail.com
169
169
  executables: []
170
170
  extensions: []
@@ -173,15 +173,21 @@ files:
173
173
  - LICENSE
174
174
  - README.md
175
175
  - lib/fastlane/plugin/airwatch_workspaceone.rb
176
+ - lib/fastlane/plugin/airwatch_workspaceone/actions/add_or_update_assignments_action.rb
177
+ - lib/fastlane/plugin/airwatch_workspaceone/actions/delete_previous_versions_action.rb
178
+ - lib/fastlane/plugin/airwatch_workspaceone/actions/delete_specific_version_action.rb
176
179
  - lib/fastlane/plugin/airwatch_workspaceone/actions/deploy_build_action.rb
177
180
  - lib/fastlane/plugin/airwatch_workspaceone/actions/retire_previous_versions_action.rb
181
+ - lib/fastlane/plugin/airwatch_workspaceone/actions/retire_specific_version_action.rb
182
+ - lib/fastlane/plugin/airwatch_workspaceone/actions/unretire_all_versions.rb
183
+ - lib/fastlane/plugin/airwatch_workspaceone/actions/unretire_specific_version_action.rb
178
184
  - lib/fastlane/plugin/airwatch_workspaceone/helper/airwatch_workspaceone_helper.rb
179
185
  - lib/fastlane/plugin/airwatch_workspaceone/version.rb
180
186
  homepage: https://github.com/letsbondiway/fastlane-plugin-airwatch_workspaceone
181
187
  licenses:
182
188
  - MIT
183
189
  metadata: {}
184
- post_install_message:
190
+ post_install_message:
185
191
  rdoc_options: []
186
192
  require_paths:
187
193
  - lib
@@ -196,8 +202,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
196
202
  - !ruby/object:Gem::Version
197
203
  version: '0'
198
204
  requirements: []
199
- rubygems_version: 3.0.3
200
- signing_key:
205
+ rubygems_version: 3.1.2
206
+ signing_key:
201
207
  specification_version: 4
202
208
  summary: The main purpose of this plugin is to upload an IPA or an APK file to an
203
209
  AirWatch or Workspace ONE enterprise instance/console.