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/cloudapi/flipgroup/create.go

71 lines
1.7 KiB

package flipgroup
import (
"context"
"encoding/json"
"net/http"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
2 years ago
// CreateRequest struct to create FLIPGroup
type CreateRequest struct {
3 years ago
// Account ID
// Required: true
3 years ago
AccountID uint64 `url:"accountId" json:"accountId" validate:"required"`
3 years ago
// FLIPGroup name
// Required: true
3 years ago
Name string `url:"name" json:"name" validate:"required"`
3 years ago
// Network type
// Should be one of:
// - EXTNET
// - VINS
// Required: true
3 years ago
NetType string `url:"netType" json:"netType" validate:"computeNetType"`
3 years ago
// ID of external network or VINS
// Required: true
3 years ago
NetID uint64 `url:"netId" json:"netId" validate:"required"`
3 years ago
// Type of client
// - 'compute'
// - 'vins' (will be later)
4 months ago
// Required: false
// Default: "compute"
ClientType string `url:"clientType,omitempty" json:"clientType,omitempty"`
3 years ago
// IP address to associate with this group. If empty, the platform will autoselect IP address
// Required: false
3 years ago
IP string `url:"ip,omitempty" json:"ip,omitempty"`
3 years ago
// Text description of this FLIPGorup instance
// Required: false
3 years ago
Description string `url:"desc,omitempty" json:"desc,omitempty"`
}
3 years ago
// Create method will create a new FLIPGorup in the specified Account
2 years ago
func (f FLIPGroup) Create(ctx context.Context, req CreateRequest) (*RecordFLIPGroupCreated, error) {
3 years ago
err := validators.ValidateRequest(req)
3 years ago
if err != nil {
2 years ago
return nil, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudapi/flipgroup/create"
3 years ago
res, err := f.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return nil, err
}
2 years ago
info := RecordFLIPGroupCreated{}
3 years ago
err = json.Unmarshal(res, &info)
if err != nil {
return nil, err
}
3 years ago
return &info, nil
}