MCPcopy Index your code
hub / github.com/coder/coder / CreateOrganizationRole

Method CreateOrganizationRole

codersdk/roles.go:90–111  ·  view source on GitHub ↗

CreateOrganizationRole will create a custom organization role

(ctx context.Context, role Role)

Source from the content-addressed store, hash-verified

88
89// CreateOrganizationRole will create a custom organization role
90func (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
114func (c *Client) UpdateOrganizationRole(ctx context.Context, role Role) (Role, error) {

Callers 11

TestEnterpriseUserLoginFunction · 0.80
TestCreateUserWorkspaceFunction · 0.80
TestTemplatesFunction · 0.80
TestAssignCustomOrgRolesFunction · 0.80
TestTemplateCreateFunction · 0.80

Calls 3

RequestMethod · 0.95
ReadBodyAsErrorFunction · 0.85
CloseMethod · 0.65

Tested by 10

TestEnterpriseUserLoginFunction · 0.64
TestCreateUserWorkspaceFunction · 0.64
TestTemplatesFunction · 0.64
TestAssignCustomOrgRolesFunction · 0.64
TestTemplateCreateFunction · 0.64