Merge 'dev' into 'main'

This commit is contained in:
stSolo
2022-10-03 16:56:47 +03:00
parent 6271fa6d45
commit 5fd450382c
400 changed files with 14394 additions and 13407 deletions

View File

@@ -1,54 +1,43 @@
package vins
import (
"context"
"encoding/json"
"errors"
"github.com/rudecs/decort-sdk/opts"
"github.com/rudecs/decort-sdk/typed"
)
type AuditsRequest struct {
VinsId uint64 `url:"vinsId"`
}
func (vrq AuditsRequest) Validate() error {
if vrq.VinsId == 0 {
return errors.New("validation-error: field VinsId can not be empty or equal to 0")
}
return nil
}
func (v Vins) Audits(ctx context.Context, req AuditsRequest, options ...opts.DecortOpts) (VinsAuditsList, error) {
err := req.Validate()
if err != nil {
return nil, err
}
url := "/vins/audits"
prefix := "/cloudapi"
option := opts.New(options)
if option != nil {
if option.IsAdmin {
prefix = "/" + option.AdminValue
}
}
url = prefix + url
auditsRaw, err := v.client.DecortApiCall(ctx, typed.POST, url, req)
if err != nil {
return nil, err
}
audits := VinsAuditsList{}
err = json.Unmarshal([]byte(auditsRaw), &audits)
if err != nil {
return nil, err
}
return audits, nil
}
package vins
import (
"context"
"encoding/json"
"errors"
"net/http"
)
type AuditsRequest struct {
VINSID uint64 `url:"vinsId"`
}
func (vrq AuditsRequest) Validate() error {
if vrq.VINSID == 0 {
return errors.New("validation-error: field VINSID can not be empty or equal to 0")
}
return nil
}
func (v VINS) Audits(ctx context.Context, req AuditsRequest) (VINSAuditsList, error) {
err := req.Validate()
if err != nil {
return nil, err
}
url := "/cloudapi/vins/audits"
auditsRaw, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return nil, err
}
audits := VINSAuditsList{}
err = json.Unmarshal(auditsRaw, &audits)
if err != nil {
return nil, err
}
return audits, nil
}

View File

@@ -1,61 +1,50 @@
package vins
import (
"context"
"errors"
"strconv"
"github.com/rudecs/decort-sdk/opts"
"github.com/rudecs/decort-sdk/typed"
)
type CreateInAccountRequest struct {
Name string `url:"name"`
AccountId uint64 `url:"accountId"`
GID uint64 `url:"gid,omitempty"`
IPCidr string `url:"ipcidr,omitempty"`
Description string `url:"desc,omitempty"`
PreReservationsNum uint `url:"preReservationsNum,omitempty"`
}
func (vrq CreateInAccountRequest) Validate() error {
if vrq.Name == "" {
return errors.New("validation-error: field Name can not be empty")
}
if vrq.AccountId == 0 {
return errors.New("validation-error: field AccountId can not be empty or equal to 0")
}
return nil
}
func (v Vins) CreateInAccount(ctx context.Context, req CreateInAccountRequest, options ...opts.DecortOpts) (uint64, error) {
err := req.Validate()
if err != nil {
return 0, err
}
url := "/vins/createInAccount"
prefix := "/cloudapi"
option := opts.New(options)
if option != nil {
if option.IsAdmin {
prefix = "/" + option.AdminValue
}
}
url = prefix + url
res, err := v.client.DecortApiCall(ctx, typed.POST, 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
}
package vins
import (
"context"
"errors"
"net/http"
"strconv"
)
type CreateInAccountRequest struct {
Name string `url:"name"`
AccountID uint64 `url:"accountId"`
GID uint64 `url:"gid,omitempty"`
IPCidr string `url:"ipcidr,omitempty"`
Description string `url:"desc,omitempty"`
PreReservationsNum uint `url:"preReservationsNum,omitempty"`
}
func (vrq CreateInAccountRequest) Validate() error {
if vrq.Name == "" {
return errors.New("validation-error: field Name can not be empty")
}
if vrq.AccountID == 0 {
return errors.New("validation-error: field AccountID can not be empty or equal to 0")
}
return nil
}
func (v VINS) CreateInAccount(ctx context.Context, req CreateInAccountRequest) (uint64, error) {
err := req.Validate()
if err != nil {
return 0, err
}
url := "/cloudapi/vins/createInAccount"
res, err := v.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
}

View File

@@ -1,62 +1,51 @@
package vins
import (
"context"
"errors"
"strconv"
"github.com/rudecs/decort-sdk/opts"
"github.com/rudecs/decort-sdk/typed"
)
type CreateInRGRequest struct {
Name string `url:"name"`
RGID uint64 `url:"rgId"`
IPCidr string `url:"ipcidr,omitempty"`
ExtNetId uint64 `url:"extNetId,omitempty"`
ExtIP string `url:"extIp,omitempty"`
Description string `url:"desc,omitempty"`
PreReservationsNum uint `url:"preReservationsNum,omitempty"`
}
func (vrq CreateInRGRequest) Validate() error {
if vrq.Name == "" {
return errors.New("validation-error: field Name can not be empty")
}
if vrq.RGID == 0 {
return errors.New("validation-error: field RGID can not be empty or equal to 0")
}
return nil
}
func (v Vins) CreateInRG(ctx context.Context, req CreateInRGRequest, options ...opts.DecortOpts) (uint64, error) {
err := req.Validate()
if err != nil {
return 0, err
}
url := "/vins/createInRG"
prefix := "/cloudapi"
option := opts.New(options)
if option != nil {
if option.IsAdmin {
prefix = "/" + option.AdminValue
}
}
url = prefix + url
res, err := v.client.DecortApiCall(ctx, typed.POST, 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
}
package vins
import (
"context"
"errors"
"net/http"
"strconv"
)
type CreateInRGRequest struct {
Name string `url:"name"`
RGID uint64 `url:"rgId"`
IPCidr string `url:"ipcidr,omitempty"`
ExtNetID uint64 `url:"extNetId,omitempty"`
ExtIP string `url:"extIp,omitempty"`
Description string `url:"desc,omitempty"`
PreReservationsNum uint `url:"preReservationsNum,omitempty"`
}
func (vrq CreateInRGRequest) Validate() error {
if vrq.Name == "" {
return errors.New("validation-error: field Name can not be empty")
}
if vrq.RGID == 0 {
return errors.New("validation-error: field RGID can not be empty or equal to 0")
}
return nil
}
func (v VINS) CreateInRG(ctx context.Context, req CreateInRGRequest) (uint64, error) {
err := req.Validate()
if err != nil {
return 0, err
}
url := "/cloudapi/vins/createInRG"
res, err := v.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
}

View File

@@ -1,54 +1,43 @@
package vins
import (
"context"
"errors"
"strconv"
"github.com/rudecs/decort-sdk/opts"
"github.com/rudecs/decort-sdk/typed"
)
type DeleteRequest struct {
VinsId uint64 `url:"vinsId"`
Force bool `url:"force"`
Permanently bool `url:"permanently"`
}
func (vrq DeleteRequest) Validate() error {
if vrq.VinsId == 0 {
return errors.New("validation-error: field VinsId can not be empty or equal to 0")
}
return nil
}
func (v Vins) Delete(ctx context.Context, req DeleteRequest, options ...opts.DecortOpts) (bool, error) {
err := req.Validate()
if err != nil {
return false, err
}
url := "/vins/delete"
prefix := "/cloudapi"
option := opts.New(options)
if option != nil {
if option.IsAdmin {
prefix = "/" + option.AdminValue
}
}
url = prefix + url
res, err := v.client.DecortApiCall(ctx, typed.POST, url, req)
if err != nil {
return false, err
}
result, err := strconv.ParseBool(string(res))
if err != nil {
return false, nil
}
return result, nil
}
package vins
import (
"context"
"errors"
"net/http"
"strconv"
)
type DeleteRequest struct {
VINSID uint64 `url:"vinsId"`
Force bool `url:"force"`
Permanently bool `url:"permanently"`
}
func (vrq DeleteRequest) Validate() error {
if vrq.VINSID == 0 {
return errors.New("validation-error: field VINSID can not be empty or equal to 0")
}
return nil
}
func (v VINS) Delete(ctx context.Context, req DeleteRequest) (bool, error) {
err := req.Validate()
if err != nil {
return false, err
}
url := "/cloudapi/vins/delete"
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return false, err
}
result, err := strconv.ParseBool(string(res))
if err != nil {
return false, err
}
return result, nil
}

View File

@@ -1,84 +1,64 @@
package vins
import (
"context"
"errors"
"strconv"
"github.com/rudecs/decort-sdk/opts"
"github.com/rudecs/decort-sdk/typed"
)
type DisableEnableRequest struct {
VinsId uint64 `url:"vinsId"`
}
func (vrq DisableEnableRequest) Validate() error {
if vrq.VinsId == 0 {
return errors.New("validation-error: field VinsId can not be empty or equal to 0")
}
return nil
}
func (v Vins) Disable(ctx context.Context, req DisableEnableRequest, options ...opts.DecortOpts) (bool, error) {
err := req.Validate()
if err != nil {
return false, err
}
url := "/vins/disable"
prefix := "/cloudapi"
option := opts.New(options)
if option != nil {
if option.IsAdmin {
prefix = "/" + option.AdminValue
}
}
url = prefix + url
res, err := v.client.DecortApiCall(ctx, typed.POST, url, req)
if err != nil {
return false, err
}
result, err := strconv.ParseBool(string(res))
if err != nil {
return false, nil
}
return result, nil
}
func (v Vins) Enable(ctx context.Context, req DisableEnableRequest, options ...opts.DecortOpts) (bool, error) {
err := req.Validate()
if err != nil {
return false, err
}
url := "/vins/enable"
prefix := "/cloudapi"
option := opts.New(options)
if option != nil {
if option.IsAdmin {
prefix = "/" + option.AdminValue
}
}
url = prefix + url
res, err := v.client.DecortApiCall(ctx, typed.POST, url, req)
if err != nil {
return false, err
}
result, err := strconv.ParseBool(string(res))
if err != nil {
return false, nil
}
return result, nil
}
package vins
import (
"context"
"errors"
"net/http"
"strconv"
)
type DisableEnableRequest struct {
VINSID uint64 `url:"vinsId"`
}
func (vrq DisableEnableRequest) Validate() error {
if vrq.VINSID == 0 {
return errors.New("validation-error: field VINSID can not be empty or equal to 0")
}
return nil
}
func (v VINS) Disable(ctx context.Context, req DisableEnableRequest) (bool, error) {
err := req.Validate()
if err != nil {
return false, err
}
url := "/cloudapi/vins/disable"
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return false, err
}
result, err := strconv.ParseBool(string(res))
if err != nil {
return false, err
}
return result, nil
}
func (v VINS) Enable(ctx context.Context, req DisableEnableRequest) (bool, error) {
err := req.Validate()
if err != nil {
return false, err
}
url := "/cloudapi/vins/enable"
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return false, err
}
result, err := strconv.ParseBool(string(res))
if err != nil {
return false, err
}
return result, nil
}

View File

@@ -1,54 +1,43 @@
package vins
import (
"context"
"errors"
"strconv"
"github.com/rudecs/decort-sdk/opts"
"github.com/rudecs/decort-sdk/typed"
)
type ExtNetConnectRequest struct {
VinsId uint64 `url:"vinsId"`
NetId uint64 `url:"netId"`
IP string `url:"ip"`
}
func (vrq ExtNetConnectRequest) Validate() error {
if vrq.VinsId == 0 {
return errors.New("validation-error: field VinsId can not be empty or equal to 0")
}
return nil
}
func (v Vins) ExtNetConnect(ctx context.Context, req ExtNetConnectRequest, options ...opts.DecortOpts) (bool, error) {
err := req.Validate()
if err != nil {
return false, err
}
url := "/vins/extNetConnect"
prefix := "/cloudapi"
option := opts.New(options)
if option != nil {
if option.IsAdmin {
prefix = "/" + option.AdminValue
}
}
url = prefix + url
res, err := v.client.DecortApiCall(ctx, typed.POST, url, req)
if err != nil {
return false, err
}
result, err := strconv.ParseBool(string(res))
if err != nil {
return false, nil
}
return result, nil
}
package vins
import (
"context"
"errors"
"net/http"
"strconv"
)
type ExtNetConnectRequest struct {
VINSID uint64 `url:"vinsId"`
NetID uint64 `url:"netId"`
IP string `url:"ip"`
}
func (vrq ExtNetConnectRequest) Validate() error {
if vrq.VINSID == 0 {
return errors.New("validation-error: field VINSID can not be empty or equal to 0")
}
return nil
}
func (v VINS) ExtNetConnect(ctx context.Context, req ExtNetConnectRequest) (bool, error) {
err := req.Validate()
if err != nil {
return false, err
}
url := "/cloudapi/vins/extNetConnect"
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return false, err
}
result, err := strconv.ParseBool(string(res))
if err != nil {
return false, err
}
return result, nil
}

View File

@@ -1,52 +1,41 @@
package vins
import (
"context"
"errors"
"strconv"
"github.com/rudecs/decort-sdk/opts"
"github.com/rudecs/decort-sdk/typed"
)
type ExtNetDisconnectRequest struct {
VinsId uint64 `url:"vinsId"`
}
func (vrq ExtNetDisconnectRequest) Validate() error {
if vrq.VinsId == 0 {
return errors.New("validation-error: field VinsId can not be empty or equal to 0")
}
return nil
}
func (v Vins) ExtNetDisconnect(ctx context.Context, req ExtNetDisconnectRequest, options ...opts.DecortOpts) (bool, error) {
err := req.Validate()
if err != nil {
return false, err
}
url := "/vins/extNetDisconnect"
prefix := "/cloudapi"
option := opts.New(options)
if option != nil {
if option.IsAdmin {
prefix = "/" + option.AdminValue
}
}
url = prefix + url
res, err := v.client.DecortApiCall(ctx, typed.POST, url, req)
if err != nil {
return false, err
}
result, err := strconv.ParseBool(string(res))
if err != nil {
return false, nil
}
return result, nil
}
package vins
import (
"context"
"errors"
"net/http"
"strconv"
)
type ExtNetDisconnectRequest struct {
VINSID uint64 `url:"vinsId"`
}
func (vrq ExtNetDisconnectRequest) Validate() error {
if vrq.VINSID == 0 {
return errors.New("validation-error: field VINSID can not be empty or equal to 0")
}
return nil
}
func (v VINS) ExtNetDisconnect(ctx context.Context, req ExtNetDisconnectRequest) (bool, error) {
err := req.Validate()
if err != nil {
return false, err
}
url := "/cloudapi/vins/extNetDisconnect"
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return false, err
}
result, err := strconv.ParseBool(string(res))
if err != nil {
return false, err
}
return result, nil
}

View File

@@ -1,49 +1,38 @@
package vins
import (
"context"
"encoding/json"
"errors"
"github.com/rudecs/decort-sdk/opts"
"github.com/rudecs/decort-sdk/typed"
)
type ExtNetListRequest struct {
VinsId uint64 `url:"vinsId"`
}
func (vrq ExtNetListRequest) Validate() error {
if vrq.VinsId == 0 {
return errors.New("validation-error: field VinsId can not be empty or equal to 0")
}
return nil
}
func (v Vins) ExtNetList(ctx context.Context, req ExtNetListRequest, options ...opts.DecortOpts) (ExtnetList, error) {
url := "/vins/extNetList"
prefix := "/cloudapi"
option := opts.New(options)
if option != nil {
if option.IsAdmin {
prefix = "/" + option.AdminValue
}
}
url = prefix + url
extnetListRaw, err := v.client.DecortApiCall(ctx, typed.POST, url, req)
if err != nil {
return nil, err
}
extnetList := ExtnetList{}
err = json.Unmarshal(extnetListRaw, &extnetList)
if err != nil {
return nil, err
}
return extnetList, nil
}
package vins
import (
"context"
"encoding/json"
"errors"
"net/http"
)
type ExtNetListRequest struct {
VINSID uint64 `url:"vinsId"`
}
func (vrq ExtNetListRequest) Validate() error {
if vrq.VINSID == 0 {
return errors.New("validation-error: field VINSID can not be empty or equal to 0")
}
return nil
}
func (v VINS) ExtNetList(ctx context.Context, req ExtNetListRequest) (ExtNetList, error) {
url := "/cloudapi/vins/extNetList"
extnetListRaw, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return nil, err
}
extnetList := ExtNetList{}
err = json.Unmarshal(extnetListRaw, &extnetList)
if err != nil {
return nil, err
}
return extnetList, nil
}

View File

@@ -1,55 +1,44 @@
package vins
import (
"context"
"encoding/json"
"errors"
"github.com/rudecs/decort-sdk/opts"
"github.com/rudecs/decort-sdk/typed"
)
type GetRequest struct {
VinsId uint64 `url:"vinsId"`
}
func (vrq GetRequest) Validate() error {
if vrq.VinsId == 0 {
return errors.New("validation-error: field VinsId can not be empty or equal to 0")
}
return nil
}
func (v Vins) Get(ctx context.Context, req GetRequest, options ...opts.DecortOpts) (*VinsDetailed, error) {
err := req.Validate()
if err != nil {
return nil, err
}
url := "/vins/get"
prefix := "/cloudapi"
option := opts.New(options)
if option != nil {
if option.IsAdmin {
prefix = "/" + option.AdminValue
}
}
url = prefix + url
res, err := v.client.DecortApiCall(ctx, typed.POST, url, req)
if err != nil {
return nil, err
}
vins := &VinsDetailed{}
err = json.Unmarshal(res, vins)
if err != nil {
return nil, err
}
return vins, nil
}
package vins
import (
"context"
"encoding/json"
"errors"
"net/http"
)
type GetRequest struct {
VINSID uint64 `url:"vinsId"`
}
func (vrq GetRequest) Validate() error {
if vrq.VINSID == 0 {
return errors.New("validation-error: field VINSID can not be empty or equal to 0")
}
return nil
}
func (v VINS) Get(ctx context.Context, req GetRequest) (*VINSDetailed, error) {
err := req.Validate()
if err != nil {
return nil, err
}
url := "/cloudapi/vins/get"
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return nil, err
}
VINS := &VINSDetailed{}
err = json.Unmarshal(res, VINS)
if err != nil {
return nil, err
}
return VINS, nil
}

View File

@@ -1,54 +1,43 @@
package vins
import (
"context"
"encoding/json"
"errors"
"github.com/rudecs/decort-sdk/opts"
"github.com/rudecs/decort-sdk/typed"
)
type IPListRequest struct {
VinsId uint64 `url:"vinsId"`
}
func (vrq IPListRequest) Validate() error {
if vrq.VinsId == 0 {
return errors.New("validation-error: field VinsId can not be empty or equal to 0")
}
return nil
}
func (v Vins) IPList(ctx context.Context, req IPListRequest, options ...opts.DecortOpts) (IPList, error) {
err := req.Validate()
if err != nil {
return nil, err
}
url := "/vins/ipList"
prefix := "/cloudapi"
option := opts.New(options)
if option != nil {
if option.IsAdmin {
prefix = "/" + option.AdminValue
}
}
url = prefix + url
ipListRaw, err := v.client.DecortApiCall(ctx, typed.POST, url, req)
if err != nil {
return nil, err
}
ipList := IPList{}
err = json.Unmarshal(ipListRaw, &ipList)
if err != nil {
return nil, err
}
return ipList, nil
}
package vins
import (
"context"
"encoding/json"
"errors"
"net/http"
)
type IPListRequest struct {
VINSID uint64 `url:"vinsId"`
}
func (vrq IPListRequest) Validate() error {
if vrq.VINSID == 0 {
return errors.New("validation-error: field VINSID can not be empty or equal to 0")
}
return nil
}
func (v VINS) IPList(ctx context.Context, req IPListRequest) (IPList, error) {
err := req.Validate()
if err != nil {
return nil, err
}
url := "/cloudapi/vins/ipList"
ipListRaw, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return nil, err
}
ipList := IPList{}
err = json.Unmarshal(ipListRaw, &ipList)
if err != nil {
return nil, err
}
return ipList, nil
}

View File

@@ -1,55 +1,44 @@
package vins
import (
"context"
"errors"
"strconv"
"github.com/rudecs/decort-sdk/opts"
"github.com/rudecs/decort-sdk/typed"
)
type IPReleaseRequest struct {
VinsId uint64 `url:"vinsId"`
IPAddr string `url:"ipAddr,omitempty"`
MAC string `url:"mac,omitempty"`
}
func (vrq IPReleaseRequest) Validate() error {
if vrq.VinsId == 0 {
return errors.New("validation-error: field VinsId can not be empty or equal to 0")
}
return nil
}
func (v Vins) IPRelese(ctx context.Context, req IPReleaseRequest, options ...opts.DecortOpts) (bool, error) {
err := req.Validate()
if err != nil {
return false, err
}
url := "/vins/ipRelease"
prefix := "/cloudapi"
option := opts.New(options)
if option != nil {
if option.IsAdmin {
prefix = "/" + option.AdminValue
}
}
url = prefix + url
res, err := v.client.DecortApiCall(ctx, typed.POST, url, req)
if err != nil {
return false, err
}
result, err := strconv.ParseBool(string(res))
if err != nil {
return false, nil
}
return result, nil
}
package vins
import (
"context"
"errors"
"net/http"
"strconv"
)
type IPReleaseRequest struct {
VINSID uint64 `url:"vinsId"`
IPAddr string `url:"ipAddr,omitempty"`
MAC string `url:"mac,omitempty"`
}
func (vrq IPReleaseRequest) Validate() error {
if vrq.VINSID == 0 {
return errors.New("validation-error: field VINSID can not be empty or equal to 0")
}
return nil
}
func (v VINS) IPRelese(ctx context.Context, req IPReleaseRequest) (bool, error) {
err := req.Validate()
if err != nil {
return false, err
}
url := "/cloudapi/vins/ipRelease"
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return false, err
}
result, err := strconv.ParseBool(string(res))
if err != nil {
return false, err
}
return result, nil
}

View File

@@ -1,55 +1,44 @@
package vins
import (
"context"
"errors"
"github.com/rudecs/decort-sdk/opts"
"github.com/rudecs/decort-sdk/typed"
)
type IPReserveRequest struct {
VinsId uint64 `url:"vinsId"`
Type string `url:"type"`
IPAddr string `url:"ipAddr,omitempty"`
MAC string `url:"mac,omitempty"`
ComputeId uint64 `url:"computeId,omitempty"`
}
func (vrq IPReserveRequest) Validate() error {
if vrq.VinsId == 0 {
return errors.New("validation-error: field VinsId can not be empty or equal to 0")
}
if vrq.Type == "" {
return errors.New("validation-error: field Type can not be empty")
}
return nil
}
func (v Vins) IPReserve(ctx context.Context, req IPReserveRequest, options ...opts.DecortOpts) (string, error) {
err := req.Validate()
if err != nil {
return "", err
}
url := "/vins/ipReserve"
prefix := "/cloudapi"
option := opts.New(options)
if option != nil {
if option.IsAdmin {
prefix = "/" + option.AdminValue
}
}
url = prefix + url
res, err := v.client.DecortApiCall(ctx, typed.POST, url, req)
if err != nil {
return "", err
}
return string(res), nil
}
package vins
import (
"context"
"errors"
"net/http"
)
type IPReserveRequest struct {
VINSID uint64 `url:"vinsId"`
Type string `url:"type"`
IPAddr string `url:"ipAddr,omitempty"`
MAC string `url:"mac,omitempty"`
ComputeID uint64 `url:"computeId,omitempty"`
}
func (vrq IPReserveRequest) Validate() error {
if vrq.VINSID == 0 {
return errors.New("validation-error: field VINSID can not be empty or equal to 0")
}
if vrq.Type == "" {
return errors.New("validation-error: field Type can not be empty")
}
return nil
}
func (v VINS) IPReserve(ctx context.Context, req IPReserveRequest) (string, error) {
err := req.Validate()
if err != nil {
return "", err
}
url := "/cloudapi/vins/ipReserve"
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return "", err
}
return string(res), nil
}

View File

@@ -1,42 +1,31 @@
package vins
import (
"context"
"encoding/json"
"github.com/rudecs/decort-sdk/opts"
"github.com/rudecs/decort-sdk/typed"
)
type ListRequest struct {
IncludeDeleted bool `url:"includeDeleted"`
Page uint64 `url:"page"`
Size uint64 `url:"size"`
}
func (v Vins) List(ctx context.Context, req ListRequest, options ...opts.DecortOpts) (VinsList, error) {
url := "/vins/list"
prefix := "/cloudapi"
option := opts.New(options)
if option != nil {
if option.IsAdmin {
prefix = "/" + option.AdminValue
}
}
url = prefix + url
vinsListRaw, err := v.client.DecortApiCall(ctx, typed.POST, url, req)
if err != nil {
return nil, err
}
vinsList := VinsList{}
err = json.Unmarshal(vinsListRaw, &vinsList)
if err != nil {
return nil, err
}
return vinsList, nil
}
package vins
import (
"context"
"encoding/json"
"net/http"
)
type ListRequest struct {
IncludeDeleted bool `url:"includeDeleted"`
Page uint64 `url:"page"`
Size uint64 `url:"size"`
}
func (v VINS) List(ctx context.Context, req ListRequest) (VINSList, error) {
url := "/cloudapi/vins/list"
VINSListRaw, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return nil, err
}
VINSList := VINSList{}
err = json.Unmarshal(VINSListRaw, &VINSList)
if err != nil {
return nil, err
}
return VINSList, nil
}

View File

@@ -1,41 +1,30 @@
package vins
import (
"context"
"encoding/json"
"github.com/rudecs/decort-sdk/opts"
"github.com/rudecs/decort-sdk/typed"
)
type ListDeletedRequest struct {
Page uint64 `url:"page"`
Size uint64 `url:"size"`
}
func (v Vins) ListDeleted(ctx context.Context, req ListDeletedRequest, options ...opts.DecortOpts) (VinsList, error) {
url := "/vins/listDeleted"
prefix := "/cloudapi"
option := opts.New(options)
if option != nil {
if option.IsAdmin {
prefix = "/" + option.AdminValue
}
}
url = prefix + url
vinsListRaw, err := v.client.DecortApiCall(ctx, typed.POST, url, req)
if err != nil {
return nil, err
}
vinsList := VinsList{}
err = json.Unmarshal(vinsListRaw, &vinsList)
if err != nil {
return nil, err
}
return vinsList, nil
}
package vins
import (
"context"
"encoding/json"
"net/http"
)
type ListDeletedRequest struct {
Page uint64 `url:"page"`
Size uint64 `url:"size"`
}
func (v VINS) ListDeleted(ctx context.Context, req ListDeletedRequest) (VINSList, error) {
url := "/cloudapi/vins/listDeleted"
VINSListRaw, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return nil, err
}
VINSList := VINSList{}
err = json.Unmarshal(VINSListRaw, &VINSList)
if err != nil {
return nil, err
}
return VINSList, nil
}

View File

@@ -1,271 +1,271 @@
package vins
type VinsRecord struct {
AccountId int `json:"accountId"`
AccountName string `json:"accountName"`
CreatedBy string `json:"createdBy"`
CreatedTime int `json:"createdTime"`
DeletedBy string `json:"deletedBy"`
DeletedTime int `json:"deletedTime"`
ExternalIP string `json:"externalIP"`
ID int `json:"id"`
Name string `json:"name"`
Network string `json:"network"`
RGID int `json:"rgId"`
RGName string `json:"rgName"`
Status string `json:"status"`
UpdatedBy string `json:"updatedBy"`
UpdatedTime int `json:"updatedTime"`
VXLanID int `json:"vxlanId"`
}
type VinsList []VinsRecord
type VinsAudits struct {
Call string `json:"call"`
ResponseTime float64 `json:"responsetime"`
StatusCode int `json:"statuscode"`
Timestamp float64 `json:"timestamp"`
User string `json:"user"`
}
type VinsAuditsList []VinsAudits
type VinsExtnet struct {
DefaultGW string `json:"default_gw"`
ExtNetID uint64 `json:"ext_net_id"`
IP string `json:"ip"`
PrefixLen uint `json:"prefixlen"`
Status string `json:"status"`
TechStatus string `json:"techStatus"`
}
type ExtnetList []VinsExtnet
type IP struct {
ClientType string `json:"clientType"`
DomainName string `json:"domainname"`
HostName string `json:"hostname"`
IP string `json:"ip"`
MAC string `json:"mac"`
Type string `json:"type"`
VMId uint64 `json:"vmId"`
}
type IPList []IP
type VNFDev struct {
CKey string `json:"_ckey"`
AccountId uint64 `json:"accountId"`
Capabilities []string `json:"capabilities"`
Config VNFConfig `json:"config"`
ConfigSaved bool `json:"configSaved"`
CustomPreConfig bool `json:"customPrecfg"`
Description string `json:"desc"`
GID uint64 `json:"gid"`
GUID uint64 `json:"guid"`
ID uint64 `json:"id"`
Interfaces VNFInterfaceList `json:"interfaces"`
LockStatus string `json:"lockStatus"`
Milestones uint64 `json:"milestones"`
Name string `json:"name"`
Status string `json:"status"`
TechStatus string `json:"techStatus"`
Type string `json:"type"`
Vins []uint64 `json:"vins"`
}
type VNFConfig struct {
MGMT VNFConfigMGMT `json:"mgmt"`
Resources VNFConfigResources `json:"resources"`
}
type VNFConfigMGMT struct {
IPAddr string `json:"ipaddr"`
Password string `json:"password"`
SSHKey string `json:"sshkey"`
User string `json:"user"`
}
type VNFConfigResources struct {
CPU uint64 `json:"cpu"`
RAM uint64 `json:"ram"`
StackId uint64 `json:"stackId"`
UUID string `json:"uuid"`
}
type VNFInterface struct {
ConnId uint64 `json:"connId"`
ConnType string `json:"connType"`
DefGW string `json:"defGw"`
FlipGroupId uint64 `json:"flipgroupId"`
GUID string `json:"guid"`
IPAddress string `json:"ipAddress"`
ListenSSH bool `json:"listenSsh"`
MAC string `json:"mac"`
Name string `json:"name"`
NetId uint64 `json:"netId"`
NetMask uint64 `json:"netMask"`
NetType string `json:"netType"`
PCISlot uint64 `json:"pciSlot"`
QOS QOS `json:"qos"`
Target string `json:"target"`
Type string `json:"type"`
VNFS []uint64 `json:"vnfs"`
}
type QOS struct {
ERate uint64 `json:"eRate"`
GUID string `json:"guid"`
InBurst uint64 `json:"inBurst"`
InRate uint64 `json:"inRate"`
}
type VNFInterfaceList []VNFInterface
type VINSCompute struct {
ID uint64 `json:"id"`
Name string `json:"name"`
}
type VINSComputeList []VINSCompute
type VNFS struct {
DHCP DHCP `json:"DHCP"`
GW GW `json:"GW"`
NAT NAT `json:"NAT"`
}
type NAT struct {
CKey string `json:"_ckey"`
AccountId uint64 `json:"accountId"`
CreatedTime uint64 `json:"createdTime"`
Devices Devices `json:"devices"`
GID uint64 `json:"gid"`
GUID uint64 `json:"guid"`
ID uint64 `json:"id"`
LockStatus string `json:"lockStatus"`
Milestones uint64 `json:"milestones"`
OwnerId uint64 `json:"ownerId"`
OwnerType string `json:"ownerType"`
PureVirtual bool `json:"pureVirtual"`
Status string `json:"status"`
TechStatus string `json:"techStatus"`
Type string `json:"type"`
}
type NATConfig struct {
NetMask uint64 `json:"netmask"`
Network string `json:"network"`
Rules []interface{} `json:"rules"`
}
type GW struct {
CKey string `json:"_ckey"`
AccountId uint64 `json:"accountId"`
Config GWConfig `json:"config"`
CreatedTime uint64 `json:"createdTime"`
Devices Devices `json:"devices"`
GID uint64 `json:"gid"`
GUID uint64 `json:"guid"`
ID uint64 `json:"id"`
LockStatus string `json:"lockStatus"`
Milestones uint64 `json:"milestones"`
OwnerId uint64 `json:"ownerId"`
OwnerType string `json:"ownerType"`
PureVirtual bool `json:"pureVirtual"`
Status string `json:"status"`
TechStatus string `json:"techStatus"`
Type string `json:"type"`
}
type GWConfig struct {
DefaultGW string `json:"default_gw"`
ExtNetId uint64 `json:"ext_net_id"`
ExtNetIp string `json:"ext_net_ip"`
ExtNetMask uint64 `json:"ext_netmask"`
QOS QOS `json:"qos"`
}
type Devices struct {
Primary DevicePrimary `json:"primary"`
}
type DevicePrimary struct {
DevId uint64 `json:"devId"`
IFace01 string `json:"iface01"`
IFace02 string `json:"iface02"`
}
type DHCP struct {
CKey string `json:"_ckey"`
AccountId uint64 `json:"accountId"`
Config DHCPConfig `json:"config"`
CreatedTime uint64 `json:"createdTime"`
Devices Devices `json:"devices"`
GID uint64 `json:"gid"`
GUID uint64 `json:"guid"`
ID uint64 `json:"id"`
LockStatus string `json:"lockStatus"`
Milestones uint64 `json:"milestones"`
OwnerId uint64 `json:"ownerId"`
OwnerType string `json:"ownerType"`
PureVirtual bool `json:"pureVirtual"`
Status string `json:"status"`
TechStatus string `json:"techStatus"`
Type string `json:"type"`
}
type DHCPConfig struct {
DefaultGW string `json:"default_gw"`
DNS []string `json:"dns"`
IPEnd string `json:"ip_end"`
IPStart string `json:"ip_start"`
Lease uint64 `json:"lease"`
Netmask uint64 `json:"netmask"`
Network string `json:"network"`
Reservations ReservationList `json:"reservations"`
}
type VinsDetailed struct {
VNFDev VNFDev `json:"VNFDev"`
CKey string `json:"_ckey"`
AccountId uint64 `json:"accountId"`
AccountName string `json:"accountName"`
Computes VINSComputeList `json:"computes"`
DefaultGW string `json:"defaultGW"`
DefaultQOS QOS `json:"defaultQos"`
Description string `json:"desc"`
GID uint64 `json:"gid"`
GUID uint64 `json:"guid"`
ID uint64 `json:"id"`
LockStatus string `json:"lockStatus"`
ManagerId uint64 `json:"managerId"`
ManagerType string `json:"managerType"`
Milestones uint64 `json:"milestones"`
Name string `json:"name"`
NetMask uint64 `json:"netMask"`
Network string `json:"network"`
PreReservaionsNum uint64 `json:"preReservationsNum"`
Redundant bool `json:"redundant"`
RGID uint64 `json:"rgId"`
RGName string `json:"rgName"`
SecVNFDevId uint64 `json:"secVnfDevId"`
Status string `json:"status"`
UserManaged bool `json:"userManaged"`
VNFS VNFS `json:"vnfs"`
VXLanId uint64 `json:"vxlanId"`
}
type Reservation struct {
ClientType string `json:"clientType"`
Description string `json:"desc"`
DomainName string `json:"domainname"`
HostName string `json:"hostname"`
IP string `json:"ip"`
MAC string `json:"mac"`
Type string `json:"type"`
VMID int `json:"vmId"`
}
type ReservationList []Reservation
package vins
type VINSRecord struct {
AccountID uint64 `json:"accountId"`
AccountName string `json:"accountName"`
CreatedBy string `json:"createdBy"`
CreatedTime uint64 `json:"createdTime"`
DeletedBy string `json:"deletedBy"`
DeletedTime uint64 `json:"deletedTime"`
ExternalIP string `json:"externalIP"`
ID uint64 `json:"id"`
Name string `json:"name"`
Network string `json:"network"`
RGID uint64 `json:"rgId"`
RGName string `json:"rgName"`
Status string `json:"status"`
UpdatedBy string `json:"updatedBy"`
UpdatedTime uint64 `json:"updatedTime"`
VXLANID uint64 `json:"vxlanId"`
}
type VINSList []VINSRecord
type VINSAudits struct {
Call string `json:"call"`
ResponseTime float64 `json:"responsetime"`
StatusCode uint64 `json:"statuscode"`
Timestamp float64 `json:"timestamp"`
User string `json:"user"`
}
type VINSAuditsList []VINSAudits
type VINSExtNet struct {
DefaultGW string `json:"default_gw"`
ExtNetID uint64 `json:"ext_net_id"`
IP string `json:"ip"`
PrefixLen uint64 `json:"prefixlen"`
Status string `json:"status"`
TechStatus string `json:"techStatus"`
}
type ExtNetList []VINSExtNet
type IP struct {
ClientType string `json:"clientType"`
DomainName string `json:"domainname"`
HostName string `json:"hostname"`
IP string `json:"ip"`
MAC string `json:"mac"`
Type string `json:"type"`
VMID uint64 `json:"vmId"`
}
type IPList []IP
type VNFDev struct {
CKey string `json:"_ckey"`
AccountID uint64 `json:"accountId"`
Capabilities []string `json:"capabilities"`
Config VNFConfig `json:"config"`
ConfigSaved bool `json:"configSaved"`
CustomPreConfig bool `json:"customPrecfg"`
Description string `json:"desc"`
GID uint64 `json:"gid"`
GUID uint64 `json:"guid"`
ID uint64 `json:"id"`
Interfaces VNFInterfaceList `json:"interfaces"`
LockStatus string `json:"lockStatus"`
Milestones uint64 `json:"milestones"`
Name string `json:"name"`
Status string `json:"status"`
TechStatus string `json:"techStatus"`
Type string `json:"type"`
VINS []uint64 `json:"vins"`
}
type VNFConfig struct {
MGMT VNFConfigMGMT `json:"mgmt"`
Resources VNFConfigResources `json:"resources"`
}
type VNFConfigMGMT struct {
IPAddr string `json:"ipaddr"`
Password string `json:"password"`
SSHKey string `json:"sshkey"`
User string `json:"user"`
}
type VNFConfigResources struct {
CPU uint64 `json:"cpu"`
RAM uint64 `json:"ram"`
StackID uint64 `json:"stackId"`
UUID string `json:"uuid"`
}
type VNFInterface struct {
ConnID uint64 `json:"connId"`
ConnType string `json:"connType"`
DefGW string `json:"defGw"`
FlipGroupID uint64 `json:"flipgroupId"`
GUID string `json:"guid"`
IPAddress string `json:"ipAddress"`
ListenSSH bool `json:"listenSsh"`
MAC string `json:"mac"`
Name string `json:"name"`
NetID uint64 `json:"netId"`
NetMask uint64 `json:"netMask"`
NetType string `json:"netType"`
PCISlot uint64 `json:"pciSlot"`
QOS QOS `json:"qos"`
Target string `json:"target"`
Type string `json:"type"`
VNFS []uint64 `json:"vnfs"`
}
type QOS struct {
ERate uint64 `json:"eRate"`
GUID string `json:"guid"`
InBurst uint64 `json:"inBurst"`
InRate uint64 `json:"inRate"`
}
type VNFInterfaceList []VNFInterface
type VINSCompute struct {
ID uint64 `json:"id"`
Name string `json:"name"`
}
type VINSComputeList []VINSCompute
type VNFS struct {
DHCP DHCP `json:"DHCP"`
GW GW `json:"GW"`
NAT NAT `json:"NAT"`
}
type NAT struct {
CKey string `json:"_ckey"`
AccountID uint64 `json:"accountId"`
CreatedTime uint64 `json:"createdTime"`
Devices Devices `json:"devices"`
GID uint64 `json:"gid"`
GUID uint64 `json:"guid"`
ID uint64 `json:"id"`
LockStatus string `json:"lockStatus"`
Milestones uint64 `json:"milestones"`
OwnerID uint64 `json:"ownerId"`
OwnerType string `json:"ownerType"`
PureVirtual bool `json:"pureVirtual"`
Status string `json:"status"`
TechStatus string `json:"techStatus"`
Type string `json:"type"`
}
type NATConfig struct {
NetMask uint64 `json:"netmask"`
Network string `json:"network"`
Rules []interface{} `json:"rules"`
}
type GW struct {
CKey string `json:"_ckey"`
AccountID uint64 `json:"accountId"`
Config GWConfig `json:"config"`
CreatedTime uint64 `json:"createdTime"`
Devices Devices `json:"devices"`
GID uint64 `json:"gid"`
GUID uint64 `json:"guid"`
ID uint64 `json:"id"`
LockStatus string `json:"lockStatus"`
Milestones uint64 `json:"milestones"`
OwnerID uint64 `json:"ownerId"`
OwnerType string `json:"ownerType"`
PureVirtual bool `json:"pureVirtual"`
Status string `json:"status"`
TechStatus string `json:"techStatus"`
Type string `json:"type"`
}
type GWConfig struct {
DefaultGW string `json:"default_gw"`
ExtNetID uint64 `json:"ext_net_id"`
ExtNetIP string `json:"ext_net_ip"`
ExtNetMask uint64 `json:"ext_netmask"`
QOS QOS `json:"qos"`
}
type Devices struct {
Primary DevicePrimary `json:"primary"`
}
type DevicePrimary struct {
DevID uint64 `json:"devId"`
IFace01 string `json:"iface01"`
IFace02 string `json:"iface02"`
}
type DHCP struct {
CKey string `json:"_ckey"`
AccountID uint64 `json:"accountId"`
Config DHCPConfig `json:"config"`
CreatedTime uint64 `json:"createdTime"`
Devices Devices `json:"devices"`
GID uint64 `json:"gid"`
GUID uint64 `json:"guid"`
ID uint64 `json:"id"`
LockStatus string `json:"lockStatus"`
Milestones uint64 `json:"milestones"`
OwnerID uint64 `json:"ownerId"`
OwnerType string `json:"ownerType"`
PureVirtual bool `json:"pureVirtual"`
Status string `json:"status"`
TechStatus string `json:"techStatus"`
Type string `json:"type"`
}
type DHCPConfig struct {
DefaultGW string `json:"default_gw"`
DNS []string `json:"dns"`
IPEnd string `json:"ip_end"`
IPStart string `json:"ip_start"`
Lease uint64 `json:"lease"`
Netmask uint64 `json:"netmask"`
Network string `json:"network"`
Reservations ReservationList `json:"reservations"`
}
type VINSDetailed struct {
VNFDev VNFDev `json:"VNFDev"`
CKey string `json:"_ckey"`
AccountID uint64 `json:"accountId"`
AccountName string `json:"accountName"`
Computes VINSComputeList `json:"computes"`
DefaultGW string `json:"defaultGW"`
DefaultQOS QOS `json:"defaultQos"`
Description string `json:"desc"`
GID uint64 `json:"gid"`
GUID uint64 `json:"guid"`
ID uint64 `json:"id"`
LockStatus string `json:"lockStatus"`
ManagerID uint64 `json:"managerId"`
ManagerType string `json:"managerType"`
Milestones uint64 `json:"milestones"`
Name string `json:"name"`
NetMask uint64 `json:"netMask"`
Network string `json:"network"`
PreReservaionsNum uint64 `json:"preReservationsNum"`
Redundant bool `json:"redundant"`
RGID uint64 `json:"rgId"`
RGName string `json:"rgName"`
SecVNFDevID uint64 `json:"secVnfDevId"`
Status string `json:"status"`
UserManaged bool `json:"userManaged"`
VNFS VNFS `json:"vnfs"`
VXLanID uint64 `json:"vxlanId"`
}
type Reservation struct {
ClientType string `json:"clientType"`
Description string `json:"desc"`
DomainName string `json:"domainname"`
HostName string `json:"hostname"`
IP string `json:"ip"`
MAC string `json:"mac"`
Type string `json:"type"`
VMID int `json:"vmId"`
}
type ReservationList []Reservation

