v1.16.4
v1.16.4
This commit is contained in:
@@ -2,8 +2,8 @@ package apiaccess
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
@@ -20,23 +20,25 @@ type DescUpdateRequest struct {
|
||||
}
|
||||
|
||||
// DescUpdate sets a new text description of the apiaccess group.
|
||||
func (a APIAccess) DescUpdate(ctx context.Context, req DescUpdateRequest) (bool, error) {
|
||||
func (a APIAccess) DescUpdate(ctx context.Context, req DescUpdateRequest) (*ItemAPIAccess, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/apiaccess/descUpdate"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
info := ItemAPIAccess{}
|
||||
|
||||
err = json.Unmarshal(res, &info)
|
||||
if err != nil {
|
||||
return false, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
return &info, nil
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package apiaccess
|
||||
|
||||
import "encoding/json"
|
||||
|
||||
type ItemAPIAccess struct {
|
||||
// APIs
|
||||
APIs APIsEndpoints `json:"apis"`
|
||||
@@ -88,43 +90,74 @@ type APIsEndpoints struct {
|
||||
// CloudBroker endpoints
|
||||
CloudBroker CloudBrokerEndpoints `json:"cloudbroker,omitempty"`
|
||||
|
||||
// LibCloud endpoints
|
||||
LibCloud LibCloudEndpoints `json:"libcloud,omitempty"`
|
||||
// SDN endpoints
|
||||
SDN SDNEndpoints `json:"sdn,omitempty"`
|
||||
|
||||
// System endpoints
|
||||
System SystemEndpoints `json:"system,omitempty"`
|
||||
}
|
||||
|
||||
// MarshalJSON omits empty namespaces, so that "{}" is not sent in requests.
|
||||
func (a APIsEndpoints) MarshalJSON() ([]byte, error) {
|
||||
namespaces := []struct {
|
||||
key string
|
||||
value interface{}
|
||||
}{
|
||||
{"cloudapi", a.CloudAPI},
|
||||
{"cloudbroker", a.CloudBroker},
|
||||
{"sdn", a.SDN},
|
||||
{"system", a.System},
|
||||
}
|
||||
|
||||
result := make(map[string]json.RawMessage, len(namespaces))
|
||||
|
||||
for _, ns := range namespaces {
|
||||
data, err := json.Marshal(ns.value)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if string(data) == "{}" {
|
||||
continue
|
||||
}
|
||||
|
||||
result[ns.key] = data
|
||||
}
|
||||
|
||||
return json.Marshal(result)
|
||||
}
|
||||
|
||||
type CloudAPIEndpoints struct {
|
||||
Account []string `json:"account,omitempty"`
|
||||
BService []string `json:"bservice,omitempty"`
|
||||
CloudSpace []string `json:"cloudspace,omitempty"`
|
||||
Compute []string `json:"compute,omitempty"`
|
||||
ComputeCI []string `json:"computeci,omitempty"`
|
||||
Disks []string `json:"disks,omitempty"`
|
||||
DPDK []string `json:"dpdk,omitempty"`
|
||||
ExtNet []string `json:"extnet,omitempty"`
|
||||
FLIPGroup []string `json:"flipgroup,omitempty"`
|
||||
GPU []string `json:"gpu,omitempty"`
|
||||
Image []string `json:"image,omitempty"`
|
||||
K8CI []string `json:"k8ci,omitempty"`
|
||||
K8S []string `json:"k8s,omitempty"`
|
||||
KVMX86 []string `json:"kvmx86,omitempty"`
|
||||
LB []string `json:"lb,omitempty"`
|
||||
Loactions []string `json:"locations,omitempty"`
|
||||
Machine []string `json:"machine,omitempty"`
|
||||
Openshift []string `json:"openshift,omitempty"`
|
||||
OpenshiftCI []string `json:"openshiftci,omitempty"`
|
||||
PCIDevice []string `json:"pcidevice,omitempty"`
|
||||
PortForwarding []string `json:"portforwarding,omitempty"`
|
||||
Prometheus []string `json:"prometheus,omitempty"`
|
||||
RG []string `json:"rg,omitempty"`
|
||||
Sizes []string `json:"sizes,omitempty"`
|
||||
Tasks []string `json:"tasks,omitempty"`
|
||||
User []string `json:"user,omitempty"`
|
||||
VGPU []string `json:"vgpu,omitempty"`
|
||||
VINS []string `json:"vins,omitempty"`
|
||||
All bool `json:"ALL,omitempty"`
|
||||
Account []string `json:"account,omitempty"`
|
||||
Audit []string `json:"audit,omitempty"`
|
||||
BService []string `json:"bservice,omitempty"`
|
||||
Compute []string `json:"compute,omitempty"`
|
||||
Disks []string `json:"disks,omitempty"`
|
||||
DPDKNet []string `json:"dpdknet,omitempty"`
|
||||
ExtNet []string `json:"extnet,omitempty"`
|
||||
FLIPGroup []string `json:"flipgroup,omitempty"`
|
||||
GPU []string `json:"gpu,omitempty"`
|
||||
Image []string `json:"image,omitempty"`
|
||||
K8CI []string `json:"k8ci,omitempty"`
|
||||
K8S []string `json:"k8s,omitempty"`
|
||||
KVMX86 []string `json:"kvmx86,omitempty"`
|
||||
LB []string `json:"lb,omitempty"`
|
||||
Loactions []string `json:"locations,omitempty"`
|
||||
PCIDevice []string `json:"pcidevice,omitempty"`
|
||||
Prometheus []string `json:"prometheus,omitempty"`
|
||||
RG []string `json:"rg,omitempty"`
|
||||
SecurityGroup []string `json:"security_group,omitempty"`
|
||||
SEP []string `json:"sep,omitempty"`
|
||||
StoragePolicy []string `json:"storage_policy,omitempty"`
|
||||
Tasks []string `json:"tasks,omitempty"`
|
||||
Trunk []string `json:"trunk,omitempty"`
|
||||
User []string `json:"user,omitempty"`
|
||||
VFPool []string `json:"vfpool,omitempty"`
|
||||
VGPU []string `json:"vgpu,omitempty"`
|
||||
VINS []string `json:"vins,omitempty"`
|
||||
VMFolder []string `json:"vmfolder,omitempty"`
|
||||
Zone []string `json:"zone,omitempty"`
|
||||
All bool `json:"ALL,omitempty"`
|
||||
}
|
||||
|
||||
type CloudBrokerEndpoints struct {
|
||||
@@ -133,74 +166,85 @@ type CloudBrokerEndpoints struct {
|
||||
Audit interface{} `json:"audit,omitempty"`
|
||||
AuditBeat []string `json:"auditbeat,omitempty"`
|
||||
AuditCollector []string `json:"auditcollector,omitempty"`
|
||||
Backup []string `json:"backup,omitempty"`
|
||||
BackupCreator []string `json:"backupcreator,omitempty"`
|
||||
BService []string `json:"bservice,omitempty"`
|
||||
CloudSpace []string `json:"cloudspace,omitempty"`
|
||||
Compute []string `json:"compute,omitempty"`
|
||||
ComputeCI []string `json:"computeci,omitempty"`
|
||||
Desnode []string `json:"desnode,omitempty"`
|
||||
Diagnostics []string `json:"diagnostics,omitempty"`
|
||||
Disks []string `json:"disks,omitempty"`
|
||||
DPDK []string `json:"dpdk,omitempty"`
|
||||
DPDKNet []string `json:"dpdknet,omitempty"`
|
||||
Eco []string `json:"eco,omitempty"`
|
||||
ExtNet []string `json:"extnet,omitempty"`
|
||||
FlIPgroup []string `json:"flipgroup,omitempty"`
|
||||
Grid []string `json:"grid,omitempty"`
|
||||
Group []string `json:"group,omitempty"`
|
||||
Health []string `json:"health,omitempty"`
|
||||
IaaS []string `json:"iaas,omitempty"`
|
||||
Image []string `json:"image,omitempty"`
|
||||
Job interface{} `json:"job,omitempty"`
|
||||
K8CI []string `json:"k8ci,omitempty"`
|
||||
K8S []string `json:"k8s,omitempty"`
|
||||
KVMX86 []string `json:"kvmx86,omitempty"`
|
||||
LB []string `json:"lb,omitempty"`
|
||||
Machine []string `json:"machine,omitempty"`
|
||||
Metering []string `json:"metering,omitempty"`
|
||||
Milestones []string `json:"milestones,omitempty"`
|
||||
Openshift []string `json:"openshift,omitempty"`
|
||||
OpenshiftCI []string `json:"openshiftci,omitempty"`
|
||||
Ovsnode []string `json:"ovsnode,omitempty"`
|
||||
Node []string `json:"node,omitempty"`
|
||||
PCIDevice []string `json:"pcidevice,omitempty"`
|
||||
PGPU []string `json:"pgpu,omitempty"`
|
||||
Prometheus []string `json:"prometheus,omitempty"`
|
||||
QOS []string `json:"qos,omitempty"`
|
||||
Resmon interface{} `json:"resmon,omitempty"`
|
||||
RG []string `json:"rg,omitempty"`
|
||||
SecurityGroup []string `json:"security_group,omitempty"`
|
||||
Sep []string `json:"sep,omitempty"`
|
||||
Node []string `json:"node,omitempty"`
|
||||
StoragePolicy []string `json:"storage_policy,omitempty"`
|
||||
Tasks []string `json:"tasks,omitempty"`
|
||||
TLock []string `json:"tlock,omitempty"`
|
||||
Trunk []string `json:"trunk,omitempty"`
|
||||
User []string `json:"user,omitempty"`
|
||||
VFPool []string `json:"vfpool,omitempty"`
|
||||
VGPU []string `json:"vgpu,omitempty"`
|
||||
VINS []string `json:"vins,omitempty"`
|
||||
VMFolder []string `json:"vmfolder,omitempty"`
|
||||
VNFDev []string `json:"vnfdev,omitempty"`
|
||||
ZeroAccess []string `json:"zeroaccess,omitempty"`
|
||||
Zone []string `json:"zone,omitempty"`
|
||||
All bool `json:"ALL,omitempty"`
|
||||
}
|
||||
|
||||
type LibCloudEndpoints struct {
|
||||
Libvirt []string `json:"libvirt,omitempty"`
|
||||
All bool `json:"ALL,omitempty"`
|
||||
type SDNEndpoints struct {
|
||||
AccessGroup []string `json:"access_group,omitempty"`
|
||||
AddressPool []string `json:"address_pool,omitempty"`
|
||||
DefaultSecurityPolicy []string `json:"default_security_policy,omitempty"`
|
||||
ExternalNetwork []string `json:"external_network,omitempty"`
|
||||
FloatingIP []string `json:"floating_ip,omitempty"`
|
||||
Hypervisor []string `json:"hypervisor,omitempty"`
|
||||
L2ExternalNetwork []string `json:"l2_external_network,omitempty"`
|
||||
LogicalPort []string `json:"logical_port,omitempty"`
|
||||
NetworkObjectGroup []string `json:"network_object_group,omitempty"`
|
||||
Router []string `json:"router,omitempty"`
|
||||
RouterGatewayPort []string `json:"router/gateway_port,omitempty"`
|
||||
RouterPolicies []string `json:"router/policies,omitempty"`
|
||||
RouterRouterPort []string `json:"router/router_port,omitempty"`
|
||||
RouterStaticRoute []string `json:"router/static_route,omitempty"`
|
||||
SecurityPolicy []string `json:"security_policy,omitempty"`
|
||||
SecurityPolicyRule []string `json:"security_policy/rule,omitempty"`
|
||||
SecurityRule []string `json:"security_rule,omitempty"`
|
||||
Segment []string `json:"segment,omitempty"`
|
||||
Version []string `json:"version,omitempty"`
|
||||
All bool `json:"ALL,omitempty"`
|
||||
}
|
||||
|
||||
type SystemEndpoints struct {
|
||||
AgentController []string `json:"agentcontroller,omitempty"`
|
||||
Alerts []string `json:"alerts,omitempty"`
|
||||
Audits []string `json:"audits,omitempty"`
|
||||
ContentManager []string `json:"contentmanager,omitempty"`
|
||||
DocGenerator []string `json:"docgenerator,omitempty"`
|
||||
EmailSender []string `json:"emailsender,omitempty"`
|
||||
ErrorConditionHandler []string `json:"errorconditionhandler,omitempty"`
|
||||
GridManager []string `json:"gridmanager,omitempty"`
|
||||
Health []string `json:"health,omitempty"`
|
||||
Info []string `json:"info,omitempty"`
|
||||
InfoMGR []string `json:"infomgr,omitempty"`
|
||||
Job []string `json:"job,omitempty"`
|
||||
Log []string `json:"log,omitempty"`
|
||||
Logo []string `json:"logo,omitempty"`
|
||||
Oauth []string `json:"oauth,omitempty"`
|
||||
Task []string `json:"task,omitempty"`
|
||||
UserManager []string `json:"usermanager,omitempty"`
|
||||
All bool `json:"ALL,omitempty"`
|
||||
Audits []string `json:"audits,omitempty"`
|
||||
Cache []string `json:"cache,omitempty"`
|
||||
ContentManager []string `json:"contentmanager,omitempty"`
|
||||
DocGenerator []string `json:"docgenerator,omitempty"`
|
||||
EmailSender []string `json:"emailsender,omitempty"`
|
||||
GridManager []string `json:"gridmanager,omitempty"`
|
||||
Health []string `json:"health,omitempty"`
|
||||
Info []string `json:"info,omitempty"`
|
||||
InfoWellknown []string `json:"info/wellknown,omitempty"`
|
||||
InfoMGR []string `json:"infomgr,omitempty"`
|
||||
Oauth []string `json:"oauth,omitempty"`
|
||||
Task []string `json:"task,omitempty"`
|
||||
UserManager []string `json:"usermanager,omitempty"`
|
||||
All bool `json:"ALL,omitempty"`
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
@@ -27,10 +26,10 @@ type wrapperUpdateRequest struct {
|
||||
}
|
||||
|
||||
// Update updates apis of apiaccess group.
|
||||
func (a APIAccess) Update(ctx context.Context, req UpdateRequest) (bool, error) {
|
||||
func (a APIAccess) Update(ctx context.Context, req UpdateRequest) (*ItemAPIAccess, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/apiaccess/update"
|
||||
@@ -41,20 +40,22 @@ func (a APIAccess) Update(ctx context.Context, req UpdateRequest) (bool, error)
|
||||
|
||||
apiJSON, err := json.Marshal(&req.APIs)
|
||||
if err != nil {
|
||||
return false, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
reqWrapped.APIString = string(apiJSON)
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return false, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
info := ItemAPIAccess{}
|
||||
|
||||
err = json.Unmarshal(res, &info)
|
||||
if err != nil {
|
||||
return false, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
return &info, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user