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.
51 lines
1.3 KiB
51 lines
1.3 KiB
package bservice
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
"strconv"
|
|
|
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
|
)
|
|
|
|
// CreateRequest struct for BasicService
|
|
type CreateRequest struct {
|
|
// Name of the service
|
|
// Required: true
|
|
Name string `url:"name" json:"name" validate:"required"`
|
|
|
|
// ID of the Resource Group where this service will be placed
|
|
// Required: true
|
|
RGID uint64 `url:"rgId" json:"rgId" validate:"required"`
|
|
|
|
// Name of the user to deploy SSH key for. Pass empty string if no SSH key deployment is required
|
|
// Required: false
|
|
SSHUser string `url:"sshUser,omitempty" json:"sshUser,omitempty"`
|
|
|
|
// SSH key to deploy for the specified user. Same key will be deployed to all computes of the service
|
|
// Required: false
|
|
SSHKey string `url:"sshKey,omitempty" json:"sshKey,omitempty"`
|
|
}
|
|
|
|
// Create creates blank BasicService instance
|
|
func (b BService) Create(ctx context.Context, req CreateRequest) (uint64, error) {
|
|
err := validators.ValidateRequest(req)
|
|
if err != nil {
|
|
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
|
}
|
|
|
|
url := "/cloudapi/bservice/create"
|
|
|
|
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
if err != nil {
|
|
return 0, err
|
|
}
|
|
|
|
result, err := strconv.ParseUint(string(res), 10, 64)
|
|
if err != nil {
|
|
return 0, err
|
|
}
|
|
|
|
return result, nil
|
|
}
|