Skip to content

Filter query parameters model is unusable by API methods #37

@VamshikShetty

Description

@VamshikShetty

GET method: /vcenter/cluster

Query params:
filter.datacenters : list[str]
filter.clusters : list[str]
filter.folders : list[str]
filter_names : list[str]

Definition: vcenter.cluster.filter_spec which is the representation of filter query params is never referenced in any path or definitions.

"vcenter.cluster.filter_spec": {
           "type": "object",
           "properties": {
               "clusters": {
                   "description": "Identifiers of clusters that can match the filter.\nIf unset or empty, clusters with any identifier match the filter.\nWhen clients pass a value of this structure as a parameter, the field must contain identifiers for the resource type: ClusterComputeResource. When operations return a value of this structure as a result, the field will contain identifiers for the resource type: ClusterComputeResource.",
                   "type": "array",
                   "uniqueItems": true,
                   "items": {
                       "type": "string"
                   }
               },
               "names": {
                   "description": "Names that clusters must have to match the filter (see Cluster.Info.name).\nIf unset or empty, clusters with any name match the filter.",
                   "type": "array",
                   "uniqueItems": true,
                   "items": {
                       "type": "string"
                   }
               },
               "folders": {
                   "description": "Folders that must contain the cluster for the cluster to match the filter.\nIf unset or empty, clusters in any folder match the filter.\nWhen clients pass a value of this structure as a parameter, the field must contain identifiers for the resource type: Folder. When operations return a value of this structure as a result, the field will contain identifiers for the resource type: Folder.",
                   "type": "array",
                   "uniqueItems": true,
                   "items": {
                       "type": "string"
                   }
               },
               "datacenters": {
                   "description": "Datacenters that must contain the cluster for the cluster to match the filter.\nIf unset or empty, clusters in any datacenter match the filter.\nWhen clients pass a value of this structure as a parameter, the field must contain identifiers for the resource type: Datacenter. When operations return a value of this structure as a result, the field will contain identifiers for the resource type: Datacenter.",
                   "type": "array",
                   "uniqueItems": true,
                   "items": {
                       "type": "string"
                   }
               }
           }
       }

This definition creates a model which is not usable by the API method itself.

Python Example of this issue:

If a list of datacenter Id is passed to VcenterClusterFilterSpec model, example:
vmsw_vsphere.vcenter.VcenterClusterFilterSpec(datacenters=["datacenter-34"]) then output object's to_dict() function produces:
{ 'folders': None,
'clusters': None,
'names': None,
'datacenters': ['datacenter-34']
}

But to be used by its own corresponding API method it needs to pass
{ "filter_datacenters":["datacenter-34"],
"filter_clusters":[],
"filter_folders":[],
"filter_names":[]
}
Given auto generated model of query params is of no use in API methods hence it needs to be removed or updated with support to query params.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions