v9.0.0
This commit is contained in:
41
pkg/cloudbroker/apiaccess/api_find.go
Normal file
41
pkg/cloudbroker/apiaccess/api_find.go
Normal file
@@ -0,0 +1,41 @@
|
||||
package apiaccess
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v9/internal/validators"
|
||||
)
|
||||
|
||||
// APIFindRequest struct for finding apiaccess groups.
|
||||
type APIFindRequest struct {
|
||||
// API function to find
|
||||
// Example: cloudbroker/k8s/create
|
||||
// Required: true
|
||||
APIName string `url:"apiName" json:"apiName" validate:"required"`
|
||||
}
|
||||
|
||||
// APIFind outputs a list of apiaccess groups that mention the specified API function.
|
||||
func (a APIAccess) APIFind(ctx context.Context, req APIFindRequest) ([]uint64, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/apiaccess/apiFind"
|
||||
|
||||
list := make([]uint64, 0)
|
||||
|
||||
res, err := a.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