You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
decort-golang-sdk/pkg/cloudbroker/apiaccess/api_find.go

42 lines
952 B

package apiaccess
import (
"context"
"encoding/json"
"net/http"
"repository.basistech.ru/BASIS/decort-golang-sdk/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
}