View File

@@ -1,70 +1,59 @@
package vins
import (
"context"
"errors"
"strconv"
"github.com/rudecs/decort-sdk/opts"
"github.com/rudecs/decort-sdk/typed"
)
type NatRuleAddRequest struct {
VinsId uint64 `url:"vinsId"`
IntIP string `url:"intIp "`
IntPort uint `url:"intPort"`
ExtPortStart uint `url:"extPortStart"`
ExtPortEnd uint `url:"extPortEnd,omitempty"`
Proto string `url:"proto"`
}
func (vrq NatRuleAddRequest) Validate() error {
if vrq.VinsId == 0 {
return errors.New("validation-error: field VinsId can not be empty or equal to 0")
}
if vrq.IntIP == "" {
return errors.New("validation-error: field IntIP can not be empty")
}
if vrq.IntPort == 0 {
return errors.New("validation-error: field IntPort can not be empty or equal to 0")
}
if vrq.ExtPortStart == 0 {
return errors.New("validation-error: field ExtPortStart can not be empty or equal to 0")
}
return nil
}
func (v Vins) NatRuleAdd(ctx context.Context, req NatRuleAddRequest, options ...opts.DecortOpts) (bool, error) {
err := req.Validate()
if err != nil {
return false, err
}
url := "/vins/natRuleAdd"
prefix := "/cloudapi"
option := opts.New(options)
if option != nil {
if option.IsAdmin {
prefix = "/" + option.AdminValue
}
}
url = prefix + url
res, err := v.client.DecortApiCall(ctx, typed.POST, url, req)
if err != nil {
return false, err
}
result, err := strconv.ParseBool(string(res))
if err != nil {
return false, nil
}
return result, nil
}
package vins
import (
"context"
"errors"
"net/http"
"strconv"
)
type NatRuleAddRequest struct {
VINSID uint64 `url:"vinsId"`
IntIP string `url:"intIp "`
IntPort uint `url:"intPort"`
ExtPortStart uint `url:"extPortStart"`
ExtPortEnd uint `url:"extPortEnd,omitempty"`
Proto string `url:"proto"`
}
func (vrq NatRuleAddRequest) Validate() error {
if vrq.VINSID == 0 {
return errors.New("validation-error: field VINSID can not be empty or equal to 0")
}
if vrq.IntIP == "" {
return errors.New("validation-error: field IntIP can not be empty")
}
if vrq.IntPort == 0 {
return errors.New("validation-error: field IntPort can not be empty or equal to 0")
}
if vrq.ExtPortStart == 0 {
return errors.New("validation-error: field ExtPortStart can not be empty or equal to 0")
}
return nil
}
func (v VINS) NatRuleAdd(ctx context.Context, req NatRuleAddRequest) (bool, error) {
err := req.Validate()
if err != nil {
return false, err
}
url := "/cloudapi/vins/natRuleAdd"
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return false, err
}
result, err := strconv.ParseBool(string(res))
if err != nil {
return false, err
}
return result, nil
}

