mgmt_console 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: dca067a993c809cca112d79708e1c279d561f0d0
4
+ data.tar.gz: ef3a9c6f8435408c168a388fb30e21d34d4cd5de
5
+ SHA512:
6
+ metadata.gz: 752ebdf19527041a430dc51c0349f9545a4a6141db32476539e396136bdc191edb9a3ac06b96b69d83b6f5b92db8a1336ffb722f7badfd323d73e374d9ec062f
7
+ data.tar.gz: 55e483833999086fbe4c571e8c85f006b30c939823858cdf13157a06368f70dcce2fb354509003986f3876317a1ee2e4e241c6fd342957e347e8e8f822d780bb
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.5
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in mgmt_console.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,46 @@
1
+ # MgmtConsole
2
+
3
+ This is an API client gem for our [mgmt console][1].
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'mgmt_console'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install mgmt_console
20
+
21
+ ## Usage
22
+
23
+ The example below is how to retrieve a list of all communities across all instances.
24
+
25
+ require 'mgmt_console'
26
+ client = MgmtConsole::Client.new(access_token: '7fd3e655e79037d66b7b2cd4094c13b4', api_endpoint: 'https://console.mindjet.com/api/v1', ssl_verify: true)
27
+ engage_communities = client.engage_communities(nil, per_page: 200)
28
+ while client.last_response.rels[:next]
29
+ engage_communities.concat(client.last_response.rels[:next].get.data)
30
+ end
31
+
32
+ ## Development
33
+
34
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
35
+
36
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
37
+
38
+ ## Contributing
39
+
40
+ 1. Fork it ( https://github.com/[my-github-username]/mgmt_console/fork )
41
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
42
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
43
+ 4. Push to the branch (`git push origin my-new-feature`)
44
+ 5. Create a new Pull Request
45
+
46
+ [1]: https://console.mindjet.com/
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "mgmt_console"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,8 @@
1
+ How to query for engage communities
2
+
3
+ require 'mgmt_console'
4
+ client = MgmtConsole::Client.new(access_token: '7fd3e655e79037d66b7b2cd4094c13b4', api_endpoint: 'https://console.dev.com/api/v1', ssl_verify: false)
5
+ engage_communities = client.engage_communities(nil, per_page: 200)
6
+ while client.last_response.rels[:next]
7
+ engage_communities.concat(client.last_response.rels[:next].get.data)
8
+ end
@@ -0,0 +1,4 @@
1
+ module MgmtConsole
2
+ class ApiError < StandardError
3
+ end
4
+ end
@@ -0,0 +1,23 @@
1
+ module MgmtConsole
2
+
3
+ # Authentication methods for {MgmtConsole::Client}
4
+ module Authentication
5
+
6
+ # Indicates if the client was supplied an OAuth
7
+ # access token
8
+ #
9
+ # @see https://developer.github.com/v3/#authentication
10
+ # @return [Boolean]
11
+ def token_authenticated?
12
+ !!@access_token
13
+ end
14
+
15
+ # Indicates if the client was supplied an access token
16
+ #
17
+ # @return [Boolean]
18
+ def user_authenticated?
19
+ token_authenticated?
20
+ end
21
+
22
+ end
23
+ end
@@ -0,0 +1,50 @@
1
+ module MgmtConsole
2
+ class Client
3
+
4
+ # Methods for the Engage Communities API
5
+ module EngageCommunities
6
+
7
+ # Get Engage Communities list
8
+ #
9
+ # @return [Array<Sawyer::Resource>] Array of engage communities
10
+ # @example Get Engage Communities
11
+ # @client.engage_communities
12
+ def engage_communities(options = {})
13
+ engage_instance_id = options.delete(:engage_instance_id)
14
+
15
+ if engage_instance_id.nil?
16
+ paginate("#{api_endpoint}/engage_communities", options)
17
+ else
18
+ paginate("#{api_endpoint}/engage_instances/#{engage_instance_id}/engage_communities", options)
19
+ end
20
+ end
21
+
22
+ # Create Engage Communities
23
+ #
24
+ # @return [Array<Sawyer::Resource>] Array of engage communities
25
+ # @example Get Engage Communities
26
+ # @client.update_engage_communities(engage_instance_id: 'df40ec3e-4ad3-4abf-b7c9-c306721f91ea',
27
+ # engage_communities: [{siteid: 1, servername: 'www1.cust.spigit.com', port: 443},
28
+ # {siteid: 2, servername: 'www2.cust.spigit.com', port: 443}],
29
+ # action: 'replace')
30
+ def create_engage_communities(options = {})
31
+ # Required
32
+ engage_instance_id = options.delete(:engage_instance_id)
33
+ engage_communities = options.delete(:engage_communities)
34
+
35
+ raise MgmtConsole::BadRequest.new('You must provide the Engage Instance ID as :engage_instance_id') unless engage_instance_id
36
+ raise MgmtConsole::BadRequest.new('You must provide the Engage Communities as :engage_communities') unless engage_communities
37
+
38
+ # Optional
39
+ action = options.delete(:action)
40
+
41
+ params = {
42
+ engage_communities: engage_communities,
43
+ action: action,
44
+ }.reject { |k,v| v.nil? }
45
+
46
+ data = post("#{api_endpoint}/engage_instances/#{engage_instance_id}/engage_communities", options.merge(params))
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,46 @@
1
+ module MgmtConsole
2
+ class Client
3
+
4
+ # Methods for the EngageEnvironmentsAPI
5
+ module EngageEnvironments
6
+
7
+ # Get Engage Environments list
8
+ #
9
+ # @return [Array<Sawyer::Resource>] Array of engage environments
10
+ # @example Get engage environments
11
+ # @client.engage_environments
12
+ def engage_environments(options = {})
13
+ data = get("#{api_endpoint}/engage_environments", options)
14
+ end
15
+
16
+ # Create Engage Environment
17
+ #
18
+ # @return [Sawyer::Resource] Engage Environment
19
+ # @example Create engage environment
20
+ # @client.create_engage_environment()
21
+ def create_engage_environment(name=nil, options = {})
22
+ params = { :name => name }
23
+ data = post("#{api_endpoint}/engage_environments", options.merge(params))
24
+ end
25
+
26
+ # Update Engage Environment
27
+ #
28
+ # @param id [String] Engage Environment ID
29
+ # @return [Sawyer::Resource] Engage Environment
30
+ # @example Update engage environment
31
+ # @client.update_engage_environment('47d80252-f65e-41bb-b589-7833a1fdd623', only_allow_one_per_cluster: true)
32
+ def update_engage_environment(id=nil, options = {})
33
+ raise MgmtConsole::BadRequest.new('You must provide the Engage Environment ID as the first paramater') unless id
34
+
35
+ # Optional
36
+ only_allow_one_per_cluster = options.delete(:only_allow_one_per_cluster)
37
+
38
+ params = {
39
+ only_allow_one_per_cluster: only_allow_one_per_cluster,
40
+ }.reject { |k,v| v.nil? }
41
+
42
+ data = patch("#{api_endpoint}/engage_environments/#{id}", options.merge(params))
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,77 @@
1
+ module MgmtConsole
2
+ class Client
3
+
4
+ # Methods for the EngageInstances API
5
+ module EngageInstances
6
+
7
+ # Get Engage Instances list
8
+ #
9
+ # @return [Array<Sawyer::Resource>] Array of engage instances
10
+ # @example Get engage instances
11
+ # @client.engage_instances
12
+ def engage_instances(options = {})
13
+ paginate("#{api_endpoint}/engage_instances", options)
14
+ end
15
+
16
+ # Create Engage Instance
17
+ #
18
+ # @return [Sawyer::Resource] Engage Instance
19
+ # @example Create engage instance
20
+ # @client.create_engage_instance(dbname: 'abc123', engage_server_id: 'b4c2719c-10ac-487c-9af4-59c297e17766', branch: '3-6-0-stable')
21
+ def create_engage_instance(options = {})
22
+ # Required
23
+ dbname = options.delete(:dbname)
24
+ engage_server_id = options.delete(:engage_server_id)
25
+
26
+ raise MgmtConsole::BadRequest.new('You must provide the Engage Instance Database name as :dbname') unless dbname
27
+ raise MgmtConsole::BadRequest.new('You must provide the Engage Server ID as :engage_server_id') unless engage_server_id
28
+
29
+ # Optional
30
+ salesforce_uid = options.delete(:salesforce_uid)
31
+ branch = options.delete(:branch)
32
+ commit = options.delete(:commit)
33
+ engage_environment_id = options.delete(:engage_environment_id)
34
+
35
+ params = {
36
+ dbname: dbname,
37
+ engage_server_id: engage_server_id,
38
+ salesforce_uid: salesforce_uid,
39
+ branch: branch,
40
+ commit: commit,
41
+ engage_environment_id: engage_environment_id,
42
+ }.reject { |k,v| v.nil? }
43
+
44
+ data = post("#{api_endpoint}/engage_instances", options.merge(params))
45
+ end
46
+
47
+ # Update Engage Instance
48
+ #
49
+ # @return [Sawyer::Resource] Engage Instance
50
+ # @example Update engage instance
51
+ # @client.update_engage_instance('bae956a6-17c9-4d65-b786-1c3aae311fb2', branch: '3-5-8-stable', commit: '7a0c870')
52
+ def update_engage_instance(id=nil, options = {})
53
+ # Required
54
+ raise MgmtConsole::BadRequest.new('You must provide the Engage Instance ID as :id') unless id
55
+
56
+ # Optional
57
+ dbname = options.delete(:dbname)
58
+ engage_server_id = options.delete(:engage_server_id)
59
+ salesforce_uid = options.delete(:salesforce_uid)
60
+ branch = options.delete(:branch)
61
+ commit = options.delete(:commit)
62
+ engage_environment_id = options.delete(:engage_environment_id)
63
+
64
+ params = {
65
+ dbname: dbname,
66
+ engage_server_id: engage_server_id,
67
+ salesforce_uid: salesforce_uid,
68
+ branch: branch,
69
+ commit: commit,
70
+ engage_environment_id: engage_environment_id,
71
+ }.reject { |k,v| v.nil? }
72
+
73
+ data = patch("#{api_endpoint}/engage_instances/#{id}", options.merge(params))
74
+ end
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,58 @@
1
+ module MgmtConsole
2
+ class Client
3
+
4
+ # Methods for the EngageServers API
5
+ module EngageServers
6
+
7
+ # Get Engage Servers list
8
+ #
9
+ # @return [Array<Sawyer::Resource>] Array of engage servers
10
+ # @example Get engage servers
11
+ # @client.engage_servers
12
+ def engage_servers(options = {})
13
+ data = get("#{api_endpoint}/engage_servers", options)
14
+ end
15
+
16
+ # Create Engage Server
17
+ #
18
+ # @param hostname [String] Engage Server hostname
19
+ # @return [Sawyer::Resource] Engage Server
20
+ # @example Create engage server
21
+ # @client.create_engage_server('r225.spigit.com')
22
+ def create_engage_server(hostname=nil, options = {})
23
+ raise MgmtConsole::BadRequest.new('You must provide the Engage Server hostname as the first paramater') unless hostname
24
+
25
+ # Optional
26
+ timezone = options.delete(:timezone)
27
+
28
+ params = {
29
+ :hostname => hostname,
30
+ :timezone => timezone
31
+ }.reject { |k,v| v.nil? }
32
+
33
+ data = post("#{api_endpoint}/engage_servers", options.merge(params))
34
+ end
35
+
36
+ # Update Engage Server
37
+ #
38
+ # @param id [String] Engage Server ID
39
+ # @return [Sawyer::Resource] Engage Server
40
+ # @example Update engage server
41
+ # @client.update_engage_server('47d80252-f65e-41bb-b589-7833a1fdd623', server_environment_id: '7ab127a6-1d80-477f-b349-08bfc7e757ac')
42
+ def update_engage_server(id=nil, options = {})
43
+ raise MgmtConsole::BadRequest.new('You must provide the Engage Server ID as the first paramater') unless id
44
+
45
+ # Optional
46
+ server_environment_id = options.delete(:server_environment_id)
47
+ timezone = options.delete(:timezone)
48
+
49
+ params = {
50
+ server_environment_id: server_environment_id,
51
+ timezone: timezone,
52
+ }.reject { |k,v| v.nil? }
53
+
54
+ data = patch("#{api_endpoint}/engage_servers/#{id}", options.merge(params))
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,27 @@
1
+ module MgmtConsole
2
+ class Client
3
+
4
+ # Methods for the ServerEnvironmentsAPI
5
+ module ServerEnvironments
6
+
7
+ # Get Server Environments list
8
+ #
9
+ # @return [Array<Sawyer::Resource>] Array of server environments
10
+ # @example Get server environments
11
+ # @client.server_environments
12
+ def server_environments(options = {})
13
+ data = get("#{api_endpoint}/server_environments", options)
14
+ end
15
+
16
+ # Create Server Environment
17
+ #
18
+ # @return [Sawyer::Resource] Server Environment
19
+ # @example Create server environment
20
+ # @client.create_server_environment()
21
+ def create_server_environment(name=nil, options = {})
22
+ params = { :name => name }
23
+ data = post("#{api_endpoint}/server_environments", options.merge(params))
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,65 @@
1
+ module MgmtConsole
2
+ class Client
3
+
4
+ # Methods for the SpigitConfigs API
5
+ module SpigitConfigs
6
+
7
+ # Get Spigit Configs list
8
+ #
9
+ # @return [Array<Sawyer::Resource>] Array of spigit configs
10
+ # @example Get spigit configs
11
+ # @client.spigit_configs
12
+ def spigit_configs(options = {})
13
+ paginate("#{api_endpoint}/spigit_configs", options)
14
+ end
15
+
16
+ # Create Spigit Config
17
+ #
18
+ # @return [Sawyer::Resource] Spigit Config
19
+ # @example Create spigit config
20
+ # @client.create_spigit_config(engage_instance_id: 'b4c2719c-10ac-487c-9af4-59c297e17766', siteid: '3-6-0-stable', config: {"SERVERNAME" => "r225.spigit.com"})
21
+ def create_spigit_config(options = {})
22
+ # Required
23
+ engage_instance_id = options.delete(:engage_instance_id)
24
+ siteid = options.delete(:siteid)
25
+
26
+ raise MgmtConsole::BadRequest.new('You must provide the Engage Instance ID as :engage_instance_id') unless engage_instance_id
27
+ raise MgmtConsole::BadRequest.new('You must provide the Site ID as :siteid') unless siteid
28
+
29
+ # Optional
30
+ config = options.delete(:config)
31
+
32
+ params = {
33
+ engage_instance_id: engage_instance_id,
34
+ siteid: siteid,
35
+ config: config,
36
+ }.reject { |k,v| v.nil? }
37
+
38
+ data = post("#{api_endpoint}/spigit_configs", options.merge(params))
39
+ end
40
+
41
+ # Update Spigit Config
42
+ #
43
+ # @return [Sawyer::Resource] Spigit Config
44
+ # @example Update spigit config
45
+ # @client.update_spigit_config(235, config: {"SERVERNAME" => "r226.spigit.com"})
46
+ def update_engage_instance(id=nil, options = {})
47
+ # Required
48
+ raise MgmtConsole::BadRequest.new('You must provide the Spigit Config ID as :id') unless id
49
+
50
+ # Optional
51
+ engage_instance_id = options.delete(:engage_instance_id)
52
+ siteid = options.delete(:siteid)
53
+ config = options.delete(:config)
54
+
55
+ params = {
56
+ engage_instance_id: engage_instance_id,
57
+ siteid: siteid,
58
+ config: config,
59
+ }.reject { |k,v| v.nil? }
60
+
61
+ data = patch("#{api_endpoint}/spigit_configs/#{id}", options.merge(params))
62
+ end
63
+ end
64
+ end
65
+ end