-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: base implementation of infiscial-project-group resource
- Loading branch information
1 parent
a15c47d
commit 0a5d037
Showing
5 changed files
with
667 additions
and
24 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
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
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,83 @@ | ||
package infisicalclient | ||
|
||
import "fmt" | ||
|
||
func (client Client) CreateProjectGroup(request CreateProjectGroupRequest) (CreateProjectGroupResponse, error) { | ||
var responseData CreateProjectGroupResponse | ||
response, err := client.Config.HttpClient. | ||
R(). | ||
SetResult(&responseData). | ||
SetHeader("User-Agent", USER_AGENT). | ||
SetBody(request). | ||
Post(fmt.Sprintf("api/v2/workspace/%s/groups/%s", request.ProjectSlug, request.GroupSlug)) | ||
|
||
if err != nil { | ||
return CreateProjectGroupResponse{}, fmt.Errorf("CallCreateProjectGroup: Unable to complete api request [err=%s]", err) | ||
} | ||
|
||
if response.IsError() { | ||
return CreateProjectGroupResponse{}, fmt.Errorf("CallCreateProjectGroup: Unsuccessful response. [response=%s]", response) | ||
} | ||
|
||
return responseData, nil | ||
} | ||
|
||
func (client Client) GetProjectGroupMembership(request GetProjectGroupMembershipRequest) (GetProjectGroupMembershipResponse, error) { | ||
var responseData GetProjectGroupMembershipResponse | ||
response, err := client.Config.HttpClient. | ||
R(). | ||
SetResult(&responseData). | ||
SetHeader("User-Agent", USER_AGENT). | ||
SetBody(request). | ||
Get(fmt.Sprintf("api/v2/workspace/%s/groups/%s", request.ProjectSlug, request.GroupSlug)) | ||
|
||
if err != nil { | ||
return GetProjectGroupMembershipResponse{}, fmt.Errorf("GetProjectGroupMembershipResponse: Unable to complete api request [err=%s]", err) | ||
} | ||
|
||
if response.IsError() { | ||
return GetProjectGroupMembershipResponse{}, fmt.Errorf("GetProjectGroupMembershipResponse: Unsuccessful response. [response=%s]", response) | ||
} | ||
|
||
return responseData, nil | ||
} | ||
|
||
func (client Client) UpdateProjectGroup(request UpdateProjectGroupRequest) (UpdateProjectGroupResponse, error) { | ||
var responseData UpdateProjectGroupResponse | ||
response, err := client.Config.HttpClient. | ||
R(). | ||
SetResult(&responseData). | ||
SetHeader("User-Agent", USER_AGENT). | ||
SetBody(request). | ||
Patch(fmt.Sprintf("api/v2/workspace/%s/groups/%s", request.ProjectSlug, request.GroupSlug)) | ||
|
||
if err != nil { | ||
return UpdateProjectGroupResponse{}, fmt.Errorf("CallUpdateProjectGroup: Unable to complete api request [err=%s]", err) | ||
} | ||
|
||
if response.IsError() { | ||
return UpdateProjectGroupResponse{}, fmt.Errorf("CallUpdateProjectGroup: Unsuccessful response. [response=%s]", response) | ||
} | ||
|
||
return responseData, nil | ||
} | ||
|
||
func (client Client) DeleteProjectGroup(request DeleteProjectGroupRequest) (DeleteProjectGroupResponse, error) { | ||
var responseData DeleteProjectGroupResponse | ||
response, err := client.Config.HttpClient. | ||
R(). | ||
SetResult(&responseData). | ||
SetHeader("User-Agent", USER_AGENT). | ||
SetBody(request). | ||
Delete(fmt.Sprintf("/api/v2/workspace/%s/groups/%s", request.ProjectSlug, request.GroupSlug)) | ||
|
||
if err != nil { | ||
return DeleteProjectGroupResponse{}, fmt.Errorf("CallDeleteProjectGroup: Unable to complete api request [err=%s]", err) | ||
} | ||
|
||
if response.IsError() { | ||
return DeleteProjectGroupResponse{}, fmt.Errorf("CallDeleteProjectGroup: Unsuccessful response. [response=%s]", response) | ||
} | ||
|
||
return responseData, nil | ||
} |
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
Oops, something went wrong.