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.
52 lines
1.3 KiB
52 lines
1.3 KiB
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 group to find (cloudbroker, cloudapi, etc)
|
|
//Available values : cloudapi, cloudbroker, system
|
|
//Required: true
|
|
APIGroup string `url:"api_group" json:"api_group" validate:"required,apiGroup"`
|
|
|
|
//API object to find (compute, vins, etc )
|
|
//Required: true
|
|
APIObject string `url:"api_object" json:"api_object" validate:"required"`
|
|
|
|
//API endpoint to find (delete, create, etc)
|
|
//Required: true
|
|
APIMethod string `url:"api_method" json:"api_method" valudate:"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
|
|
}
|