View File

@@ -1,58 +1,47 @@
package vins
import (
"context"
"errors"
"strconv"
"github.com/rudecs/decort-sdk/opts"
"github.com/rudecs/decort-sdk/typed"
)
type NatRuleDelRequest struct {
VinsId uint64 `url:"vinsId"`
RuleId uint64 `url:"ruleId"`
}
func (vrq NatRuleDelRequest) Validate() error {
if vrq.VinsId == 0 {
return errors.New("validation-error: field VinsId can not be empty or equal to 0")
}
if vrq.RuleId == 0 {
return errors.New("validation-error: field RuleId can not be empty or equal to 0")
}
return nil
}
func (v Vins) NatRuleDel(ctx context.Context, req NatRuleDelRequest, options ...opts.DecortOpts) (bool, error) {
err := req.Validate()
if err != nil {
return false, err
}
url := "/vins/natRuleDel"
prefix := "/cloudapi"
option := opts.New(options)
if option != nil {
if option.IsAdmin {
prefix = "/" + option.AdminValue
}
}
url = prefix + url
res, err := v.client.DecortApiCall(ctx, typed.POST, url, req)
if err != nil {
return false, err
}
result, err := strconv.ParseBool(string(res))
if err != nil {
return false, nil
}
return result, nil
}
package vins
import (
"context"
"errors"
"net/http"
"strconv"
)
type NatRuleDelRequest struct {
VINSID uint64 `url:"vinsId"`
RuleID uint64 `url:"ruleId"`
}
func (vrq NatRuleDelRequest) Validate() error {
if vrq.VINSID == 0 {
return errors.New("validation-error: field VINSID can not be empty or equal to 0")
}
if vrq.RuleID == 0 {
return errors.New("validation-error: field RuleID can not be empty or equal to 0")
}
return nil
}
func (v VINS) NatRuleDel(ctx context.Context, req NatRuleDelRequest) (bool, error) {
err := req.Validate()
if err != nil {
return false, err
}
url := "/cloudapi/vins/natRuleDel"
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return false, err
}
result, err := strconv.ParseBool(string(res))
if err != nil {
return false, err
}
return result, nil
}

View File

@@ -1,47 +1,36 @@
package vins
import (
"context"
"errors"
"github.com/rudecs/decort-sdk/opts"
"github.com/rudecs/decort-sdk/typed"
)
type NatRuleListRequest struct {
VinsId uint64 `url:"vinsId"`
}
func (vrq NatRuleListRequest) Validate() error {
if vrq.VinsId == 0 {
return errors.New("validation-error: field VinsId can not be empty or equal to 0")
}
return nil
}
func (v Vins) NatRuleList(ctx context.Context, req NatRuleListRequest, options ...opts.DecortOpts) (string, error) {
err := req.Validate()
if err != nil {
return "", err
}
url := "/vins/natRuleList"
prefix := "/cloudapi"
option := opts.New(options)
if option != nil {
if option.IsAdmin {
prefix = "/" + option.AdminValue
}
}
url = prefix + url
res, err := v.client.DecortApiCall(ctx, typed.POST, url, req)
if err != nil {
return "", err
}
return string(res), nil
}
package vins
import (
"context"
"errors"
"net/http"
)
type NatRuleListRequest struct {
VINSID uint64 `url:"vinsId"`
}
func (vrq NatRuleListRequest) Validate() error {
if vrq.VINSID == 0 {
return errors.New("validation-error: field VINSID can not be empty or equal to 0")
}
return nil
}
func (v VINS) NatRuleList(ctx context.Context, req NatRuleListRequest) (string, error) {
err := req.Validate()
if err != nil {
return "", err
}
url := "/cloudapi/vins/natRuleList"
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return "", err
}
return string(res), nil
}

View File

@@ -1,53 +1,42 @@
package vins
import (
"context"
"errors"
"strconv"
"github.com/rudecs/decort-sdk/opts"
"github.com/rudecs/decort-sdk/typed"
)
type RestoreRequest struct {
VinsId uint64 `url:"vinsId"`
}
func (vrq RestoreRequest) Validate() error {
if vrq.VinsId == 0 {
return errors.New("validation-error: field VinsId can not be empty or equal to 0")
}
return nil
}
func (v Vins) Restore(ctx context.Context, req RestoreRequest, options ...opts.DecortOpts) (bool, error) {
err := req.Validate()
if err != nil {
return false, err
}
url := "/vins/restore"
prefix := "/cloudapi"
option := opts.New(options)
if option != nil {
if option.IsAdmin {
prefix = "/" + option.AdminValue
}
}
url = prefix + url
res, err := v.client.DecortApiCall(ctx, typed.POST, url, req)
if err != nil {
return false, err
}
result, err := strconv.ParseBool(string(res))
if err != nil {
return false, nil
}
return result, nil
}
package vins
import (
"context"
"errors"
"net/http"
"strconv"
)
type RestoreRequest struct {
VINSID uint64 `url:"vinsId"`
}
func (vrq RestoreRequest) Validate() error {
if vrq.VINSID == 0 {
return errors.New("validation-error: field VINSID can not be empty or equal to 0")
}
return nil
}
func (v VINS) Restore(ctx context.Context, req RestoreRequest) (bool, error) {
err := req.Validate()
if err != nil {
return false, err
}
url := "/cloudapi/vins/restore"
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return false, err
}
result, err := strconv.ParseBool(string(res))
if err != nil {
return false, err
}
return result, nil
}

View File

@@ -1,43 +1,32 @@
package vins
import (
"context"
"encoding/json"
"github.com/rudecs/decort-sdk/opts"
"github.com/rudecs/decort-sdk/typed"
)
type SearchRequest struct {
AccountId uint64 `url:"accountId,omitempty"`
RGID uint64 `url:"rgId,omitempty"`
Name string `url:"name,omitempty"`
ShowAll bool `url:"show_all,omitempty"`
}
func (v Vins) Search(ctx context.Context, req SearchRequest, options ...opts.DecortOpts) (VinsList, error) {
url := "/vins/search"
prefix := "/cloudapi"
option := opts.New(options)
if option != nil {
if option.IsAdmin {
prefix = "/" + option.AdminValue
}
}
url = prefix + url
vinsListRaw, err := v.client.DecortApiCall(ctx, typed.POST, url, req)
if err != nil {
return nil, err
}
vinsList := VinsList{}
err = json.Unmarshal(vinsListRaw, &vinsList)
if err != nil {
return nil, err
}
return vinsList, nil
}
package vins
import (
"context"
"encoding/json"
"net/http"
)
type SearchRequest struct {
AccountID uint64 `url:"accountId,omitempty"`
RGID uint64 `url:"rgId,omitempty"`
Name string `url:"name,omitempty"`
ShowAll bool `url:"show_all,omitempty"`
}
func (v VINS) Search(ctx context.Context, req SearchRequest) (VINSList, error) {
url := "/cloudapi/vins/search"
VINSListRaw, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return nil, err
}
VINSList := VINSList{}
err = json.Unmarshal(VINSListRaw, &VINSList)
if err != nil {
return nil, err
}
return VINSList, nil
}

View File

@@ -1,15 +1,15 @@
package vins
import (
"github.com/rudecs/decort-sdk/interfaces"
)
type Vins struct {
client interfaces.Caller
}
func New(client interfaces.Caller) *Vins {
return &Vins{
client,
}
}
package vins
import (
"github.com/rudecs/decort-sdk/interfaces"
)
type VINS struct {
client interfaces.Caller
}
func New(client interfaces.Caller) *VINS {
return &VINS{
client,
}
}

View File

@@ -1,53 +1,42 @@
package vins
import (
"context"
"errors"
"strconv"
"github.com/rudecs/decort-sdk/opts"
"github.com/rudecs/decort-sdk/typed"
)
type VnfdevRedeployRequest struct {
VinsId uint64 `url:"vinsId"`
}
func (vrq VnfdevRedeployRequest) Validate() error {
if vrq.VinsId == 0 {
return errors.New("validation-error: field VinsId can not be empty or equal to 0")
}
return nil
}
func (v Vins) VnfdevRedeploy(ctx context.Context, req VnfdevRedeployRequest, options ...opts.DecortOpts) (bool, error) {
err := req.Validate()
if err != nil {
return false, err
}
url := "/vins/vnfdevRedeploy"
prefix := "/cloudapi"
option := opts.New(options)
if option != nil {
if option.IsAdmin {
prefix = "/" + option.AdminValue
}
}
url = prefix + url
res, err := v.client.DecortApiCall(ctx, typed.POST, url, req)
if err != nil {
return false, err
}
result, err := strconv.ParseBool(string(res))
if err != nil {
return false, nil
}
return result, nil
}
package vins
import (
"context"
"errors"
"net/http"
"strconv"
)
type VNFDevRedeployRequest struct {
VINSID uint64 `url:"vinsId"`
}
func (vrq VNFDevRedeployRequest) Validate() error {
if vrq.VINSID == 0 {
return errors.New("validation-error: field VINSID can not be empty or equal to 0")
}
return nil
}
func (v VINS) VNFDevRedeploy(ctx context.Context, req VNFDevRedeployRequest) (bool, error) {
err := req.Validate()
if err != nil {
return false, err
}
url := "/cloudapi/vins/vnfdevRedeploy"
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return false, err
}
result, err := strconv.ParseBool(string(res))
if err != nil {
return false, err
}
return result, nil
}

View File

@@ -1,53 +1,42 @@
package vins
import (
"context"
"errors"
"strconv"
"github.com/rudecs/decort-sdk/opts"
"github.com/rudecs/decort-sdk/typed"
)
type VnfdevRestartRequest struct {
VinsId uint64 `url:"vinsId"`
}
func (vrq VnfdevRestartRequest) Validate() error {
if vrq.VinsId == 0 {
return errors.New("validation-error: field VinsId can not be empty or equal to 0")
}
return nil
}
func (v Vins) VnfdevRestart(ctx context.Context, req VnfdevRestartRequest, options ...opts.DecortOpts) (bool, error) {
err := req.Validate()
if err != nil {
return false, err
}
url := "/vins/vnfdevRestart"
prefix := "/cloudapi"
option := opts.New(options)
if option != nil {
if option.IsAdmin {
prefix = "/" + option.AdminValue
}
}
url = prefix + url
res, err := v.client.DecortApiCall(ctx, typed.POST, url, req)
if err != nil {
return false, err
}
result, err := strconv.ParseBool(string(res))
if err != nil {
return false, nil
}
return result, nil
}
package vins
import (
"context"
"errors"
"net/http"
"strconv"
)
type VNFDevRestartRequest struct {
VINSID uint64 `url:"vinsId"`
}
func (vrq VNFDevRestartRequest) Validate() error {
if vrq.VINSID == 0 {
return errors.New("validation-error: field VINSID can not be empty or equal to 0")
}
return nil
}
func (v VINS) VNFDevRestart(ctx context.Context, req VNFDevRestartRequest) (bool, error) {
err := req.Validate()
if err != nil {
return false, err
}
url := "/cloudapi/vins/vnfdevRestart"
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return false, err
}
result, err := strconv.ParseBool(string(res))
if err != nil {
return false, err
}
return result, nil
}