CreateOrganizationRole will create a custom organization role
(ctx context.Context, role Role)
| 88 | |
| 89 | // CreateOrganizationRole will create a custom organization role |
| 90 | func (c *Client) CreateOrganizationRole(ctx context.Context, role Role) (Role, error) { |
| 91 | req := CustomRoleRequest{ |
| 92 | Name: role.Name, |
| 93 | DisplayName: role.DisplayName, |
| 94 | SitePermissions: role.SitePermissions, |
| 95 | UserPermissions: role.UserPermissions, |
| 96 | OrganizationPermissions: role.OrganizationPermissions, |
| 97 | OrganizationMemberPermissions: role.OrganizationMemberPermissions, |
| 98 | } |
| 99 | |
| 100 | res, err := c.Request(ctx, http.MethodPost, |
| 101 | fmt.Sprintf("/api/v2/organizations/%s/members/roles", role.OrganizationID), req) |
| 102 | if err != nil { |
| 103 | return Role{}, err |
| 104 | } |
| 105 | defer res.Body.Close() |
| 106 | if res.StatusCode != http.StatusOK { |
| 107 | return Role{}, ReadBodyAsError(res) |
| 108 | } |
| 109 | var r Role |
| 110 | return r, json.NewDecoder(res.Body).Decode(&r) |
| 111 | } |
| 112 | |
| 113 | // UpdateOrganizationRole will update an existing custom organization role |
| 114 | func (c *Client) UpdateOrganizationRole(ctx context.Context, role Role) (Role, error) { |