confyio 0.1.0 → 1.0.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ea9e4413332fb7ad883b464c1a25cab29716df58
4
- data.tar.gz: 391ffa974eba2de3d5245a46885918f0e06f6c41
3
+ metadata.gz: fa2dccd72c8a354d13cb76db736a3295a1fb0a33
4
+ data.tar.gz: 90319998a80cfd9fb81438dbcd83c899bc977231
5
5
  SHA512:
6
- metadata.gz: d187682791f3ebf9bb4456ae708865c28e0b97352c4da5aac25eac12ff8c4abc664712c8e1629b96e11f37d0bce7ce6e70d8f83ee1f8f12bd5807011e066fe8b
7
- data.tar.gz: 54ff76bd53bfa3801383fedb436107e0e3d0463d0945d7a41109f435df3e2dc85aa3d0c2d065eba0a0dfe7511b0e6ddba8ddd2ecc5023f771cb39a47391f7974
6
+ metadata.gz: e3470b9e5e4a876ec5e3be055ac4e3be1c0bea8a0da0eabb9857886d7604b1b61e8c219d38770db9493f28f9499d8b55a6888c828e3c881e245423f716e3d441
7
+ data.tar.gz: 59ec58a9370f41bdb24f65b2e8fe86503b5dd84dcebe0026ec0f1347c954ba4ff5a81f78d175da0c283e6784c5ec06ffaee1c9494e7d254a8eec1982b4e6c9a0
@@ -0,0 +1,45 @@
1
+ module Confy
2
+
3
+ module Api
4
+
5
+ # List of teams who has access to the project. Default team __Owners__ will have access to every project. Authenticated user should be the owner of the organization for the below endpoints.
6
+ #
7
+ # org - Name of the organization
8
+ # project - Name of the project
9
+ class Access
10
+
11
+ def initialize(org, project, client)
12
+ @org = org
13
+ @project = project
14
+ @client = client
15
+ end
16
+
17
+ # Give the team access to the given project. The __team__ in the request needs to be a string.
18
+ #
19
+ # '/orgs/:org/projects/:project/access' POST
20
+ #
21
+ # team - Name of the team
22
+ def add(team, options = {})
23
+ body = options.fetch(:body, {})
24
+ body[:team] = team
25
+
26
+ @client.post("/orgs/#{@org}/projects/#{@project}/access", body, options)
27
+ end
28
+
29
+ # Remove project access for the given team. The __team__ in the request needs to be a string. Can't delete default team's access.
30
+ #
31
+ # '/orgs/:org/projects/:project/access' DELETE
32
+ #
33
+ # team - Name of the team
34
+ def remove(team, options = {})
35
+ body = options.fetch(:body, {})
36
+ body[:team] = team
37
+
38
+ @client.delete("/orgs/#{@org}/projects/#{@project}/access", body, options)
39
+ end
40
+
41
+ end
42
+
43
+ end
44
+
45
+ end
@@ -0,0 +1,41 @@
1
+ module Confy
2
+
3
+ module Api
4
+
5
+ # Any member of the team which has access to the project can retrieve any of it's environment's configuration document or edit it.
6
+ #
7
+ # org - Name of the organization
8
+ # project - Name of the project
9
+ # env - Name of the environment
10
+ class Config
11
+
12
+ def initialize(org, project, env, client)
13
+ @org = org
14
+ @project = project
15
+ @env = env
16
+ @client = client
17
+ end
18
+
19
+ # Get an environment config of the project.
20
+ #
21
+ # '/orgs/:org/projects/:project/envs/:env/config' GET
22
+ def retrieve(options = {})
23
+ body = options.fetch(:query, {})
24
+
25
+ @client.get("/orgs/#{@org}/projects/#{@project}/envs/#{@env}/config", body, options)
26
+ end
27
+
28
+ # Update the configuration document for the given environment of the project. We will patch the document recursively.
29
+ #
30
+ # '/orgs/:org/projects/:project/envs/:env/config' POST
31
+ #
32
+ # body - Configuration to update
33
+ def update(body, options = {})
34
+ @client.post("/orgs/#{@org}/projects/#{@project}/envs/#{@env}/config", body, options)
35
+ end
36
+
37
+ end
38
+
39
+ end
40
+
41
+ end
@@ -0,0 +1,79 @@
1
+ module Confy
2
+
3
+ module Api
4
+
5
+ # Every project has a default environment named Production. Each environment has one configuration document which can have many keys and values.
6
+ #
7
+ # org - Name of the organization
8
+ # project - Name of the project
9
+ class Envs
10
+
11
+ def initialize(org, project, client)
12
+ @org = org
13
+ @project = project
14
+ @client = client
15
+ end
16
+
17
+ # List all the environmens of the project which can be seen by the authenticated user.
18
+ #
19
+ # '/orgs/:org/projects/:project/envs' GET
20
+ def list(options = {})
21
+ body = options.fetch(:query, {})
22
+
23
+ @client.get("/orgs/#{@org}/projects/#{@project}/envs", body, options)
24
+ end
25
+
26
+ # Create an environment for the given project. Authenticated user should have access to the project.
27
+ #
28
+ # '/orgs/:org/projects/:project/envs' POST
29
+ #
30
+ # name - Name of the environment
31
+ # description - Description of the environment
32
+ def create(name, description, options = {})
33
+ body = options.fetch(:body, {})
34
+ body[:name] = name
35
+ body[:description] = description
36
+
37
+ @client.post("/orgs/#{@org}/projects/#{@project}/envs", body, options)
38
+ end
39
+
40
+ # Get an environment of the project the user has access to.
41
+ #
42
+ # '/orgs/:org/projects/:project/envs/:env' GET
43
+ #
44
+ # env - Name of the environment
45
+ def retrieve(env, options = {})
46
+ body = options.fetch(:query, {})
47
+
48
+ @client.get("/orgs/#{@org}/projects/#{@project}/envs/#{env}", body, options)
49
+ end
50
+
51
+ # Update an environment. Authenticated user should have access to the project.
52
+ #
53
+ # '/orgs/:org/projects/:project/envs/:env' PATCH
54
+ #
55
+ # env - Name of the environment
56
+ # description - Description of the environment
57
+ def update(env, description, options = {})
58
+ body = options.fetch(:body, {})
59
+ body[:description] = description
60
+
61
+ @client.patch("/orgs/#{@org}/projects/#{@project}/envs/#{env}", body, options)
62
+ end
63
+
64
+ # Delete the given environment of the project. Authenticated user should have access to the project. Cannot delete the default environment.
65
+ #
66
+ # '/orgs/:org/projects/:project/envs/:env' DELETE
67
+ #
68
+ # env - Name of the environment
69
+ def destroy(env, options = {})
70
+ body = options.fetch(:body, {})
71
+
72
+ @client.delete("/orgs/#{@org}/projects/#{@project}/envs/#{env}", body, options)
73
+ end
74
+
75
+ end
76
+
77
+ end
78
+
79
+ end
@@ -0,0 +1,45 @@
1
+ module Confy
2
+
3
+ module Api
4
+
5
+ # Teams contain a list of users. The Authenticated user should be the owner of the organization.
6
+ #
7
+ # org - Name of the organization
8
+ # team - Name of the team
9
+ class Members
10
+
11
+ def initialize(org, team, client)
12
+ @org = org
13
+ @team = team
14
+ @client = client
15
+ end
16
+
17
+ # Add the user to the given team. The __user__ in the request needs to be a string.
18
+ #
19
+ # '/orgs/:org/teams/:team/member' POST
20
+ #
21
+ # user - Username of the user
22
+ def add(user, options = {})
23
+ body = options.fetch(:body, {})
24
+ body[:user] = user
25
+
26
+ @client.post("/orgs/#{@org}/teams/#{@team}/member", body, options)
27
+ end
28
+
29
+ # Remove users from the given team. The __user__ in the request needs to be a string. Cannot delete the default member in a team.
30
+ #
31
+ # '/orgs/:org/teams/:team/member' DELETE
32
+ #
33
+ # user - Username of the user
34
+ def remove(user, options = {})
35
+ body = options.fetch(:body, {})
36
+ body[:user] = user
37
+
38
+ @client.delete("/orgs/#{@org}/teams/#{@team}/member", body, options)
39
+ end
40
+
41
+ end
42
+
43
+ end
44
+
45
+ end
@@ -18,6 +18,20 @@ module Confy
18
18
  @client.get("/orgs", body, options)
