Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(user): add support for user add endpoint #26

Merged
merged 1 commit into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pkg/acloudapi/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ type OrganisationAPI interface {
GetOrganisation(ctx context.Context, organisationSlug string) (*Organisation, error)
}

type UserAPI interface {
AddUser(ctx context.Context) (AddUserResponse, error)
}

type Client interface {
CloudAccountAPI
CloudProvidersAPI
Expand All @@ -105,6 +109,7 @@ type Client interface {
ObservabilityAPI
OrganisationAPI
CloudAccountsAPI
UserAPI

Resty() *resty.Client
}
Expand Down
29 changes: 29 additions & 0 deletions pkg/acloudapi/user.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package acloudapi

import (
"context"
"fmt"
)

type AddUserResponse struct {
OidcId string `json:"oidcId" yaml:"OidcId"`
Identity string `json:"identity" yaml:"Identity"`
Username string `json:"username" yaml:"Username"`
Email string `json:"email" yaml:"Email"`
CreatedAt string `json:"createdAt" yaml:"CreatedAt"`
CanCreateOrganisation bool `json:"canCreateOrganisation" yaml:"CanCreateOrganisation"`
}

// AddUser associates your existing OpenID Connect user ID with your Avisi Cloud organization,
// linking your account without creating a new user.
func (c *clientImpl) AddUser(ctx context.Context) (AddUserResponse, error) {
result := AddUserResponse{}
response, err := c.R().
SetContext(ctx).
SetResult(&result).
Post(fmt.Sprintf("/api/v1/user/add"))
if err := c.CheckResponse(response, err); err != nil {
return AddUserResponse{}, err
}
return result, nil
}
Loading