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.
44 lines
953 B
44 lines
953 B
package securitygroup
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"net/http"
|
|
|
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
|
)
|
|
|
|
type GetRequest struct {
|
|
// ID of security group
|
|
// Required: true
|
|
SecurityGroupID uint64 `url:"security_group_id" json:"security_group_id" validate:"required"`
|
|
}
|
|
|
|
func (sg SecurityGroup) Get(ctx context.Context, req GetRequest) (*RecordSecurityGroup, error) {
|
|
res, err := sg.GetRaw(ctx, req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
info := RecordSecurityGroup{}
|
|
|
|
err = json.Unmarshal(res, &info)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &info, nil
|
|
}
|
|
|
|
func (sg SecurityGroup) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
|
err := validators.ValidateRequest(req)
|
|
if err != nil {
|
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
|
}
|
|
|
|
url := "/cloudapi/security_group/get"
|
|
|
|
res, err := sg.client.DecortApiCall(ctx, http.MethodGet, url, req)
|
|
return res, err
|
|
}
|