airwatch-ruby 0.1.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +14 -1
- data/airwatch-ruby.gemspec +2 -1
- data/lib/airwatch/client.rb +73 -16
- data/lib/airwatch/ruby/version.rb +1 -1
- metadata +19 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2581091b514c206bed7c8b6bd4df20f0cb48df1b35b0ce9d4cb94a788908134b
|
4
|
+
data.tar.gz: 6b6ce9a27c6770bb3672126b3dba1b3f42cdbb763bd79898baa5cfa07e25aeaa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c70255cea9631d936e5d7b1625c520d87b8bfe76f22f8389405680636d1baf47ec05f7c1e64e196733c3bfbe43f62e72fe54f2164c31e80d5f4c8d372bfdcb0
|
7
|
+
data.tar.gz: dca17a910f60a7c7cfba52938eb96f8a5f1e3f014e1143d7465fa5d410db1b14b3c252a10ca09537684ffeaa50f44cfcb814eb95fdd84ae3afac93b87cbb4013
|
data/README.md
CHANGED
@@ -1,3 +1,16 @@
|
|
1
1
|
# airwatch-ruby
|
2
2
|
|
3
|
-
|
3
|
+
Add the gem to your Gemfile:
|
4
|
+
|
5
|
+
```ruby
|
6
|
+
gem 'airwatch-ruby'
|
7
|
+
```
|
8
|
+
|
9
|
+
Example usage:
|
10
|
+
|
11
|
+
```
|
12
|
+
require 'airwatch'
|
13
|
+
|
14
|
+
client = Airwatch::Client.new('as1111.awmdm.com', 'MY_API_KEY', email: 'admin@example.com', password: 'password')
|
15
|
+
client.apps_search # returns a list of apps
|
16
|
+
```
|
data/airwatch-ruby.gemspec
CHANGED
@@ -40,5 +40,6 @@ Gem::Specification.new do |spec|
|
|
40
40
|
spec.add_development_dependency "rake", "~> 10.0"
|
41
41
|
spec.add_development_dependency "rspec", "~> 3.0"
|
42
42
|
spec.add_runtime_dependency 'httparty', '~> 0.18'
|
43
|
-
spec.add_runtime_dependency 'addressable', '~> 2.
|
43
|
+
spec.add_runtime_dependency 'addressable', '~> 2.8.1'
|
44
|
+
spec.add_runtime_dependency 'rest-client', '~> 2.1.0'
|
44
45
|
end
|
data/lib/airwatch/client.rb
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
require 'addressable'
|
3
|
+
require 'rest-client'
|
4
|
+
|
1
5
|
module Airwatch
|
2
6
|
class Client
|
3
7
|
# @param [String] host make sure you get this from Settings > System > Advanced > Site URLs
|
@@ -35,6 +39,50 @@ module Airwatch
|
|
35
39
|
post("mam/apps/internal/#{app_id}/install", { deviceid: device_id })
|
36
40
|
end
|
37
41
|
|
42
|
+
def upload_blob(file_path, org_group_id)
|
43
|
+
raise "No IPA found at path: #{file_path}" unless File.file?(file_path)
|
44
|
+
filename = File.basename(file_path)
|
45
|
+
url = build_url('mam/blobs/uploadblob', { filename: filename, organizationgroupid: org_group_id.to_s })
|
46
|
+
payload = File.open(file_path, 'rb')
|
47
|
+
headers = request_headers
|
48
|
+
headers[:'Content-Type'] = 'application/octet-stream'
|
49
|
+
headers[:'Expect'] = '100-continue'
|
50
|
+
response = nil
|
51
|
+
begin
|
52
|
+
response = RestClient::Request.execute(
|
53
|
+
:url => url,
|
54
|
+
:method => :post,
|
55
|
+
:headers => headers,
|
56
|
+
:payload => File.open(file_path, 'rb')
|
57
|
+
)
|
58
|
+
rescue RestClient::BadRequest => e
|
59
|
+
puts "Error uploading blob"
|
60
|
+
puts "Exception message: ---------"
|
61
|
+
puts e.message
|
62
|
+
puts "HTTP status code: ---------"
|
63
|
+
puts e.http_code
|
64
|
+
puts "HTTP body: ---------"
|
65
|
+
puts e.http_body
|
66
|
+
return nil
|
67
|
+
end
|
68
|
+
JSON.parse(response)
|
69
|
+
end
|
70
|
+
|
71
|
+
def begin_install(blob_id, app_name, org_group_id)
|
72
|
+
supportedmodels = {'Model' => [{'ModelId' => 1,'ModelName' => 'iPhone'},{'ModelId' => 2,'ModelName' => 'iPad'},{'ModelId' => 3,'ModelName' => 'iPod Touch'}]}
|
73
|
+
params = {
|
74
|
+
'BlobId' => blob_id,
|
75
|
+
'DeviceType' => 'Apple', # 'Apple',
|
76
|
+
'ApplicationName' => app_name,
|
77
|
+
'AppVersion' => nil,
|
78
|
+
'SupportedModels' => supportedmodels,
|
79
|
+
'PushMode' => 'On Demand',
|
80
|
+
'LocationGroupId' => org_group_id
|
81
|
+
}
|
82
|
+
url = build_url('mam/apps/internal/begininstall')
|
83
|
+
post('mam/apps/internal/begininstall', params.to_json)
|
84
|
+
end
|
85
|
+
|
38
86
|
#############################
|
39
87
|
# Profiles #
|
40
88
|
#############################
|
@@ -90,6 +138,20 @@ module Airwatch
|
|
90
138
|
get("mdm/smartgroups/#{smart_group_id}")
|
91
139
|
end
|
92
140
|
|
141
|
+
def smart_group_update(smart_group_id, device_addition_ids:)
|
142
|
+
raise 'need to assign to at least 1 device' if device_addition_ids.empty?
|
143
|
+
device_additions = device_addition_ids.map { |id| { id: id } }
|
144
|
+
put("mdm/smartgroups/#{smart_group_id}", { criteriatype: 'UserDevice', deviceadditions: device_additions }.to_json)
|
145
|
+
end
|
146
|
+
|
147
|
+
def add_smart_group_assignment_to_app(smart_group_id, app_id)
|
148
|
+
post("mam/apps/internal/#{app_id}/smartgroups/#{smart_group_id}")
|
149
|
+
end
|
150
|
+
|
151
|
+
def remove_smart_group_asignment_from_app(smart_group_id, app_id)
|
152
|
+
delete("mam/apps/internal/#{app_id}/smartgroups/#{smart_group_id}")
|
153
|
+
end
|
154
|
+
|
93
155
|
#############################
|
94
156
|
# Devices #
|
95
157
|
#############################
|
@@ -114,6 +176,16 @@ module Airwatch
|
|
114
176
|
get('mdm/devices/profiles', params)
|
115
177
|
end
|
116
178
|
|
179
|
+
def search_devices(serial_number: nil)
|
180
|
+
params = {}
|
181
|
+
|
182
|
+
unless serial_number.nil?
|
183
|
+
params[:serialnumber] = serial_number
|
184
|
+
end
|
185
|
+
|
186
|
+
get('mdm/devices', params)
|
187
|
+
end
|
188
|
+
|
117
189
|
#############################
|
118
190
|
# HTTP request stuff #
|
119
191
|
#############################
|
@@ -143,27 +215,12 @@ module Airwatch
|
|
143
215
|
puts JSON.pretty_generate(response.parsed_response)
|
144
216
|
end
|
145
217
|
|
146
|
-
def upload_blob(file_path, org_group_id)
|
147
|
-
raise "No IPA found at path: #{file_path}" unless File.file?(file_path)
|
148
|
-
filename = File.basename(file_path)
|
149
|
-
url = build_url('mam/blobs/uploadblob', { filename: filename, organizationgroupid: org_group_id })
|
150
|
-
payload = File.open(file_path, 'rb')
|
151
|
-
headers = request_headers
|
152
|
-
headers[:'Content-Type'] = 'application/octet-stream'
|
153
|
-
headers[:'Expect'] = '100-continue'
|
154
|
-
response = RestClient::Request.execute(
|
155
|
-
:url => url,
|
156
|
-
:method => :post,
|
157
|
-
:headers => headers,
|
158
|
-
:payload => File.open(file_path, 'rb')
|
159
|
-
)
|
160
|
-
end
|
161
|
-
|
162
218
|
# private
|
163
219
|
def request_headers
|
164
220
|
{
|
165
221
|
'aw-tenant-code': @api_key,
|
166
222
|
'Accept': 'application/json',
|
223
|
+
'Content-Type': 'application/json',
|
167
224
|
'Authorization': @authorization
|
168
225
|
}
|
169
226
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: airwatch-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dave Schukin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-10-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -72,14 +72,28 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 2.
|
75
|
+
version: 2.8.1
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 2.
|
82
|
+
version: 2.8.1
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rest-client
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 2.1.0
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 2.1.0
|
83
97
|
description: Ruby wrapper around AirWatch REST API.
|
84
98
|
email:
|
85
99
|
- daveschukin@gmail.com
|
@@ -122,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
122
136
|
- !ruby/object:Gem::Version
|
123
137
|
version: '0'
|
124
138
|
requirements: []
|
125
|
-
rubygems_version: 3.0.
|
139
|
+
rubygems_version: 3.0.3.1
|
126
140
|
signing_key:
|
127
141
|
specification_version: 4
|
128
142
|
summary: Ruby wrapper around AirWatch REST API
|