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,15 +1,15 @@
package extnet
import (
"github.com/rudecs/decort-sdk/interfaces"
)
type Extnet struct {
client interfaces.Caller
}
func New(client interfaces.Caller) *Extnet {
return &Extnet{
client,
}
}
package extnet
import (
"github.com/rudecs/decort-sdk/interfaces"
)
type ExtNet struct {
client interfaces.Caller
}
func New(client interfaces.Caller) *ExtNet {
return &ExtNet{
client,
}
}

View File

@@ -1,53 +1,42 @@
package extnet
import (
"context"
"encoding/json"
"errors"
"github.com/rudecs/decort-sdk/opts"
"github.com/rudecs/decort-sdk/typed"
)
type GetRequest struct {
NetId uint64 `url:"net_id"`
}
func (erq GetRequest) Validate() error {
if erq.NetId == 0 {
return errors.New("validation-error: field NetId can not be empty or equal to 0")
}
return nil
}
func (e Extnet) Get(ctx context.Context, req GetRequest, options ...opts.DecortOpts) (*ExtnetDetailed, error) {
err := req.Validate()
if err != nil {
return nil, err
}
url := "/extnet/get"
prefix := "/cloudapi"
option := opts.New(options)
if option != nil {
if option.IsAdmin {
prefix = "/" + option.AdminValue
}
}
url = prefix + url
extnetRaw, err := e.client.DecortApiCall(ctx, typed.POST, url, req)
if err != nil {
return nil, err
}
extnet := &ExtnetDetailed{}
err = json.Unmarshal(extnetRaw, &extnet)
if err != nil {
return nil, err
}
return extnet, nil
}
package extnet
import (
"context"
"encoding/json"
"errors"
"net/http"
)
type GetRequest struct {
NetID uint64 `url:"net_id"`
}
func (erq GetRequest) Validate() error {
if erq.NetID == 0 {
return errors.New("validation-error: field NetID can not be empty or equal to 0")
}
return nil
}
func (e ExtNet) Get(ctx context.Context, req GetRequest) (*ExtNetDetailed, error) {
err := req.Validate()
if err != nil {
return nil, err
}
url := "/cloudapi/extnet/get"
extnetRaw, err := e.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return nil, err
}
extnet := &ExtNetDetailed{}
err = json.Unmarshal(extnetRaw, &extnet)
if err != nil {
return nil, err
}
return extnet, nil
}

View File

