This repository has been archived by the owner on Oct 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Adrián López Gómez
committed
Oct 25, 2016
1 parent
ef2ccd8
commit bad9ec1
Showing
2 changed files
with
188 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
package api | ||
|
||
import internalhttp "github.com/Tecsisa/foulkon/http" | ||
|
||
func (c *ClientAPI) GetGroup(organizationId, groupName string) (string, error) { | ||
req, err := c.prepareRequest("GET", internalhttp.API_VERSION_1+"/organizations/"+organizationId+"/groups/"+groupName, nil, nil) | ||
if err != nil { | ||
return "", err | ||
} | ||
return c.makeRequest(req) | ||
} | ||
|
||
func (c *ClientAPI) GetAllGroups(pathPrefix, offset, limit, orderBy string) (string, error) { | ||
urlParams := map[string]string{ | ||
"PathPrefix": pathPrefix, | ||
"Offset": offset, | ||
"Limit": limit, | ||
"OrderBy": orderBy, | ||
} | ||
req, err := c.prepareRequest("GET", internalhttp.API_VERSION_1+"/groups", nil, urlParams) | ||
if err != nil { | ||
return "", err | ||
} | ||
return c.makeRequest(req) | ||
} | ||
|
||
func (c *ClientAPI) GetGroupsByOrg(organizationId, pathPrefix, offset, limit, orderBy string) (string, error) { | ||
urlParams := map[string]string{ | ||
"PathPrefix": pathPrefix, | ||
"Offset": offset, | ||
"Limit": limit, | ||
"OrderBy": orderBy, | ||
} | ||
req, err := c.prepareRequest("GET", internalhttp.API_VERSION_1+"/organizations/"+organizationId+"/groups", nil, urlParams) | ||
if err != nil { | ||
return "", err | ||
} | ||
return c.makeRequest(req) | ||
} | ||
|
||
func (c *ClientAPI) CreateGroup(organizationId, groupName, path string) (string, error) { | ||
body := map[string]string{ | ||
"name": groupName, | ||
"path": path, | ||
} | ||
req, err := c.prepareRequest("POST", internalhttp.API_VERSION_1+"/organizations/"+organizationId+"/groups", body, nil) | ||
if err != nil { | ||
return "", err | ||
} | ||
return c.makeRequest(req) | ||
} | ||
|
||
func (c *ClientAPI) UpdateGroup(organizationId, groupName, newName, newPath string) (string, error) { | ||
body := map[string]string{ | ||
"name": newName, | ||
"path": newPath, | ||
} | ||
req, err := c.prepareRequest("PUT", internalhttp.API_VERSION_1+"/organizations/"+organizationId+"/policies/"+groupName, body, nil) | ||
if err != nil { | ||
return "", err | ||
} | ||
return c.makeRequest(req) | ||
} | ||
|
||
func (c *ClientAPI) DeleteGroup(organizationId, groupName string) (string, error) { | ||
req, err := c.prepareRequest("DELETE", internalhttp.API_VERSION_1+"/organizations/"+organizationId+"/groups/"+groupName, nil, nil) | ||
if err != nil { | ||
return "", err | ||
} | ||
return c.makeRequest(req) | ||
} | ||
|
||
func (c *ClientAPI) GetGroupPolicies(organizationId, groupName, offset, limit, orderBy string) (string, error) { | ||
urlParams := map[string]string{ | ||
"Offset": offset, | ||
"Limit": limit, | ||
"OrderBy": orderBy, | ||
} | ||
req, err := c.prepareRequest("GET", internalhttp.API_VERSION_1+"/organizations/"+organizationId+"/groups/"+groupName+"/groups", nil, urlParams) | ||
if err != nil { | ||
return "", err | ||
} | ||
return c.makeRequest(req) | ||
} | ||
|
||
func (c *ClientAPI) AttachPolicyToGroup(organizationId, groupName, policyName string) (string, error) { | ||
req, err := c.prepareRequest("POST", internalhttp.API_VERSION_1+"/organizations/"+organizationId+"/groups/"+groupName+"/policies/"+policyName, nil, nil) | ||
if err != nil { | ||
return "", err | ||
} | ||
return c.makeRequest(req) | ||
} | ||
|
||
func (c *ClientAPI) DetachPolicyFromGroup(organizationId, groupName, policyName string) (string, error) { | ||
req, err := c.prepareRequest("DELETE", internalhttp.API_VERSION_1+"/organizations/"+organizationId+"/groups/"+groupName+"/policies/"+policyName, nil, nil) | ||
if err != nil { | ||
return "", err | ||
} | ||
return c.makeRequest(req) | ||
} | ||
|
||
func (c *ClientAPI) GetGroupMembers(organizationId, groupName, pathPrefix, offset, limit, orderBy string) (string, error) { | ||
urlParams := map[string]string{ | ||
"PathPrefix": pathPrefix, | ||
"Offset": offset, | ||
"Limit": limit, | ||
"OrderBy": orderBy, | ||
} | ||
req, err := c.prepareRequest("GET", internalhttp.API_VERSION_1+"/organizations/"+organizationId+"/groups/"+groupName+"/users", nil, urlParams) | ||
if err != nil { | ||
return "", err | ||
} | ||
return c.makeRequest(req) | ||
} | ||
|
||
func (c *ClientAPI) AddMemberToGroup(organizationId, groupName, userName string) (string, error) { | ||
req, err := c.prepareRequest("POST", internalhttp.API_VERSION_1+"/organizations/"+organizationId+"/groups/"+groupName+"/users"+userName, nil, nil) | ||
if err != nil { | ||
return "", err | ||
} | ||
return c.makeRequest(req) | ||
} | ||
|
||
func (c *ClientAPI) RemoveMemberToGroup(organizationId, groupName, userName string) (string, error) { | ||
req, err := c.prepareRequest("DELETE", internalhttp.API_VERSION_1+"/organizations/"+organizationId+"/groups/"+groupName+"/users"+userName, nil, nil) | ||
if err != nil { | ||
return "", err | ||
} | ||
return c.makeRequest(req) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters