v9.0.0
This commit is contained in:
45
pkg/cloudbroker/user/get_matching_usernames.go
Normal file
45
pkg/cloudbroker/user/get_matching_usernames.go
Normal file
@@ -0,0 +1,45 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v9/internal/validators"
|
||||
)
|
||||
|
||||
// GetMatchingUsernamesRequest struct for getting a list of the matching usernames for a given string.
|
||||
type GetMatchingUsernamesRequest struct {
|
||||
// Regex of the usernames to searched for.
|
||||
// Required: true
|
||||
UsernameRegex string `url:"usernameregex" json:"usernameregex" validate:"required"`
|
||||
|
||||
// The number of usernames to return.
|
||||
// Required: true
|
||||
Limit uint64 `url:"limit" json:"limit" validate:"required"`
|
||||
}
|
||||
|
||||
// GetMatchingUsernames gets a list of the matching usernames for a given string.
|
||||
func (u User) GetMatchingUsernames(ctx context.Context, req GetMatchingUsernamesRequest) (ListMatchingUsernames, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/user/getMatchingUsernames"
|
||||
|
||||
list := ListMatchingUsernames{}
|
||||
|
||||
res, err := u.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(res, &list)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return list, nil
|
||||
}
|
||||
Reference in New Issue
Block a user