19
19
  end
20
20
 
21
+ # Create an organization with a name and the email for billing.
22
+ #
23
+ # '/orgs' POST
24
+ #
25
+ # name - Name of the organization
26
+ # email - Billing email of the organization
27
+ def create(name, email, options = {})
28
+ body = options.fetch(:body, {})
29
+ body[:name] = name
30
+ body[:email] = email
31
+
32
+ @client.post("/orgs", body, options)
33
+ end
34
+
21
35
  # Get an organization the user has access to.
22
36
  #
23
37
  # '/orgs/:org' GET
@@ -0,0 +1,77 @@
1
+ module Confy
2
+
3
+ module Api
4
+
5
+ # An organization can contain any number of projects.
6
+ #
7
+ # org - Name of the organization
8
+ class Projects
9
+
10
+ def initialize(org, client)
11
+ @org = org
12
+ @client = client
13
+ end
14
+
15
+ # List all the projects of the organization which can be seen by the authenticated user.
16
+ #
17
+ # '/orgs/:org/projects' GET
18
+ def list(options = {})
19
+ body = options.fetch(:query, {})
20
+
21
+ @client.get("/orgs/#{@org}/projects", body, options)
22
+ end
23
+
24
+ # Create a project for the given organization. Authenticated user should be the owner of the organization.
25
+ #
26
+ # '/orgs/:org/projects' POST
27
+ #
28
+ # name - Name of the project
29
+ # description - Description of the project
30
+ def create(name, description, options = {})
31
+ body = options.fetch(:body, {})
32
+ body[:name] = name
33
+ body[:description] = description
34
+
35
+ @client.post("/orgs/#{@org}/projects", body, options)
36
+ end
37
+
38
+ # Get a project the user has access to.
39
+ #
40
+ # '/orgs/:org/projects/:project' GET
41
+ #
42
+ # project - Name of the project
43
+ def retrieve(project, options = {})
44
+ body = options.fetch(:query, {})
45
+
46
+ @client.get("/orgs/#{@org}/projects/#{project}", body, options)
47
+ end
48
+
49
+ # Update a project. Authenticated user should be the owner of the organization.
50
+ #
51
+ # '/orgs/:org/projects/:project' PATCH
52
+ #
53
+ # project - Name of the project
54
+ # description - Description of the project
55
+ def update(project, description, options = {})
56
+ body = options.fetch(:body, {})
57
+ body[:description] = description
58
+
59
+ @client.patch("/orgs/#{@org}/projects/#{project}", body, options)
60
+ end
61
+
62
+ # Delete the given project. Cannot delete the default project in the organization. Authenticated user should be the owner of the organization.
63
+ #
64
+ # '/orgs/:org/projects/:project' DELETE
65
+ #
66
+ # project - Name of the project
67
+ def destroy(project, options = {})
68
+ body = options.fetch(:body, {})
69
+
70
+ @client.delete("/orgs/#{@org}/projects/#{project}", body, options)
71
+ end
72
+
73
+ end
74
+
75
+ end
76
+
77
+ end
@@ -0,0 +1,77 @@
1
+ module Confy
2
+
3
+ module Api
4
+
5
+ # Every organization will have a default team named Owners. Owner of the organization will be a default member for every team.
6
+ #
7
+ # org - Name of the organization
8
+ class Teams
9
+
10
+ def initialize(org, client)
11
+ @org = org
12
+ @client = client
13
+ end
14
+
15
+ # List teams of the given organization authenticated user is a member of.
16
+ #
17
+ # '/orgs/:org/teams' GET
18
+ def list(options = {})
19
+ body = options.fetch(:query, {})
20
+
21
+ @client.get("/orgs/#{@org}/teams", body, options)
22
+ end
23
+
24
+ # Create a team for the given organization. Authenticated user should be the owner of the organization.
25
+ #
26
+ # '/orgs/:org/teams' POST
27
+ #
28
+ # name - Name of the team
29
+ # description - Description of the team
30
+ def create(name, description, options = {})
31
+ body = options.fetch(:body, {})
32
+ body[:name] = name
33
+ body[:description] = description
34
+
35
+ @client.post("/orgs/#{@org}/teams", body, options)
36
+ end
37
+
38
+ # Get a team the user is member of.
39
+ #
40
+ # '/orgs/:org/teams/:team' GET
41
+ #
42
+ # team - Name of the team
43
+ def retrieve(team, options = {})
44
+ body = options.fetch(:query, {})
45
+
46
+ @client.get("/orgs/#{@org}/teams/#{team}", body, options)
47
+ end
48
+
49
+ # Update a team. Authenticated user should be the owner of the organization.
50
+ #
51
+ # '/orgs/:org/teams/:team' PATCH
52
+ #
53
+ # team - Name of the team
54
+ # description - Description of the team
55
+ def update(team, description, options = {})
56
+ body = options.fetch(:body, {})
57
+ body[:description] = description
58
+
59
+ @client.patch("/orgs/#{@org}/teams/#{team}", body, options)
60
+ end
61
+
62
+ # Delete the given team. Cannot delete the default team in the organization. Authenticated user should be the owner of the organization.
63
+ #
64
+ # '/orgs/:org/teams/:team' DELETE
65
+ #
66
+ # team - Name of the team
67
+ def destroy(team, options = {})
68
+ body = options.fetch(:body, {})
69
+
70
+ @client.delete("/orgs/#{@org}/teams/#{team}", body, options)
71
+ end
72
+
73
+ end
74
+
75
+ end
76
+
77
+ end
@@ -9,7 +9,7 @@ module Confy
9
9
  @client = client
