mms-ruby 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +7 -0
  2. data/lib/mms-ruby.rb +24 -0
  3. data/lib/mms-ruby/group.rb +33 -0
  4. metadata +45 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4ad7a2abaf518a9e6b0a92f2ec0df5bf3512140d
4
+ data.tar.gz: e767988da10915f76d4ba5aa569d5e426528e4c0
5
+ SHA512:
6
+ metadata.gz: 485788f387328a2586ddacead91fc236552e925fb648006a66fe65db59b7dbab7c07478a59684d4bd666d434919af443579f4554296304888f3606ff9113fef7
7
+ data.tar.gz: 440e01cca441706f8b981484bd8259ddd254b4069a5b07cfd0963eecab89ae0e9c65dbe7dbbf8a7b49895205a7d2c40954babe782de669d0c6733e8e8e25cfd8
@@ -0,0 +1,24 @@
1
+ require 'httparty'
2
+ require 'mms-ruby/group'
3
+
4
+ module MongoMS
5
+ class MMS
6
+ include HTTParty
7
+ include MongoMS::Group
8
+ base_uri 'https://mms-qa.mongodb.com/api/public/v1.0'
9
+
10
+ def initialize(u, p)
11
+ @auth = {username: u, password: p}
12
+ @options = { digest_auth: @auth,
13
+ headers: { 'Content-Type' => 'application/json' } }
14
+ end
15
+
16
+ def root()
17
+ self.class.get('', @options)
18
+ end
19
+
20
+ def throttling?()
21
+ root()['throttling']
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,33 @@
1
+ module MongoMS
2
+ module Group
3
+ def group(o={})
4
+ if o.empty?
5
+ self.class.get("/groups", @options)['results']
6
+ elsif o.has_key? "id"
7
+ self.class.get("/groups/#{o['id']}", @options)
8
+ elsif o.has_key? "name"
9
+ _get_group_by_name o['name']
10
+ end
11
+ end
12
+
13
+ def create_group (name)
14
+ options = @options.clone
15
+ options[:body] = {name: name}.to_json
16
+ self.class.post("/groups", options)
17
+ end
18
+
19
+ def delete_group (id)
20
+ self.class.delete("/groups/#{id}", @options)
21
+ end
22
+
23
+ def _get_group_by_name(name)
24
+ groups = group
25
+ groups.each do |grp|
26
+ if grp['name'] == name
27
+ return grp
28
+ end
29
+ end
30
+ nil
31
+ end
32
+ end
33
+ end
metadata ADDED
@@ -0,0 +1,45 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mms-ruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Jonathan Balsano
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-07-10 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Takes advantage of the MongoDB Management System REST API to give access
14
+ to your MMS services from Ruby
15
+ email: jonathan.balsano@10gen.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - lib/mms-ruby.rb
21
+ - lib/mms-ruby/group.rb
22
+ homepage: http://github.com/jrbalsano/mms-ruby
23
+ licenses: []
24
+ metadata: {}
25
+ post_install_message:
26
+ rdoc_options: []
27
+ require_paths:
28
+ - lib
29
+ required_ruby_version: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ required_rubygems_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ requirements: []
40
+ rubyforge_project:
41
+ rubygems_version: 2.3.0
42
+ signing_key:
43
+ specification_version: 4
44
+ summary: A Ruby library for developing with the MongoDB Management System
45
+ test_files: []