251 lines
8.2 KiB
Go
251 lines
8.2 KiB
Go
package apiaccess
|
|
|
|
import "encoding/json"
|
|
|
|
type ItemAPIAccess struct {
|
|
// APIs
|
|
APIs APIsEndpoints `json:"apis"`
|
|
|
|
CreatedTime uint64 `json:"created_at"`
|
|
|
|
// Is default
|
|
Default bool `json:"default"`
|
|
|
|
// Deleted time
|
|
DeletedTime uint64 `json:"deleted_at"`
|
|
|
|
// Description
|
|
Description string `json:"desc"`
|
|
|
|
// GID
|
|
GID uint64 `json:"gid"`
|
|
|
|
// GUID
|
|
GUID uint64 `json:"guid"`
|
|
|
|
// ID
|
|
ID uint64 `json:"id"`
|
|
|
|
// Name
|
|
Name string `json:"name"`
|
|
|
|
// Is protected
|
|
Protected bool `json:"protected"`
|
|
|
|
// Status
|
|
Status string `json:"status"`
|
|
|
|
// Updated time
|
|
UpdatedTime uint64 `json:"updated_at"`
|
|
}
|
|
|
|
type ItemAPIAccessDefault struct {
|
|
// APIs
|
|
APIs APIsEndpoints `json:"apis"`
|
|
|
|
// Created at
|
|
CreatedAt uint64 `json:"created_at"`
|
|
|
|
// Is default
|
|
Default bool `json:"default"`
|
|
|
|
// Deleted at
|
|
DeletedAt uint64 `json:"deleted_at"`
|
|
|
|
// Description
|
|
Description string `json:"decs"`
|
|
|
|
// GID
|
|
GID uint64 `json:"gid"`
|
|
|
|
// GUID
|
|
GUID uint64 `json:"guid"`
|
|
|
|
// ID
|
|
ID uint64 `json:"id"`
|
|
|
|
// Name
|
|
Name string `json:"name"`
|
|
|
|
// Protected
|
|
Protected bool `json:"protected"`
|
|
|
|
// Status
|
|
Status string `json:"status"`
|
|
|
|
//Updated at
|
|
UpdatedAt uint64 `json:"updated_at"`
|
|
}
|
|
|
|
type ListAPIAccess struct {
|
|
Data []ItemAPIAccess `json:"data"`
|
|
|
|
EntryCount uint64 `json:"entryCount"`
|
|
}
|
|
|
|
type APIsEndpoints struct {
|
|
// CloudAPI endpoints
|
|
CloudAPI CloudAPIEndpoints `json:"cloudapi,omitempty"`
|
|
|
|
// CloudBroker endpoints
|
|
CloudBroker CloudBrokerEndpoints `json:"cloudbroker,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"`
|
|
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 {
|
|
Account []string `json:"account,omitempty"`
|
|
APIAccess []string `json:"apiaccess,omitempty"`
|
|
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"`
|
|
Compute []string `json:"compute,omitempty"`
|
|
Disks []string `json:"disks,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"`
|
|
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"`
|
|
Metering []string `json:"metering,omitempty"`
|
|
Milestones []string `json:"milestones,omitempty"`
|
|
Node []string `json:"node,omitempty"`
|
|
PCIDevice []string `json:"pcidevice,omitempty"`
|
|
PGPU []string `json:"pgpu,omitempty"`
|
|
Prometheus []string `json:"prometheus,omitempty"`
|
|
Resmon interface{} `json:"resmon,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"`
|
|
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 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 {
|
|
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"`
|
|
}
|