Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
161 changes: 161 additions & 0 deletions doc/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1468,6 +1468,10 @@ <h2>Table of Contents</h2>
<a href="#metalstack.api.v2.SwitchNic"><span class="badge">M</span>SwitchNic</a>
</li>

<li>
<a href="#metalstack.api.v2.SwitchNicWithMachine"><span class="badge">M</span>SwitchNicWithMachine</a>
</li>

<li>
<a href="#metalstack.api.v2.SwitchOS"><span class="badge">M</span>SwitchOS</a>
</li>
Expand All @@ -1484,6 +1488,10 @@ <h2>Table of Contents</h2>
<a href="#metalstack.api.v2.SwitchSync"><span class="badge">M</span>SwitchSync</a>
</li>

<li>
<a href="#metalstack.api.v2.SwitchWithMachines"><span class="badge">M</span>SwitchWithMachines</a>
</li>


<li>
<a href="#metalstack.api.v2.BGPState"><span class="badge">E</span>BGPState</a>
Expand Down Expand Up @@ -1511,6 +1519,14 @@ <h2>Table of Contents</h2>
<a href="#metalstack%2fadmin%2fv2%2fswitch.proto">metalstack/admin/v2/switch.proto</a>
<ul>

<li>
<a href="#metalstack.admin.v2.SwitchServiceConnectedMachinesRequest"><span class="badge">M</span>SwitchServiceConnectedMachinesRequest</a>
</li>

<li>
<a href="#metalstack.admin.v2.SwitchServiceConnectedMachinesResponse"><span class="badge">M</span>SwitchServiceConnectedMachinesResponse</a>
</li>

<li>
<a href="#metalstack.admin.v2.SwitchServiceDeleteRequest"><span class="badge">M</span>SwitchServiceDeleteRequest</a>
</li>
Expand Down Expand Up @@ -12798,6 +12814,44 @@ <h3 id="metalstack.api.v2.SwitchNic">SwitchNic</h3>



<h3 id="metalstack.api.v2.SwitchNicWithMachine">SwitchNicWithMachine</h3>
<p>SwitchNicWithMachine associates a switch port with its connected machine.</p>


<table class="field-table">
<thead>
<tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>
</thead>
<tbody>

<tr>
<td>nic</td>
<td><a href="#metalstack.api.v2.SwitchNic">SwitchNic</a></td>
<td></td>
<td><p>Nic is the switch nic the machine is connected to. </p></td>
</tr>

<tr>
<td>machine</td>
<td><a href="#metalstack.api.v2.Machine">Machine</a></td>
<td></td>
<td><p>Machine connected to this nic. </p></td>
</tr>

<tr>
<td>fru</td>
<td><a href="#metalstack.api.v2.MachineFRU">MachineFRU</a></td>
<td></td>
<td><p>FRU of the connected machine. </p></td>
</tr>

</tbody>
</table>





<h3 id="metalstack.api.v2.SwitchOS">SwitchOS</h3>
<p>SwitchOS holds information about the NOS and versions running on the switch.</p>

Expand Down Expand Up @@ -12950,6 +13004,51 @@ <h3 id="metalstack.api.v2.SwitchSync">SwitchSync</h3>



<h3 id="metalstack.api.v2.SwitchWithMachines">SwitchWithMachines</h3>
<p>SwitchWithMachines contains a mapping from switch ports to connected machines.</p>


<table class="field-table">
<thead>
<tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>
</thead>
<tbody>

<tr>
<td>id</td>
<td><a href="#string">string</a></td>
<td></td>
<td><p>Id of the switch. </p></td>
</tr>

<tr>
<td>partition</td>
<td><a href="#string">string</a></td>
<td></td>
<td><p>Partition of the switch. </p></td>
</tr>

<tr>
<td>rack</td>
<td><a href="#string">string</a></td>
<td></td>
<td><p>Rack of the switch. </p></td>
</tr>

<tr>
<td>connections</td>
<td><a href="#metalstack.api.v2.SwitchNicWithMachine">SwitchNicWithMachine</a></td>
<td>repeated</td>
<td><p>Connections associates switch ports with the machines connected to them. </p></td>
</tr>

</tbody>
</table>







<h3 id="metalstack.api.v2.BGPState">BGPState</h3>
Expand Down Expand Up @@ -13110,6 +13209,61 @@ <h2 id="metalstack/admin/v2/switch.proto">metalstack/admin/v2/switch.proto</h2><
<p></p>


<h3 id="metalstack.admin.v2.SwitchServiceConnectedMachinesRequest">SwitchServiceConnectedMachinesRequest</h3>
<p>SwitchServiceConnectedMachinesRequest.</p>


<table class="field-table">
<thead>
<tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>
</thead>
<tbody>

<tr>
<td>query</td>
<td><a href="#metalstack.api.v2.SwitchQuery">metalstack.api.v2.SwitchQuery</a></td>
<td></td>
<td><p>Query to filter the switch results. </p></td>
</tr>

