Class: Applocate::API
Class Method Summary collapse
-
.active_commands(udid) ⇒ Object
expected params, udid = “ABCD-DCCDDC-12394812389-CDC”.
-
.app_list(options = {}) ⇒ Object
expected options { udid: “ABCD-DCCDDC-12394812389-CDC” }.
-
.apply_named_restrictions(udid, name, options = {}) ⇒ Object
expected params: udid = “ABCD-DCCDDC-12394812389-CDC”, name = “me.example.restrictions” options { … Apple MDM Restrictions Profile … }.
- .authentication ⇒ Object
-
.cancel_commmand(udid, commmand_uuid) ⇒ Object
expected params, udid = “ABCD-DCCDDC-12394812389-CDC”, commmand_uuid = “xxxx-xxx-xxxx-xxxxxxxxxxx”.
-
.delete_device(options) ⇒ Object
expected options { device_id: 12345 } OR { udid: “ABCD-DCCDDC-12394812389-CDC” }.
-
.get_devices(udid_or_identifier) ⇒ Object
expected options udid_or_identifier = 12345 OR udid_or_identifier = “ABCD-DCCDDC-12394812389-CDC” NOTE: this may return more than one device.
-
.install_app(options = {}) ⇒ Object
expected options { udid: “ABCD-DCCDDC-12394812389-CDC”, itunes_id: “284910350” }.
-
.install_vpn(options = {}) ⇒ Object
expected options { udid: “ABCD-DCCDDC-12394812389-CDC”, vpn_username: “123456”, vpn_password: “p@ssw0rd” }.
- .list_devices ⇒ Object
-
.mdm_app_list(options = {}) ⇒ Object
expected options { udid: “ABCD-DCCDDC-12394812389-CDC” }.
-
.profile_list(udid) ⇒ Object
expected params, udid = “ABCD-DCCDDC-12394812389-CDC”.
-
.recent_checkins(udid) ⇒ Object
expected params, udid = “ABCD-DCCDDC-12394812389-CDC”.
-
.recent_commands(udid) ⇒ Object
expected params, udid = “ABCD-DCCDDC-12394812389-CDC”.
-
.register_device(options = {}) ⇒ Object
expected options { name: “Steve J’s iPad Air”, identifier: “XXX-123456 APPLE INC.”, configuration: “default” }.
-
.remove_named_restrictions(udid, name) ⇒ Object
expected params, udid = “ABCD-DCCDDC-12394812389-CDC”, name = “me.example.restrictions”.
-
.remove_vpn(options = {}) ⇒ Object
expected options { udid: “ABCD-DCCDDC-12394812389-CDC” }.
-
.restrict(options = {}) ⇒ Object
expected options { udid: “ABCD-DCCDDC-12394812389-CDC” }.
-
.restrictions(udid) ⇒ Object
expected params, udid = “ABCD-DCCDDC-12394812389-CDC”.
- .secret ⇒ Object
- .token ⇒ Object
-
.unrestrict(options = {}) ⇒ Object
expected options { udid: “ABCD-DCCDDC-12394812389-CDC” }.
Class Method Details
.active_commands(udid) ⇒ Object
expected params, udid = “ABCD-DCCDDC-12394812389-CDC”
24 25 26 27 |
# File 'lib/applocate/api.rb', line 24 def self.active_commands(udid) response = self.get("/api/devices/#{udid}/active_commands", { headers: authentication }) JSON.parse response.body rescue [] end |
.app_list(options = {}) ⇒ Object
expected options { udid: “ABCD-DCCDDC-12394812389-CDC” }
92 93 94 95 |
# File 'lib/applocate/api.rb', line 92 def self.app_list( = {}) response = self.post('/deploy/app_list', { body: .to_json, headers: authentication }) JSON.parse response.body rescue [] end |
.apply_named_restrictions(udid, name, options = {}) ⇒ Object
expected params: udid = “ABCD-DCCDDC-12394812389-CDC”, name = “me.example.restrictions” options { … Apple MDM Restrictions Profile … }
48 49 50 51 52 |
# File 'lib/applocate/api.rb', line 48 def self.apply_named_restrictions(udid, name, = {}) = .merge({ profile_name: name }) response = self.post("/api/devices/#{udid}/profiles", { body: .to_json, headers: authentication }) JSON.parse response.body rescue {} end |
.authentication ⇒ Object
128 129 130 |
# File 'lib/applocate/api.rb', line 128 def self.authentication { "X-Applocate-Secret" => secret, "X-Applocate-Token" => token, 'Content-Type' => "application/json" } end |
.cancel_commmand(udid, commmand_uuid) ⇒ Object
expected params, udid = “ABCD-DCCDDC-12394812389-CDC”, commmand_uuid = “xxxx-xxx-xxxx-xxxxxxxxxxx”
30 31 32 33 |
# File 'lib/applocate/api.rb', line 30 def self.cancel_commmand(udid, commmand_uuid) response = self.get("/api/devices/#{udid}/commands/#{commmand_uuid}", { headers: authentication }) JSON.parse response.body rescue {} end |
.delete_device(options) ⇒ Object
expected options { device_id: 12345 }
OR { udid: "ABCD-DCCDDC-12394812389-CDC" }
123 124 125 126 |
# File 'lib/applocate/api.rb', line 123 def self.delete_device() response = self.delete("/api/devices", { body: .to_json, headers: authentication }) response.code == 200 end |
.get_devices(udid_or_identifier) ⇒ Object
expected options udid_or_identifier = 12345 OR udid_or_identifier = “ABCD-DCCDDC-12394812389-CDC” NOTE: this may return more than one device.
116 117 118 119 |
# File 'lib/applocate/api.rb', line 116 def self.get_devices(udid_or_identifier) response = self.get("/api/devices/#{udid_or_identifier}", { headers: authentication }) JSON.parse response.body rescue [] end |
.install_app(options = {}) ⇒ Object
expected options { udid: “ABCD-DCCDDC-12394812389-CDC”, itunes_id: “284910350” }
86 87 88 89 |
# File 'lib/applocate/api.rb', line 86 def self.install_app( = {}) response = self.post('/deploy/app', { body: .to_json, headers: authentication }) JSON.parse response.body rescue [] end |
.install_vpn(options = {}) ⇒ Object
expected options { udid: “ABCD-DCCDDC-12394812389-CDC”, vpn_username: “123456”, vpn_password: “p@ssw0rd” }
74 75 76 77 |
# File 'lib/applocate/api.rb', line 74 def self.install_vpn( = {}) response = self.post('/deploy/vpn', { body: .to_json, headers: authentication }) JSON.parse response.body rescue [] end |
.list_devices ⇒ Object
109 110 111 112 |
# File 'lib/applocate/api.rb', line 109 def self.list_devices response = self.get('/api/devices', { headers: authentication }) JSON.parse response.body rescue [] end |
.mdm_app_list(options = {}) ⇒ Object
expected options { udid: “ABCD-DCCDDC-12394812389-CDC” }
98 99 100 101 |
# File 'lib/applocate/api.rb', line 98 def self.mdm_app_list( = {}) response = self.post('/deploy/mdm_app_list', { body: .to_json, headers: authentication }) JSON.parse response.body rescue [] end |
.profile_list(udid) ⇒ Object
expected params, udid = “ABCD-DCCDDC-12394812389-CDC”
42 43 44 45 |
# File 'lib/applocate/api.rb', line 42 def self.profile_list(udid) response = self.get("/api/devices/#{udid}/profiles", { headers: authentication }) JSON.parse response.body rescue [] end |
.recent_checkins(udid) ⇒ Object
expected params, udid = “ABCD-DCCDDC-12394812389-CDC”
12 13 14 15 |
# File 'lib/applocate/api.rb', line 12 def self.recent_checkins(udid) response = self.get("/api/devices/#{udid}/recent_checkins", { headers: authentication }) JSON.parse response.body rescue [] end |
.recent_commands(udid) ⇒ Object
expected params, udid = “ABCD-DCCDDC-12394812389-CDC”
18 19 20 21 |
# File 'lib/applocate/api.rb', line 18 def self.recent_commands(udid) response = self.get("/api/devices/#{udid}/recent_commands", { headers: authentication }) JSON.parse response.body rescue [] end |
.register_device(options = {}) ⇒ Object
expected options { name: “Steve J’s iPad Air”, identifier: “XXX-123456 APPLE INC.”, configuration: “default” }
104 105 106 107 |
# File 'lib/applocate/api.rb', line 104 def self.register_device( = {}) response = self.post('/api/devices', { body: .to_json, headers: authentication }) JSON.parse response.body rescue [] end |
.remove_named_restrictions(udid, name) ⇒ Object
expected params, udid = “ABCD-DCCDDC-12394812389-CDC”, name = “me.example.restrictions”
55 56 57 58 59 |
# File 'lib/applocate/api.rb', line 55 def self.remove_named_restrictions(udid, name) query = { profile_name: name } response = self.delete("/api/devices/#{udid}/profiles", { query: query, headers: authentication }) JSON.parse response.body rescue {} end |
.remove_vpn(options = {}) ⇒ Object
expected options { udid: “ABCD-DCCDDC-12394812389-CDC” }
80 81 82 83 |
# File 'lib/applocate/api.rb', line 80 def self.remove_vpn( = {}) response = self.delete('/deploy/vpn', { body: .to_json, headers: authentication }) JSON.parse response.body rescue [] end |
.restrict(options = {}) ⇒ Object
expected options { udid: “ABCD-DCCDDC-12394812389-CDC” }
62 63 64 65 |
# File 'lib/applocate/api.rb', line 62 def self.restrict( = {}) response = self.post('/deploy/profile', { body: .to_json, headers: authentication }) JSON.parse response.body rescue [] end |
.restrictions(udid) ⇒ Object
expected params, udid = “ABCD-DCCDDC-12394812389-CDC”
36 37 38 39 |
# File 'lib/applocate/api.rb', line 36 def self.restrictions(udid) response = self.get("/api/devices/#{udid}/restrictions", { headers: authentication }) JSON.parse response.body rescue [] end |
.secret ⇒ Object
136 137 138 |
# File 'lib/applocate/api.rb', line 136 def self.secret Applocate.configuration.secret end |
.token ⇒ Object
132 133 134 |
# File 'lib/applocate/api.rb', line 132 def self.token Applocate.configuration.token end |
.unrestrict(options = {}) ⇒ Object
expected options { udid: “ABCD-DCCDDC-12394812389-CDC” }
68 69 70 71 |
# File 'lib/applocate/api.rb', line 68 def self.unrestrict( = {}) response = self.delete('/deploy/profile', { body: .to_json, headers: authentication }) JSON.parse response.body rescue [] end |