github.com/chnsz/golangsdk@v0.0.0-20240506093406-85a3fbfa605b/openstack/identity/v3.0/eps_permissions/requests.go (about) 1 package eps_permissions 2 3 import ( 4 "github.com/chnsz/golangsdk" 5 ) 6 7 // UserGroupPermissionsCreate assigns enterprise project, user group and role. 8 func UserGroupPermissionsCreate(client *golangsdk.ServiceClient, enterpriseProjectID, groupID, roleID string) (r CommonResult) { 9 _, r.Err = client.Put(userGroupPermissionsURL(client, enterpriseProjectID, groupID, roleID), nil, nil, &golangsdk.RequestOpts{ 10 OkCodes: []int{204}, 11 }) 12 return 13 } 14 15 // UserGroupPermissionsCreate unassigns enterprise project, user group and role. 16 func UserGroupPermissionsDelete(client *golangsdk.ServiceClient, enterpriseProjectID, groupID, roleID string) (r CommonResult) { 17 _, r.Err = client.Delete(userGroupPermissionsURL(client, enterpriseProjectID, groupID, roleID), &golangsdk.RequestOpts{ 18 OkCodes: []int{204}, 19 }) 20 return 21 } 22 23 // UserGroupPermissionsGet gets roles assigned to specified enterprise project and user group. 24 func UserGroupPermissionsGet(client *golangsdk.ServiceClient, enterpriseProjectID, groupID string) (r RoleResult) { 25 _, r.Err = client.Get(userGroupPermissionsGetURL(client, enterpriseProjectID, groupID), &r.Body, nil) 26 return 27 } 28 29 // UserPermissionsCreate assigns enterprise project, user and role. 30 func UserPermissionsCreate(client *golangsdk.ServiceClient, enterpriseProjectID, userID, roleID string) (r CommonResult) { 31 _, r.Err = client.Put(userPermissionsURL(client, enterpriseProjectID, userID, roleID), nil, nil, &golangsdk.RequestOpts{ 32 OkCodes: []int{204}, 33 }) 34 return 35 } 36 37 // UserPermissionsDelete unassigns enterprise project, group and role. 38 func UserPermissionsDelete(client *golangsdk.ServiceClient, enterpriseProjectID, userID, roleID string) (r CommonResult) { 39 _, r.Err = client.Delete(userPermissionsURL(client, enterpriseProjectID, userID, roleID), &golangsdk.RequestOpts{ 40 OkCodes: []int{204}, 41 }) 42 return 43 } 44 45 // UserPermissionsGet gets roles assigned to specified enterprise project and user. 46 func UserPermissionsGet(client *golangsdk.ServiceClient, enterpriseProjectID, userID string) (r RoleResult) { 47 _, r.Err = client.Get(userPermissionsGetURL(client, enterpriseProjectID, userID), &r.Body, nil) 48 return 49 } 50 51 type AgencyPermissionsOpts struct { 52 RoleAssignments []RoleAssignment `json:"role_assignments" required:"true"` 53 } 54 55 type RoleAssignment struct { 56 AgencyID string `json:"agency_id" required:"true"` 57 EnterprisePorjectID string `json:"enterprise_project_id" required:"true"` 58 RoleID string `json:"role_id" required:"true"` 59 } 60 61 // AgencyPermissionsCreate assigns enterprise project, agency and role. 62 func AgencyPermissionsCreate(client *golangsdk.ServiceClient, opts *AgencyPermissionsOpts) (r CommonResult) { 63 b, err := golangsdk.BuildRequestBody(opts, "") 64 if err != nil { 65 r.Err = err 66 return 67 } 68 69 _, r.Err = client.Put(agencyPermissionsURL(client), &b, nil, &golangsdk.RequestOpts{ 70 OkCodes: []int{200}, 71 }) 72 return 73 } 74 75 // AgencyPermissionsDelete unassigns enterprise project, agency and role. 76 func AgencyPermissionsDelete(client *golangsdk.ServiceClient, opts *AgencyPermissionsOpts) (r CommonResult) { 77 b, err := golangsdk.BuildRequestBody(opts, "") 78 if err != nil { 79 r.Err = err 80 return 81 } 82 83 _, r.Err = client.Delete(agencyPermissionsURL(client), &golangsdk.RequestOpts{ 84 JSONBody: b, 85 OkCodes: []int{204}, 86 }) 87 return 88 }