Class: Fastlane::Actions::UnretireSpecificVersionAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/airwatch_workspaceone/actions/unretire_specific_version_action.rb

Class Method Summary collapse

Class Method Details

.authorsObject



70
71
72
# File 'lib/fastlane/plugin/airwatch_workspaceone/actions/unretire_specific_version_action.rb', line 70

def self.authors
  ["Ram Awadhesh Sharan"]
end

.available_optionsObject



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# File 'lib/fastlane/plugin/airwatch_workspaceone/actions/unretire_specific_version_action.rb', line 83

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :host_url,
                            env_name: "AIRWATCH_HOST_API_URL",
                         description: "Host API URL of the AirWatch/Workspace ONE instance without /API/ at the end",
                            optional: false,
                                type: String,
                        verify_block: proc do |value|
                                        UI.user_error!("No AirWatch/Workspace ONE Host API URl given, pass using `host_url: 'https://yourhost.com'`") unless value and !value.empty?
                                      end),

    FastlaneCore::ConfigItem.new(key: :aw_tenant_code,
                            env_name: "AIRWATCH_API_KEY",
                         description: "API key or the tenant code to access AirWatch/Workspace ONE Rest APIs",
                            optional: false,
                                type: String,
                        verify_block: proc do |value|
                                        UI.user_error!("Api tenant code header is missing, pass using `aw_tenant_code: 'yourapikey'`") unless value and !value.empty?
                                      end),

    FastlaneCore::ConfigItem.new(key: :b64_encoded_auth,
                            env_name: "AIRWATCH_BASE64_ENCODED_BASIC_AUTH_STRING",
                         description: "The base64 encoded Basic Auth string generated by authorizing username and password to the AirWatch/Workspace ONE instance",
                            optional: false,
                                type: String,
                        verify_block: proc do |value|
                                        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?
                                      end),

    FastlaneCore::ConfigItem.new(key: :org_group_id,
                            env_name: "AIRWATCH_ORGANIZATION_GROUP_ID",
                         description: "Organization Group ID integer identifying the customer or container",
                            optional: false,
                                type: String,
                        verify_block: proc do |value|
                                        UI.user_error!("No Organization Group ID integer given, pass using `org_group_id: 'yourorggrpintid'`") unless value and !value.empty?
                                      end),

    FastlaneCore::ConfigItem.new(key: :app_identifier,
                            env_name: "APP_IDENTIFIER",
                         description: "Bundle identifier of your app",
                            optional: false,
                                type: String,
                        verify_block: proc do |value|
                                        UI.user_error!("No app identifier given, pass using `app_identifier: 'com.example.app'`") unless value and !value.empty?
                                      end),

    FastlaneCore::ConfigItem.new(key: :version_number,
                            env_name: "AIRWATCH_VERSION_NUMBER",
                         description: "Version number of the application to unretire",
                            optional: false,
                                type: String,
                        verify_block: proc do |value|
                                        UI.user_error!("No version number given, pass using `version_number: '1.0'`") unless value and !value.empty?
                                      end),

    FastlaneCore::ConfigItem.new(key: :debug,
                            env_name: "AIRWATCH_DEBUG",
                         description: "Debug flag, set to true to show extended output. default: false",
                            optional: true,
                           is_string: false,
                       default_value: false)
  ]
end

.debugObject

helpers



158
159
160
# File 'lib/fastlane/plugin/airwatch_workspaceone/actions/unretire_specific_version_action.rb', line 158

def self.debug
  $is_debug
end

.descriptionObject



66
67
68
# File 'lib/fastlane/plugin/airwatch_workspaceone/actions/unretire_specific_version_action.rb', line 66

def self.description
  "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."
end

.detailsObject



78
79
80
81
# File 'lib/fastlane/plugin/airwatch_workspaceone/actions/unretire_specific_version_action.rb', line 78

def self.details
  # Optional:
  "unretire_specific_version - To unretire specific version of an application on the AirWatch/Workspace ONE console."
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


148
149
150
151
152
153
154
# File 'lib/fastlane/plugin/airwatch_workspaceone/actions/unretire_specific_version_action.rb', line 148

def self.is_supported?(platform)
  # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
  # See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform

  [:ios, :android].include?(platform)
  true
end

.return_valueObject



74
75
76
# File 'lib/fastlane/plugin/airwatch_workspaceone/actions/unretire_specific_version_action.rb', line 74

def self.return_value
  # If your method provides a return value, you can describe here what it does
end

.run(params) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/fastlane/plugin/airwatch_workspaceone/actions/unretire_specific_version_action.rb', line 10

def self.run(params)
  UI.message("The airwatch_workspaceone plugin is working!")

  # check if debug is enabled
  $is_debug = params[:debug]

  if debug
    UI.message("-----------------------------------------------")
    UI.message("UnretireSpecificVersionAction debug information")
    UI.message("-----------------------------------------------")
    UI.message(" host_url: #{params[:host_url]}")
    UI.message(" aw_tenant_code: #{params[:aw_tenant_code]}")
    UI.message(" b64_encoded_auth: #{params[:b64_encoded_auth]}")
    UI.message(" organization_group_id: #{params[:org_group_id]}")
    UI.message(" app_identifier: #{params[:app_identifier]}")
    UI.message(" version_number: #{params[:version_number]}")
  end

  $host_url         = params[:host_url]
  $aw_tenant_code   = params[:aw_tenant_code]
  $b64_encoded_auth = params[:b64_encoded_auth]
  $org_group_id     = params[:org_group_id]
  app_identifier    = params[:app_identifier]
  version_number    = params[:version_number]

  # step 1: find app
  UI.message("-------------------------------")
  UI.message("1. Finding retired app versions")
  UI.message("-------------------------------")

  retired_app_versions = Helper::AirwatchWorkspaceoneHelper.find_app_versions(app_identifier, 'Retired', $host_url, $aw_tenant_code, $b64_encoded_auth, $org_group_id, debug)
  if retired_app_versions.count <= 0
    UI.important("No retired app versions found for application with bundle identifier given: %s" % [app_identifier])
    return
  end
  
  retired_version_numbers = retired_app_versions.map {|retired_app_version| retired_app_version.values[1]}
  UI.success("Found %d retired app version(s)" % [retired_app_versions.count])
  UI.success("Version number(s): %s" % [retired_version_numbers])

  # step 2: retire specific version
  UI.message("----------------------------------")
  UI.message("2. UnRetiring specific app version")
  UI.message("----------------------------------")

  if retired_version_numbers.include? version_number
    version_index = retired_version_numbers.index(version_number)
    app_version_to_unretire = retired_app_versions[version_index]
    Helper::AirwatchWorkspaceoneHelper.unretire_app(app_version_to_unretire, $host_url, $aw_tenant_code, $b64_encoded_auth, debug)
  else
    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])
  end

  UI.success("Version %s successfully unretired" % [version_number])
end