v1.16.1
This commit is contained in:
dayterr
2026-08-28 16:36:41 +03:00
parent eb195dd992
commit b3fccfb000
131 changed files with 3204 additions and 478 deletions

View File

@@ -0,0 +1,38 @@
package pcidevice
import (
"context"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// AccessGrant struct to grant access to a PCI device
type AccessGrantRequest struct {
DeviceID uint64 `url:"device_id" json:"device_id" validate:"required"`
AccountIDs []uint64 `url:"account_ids" json:"account_ids" validate:"required"`
}
// AccessGrant grants access to a PCI device
func (p PCIDevice) AccessGrant(ctx context.Context, req AccessGrantRequest) (bool, error) {
err := validators.ValidateRequest(req)
if err != nil {
return false, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/pcidevice/access_grant"
res, err := p.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
if err != nil {
return false, err
}
result, err := strconv.ParseBool(string(res))
if err != nil {
return false, err
}
return result, nil
}

View File

@@ -0,0 +1,38 @@
package pcidevice
import (
"context"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// AccessRevoke struct to revoke access from a PCI device
type AccessRevokeRequest struct {
DeviceID uint64 `url:"device_id" json:"device_id" validate:"required"`
AccountIDs []uint64 `url:"account_ids" json:"account_ids" validate:"required"`
}
// AccessRevoke revokes access from a PCI device
func (p PCIDevice) AccessRevoke(ctx context.Context, req AccessRevokeRequest) (bool, error) {
err := validators.ValidateRequest(req)
if err != nil {
return false, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/pcidevice/access_revoke"
res, err := p.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
if err != nil {
return false, err
}
result, err := strconv.ParseBool(string(res))
if err != nil {
return false, err
}
return result, nil
}

View File

@@ -5,6 +5,7 @@ import (
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
@@ -14,10 +15,6 @@ type CreateRequest struct {
// Required: true
NodeID uint64 `url:"node_id" json:"node_id" validate:"required"`
// Resource group ID
// Required: true
RGID uint64 `url:"rgId" json:"rgId" validate:"required"`
// Name of device
// Required: true
Name string `url:"name" json:"name" validate:"required"`
@@ -30,6 +27,10 @@ type CreateRequest struct {
// Description, just for information
// Required: false
Description string `url:"description,omitempty" json:"description,omitempty"`
// Account IDs
// Required: false
AccountIDs []uint64 `url:"account_ids,omitempty" json:"account_ids,omitempty"`
}
// Create creates PCI Device
@@ -41,7 +42,7 @@ func (p PCIDevice) Create(ctx context.Context, req CreateRequest) (uint64, error
url := "/cloudbroker/pcidevice/create"
res, err := p.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := p.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
if err != nil {
return 0, err
}

View File

@@ -22,9 +22,9 @@ type ListRequest struct {
// Required: false
Name string `url:"name,omitempty" json:"name,omitempty"`
// Find by rgId
// Find by account ID
// Required: false
RGID uint64 `url:"rgId,omitempty" json:"rgId,omitempty"`
AccountID uint64 `url:"account_id,omitempty" json:"account_id,omitempty"`
// Find by status
// Required: false

View File

@@ -26,8 +26,8 @@ type ItemPCIDevice struct {
// Name
Name string `json:"name"`
// Resource group ID
RGID uint64 `json:"rgId"`
// Account IDs
AccountIDs []uint64 `json:"account_ids"`
// Node ID
NodeID uint64 `json:"nodeId"`