@@ -1,35 +1,24 @@
package extnet
import (
"context"
"strconv"
"github.com/rudecs/decort-sdk/opts"
"github.com/rudecs/decort-sdk/typed"
)
func (e Extnet) GetDefault(ctx context.Context, options ...opts.DecortOpts) (uint64, error) {
url := "/extnet/getDefault"
prefix := "/cloudapi"
option := opts.New(options)
if option != nil {
if option.IsAdmin {
prefix = "/" + option.AdminValue
}
}
url = prefix + url
res, err := e.client.DecortApiCall(ctx, typed.POST, url, nil)
if err != nil {
return 0, err
}
result, err := strconv.ParseUint(string(res), 10, 64)
if err != nil {
return 0, err
}
return result, nil
}
package extnet
import (
"context"
"net/http"
"strconv"
)
func (e ExtNet) GetDefault(ctx context.Context) (uint64, error) {
url := "/cloudapi/extnet/getDefault"
res, err := e.client.DecortApiCall(ctx, http.MethodPost, url, nil)
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,42 +1,31 @@
package extnet
import (
"context"
"encoding/json"
"github.com/rudecs/decort-sdk/opts"
"github.com/rudecs/decort-sdk/typed"
)
type ListRequest struct {
AccountId uint64 `url:"accountId"`
Page uint64 `url:"page"`
Size uint64 `url:"size"`
}
func (e Extnet) List(ctx context.Context, req ListRequest, options ...opts.DecortOpts) (ExtnetList, error) {
url := "/extnet/list"
prefix := "/cloudapi"
option := opts.New(options)
if option != nil {
if option.IsAdmin {
prefix = "/" + option.AdminValue
}
}
url = prefix + url
extnetListRaw, err := e.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 extnet
import (
"context"
"encoding/json"
"net/http"
)
type ListRequest struct {
AccountID uint64 `url:"accountId"`
Page uint64 `url:"page"`
Size uint64 `url:"size"`
}
func (e ExtNet) List(ctx context.Context, req ListRequest) (ExtNetList, error) {
url := "/cloudapi/extnet/list"
extnetListRaw, err := e.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,49 +1,38 @@
package extnet
import (
"context"
"encoding/json"
"errors"
"github.com/rudecs/decort-sdk/opts"
"github.com/rudecs/decort-sdk/typed"
)
type ListComputesRequest struct {
AccountId uint64 `url:"accountId"`
}
func (erq ListComputesRequest) Validate() error {
if erq.AccountId == 0 {
return errors.New("validation-error: field AccountId can not be empty or equal to 0")
}
return nil
}
func (e Extnet) ListComputes(ctx context.Context, req ListComputesRequest, options ...opts.DecortOpts) (ExtnetComputesList, error) {
url := "/extnet/listComputes"
prefix := "/cloudapi"
option := opts.New(options)
if option != nil {
if option.IsAdmin {
prefix = "/" + option.AdminValue
}
}
url = prefix + url
extnetComputesListRaw, err := e.client.DecortApiCall(ctx, typed.POST, url, req)
if err != nil {
return nil, err
}
extnetComputesList := ExtnetComputesList{}
err = json.Unmarshal(extnetComputesListRaw, &extnetComputesList)
if err != nil {
return nil, err
}
return extnetComputesList, nil
}
package extnet
import (
"context"
"encoding/json"
"errors"
"net/http"
)
type ListComputesRequest struct {
AccountID uint64 `url:"accountId"`
}
func (erq ListComputesRequest) Validate() error {
if erq.AccountID == 0 {
return errors.New("validation-error: field AccountID can not be empty or equal to 0")
}
return nil
}
func (e ExtNet) ListComputes(ctx context.Context, req ListComputesRequest) (ExtNetComputesList, error) {
url := "/cloudapi/extnet/listComputes"
extnetComputesListRaw, err := e.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return nil, err
}
extnetComputesList := ExtNetComputesList{}
err = json.Unmarshal(extnetComputesListRaw, &extnetComputesList)
if err != nil {
return nil, err
}
return extnetComputesList, nil
}

View File

@@ -1,80 +1,80 @@
package extnet
type ExtnetRecord struct {
ID int `json:"id"`
IPCidr string `json:"ipcidr"`
Name string `json:"name"`
}
type ExtnetExtend struct {
ExtnetRecord
IPAddr string `json:"ipaddr"`
}
type ExtnetList []ExtnetRecord
type ExtnetExtendList []ExtnetExtend
type ExtnetComputes struct {
AccountId int `json:"accountId"`
AccountName string `json:"accountName"`
Extnets ExtnetExtendList `json:"extnets"`
ID int `json:"id"`
Name string `json:"name"`
RGID int `json:"rgId"`
RGName string `json:"rgName"`
}
type ExtnetComputesList []ExtnetComputes
type ExtnetQos struct {
ERate int `json:"eRate"`
GUID string `json:"guid"`
InBurst int `json:"inBurst"`
InRate int `json:"inRate"`
}
type ExtnetReservation 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 ExtnetReservations []ExtnetReservation
type ExtnetVNFS struct {
DHCP int `json:"dhcp"`
}
type ExtnetDetailed struct {
CKey string `json:"_ckey"`
Meta []interface{} `json:"_meta"`
CheckIPs []string `json:"checkIPs"`
CheckIps []string `json:"checkIps"`
Default bool `json:"default"`
DefaultQos ExtnetQos `json:"defaultQos"`
Description string `json:"desc"`
Dns []string `json:"dns"`
Excluded []string `json:"excluded"`
FreeIps int `json:"free_ips"`
Gateway string `json:"gateway"`
GID int `json:"gid"`
GUID int `json:"guid"`
ID int `json:"id"`
IPCidr string `json:"ipcidr"`
Milestones int `json:"milestones"`
Name string `json:"name"`
Network string `json:"network"`
NetworkId int `json:"networkId"`
PreReservationsNum int `json:"preReservationsNum"`
Prefix int `json:"prefix"`
PriVnfDevId int `json:"priVnfDevId"`
Reservations ExtnetReservations `json:"reservations"`
SharedWith []int `json:"sharedWith"`
Status string `json:"status"`
VlanID int `json:"vlanId"`
VNFS ExtnetVNFS `json:"vnfs"`
}
package extnet
type ExtNetRecord struct {
ID uint64 `json:"id"`
IPCidr string `json:"ipcidr"`
Name string `json:"name"`
}
type ExtNetExtend struct {
ExtNetRecord
IPAddr string `json:"ipaddr"`
}
type ExtNetList []ExtNetRecord
type ExtNetExtendList []ExtNetExtend
type ExtNetComputes struct {
AccountID uint64 `json:"accountId"`
AccountName string `json:"accountName"`
ExtNets ExtNetExtendList `json:"extnets"`
ID uint64 `json:"id"`
Name string `json:"name"`
RGID uint64 `json:"rgId"`
RGName string `json:"rgName"`
}
type ExtNetComputesList []ExtNetComputes
type ExtNetQos struct {
ERate uint64 `json:"eRate"`
GUID string `json:"guid"`
InBurst uint64 `json:"inBurst"`
InRate uint64 `json:"inRate"`
}
type ExtNetReservation 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 uint64 `json:"vmId"`
}
type ExtNetReservations []ExtNetReservation
type ExtNetVNFS struct {
DHCP uint64 `json:"dhcp"`
}
type ExtNetDetailed struct {
CKey string `json:"_ckey"`
Meta []interface{} `json:"_meta"`
CheckIPs []string `json:"checkIPs"`
CheckIps []string `json:"checkIps"`
Default bool `json:"default"`
DefaultQos ExtNetQos `json:"defaultQos"`
Description string `json:"desc"`
Dns []string `json:"dns"`
Excluded []string `json:"excluded"`
FreeIps uint64 `json:"free_ips"`
Gateway string `json:"gateway"`
GID uint64 `json:"gid"`
GUID uint64 `json:"guid"`
ID uint64 `json:"id"`
IPCidr string `json:"ipcidr"`
Milestones uint64 `json:"milestones"`
Name string `json:"name"`
Network string `json:"network"`
NetworkID uint64 `json:"networkId"`
PreReservationsNum uint64 `json:"preReservationsNum"`
Prefix uint64 `json:"prefix"`
PriVNFDevID uint64 `json:"priVnfDevId"`
Reservations ExtNetReservations `json:"reservations"`
SharedWith []uint64 `json:"sharedWith"`
Status string `json:"status"`
VlanID uint64 `json:"vlanId"`
VNFS ExtNetVNFS `json:"vnfs"`
}