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 +4 -4
- data/lib/confy/api/access.rb +45 -0
- data/lib/confy/api/config.rb +41 -0
- data/lib/confy/api/envs.rb +79 -0
- data/lib/confy/api/members.rb +45 -0
- data/lib/confy/api/orgs.rb +14 -0
- data/lib/confy/api/projects.rb +77 -0
- data/lib/confy/api/teams.rb +77 -0
- data/lib/confy/api/user.rb +1 -1
- data/lib/confy/client.rb +53 -0
- data/lib/confy/config.rb +26 -0
- data/lib/confy/http_client.rb +1 -1
- data/lib/confyio.rb +1 -0
- metadata +9 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa2dccd72c8a354d13cb76db736a3295a1fb0a33
|
4
|
+
data.tar.gz: 90319998a80cfd9fb81438dbcd83c899bc977231
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/lib/confy/api/orgs.rb
CHANGED
@@ -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
|
data/lib/confy/api/user.rb
CHANGED
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
|
data/lib/confy/config.rb
ADDED
@@ -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
|
data/lib/confy/http_client.rb
CHANGED
data/lib/confyio.rb
CHANGED
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:
|
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-
|
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
|