diff --git a/client.go b/client.go index 1548713a..4ed3e57a 100644 --- a/client.go +++ b/client.go @@ -4508,6 +4508,7 @@ func (g *GoCloak) GetUsersManagementPermissions(ctx context.Context, accessToken return &result, nil } +// CreateOrganization creates a new Organization func (g *GoCloak) CreateOrganization(ctx context.Context, token, realm string, organization Organization) (string, error) { const errMessage = "could not create organization" @@ -4522,17 +4523,18 @@ func (g *GoCloak) CreateOrganization(ctx context.Context, token, realm string, o return getID(resp), nil } -func (g *GoCloak) GetOrganization(ctx context.Context, token, realm, idOfOrganization string) (*Organization, error) { +// GetOrganization returns a list of the organization +func (g *GoCloak) GetOrganization(ctx context.Context, token, realm string) ([]*Organization, error) { const errMessage = "could not get organization" - var result Organization + var result []*Organization resp, err := g.GetRequestWithBearerAuth(ctx, token). SetResult(&result). - Get(g.getAdminRealmURL(realm, "organizations", idOfOrganization)) + Get(g.getAdminRealmURL(realm, "organizations")) if err := checkForError(resp, err, errMessage); err != nil { return nil, err } - return &result, nil + return result, nil } diff --git a/models.go b/models.go index f16886b9..0ae8dc3d 100644 --- a/models.go +++ b/models.go @@ -1454,17 +1454,22 @@ func prettyStringStruct(t interface{}) string { return string(json) } +type Domain struct { + Name *string `json:"name,omitempty"` + Verified *bool `json:"verified,omitempty"` +} + type Organization struct { - Id *string `json:"id,omitempty"` - Name *string `json:"name,omitempty"` - Alias *string `json:"alias,omitempty"` - Enable *bool `json:"enabled,omitempty"` - Description *string `json:"description,omitempty"` - RedirectUrl *string `json:"redirectUrl,omitempty"` - Attributes *map[string]string `json:"attributes,omitempty"` - Domain *[]string `json:"domains,omitempty"` - Member *[]string `json:"member,omitempty"` - IdentityProviders *[]string `json:"identityProviders,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Alias *string `json:"alias,omitempty"` + Enable *bool `json:"enabled,omitempty"` + Description *string `json:"description,omitempty"` + RedirectUrl *string `json:"redirectUrl,omitempty"` + Attributes *map[string][]string `json:"attributes,omitempty"` + Domains *[]Domain `json:"domains,omitempty"` + Members *[]string `json:"members,omitempty"` + IdentityProviders *[]string `json:"identityProviders,omitempty"` } // Stringer implementations for all struct types @@ -1551,4 +1556,5 @@ func (v *CredentialRepresentation) String() string { return pre func (v *RequiredActionProviderRepresentation) String() string { return prettyStringStruct(v) } func (v *BruteForceStatus) String() string { return prettyStringStruct(v) } func (v *GetClientUserSessionsParams) String() string { return prettyStringStruct(v) } +func (v *Domain) String() string { return prettyStringStruct(v) } func (v *Organization) String() string { return prettyStringStruct(v) }