fastlane-plugin-simplemdm 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/README.md +50 -0
- data/lib/fastlane/plugin/simplemdm.rb +16 -0
- data/lib/fastlane/plugin/simplemdm/actions/upload_to_simplemdm_action.rb +77 -0
- data/lib/fastlane/plugin/simplemdm/helper/simplemdm_helper.rb +16 -0
- data/lib/fastlane/plugin/simplemdm/version.rb +5 -0
- data/lib/simplemdm.rb +9 -0
- data/lib/simplemdm/account.rb +18 -0
- data/lib/simplemdm/app.rb +83 -0
- data/lib/simplemdm/app_group.rb +166 -0
- data/lib/simplemdm/base.rb +73 -0
- data/lib/simplemdm/device.rb +71 -0
- data/lib/simplemdm/device_group.rb +30 -0
- data/lib/simplemdm/installed_app.rb +19 -0
- data/lib/simplemdm/simplemdm.rb +25 -0
- data/lib/simplemdm/version.rb +3 -0
- metadata +226 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: da8a762c34d7b2afe89cf06c56a16fc8664a84c89af454cf81fc4d92515f6cd4
|
4
|
+
data.tar.gz: 356adbf70d229a5d228ca33a819472fd7162e27d9e0c45923352239dbf16b4a5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a3f50fa6555c4830988bd4c357f0fa63aa370395c6030dd768b6a69d71f07e77a1aa877f72aa522eb4b345377af773177154ec5ce6ea4d1596b46c5423abdb75
|
7
|
+
data.tar.gz: 2e8b694f401b7ed2f58bc758359e9b17d1733babd16d6bc67a36ffa0c5c70613f16ac64801e9cd1ac93c882c3fc04dba3089177b848212d763803ff1540b7caf
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2021 Shannon Hicks <shan@iotashan.com>
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# simplemdm plugin
|
2
|
+
|
3
|
+
[![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-simplemdm)
|
4
|
+
|
5
|
+
## Getting Started
|
6
|
+
|
7
|
+
This project is a [_fastlane_](https://github.com/fastlane/fastlane) plugin. To get started with `fastlane-plugin-simplemdm`, add it to your project by running:
|
8
|
+
|
9
|
+
```bash
|
10
|
+
fastlane add_plugin simplemdm
|
11
|
+
```
|
12
|
+
|
13
|
+
## About simplemdm
|
14
|
+
|
15
|
+
Fastlane plugin for uploading iOS builds to SimpleMDM
|
16
|
+
|
17
|
+
Based on a [gist by Kevin Harwood](https://gist.github.com/kcharwood/dd9b3882f0aa43bc03cfcfaf145e992d)
|
18
|
+
|
19
|
+
## Example
|
20
|
+
|
21
|
+
Check out the [example `Fastfile`](fastlane/Fastfile) to see how to use this plugin. Try it by cloning the repo, running `fastlane install_plugins` and `bundle exec fastlane test`.
|
22
|
+
|
23
|
+
## Run tests for this plugin
|
24
|
+
|
25
|
+
To run both the tests, and code style validation, run
|
26
|
+
|
27
|
+
```
|
28
|
+
rake
|
29
|
+
```
|
30
|
+
|
31
|
+
To automatically fix many of the styling issues, use
|
32
|
+
```
|
33
|
+
rubocop -a
|
34
|
+
```
|
35
|
+
|
36
|
+
## Issues and Feedback
|
37
|
+
|
38
|
+
For any other issues and feedback about this plugin, please submit it to this repository.
|
39
|
+
|
40
|
+
## Troubleshooting
|
41
|
+
|
42
|
+
If you have trouble using plugins, check out the [Plugins Troubleshooting](https://docs.fastlane.tools/plugins/plugins-troubleshooting/) guide.
|
43
|
+
|
44
|
+
## Using _fastlane_ Plugins
|
45
|
+
|
46
|
+
For more information about how the `fastlane` plugin system works, check out the [Plugins documentation](https://docs.fastlane.tools/plugins/create-plugin/).
|
47
|
+
|
48
|
+
## About _fastlane_
|
49
|
+
|
50
|
+
_fastlane_ is the easiest way to automate beta deployments and releases for your iOS and Android apps. To learn more, check out [fastlane.tools](https://fastlane.tools).
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'fastlane/plugin/simplemdm/version'
|
2
|
+
|
3
|
+
module Fastlane
|
4
|
+
module Simplemdm
|
5
|
+
# Return all .rb files inside the "actions" and "helper" directory
|
6
|
+
def self.all_classes
|
7
|
+
Dir[File.expand_path('**/{actions,helper}/*.rb', File.dirname(__FILE__))]
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
# By default we want to import all available actions and helpers
|
13
|
+
# A plugin can contain any number of actions and plugins
|
14
|
+
Fastlane::Simplemdm.all_classes.each do |current|
|
15
|
+
require current
|
16
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'fastlane/action'
|
2
|
+
require_relative '../helper/simplemdm_helper'
|
3
|
+
require_relative "../../../../simplemdm"
|
4
|
+
|
5
|
+
module Fastlane
|
6
|
+
module Actions
|
7
|
+
module SharedValues
|
8
|
+
end
|
9
|
+
|
10
|
+
class UploadToSimplemdmAction < Action
|
11
|
+
def self.run(params)
|
12
|
+
SimpleMDM.api_key = (params[:api_key]).to_s
|
13
|
+
|
14
|
+
data = File.open((params[:ipa_path]).to_s)
|
15
|
+
|
16
|
+
app = SimpleMDM::App.find(params[:app_id])
|
17
|
+
|
18
|
+
app.binary = data
|
19
|
+
app.name = params[:name] if params[:name]
|
20
|
+
|
21
|
+
UI.message("Uploading #{app.name} `#{params[:ipa_path]}` to SimpleMDM for app ID #{params[:app_id]} deploying to #{params[:deploy_to]}")
|
22
|
+
|
23
|
+
app.save(params[:deploy_to])
|
24
|
+
|
25
|
+
UI.message("Uploaded #{app.name} (#{app.bundle_identifier} #{app.version})")
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.description
|
29
|
+
"Upload IPA to Simple MDM"
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.authors
|
33
|
+
["iotashan"]
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.details
|
37
|
+
# Optional:
|
38
|
+
"When using SimpleMDM for iOS app distribution, this provides an automate way to send updates directly to SimpleMDM"
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.available_options
|
42
|
+
[
|
43
|
+
FastlaneCore::ConfigItem.new(key: :api_key,
|
44
|
+
env_name: "SIMPLEMDM_API_KEY", # The name of the environment variable
|
45
|
+
description: "API Token for SimpleMDM"), # a short description of this parameter
|
46
|
+
FastlaneCore::ConfigItem.new(key: :app_id,
|
47
|
+
env_name: "SIMPLEMDM_APP_ID",
|
48
|
+
description: "The SimpleMDM App ID that will be uploaded",
|
49
|
+
is_string: false),
|
50
|
+
FastlaneCore::ConfigItem.new(key: :ipa_path,
|
51
|
+
env_name: "SIMPLEMDM_IPA_PATH",
|
52
|
+
description: "The the path to the IPA",
|
53
|
+
default_value: Actions.lane_context[SharedValues::IPA_OUTPUT_PATH],
|
54
|
+
verify_block: proc do |value|
|
55
|
+
UI.user_error!("Couldn't find ipa file at path '#{value}'") unless File.exist?(value)
|
56
|
+
end),
|
57
|
+
FastlaneCore::ConfigItem.new(key: :name,
|
58
|
+
env_name: "SIMPLEMDM_APP_NAME", # The name of the environment variable
|
59
|
+
optional: true,
|
60
|
+
description: "The name that SimpleMDM will use to reference this app. If left blank, SimpleMDM will automatically set this to the app name specified by the binary"), # a short description of this parameter
|
61
|
+
FastlaneCore::ConfigItem.new(key: :deploy_to,
|
62
|
+
env_name: "SIMPLEMDM_DEPLOY_TO", # The name of the environment variable
|
63
|
+
description: "Deploy the app to associated devices immediately after the app has been uploaded and processed. Possible values are none, outdated or all", # a short description of this parameter
|
64
|
+
default_value: "none",
|
65
|
+
verify_block: proc do |value|
|
66
|
+
accepted_formats = ["none", "outdated", "all"]
|
67
|
+
UI.user_error!("Only \"none\" \"outdated\" or \"all\" values are allowed, you provided \"#{value}\"") unless accepted_formats.include? value
|
68
|
+
end)
|
69
|
+
]
|
70
|
+
end
|
71
|
+
|
72
|
+
def self.is_supported?(platform)
|
73
|
+
platform == :ios
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'fastlane_core/ui/ui'
|
2
|
+
|
3
|
+
module Fastlane
|
4
|
+
UI = FastlaneCore::UI unless Fastlane.const_defined?("UI")
|
5
|
+
|
6
|
+
module Helper
|
7
|
+
class SimplemdmHelper
|
8
|
+
# class methods that you define here become available in your action
|
9
|
+
# as `Helper::SimplemdmHelper.your_method`
|
10
|
+
#
|
11
|
+
def self.show_message
|
12
|
+
UI.message("Hello from the simplemdm plugin helper!")
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/simplemdm.rb
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
require 'simplemdm/version'
|
2
|
+
require 'simplemdm/simplemdm'
|
3
|
+
require 'simplemdm/base'
|
4
|
+
require 'simplemdm/account'
|
5
|
+
require 'simplemdm/app'
|
6
|
+
require 'simplemdm/app_group'
|
7
|
+
require 'simplemdm/device'
|
8
|
+
require 'simplemdm/device_group'
|
9
|
+
require 'simplemdm/installed_app'
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'singleton'
|
2
|
+
|
3
|
+
module SimpleMDM
|
4
|
+
class Account < Hash
|
5
|
+
include Singleton
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
hash, code = SimpleMDM::Base.fetch("account")
|
9
|
+
|
10
|
+
self['name'] = hash['data']['attributes']['name']
|
11
|
+
end
|
12
|
+
|
13
|
+
def name
|
14
|
+
self['name']
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
module SimpleMDM
|
2
|
+
class App < Base
|
3
|
+
|
4
|
+
# overwrite base class
|
5
|
+
def initialize(source_hash = nil, default = nil, &blk)
|
6
|
+
if source_hash && source_hash.kind_of?(Hash) && binary = source_hash[:binary]
|
7
|
+
self.binary = binary
|
8
|
+
source_hash.delete(:binary)
|
9
|
+
end
|
10
|
+
|
11
|
+
super(source_hash, detault, &blk)
|
12
|
+
end
|
13
|
+
|
14
|
+
def build(hash = nil)
|
15
|
+
@dirty = false
|
16
|
+
@binary_file = nil
|
17
|
+
|
18
|
+
super
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.all
|
22
|
+
hash, code = fetch("apps")
|
23
|
+
|
24
|
+
hash['data'].collect { |d| build d }
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.find(id)
|
28
|
+
hash, code = fetch("apps/#{id}")
|
29
|
+
|
30
|
+
build hash['data']
|
31
|
+
end
|
32
|
+
|
33
|
+
def binary=(val)
|
34
|
+
raise "binary must be a File object" unless val.kind_of? File
|
35
|
+
|
36
|
+
@dirty = true
|
37
|
+
@binary_file = val
|
38
|
+
end
|
39
|
+
|
40
|
+
def name=(val)
|
41
|
+
if val != self.name
|
42
|
+
@dirty = true
|
43
|
+
end
|
44
|
+
|
45
|
+
self['name'] = val
|
46
|
+
end
|
47
|
+
|
48
|
+
def save(deploy_to)
|
49
|
+
raise "binary must be set before saving" if new? && @binary_file.nil?
|
50
|
+
|
51
|
+
if @dirty || new?
|
52
|
+
params = {}
|
53
|
+
params[:name] = self.name unless self.name.nil?
|
54
|
+
params[:binary] = @binary_file if @binary_file
|
55
|
+
params[:deploy_to] = deploy_to
|
56
|
+
|
57
|
+
if new?
|
58
|
+
hash, code = fetch("apps", :post, params)
|
59
|
+
|
60
|
+
self.id = hash['data']['id']
|
61
|
+
self.merge!(hash['data']['attributes'])
|
62
|
+
else
|
63
|
+
hash, code = fetch("apps/#{self.id}", :patch, params)
|
64
|
+
self.merge!(hash['data']['attributes'])
|
65
|
+
end
|
66
|
+
|
67
|
+
@dirty = false
|
68
|
+
@binary_file = nil
|
69
|
+
end
|
70
|
+
|
71
|
+
self
|
72
|
+
end
|
73
|
+
|
74
|
+
def destroy
|
75
|
+
raise "You cannot delete an app that hasn't been created yet." if new?
|
76
|
+
|
77
|
+
hash, code = fetch("apps/#{self.id}", :delete)
|
78
|
+
|
79
|
+
code == 204
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,166 @@
|
|
1
|
+
module SimpleMDM
|
2
|
+
class AppGroup < Base
|
3
|
+
|
4
|
+
def build(hash = nil)
|
5
|
+
@dirty = false
|
6
|
+
|
7
|
+
super
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.all
|
11
|
+
hash, code = fetch("app_groups")
|
12
|
+
|
13
|
+
hash['data'].collect { |d| build d }
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.find(id)
|
17
|
+
hash, code = fetch("app_groups/#{id}")
|
18
|
+
|
19
|
+
build hash['data']
|
20
|
+
end
|
21
|
+
|
22
|
+
def save
|
23
|
+
if @dirty || new?
|
24
|
+
params = {}
|
25
|
+
params[:name] = self.name unless self.name.nil?
|
26
|
+
params[:auto_deploy] = self.auto_deploy unless self.auto_deploy.nil?
|
27
|
+
|
28
|
+
if new?
|
29
|
+
hash, code = fetch("app_groups", :post, params)
|
30
|
+
|
31
|
+
self.id = hash['data']['id']
|
32
|
+
self.merge!(hash['data']['attributes'])
|
33
|
+
else
|
34
|
+
fetch("app_groups/#{self.id}", :patch, params)
|
35
|
+
end
|
36
|
+
|
37
|
+
@dirty = false
|
38
|
+
end
|
39
|
+
|
40
|
+
self
|
41
|
+
end
|
42
|
+
|
43
|
+
def name=(val)
|
44
|
+
if val != self.name
|
45
|
+
@dirty = true
|
46
|
+
end
|
47
|
+
|
48
|
+
self['name'] = val
|
49
|
+
end
|
50
|
+
|
51
|
+
def auto_deploy=(val)
|
52
|
+
if val != self.auto_deploy
|
53
|
+
@dirty = true
|
54
|
+
end
|
55
|
+
|
56
|
+
self['auto_deploy'] = val
|
57
|
+
end
|
58
|
+
|
59
|
+
def destroy
|
60
|
+
raise "You cannot delete an app group that hasn't been created yet" if new?
|
61
|
+
|
62
|
+
hash, code = fetch("app_groups/#{self.id}", :delete)
|
63
|
+
|
64
|
+
code == 204
|
65
|
+
end
|
66
|
+
|
67
|
+
def add_app(app)
|
68
|
+
raise "You must save this app group before changing associations" if new?
|
69
|
+
raise "The object you provided is not an app" unless app.kind_of?(SimpleMDM::App)
|
70
|
+
raise "You must save the app before associating it" if app.id.nil?
|
71
|
+
|
72
|
+
hash, code = fetch("app_groups/#{self.id}/apps/#{app.id}", :post)
|
73
|
+
|
74
|
+
if code == 204
|
75
|
+
self['app_ids'] = self['app_ids'] | [app.id]
|
76
|
+
true
|
77
|
+
else
|
78
|
+
false
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def remove_app(app)
|
83
|
+
raise "You must save this app group before changing associations." if new?
|
84
|
+
raise "The object you provided is not an app" unless app.kind_of?(SimpleMDM::App)
|
85
|
+
raise "The app you provided doesn't exist" if app.id.nil?
|
86
|
+
|
87
|
+
hash, code = fetch("app_groups/#{self.id}/apps/#{app.id}", :delete)
|
88
|
+
|
89
|
+
if code == 204
|
90
|
+
self['app_ids'].delete(app.id)
|
91
|
+
true
|
92
|
+
else
|
93
|
+
false
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def add_device_group(device_group)
|
98
|
+
raise "You must save this app group before changing associations." if new?
|
99
|
+
raise "The object you provided is not a device group" unless device_group.kind_of?(SimpleMDM::DeviceGroup)
|
100
|
+
raise "You must save the device_group before associating it" if device_group.id.nil?
|
101
|
+
|
102
|
+
hash, code = fetch("app_groups/#{self.id}/device_groups/#{device_group.id}", :post)
|
103
|
+
|
104
|
+
if code == 204
|
105
|
+
self['device_group_ids'] = self['device_group_ids'] | [device_group.id]
|
106
|
+
true
|
107
|
+
else
|
108
|
+
false
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
def remove_device_group(device_group)
|
113
|
+
raise "You must save this app group before changing associations" if new?
|
114
|
+
raise "The object you provided is not a device group" unless device_group.kind_of?(SimpleMDM::DeviceGroup)
|
115
|
+
raise "The device group you provided doesn't exist" if device_group.id.nil?
|
116
|
+
|
117
|
+
hash, code = fetch("app_groups/#{self.id}/device_groups/#{device_group.id}", :delete)
|
118
|
+
|
119
|
+
if code == 204
|
120
|
+
self['device_group_ids'].delete(device_group.id)
|
121
|
+
true
|
122
|
+
else
|
123
|
+
false
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
def add_device(device)
|
128
|
+
raise "You must save this app group before changing associations." if new?
|
129
|
+
raise "The object you provided is not a device" unless device.kind_of?(SimpleMDM::Device)
|
130
|
+
raise "You must save the device before associating it" if device.id.nil?
|
131
|
+
|
132
|
+
hash, code = fetch("app_groups/#{self.id}/devices/#{device.id}", :post)
|
133
|
+
|
134
|
+
if code == 204
|
135
|
+
self['device_ids'] = self['device_ids'] | [device.id]
|
136
|
+
true
|
137
|
+
else
|
138
|
+
false
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
def remove_device(device)
|
143
|
+
raise "You must save this app group before changing associations" if new?
|
144
|
+
raise "The object you provided is not a device" unless device.kind_of?(SimpleMDM::Device)
|
145
|
+
raise "The device you provided doesn't exist" if device.id.nil?
|
146
|
+
|
147
|
+
hash, code = fetch("app_groups/#{self.id}/devices/#{device.id}", :delete)
|
148
|
+
|
149
|
+
if code == 204
|
150
|
+
self['device_ids'].delete(device.id)
|
151
|
+
true
|
152
|
+
else
|
153
|
+
false
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
def push_apps
|
158
|
+
raise "You cannot push apps for an app group that hasn't been created yet" if new?
|
159
|
+
|
160
|
+
hash, code = fetch("app_groups/#{self.id}/push_apps", :post)
|
161
|
+
|
162
|
+
code == 202
|
163
|
+
end
|
164
|
+
|
165
|
+
end
|
166
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'rest-client'
|
2
|
+
require 'json'
|
3
|
+
require 'hashie'
|
4
|
+
|
5
|
+
module SimpleMDM
|
6
|
+
class Base < Hashie::Mash
|
7
|
+
|
8
|
+
def self.build(hash = nil)
|
9
|
+
if hash
|
10
|
+
attrs = {}
|
11
|
+
|
12
|
+
if hash['id']
|
13
|
+
attrs[:id] = hash['id']
|
14
|
+
end
|
15
|
+
|
16
|
+
if hash['attributes']
|
17
|
+
attrs.merge!(hash['attributes'])
|
18
|
+
end
|
19
|
+
|
20
|
+
if hash['relationships']
|
21
|
+
if hash['relationships']['device_group']
|
22
|
+
attrs['device_group_id'] = hash['relationships']['device_group']['data']['id']
|
23
|
+
end
|
24
|
+
|
25
|
+
if hash['relationships']['device_groups']
|
26
|
+
attrs['device_group_ids'] = hash['relationships']['device_groups']['data'].collect { |o| o['id'] }
|
27
|
+
end
|
28
|
+
|
29
|
+
if hash['relationships']['devices']
|
30
|
+
attrs['device_ids'] = hash['relationships']['devices']['data'].collect { |o| o['id'] }
|
31
|
+
end
|
32
|
+
|
33
|
+
if hash['relationships']['apps']
|
34
|
+
attrs['app_ids'] = hash['relationships']['apps']['data'].collect { |o| o['id'] }
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
new attrs
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def new?
|
45
|
+
self.id.nil?
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.fetch(method, verb = :get, params = {})
|
49
|
+
headers = { 'SIMPLEMDM-CLIENT-VERSION' => SimpleMDM::VERSION }
|
50
|
+
url = SimpleMDM.api_url + method
|
51
|
+
if [:get, :delete].include? verb
|
52
|
+
resp = RestClient.send(verb, url, headers)
|
53
|
+
else
|
54
|
+
resp = RestClient.send(verb, url, params, headers)
|
55
|
+
end
|
56
|
+
|
57
|
+
begin
|
58
|
+
hash = JSON.parse(resp)
|
59
|
+
rescue JSON::ParserError
|
60
|
+
hash = nil
|
61
|
+
end
|
62
|
+
|
63
|
+
code = resp.code
|
64
|
+
|
65
|
+
return hash, code
|
66
|
+
end
|
67
|
+
|
68
|
+
def fetch(method, verb = :get, params = {})
|
69
|
+
self.class.fetch(method, verb, params)
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
module SimpleMDM
|
2
|
+
class Device < Base
|
3
|
+
|
4
|
+
def self.all
|
5
|
+
hash, code = fetch("devices")
|
6
|
+
|
7
|
+
hash['data'].collect { |d| build d }
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.find(id)
|
11
|
+
hash, code = fetch("devices/#{id}")
|
12
|
+
|
13
|
+
build hash['data']
|
14
|
+
end
|
15
|
+
|
16
|
+
def save
|
17
|
+
unless new?
|
18
|
+
raise "You can only save new device objects"
|
19
|
+
end
|
20
|
+
|
21
|
+
params = {}
|
22
|
+
params[:name] = self.name unless self.name.nil?
|
23
|
+
params[:group_id] = self.group_id unless self.group_id.nil?
|
24
|
+
|
25
|
+
hash, code = fetch("devices", :post, params)
|
26
|
+
|
27
|
+
self.id = hash['data']['id']
|
28
|
+
self.merge!(hash['data']['attributes'])
|
29
|
+
|
30
|
+
@dirty = false
|
31
|
+
|
32
|
+
self
|
33
|
+
end
|
34
|
+
|
35
|
+
def installed_apps
|
36
|
+
raise "You cannot retrieve installed apps for a device that hasn't been created yet." if new?
|
37
|
+
|
38
|
+
hash, code = fetch("devices/#{id}/installed_apps")
|
39
|
+
|
40
|
+
hash['data'].collect { |a| InstalledApp.build a }
|
41
|
+
end
|
42
|
+
|
43
|
+
def lock(options = {})
|
44
|
+
params = options.delete_if { |k,v| ![:message, :phone_number, :pin].include?(k) }
|
45
|
+
|
46
|
+
hash, code = fetch("devices/#{id}/lock", :post, params)
|
47
|
+
|
48
|
+
code == 202
|
49
|
+
end
|
50
|
+
|
51
|
+
def clear_passcode
|
52
|
+
hash, code = fetch("devices/#{id}/clear_passcode", :post)
|
53
|
+
|
54
|
+
code == 202
|
55
|
+
end
|
56
|
+
|
57
|
+
def wipe
|
58
|
+
hash, code = fetch("devices/#{id}/wipe", :post)
|
59
|
+
|
60
|
+
code == 202
|
61
|
+
end
|
62
|
+
|
63
|
+
def push_apps
|
64
|
+
hash, code = fetch("devices/#{id}/push_apps", :post)
|
65
|
+
|
66
|
+
code == 202
|
67
|
+
end
|
68
|
+
|
69
|
+
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module SimpleMDM
|
2
|
+
class DeviceGroup < Base
|
3
|
+
|
4
|
+
def self.all
|
5
|
+
hash, code = fetch("device_groups")
|
6
|
+
|
7
|
+
hash['data'].collect { |d| build d }
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.find(id)
|
11
|
+
hash, code = fetch("device_groups/#{id}")
|
12
|
+
|
13
|
+
build hash['data']
|
14
|
+
end
|
15
|
+
|
16
|
+
def add_device(device)
|
17
|
+
raise "The object you provided is not a device" unless device.kind_of?(SimpleMDM::Device)
|
18
|
+
|
19
|
+
hash, code = fetch("device_groups/#{self.id}/devices/#{device.id}", :post)
|
20
|
+
|
21
|
+
if code == 204
|
22
|
+
self['device_ids'] = self['device_ids'] | [device.id]
|
23
|
+
true
|
24
|
+
else
|
25
|
+
false
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module SimpleMDM
|
2
|
+
class InstalledApp < Base
|
3
|
+
|
4
|
+
def self.find(id)
|
5
|
+
hash, code = fetch("installed_apps/#{id}")
|
6
|
+
|
7
|
+
build hash['data']
|
8
|
+
end
|
9
|
+
|
10
|
+
def uninstall
|
11
|
+
raise "You cannot uninstall an unmanaged app" if !self.managed
|
12
|
+
|
13
|
+
hash, code = fetch("installed_apps/#{id}", :delete)
|
14
|
+
|
15
|
+
code == 202
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module SimpleMDM
|
2
|
+
|
3
|
+
@BASE_URL = 'a.simplemdm.com/api/v1/'
|
4
|
+
|
5
|
+
def self.api_key=(value)
|
6
|
+
@API_KEY = value
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.api_key
|
10
|
+
@API_KEY
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.base_url=(value)
|
14
|
+
@BASE_URL = value
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.base_url
|
18
|
+
@BASE_URL
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.api_url
|
22
|
+
"https://#{@API_KEY}:@#{@BASE_URL}"
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,226 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fastlane-plugin-simplemdm
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Shannon Hicks
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-08-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rest-client
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: hashie
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 3.4.4
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 3.4.4
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: fastlane
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 2.188.0
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 2.188.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: pry
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rake
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rspec
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rspec_junit_formatter
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rubocop
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - '='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 1.12.1
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - '='
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 1.12.1
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: rubocop-performance
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: rubocop-require_tools
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: simplecov
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
181
|
+
description:
|
182
|
+
email: shan@iotashan.com
|
183
|
+
executables: []
|
184
|
+
extensions: []
|
185
|
+
extra_rdoc_files: []
|
186
|
+
files:
|
187
|
+
- LICENSE
|
188
|
+
- README.md
|
189
|
+
- lib/fastlane/plugin/simplemdm.rb
|
190
|
+
- lib/fastlane/plugin/simplemdm/actions/upload_to_simplemdm_action.rb
|
191
|
+
- lib/fastlane/plugin/simplemdm/helper/simplemdm_helper.rb
|
192
|
+
- lib/fastlane/plugin/simplemdm/version.rb
|
193
|
+
- lib/simplemdm.rb
|
194
|
+
- lib/simplemdm/account.rb
|
195
|
+
- lib/simplemdm/app.rb
|
196
|
+
- lib/simplemdm/app_group.rb
|
197
|
+
- lib/simplemdm/base.rb
|
198
|
+
- lib/simplemdm/device.rb
|
199
|
+
- lib/simplemdm/device_group.rb
|
200
|
+
- lib/simplemdm/installed_app.rb
|
201
|
+
- lib/simplemdm/simplemdm.rb
|
202
|
+
- lib/simplemdm/version.rb
|
203
|
+
homepage: https://github.com/latitude-digital/fastlane-plugin-simplemdm
|
204
|
+
licenses:
|
205
|
+
- MIT
|
206
|
+
metadata: {}
|
207
|
+
post_install_message:
|
208
|
+
rdoc_options: []
|
209
|
+
require_paths:
|
210
|
+
- lib
|
211
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
212
|
+
requirements:
|
213
|
+
- - ">="
|
214
|
+
- !ruby/object:Gem::Version
|
215
|
+
version: '2.5'
|
216
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
217
|
+
requirements:
|
218
|
+
- - ">="
|
219
|
+
- !ruby/object:Gem::Version
|
220
|
+
version: '0'
|
221
|
+
requirements: []
|
222
|
+
rubygems_version: 3.0.1
|
223
|
+
signing_key:
|
224
|
+
specification_version: 4
|
225
|
+
summary: Fastlane plugin for uploading iOS builds to SimpleMDM
|
226
|
+
test_files: []
|