10
10
  end
11
11
 
12
- # Get the authenticated user's info.
12
+ # Get the authenticated user's profile.
13
13
  #
14
14
  # '/user' GET
15
15
  def retrieve(options = {})
data/lib/confy/client.rb CHANGED
@@ -3,6 +3,12 @@ require "json"
3
3
 
4
4
  require "confy/api/user"
5
5
  require "confy/api/orgs"
6
+ require "confy/api/teams"
7
+ require "confy/api/members"
8
+ require "confy/api/projects"
9
+ require "confy/api/access"
10
+ require "confy/api/envs"
11
+ require "confy/api/config"
6
12
 
7
13
  module Confy
8
14
 
@@ -22,6 +28,53 @@ module Confy
22
28
  Confy::Api::Orgs.new(@http_client)
23
29
  end
24
30
 
31
+ # Every organization will have a default team named Owners. Owner of the organization will be a default member for every team.
32
+ #
33
+ # org - Name of the organization
34
+ def teams(org)
35
+ Confy::Api::Teams.new(org, @http_client)
36
+ end
37
+
38
+ # Teams contain a list of users. The Authenticated user should be the owner of the organization.
39
+ #
40
+ # org - Name of the organization
41
+ # team - Name of the team
42
+ def members(org, team)
43
+ Confy::Api::Members.new(org, team, @http_client)
44
+ end
45
+
46
+ # An organization can contain any number of projects.
47
+ #
48
+ # org - Name of the organization
49
+ def projects(org)
50
+ Confy::Api::Projects.new(org, @http_client)
51
+ end
52
+
53
+ # List of teams who has access to the project. Default team __Owners__ will have access to every project. Authenticated user should be the owner of the organization for the below endpoints.
54
+ #
55
+ # org - Name of the organization
56
+ # project - Name of the project
57
+ def access(org, project)
58
+ Confy::Api::Access.new(org, project, @http_client)
59
+ end
60
+
61
+ # Every project has a default environment named Production. Each environment has one configuration document which can have many keys and values.
62
+ #
63
+ # org - Name of the organization
64
+ # project - Name of the project
65
+ def envs(org, project)
66
+ Confy::Api::Envs.new(org, project, @http_client)
67
+ end
68
+
69
+ # Any member of the team which has access to the project can retrieve any of it's environment's configuration document or edit it.
70
+ #
71
+ # org - Name of the organization
72
+ # project - Name of the project
73
+ # env - Name of the environment
74
+ def config(org, project, env)
75
+ Confy::Api::Config.new(org, project, env, @http_client)
76
+ end
77
+
25
78
  end
