Skip to content

Commit

Permalink
enable query orgs
Browse files Browse the repository at this point in the history
  • Loading branch information
Roman Hochuli committed Aug 25, 2023
1 parent ad7fd03 commit 0d5104b
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 0 deletions.
19 changes: 19 additions & 0 deletions govcd/filter_interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type (
QueryOrgVdc types.QueryResultOrgVdcRecordType
QueryTask types.QueryResultTaskRecordType
QueryAdminTask types.QueryResultTaskRecordType
QueryOrg types.QueryResultOrgRecordType
)

// getMetadataValue is a generic metadata lookup for all query items
Expand Down Expand Up @@ -230,6 +231,20 @@ func (vm QueryVm) GetMetadataValue(key string) string {
return getMetadataValue(vm.MetaData, key)
}

// --------------------------------------------------------------
// Organization
// --------------------------------------------------------------
func (org QueryOrg) GetHref() string { return org.HREF }
func (org QueryOrg) GetName() string { return org.Name }
func (org QueryOrg) GetType() string { return "organization" }
func (org QueryOrg) GetDate() string { return "" }
func (org QueryOrg) GetIp() string { return "" }
func (org QueryOrg) GetParentId() string { return "" }
func (org QueryOrg) GetParentName() string { return "" }
func (org QueryOrg) GetMetadataValue(key string) string {
return getMetadataValue(org.Metadata, key)
}

// --------------------------------------------------------------
// result conversion
// --------------------------------------------------------------
Expand Down Expand Up @@ -273,6 +288,10 @@ func resultToQueryItems(queryType string, results Results) ([]QueryItem, error)
for i, item := range results.Results.OrgVdcNetworkRecord {
items[i] = QueryOrgVdcNetwork(*item)
}
case types.QtOrg:
for i, item := range results.Results.OrgRecord {
items[i] = QueryOrg(*item)
}
case types.QtCatalog:
for i, item := range results.Results.CatalogRecord {
items[i] = QueryCatalog(*item)
Expand Down
3 changes: 3 additions & 0 deletions govcd/query_metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ func queryFieldsOnDemand(queryType string) ([]string, error) {
"cpuOverheadMhz", "isVCEnabled", "memoryReservedMB", "cpuReservedMhz", "storageOverheadMB", "memoryOverheadMB", "vc"}
taskFields = []string{"href", "id", "type", "org", "orgName", "name", "operationFull", "message", "startDate",
"endDate", "status", "progress", "ownerName", "object", "objectType", "objectName", "serviceNamespace"}
orgFields = []string{"href", "id", "type", "name", "displayName", "isEnabled", "isReadOnly", "canPublishCatalogs",
"deployedVMQuota", "storedVMQuota", "numberOfCatalogs", "numberOfVdcs", "numberOfVApps", "numberOfGroups", "numberOfDisks"}
fieldsOnDemand = map[string][]string{
types.QtVappTemplate: vappTemplatefields,
types.QtAdminVappTemplate: vappTemplatefields,
Expand All @@ -97,6 +99,7 @@ func queryFieldsOnDemand(queryType string) ([]string, error) {
types.QtAdminOrgVdc: orgVdcFields,
types.QtTask: taskFields,
types.QtAdminTask: taskFields,
types.QtOrg: orgFields,
}
)

Expand Down
2 changes: 2 additions & 0 deletions types/v56/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ const (
QtVappTemplate = "vAppTemplate" // vApp template
QtAdminVappTemplate = "adminVAppTemplate" // vApp template as admin
QtEdgeGateway = "edgeGateway" // edge gateway
QtOrg = "organization" // Organization
QtOrgVdcNetwork = "orgVdcNetwork" // Org VDC network
QtCatalog = "catalog" // catalog
QtAdminCatalog = "adminCatalog" // catalog as admin
Expand All @@ -283,6 +284,7 @@ const (
// AdminQueryTypes returns the corresponding "admin" query type for each regular type
var AdminQueryTypes = map[string]string{
QtEdgeGateway: QtEdgeGateway, // EdgeGateway query type is the same for admin and regular users
QtOrg: QtOrg, // Organisation query is admin per default
QtOrgVdcNetwork: QtOrgVdcNetwork, // Org VDC Network query type is the same for admin and regular users
QtVappTemplate: QtAdminVappTemplate,
QtCatalog: QtAdminCatalog,
Expand Down
22 changes: 22 additions & 0 deletions types/v56/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -2369,6 +2369,7 @@ type QueryResultRecordsType struct {
VmGroupsRecord []*QueryResultVmGroupsRecordType `xml:"VmGroupsRecord"` // A record representing a VM Group
TaskRecord []*QueryResultTaskRecordType `xml:"TaskRecord"` // A record representing a Task
AdminTaskRecord []*QueryResultTaskRecordType `xml:"AdminTaskRecord"` // A record representing an Admin Task
OrgRecord []*QueryResultOrgRecordType `xml:"OrgRecord"` // A record representing an Organisation
}

// QueryResultVmGroupsRecordType represent a VM Groups record
Expand Down Expand Up @@ -3357,6 +3358,27 @@ type QueryResultTaskRecordType struct {
Metadata *Metadata `xml:"Metadata,omitempty"`
}

// QueryResultOrgVdcRecordType represents an Organisation record
type QueryResultOrgRecordType struct {
HREF string `xml:"href,attr,omitempty"`
Type string `xml:"type,attr,omitempty"`
ID string `xml:"id,attr,omitempty"`
Name string `xml:"name,attr"`
DisplayName string `xml:"displayName,attr,omitempty"`
IsEnabled bool `xml:"IsEnabled,attr,omitempty"`
IsReadOnly bool `xml:"isReadOnly,attr,omitempty"`
CanPublishCatalogs bool `xml:"canPublishCatalogs,attr,omitempty"`
DeployedVMQuota *int `xml:"deployedVMQuota,attr,omitempty"`
StoredVMQuota *int `xml:"storedVMQuota,attr,omitempty"`
NumberOfCatalogs *int `xml:"numberOfCatalogs,attr,omitempty"`
NumberOfVdcs *int `xml:"numberOfVdcs,attr,omitempty"`
NumberOfVApps *int `xml:"numberOfVApps,attr,omitempty"`
NumberOfGroups *int `xml:"numberOfGroups,attr,omitempty"`
NumberOfDisks *int `xml:"numberOfDisks,attr,omitempty"`
Link *LinkList `xml:"Link,omitempty"`
Metadata *Metadata `xml:"Metadata,omitempty"`
}

// ProviderVdcCreation contains the data needed to create a provider VDC.
// Note that this is a subset of the full structure of a provider VDC.
type ProviderVdcCreation struct {
Expand Down

0 comments on commit 0d5104b

Please sign in to comment.