Skip to content

Commit f96d900

Browse files
Allow to filter networks by query params
1 parent 6162642 commit f96d900

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

src/Networking/v2/Api.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@ public function getNetworks(): array
3333
return [
3434
'method' => 'GET',
3535
'path' => $this->pathPrefix . '/networks',
36-
'params' => [],
36+
'params' => [
37+
'name' => $this->params->queryName(),
38+
'tenantId' => $this->params->queryTenantId(),
39+
'status' => $this->params->queryStatus(),
40+
],
3741
];
3842
}
3943

src/Networking/v2/Params.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,4 +340,30 @@ public function deviceId(): array
340340
'description' => 'The UUID of the device that uses this port. For example, a virtual server.',
341341
];
342342
}
343+
344+
public function queryName(): array
345+
{
346+
return $this->queryFilter('name');
347+
}
348+
349+
public function queryTenantId(): array
350+
{
351+
return $this->queryFilter('tenant_id');
352+
}
353+
354+
public function queryStatus(): array
355+
{
356+
return $this->queryFilter('status');
357+
}
358+
359+
private function queryFilter($field): array
360+
{
361+
return [
362+
'type' => self::STRING_TYPE,
363+
'location' => self::QUERY,
364+
'sentAs' => $field,
365+
'description' => 'The Neutron API supports filtering based on all top level attributes of a resource.
366+
Filters are applicable to all list requests.',
367+
];
368+
}
343369
}

0 commit comments

Comments
 (0)