26
79
 
27
80
  end
@@ -0,0 +1,26 @@
1
+ module Confy
2
+
3
+ class Config
4
+
5
+ def self.new(url = {})
6
+
7
+ if url.is_a?(String)
8
+ regex = Regexp.new('(https?:\/\/)(.*):(.*)@(.*)\/orgs\/([a-z0-9]*)\/projects\/([a-z0-9]*)\/envs\/([a-z0-9]*)\/config', true)
9
+ matches = regex.match(url)
10
+
11
+ url = {
12
+ :host => matches[1] + matches[4], :user => matches[2], :pass => matches[3],
13
+ :org => matches[5], :project => matches[6], :env => matches[7]
14
+ }
15
+ end
16
+
17
+ client = Confy::Client.new({
18
+ :username => url[:user], :password => url[:pass]
19
+ }, { :base => url[:host] })
20
+
21
+ client.config(url[:org], url[:project], url[:env]).retrieve().body
22
+ end
23
+
24
+ end
25
+
26
+ end
@@ -17,7 +17,7 @@ module Confy
17
17
 
18
18
  @options = {
19
19
  :base => "https://api.confy.io",
20
- :user_agent => "alpaca/0.2.0 (https://github.com/pksunkara/alpaca)"
20
+ :user_agent => "alpaca/0.2.1 (https://github.com/pksunkara/alpaca)"
21
21
  }
22
22
 
23
23
  @options.update(options)
data/lib/confyio.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require "rubygems"
2
2
 
3
3
  require "confy/client"
4
+ require "confy/config"
4
5
  require "confy/error"
5
6
  require "confy/http_client"
6
7
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: confyio
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavan Kumar Sunkara
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-14 00:00:00.000000000 Z
11
+ date: 2014-05-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -49,11 +49,18 @@ files:
49
49
  - lib/confy/http_client/response.rb
50
50
  - lib/confy/http_client/error_handler.rb
51
51
  - lib/confy/http_client/auth_handler.rb
52
+ - lib/confy/api/access.rb
53
+ - lib/confy/api/envs.rb
54
+ - lib/confy/api/teams.rb
55
+ - lib/confy/api/config.rb
56
+ - lib/confy/api/projects.rb
57
+ - lib/confy/api/members.rb
52
58
  - lib/confy/api/orgs.rb
53
59
  - lib/confy/api/user.rb
54
60
  - lib/confy/http_client.rb
55
61
  - lib/confy/client.rb
56
62
  - lib/confy/error/client_error.rb
63
+ - lib/confy/config.rb
57
64
  - lib/confy/error.rb
58
65
  - lib/confyio.rb
59
66
  homepage: https://confy.io