<tr>
<td>machine_query</td>
<td><a href="#metalstack.api.v2.MachineQuery">metalstack.api.v2.MachineQuery</a></td>
<td></td>
<td><p>MachineQuery to filter the machine results. </p></td>
</tr>

</tbody>
</table>





<h3 id="metalstack.admin.v2.SwitchServiceConnectedMachinesResponse">SwitchServiceConnectedMachinesResponse</h3>
<p>SwitchServiceConnectedMachinesResponse.</p>


<table class="field-table">
<thead>
<tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>
</thead>
<tbody>

<tr>
<td>switches_with_machines</td>
<td><a href="#metalstack.api.v2.SwitchWithMachines">metalstack.api.v2.SwitchWithMachines</a></td>
<td>repeated</td>
<td><p>SwitchesWithMachines contains all switches with their machine connections. </p></td>
</tr>

</tbody>
</table>





<h3 id="metalstack.admin.v2.SwitchServiceDeleteRequest">SwitchServiceDeleteRequest</h3>
<p>SwitchServiceDeleteRequest.</p>

Expand Down Expand Up @@ -13546,6 +13700,13 @@ <h3 id="metalstack.admin.v2.SwitchService">SwitchService</h3>
<td><p>Port set the port status of a switch port.</p></td>
</tr>

<tr>
<td>ConnectedMachines</td>
<td><a href="#metalstack.admin.v2.SwitchServiceConnectedMachinesRequest">SwitchServiceConnectedMachinesRequest</a></td>
<td><a href="#metalstack.admin.v2.SwitchServiceConnectedMachinesResponse">SwitchServiceConnectedMachinesResponse</a></td>
<td><p>ConnectedMachines lists all switches with their machine connections.</p></td>
</tr>

</tbody>
</table>

Expand Down
14 changes: 10 additions & 4 deletions examples/python/ip-list.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,16 @@
baseurl = os.environ['METAL_APISERVER_URL']
token = os.environ['API_TOKEN']
project = os.environ['PROJECT_ID']
headers = dict(Authorization="Bearer " + token)

client = apiclient.Client(baseurl=baseurl, token=token, timeout=timeout_s)
client = apiclient.Client(baseurl=baseurl, timeout=timeout_s)

try:
resp = client.apiv2().ip().list(request=ip_pb2.IPServiceListRequest(
project=project))
resp = client.apiv2().ip().list(
headers=headers,
request=ip_pb2.IPServiceListRequest(
project=project),
)
except ConnectError as e:
print(e.code, e.message, e.to_dict())
sys.exit(1)
Expand All @@ -28,7 +32,9 @@
print(ip.ip, ip.name, ip.project, ip.network)

resp = client.adminv2().network().list(
request=network_pb2.NetworkServiceListRequest())
headers=headers,
request=network_pb2.NetworkServiceListRequest(),
)

for nw in resp.networks:
print(nw.id, nw.name, nw.project)
21 changes: 11 additions & 10 deletions generate/python_client.tpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Code generated by generate.go. DO NOT EDIT.

import httpx
import pyqwest

{{ range $name, $api := . -}}
{{ range $svc := $api.Services -}}
Expand All @@ -9,28 +9,29 @@ import metalstack.{{ $name | trimSuffix "v2" }}.v2.{{ $svc | trimSuffix "Service
{{ end }}

class Client:
def __init__(self, baseurl: str, token: str, timeout: int = 10):
def __init__(self, baseurl: str, timeout: float = 10):
self._baseurl = baseurl

headers = {}
if token:
headers["Authorization"] = "Bearer " + token
transport = pyqwest.SyncHTTPTransport(
http_version=pyqwest.HTTPVersion.HTTP2,
timeout=timeout,
)

self._session = httpx.Client(headers=headers, timeout=timeout)
self._client = pyqwest.SyncClient(transport=transport)

{{ range $name, $api := . }}
def {{ $name | lower }}(self):
return self._{{ $name | title }}(baseurl=self._baseurl, session=self._session)
return self._{{ $name | title }}(baseurl=self._baseurl, client=self._client)
{{ end }}

{{ range $name, $api := . }}
class _{{ $name | title }}:
def __init__(self, baseurl: str, session=None):
def __init__(self, baseurl: str, client: pyqwest.SyncClient = None):
self._baseurl = baseurl
self._session = session
self._client = client

{{ range $svc := $api.Services }}
def {{ $svc | trimSuffix "Service" | lower }}(self):
return {{ $name | trimSuffix "v2" }}_{{ $svc | trimSuffix "Service" | lower }}_connect.{{ $svc }}ClientSync(address=self._baseurl, session=self._session)
return {{ $name | trimSuffix "v2" }}_{{ $svc | trimSuffix "Service" | lower }}_connect.{{ $svc }}ClientSync(address=self._baseurl, http_client=self._client)
{{ end }}
{{ end }}
47 changes: 41 additions & 6 deletions go/metalstack/admin/v2/adminv2connect/switch.connect.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading