Skip to content

Commit

Permalink
update: get organization to list of organization
Browse files Browse the repository at this point in the history
  • Loading branch information
Herdanis committed Dec 12, 2024
1 parent 20edccd commit df966d9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
10 changes: 6 additions & 4 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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
}
26 changes: 16 additions & 10 deletions models.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) }

0 comments on commit df966d9

Please sign in to comment.