v1.16.1
v1.16.1
This commit is contained in:
38
pkg/cloudbroker/pcidevice/access_grant.go
Normal file
38
pkg/cloudbroker/pcidevice/access_grant.go
Normal 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
|
||||
}
|
||||
38
pkg/cloudbroker/pcidevice/access_revoke.go
Normal file
38
pkg/cloudbroker/pcidevice/access_revoke.go
Normal 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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"`
|
||||
|
||||
Reference in New Issue
Block a user