-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48 from netboxlabs/feat-OBS-407-diode-reconciler-…
…python-sdk feat: OBS-407 - netbox plugin: diode reconciler sdk
- Loading branch information
Showing
43 changed files
with
9,711 additions
and
31 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
diode-netbox-plugin/netbox_diode_plugin/diode_reconciler_sdk/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env python | ||
# Copyright 2024 NetBox Labs Inc | ||
"""Diode Netbox Plugin - Reconciler SDK.""" |
55 changes: 55 additions & 0 deletions
55
diode-netbox-plugin/netbox_diode_plugin/diode_reconciler_sdk/client.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#!/usr/bin/env python | ||
# Copyright 2024 NetBox Labs Inc | ||
"""Diode Netbox Plugin - Diode Reconciler SDK.""" | ||
|
||
import grpc | ||
|
||
from netbox_diode_plugin.diode_reconciler_sdk.reconciler.v1 import reconciler_pb2, reconciler_pb2_grpc | ||
from netbox_diode_plugin.diode_reconciler_sdk.version import version_display | ||
|
||
|
||
class DiodeReconcilerClient: | ||
"""Diode Reconciler client.""" | ||
|
||
_name = "diode-reconciler-sdk-python" | ||
_version = version_display() | ||
_target = None | ||
_channel = None | ||
_stub = None | ||
|
||
def __init__(self, target: str, api_key: str): | ||
"""Initiate a new client configuration.""" | ||
self._target = target | ||
# TODO(mfiedorowicz): configure secure channel with auth metatada callback | ||
self._auth_metadata = (("diode-api-key", api_key),) | ||
self._channel = grpc.insecure_channel(target) | ||
self._stub = reconciler_pb2_grpc.ReconcilerServiceStub(self._channel) | ||
|
||
@property | ||
def name(self) -> str: | ||
"""Retrieve the name.""" | ||
return self._name | ||
|
||
@property | ||
def version(self) -> str: | ||
"""Retrieve the version.""" | ||
return self._version | ||
|
||
@property | ||
def target(self) -> str: | ||
"""Retrieve the target.""" | ||
return self._target | ||
|
||
@property | ||
def channel(self) -> grpc.Channel: | ||
"""Retrieve the channel.""" | ||
return self._channel | ||
|
||
def add_object_state(self, object_id: int, object_type: str, | ||
object_change_id: int, object: dict) -> reconciler_pb2.AddObjectStateResponse: | ||
"""Add an object state.""" | ||
request = reconciler_pb2.AddObjectStateRequest(object_id=object_id, object_type=object_type, | ||
object_change_id=object_change_id, object=object, | ||
sdk_name=self.name, sdk_version=self.version) | ||
|
||
return self._stub.AddObjectState(request, metadata=self._auth_metadata) |
3 changes: 3 additions & 0 deletions
3
diode-netbox-plugin/netbox_diode_plugin/diode_reconciler_sdk/reconciler/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env python | ||
# Copyright 2024 NetBox Labs Inc | ||
"""Diode Netbox Plugin - Reconciler SDK.""" |
3 changes: 3 additions & 0 deletions
3
diode-netbox-plugin/netbox_diode_plugin/diode_reconciler_sdk/reconciler/v1/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env python | ||
# Copyright 2024 NetBox Labs Inc | ||
"""Diode Netbox Plugin - Reconciler SDK - v1.""" |
50 changes: 50 additions & 0 deletions
50
diode-netbox-plugin/netbox_diode_plugin/diode_reconciler_sdk/reconciler/v1/device_pb2.py
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
4 changes: 4 additions & 0 deletions
4
...e-netbox-plugin/netbox_diode_plugin/diode_reconciler_sdk/reconciler/v1/device_pb2_grpc.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! | ||
"""Client and server classes corresponding to protobuf-defined services.""" | ||
import grpc | ||
|
36 changes: 36 additions & 0 deletions
36
...e-netbox-plugin/netbox_diode_plugin/diode_reconciler_sdk/reconciler/v1/device_role_pb2.py
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
4 changes: 4 additions & 0 deletions
4
...box-plugin/netbox_diode_plugin/diode_reconciler_sdk/reconciler/v1/device_role_pb2_grpc.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! | ||
"""Client and server classes corresponding to protobuf-defined services.""" | ||
import grpc | ||
|
39 changes: 39 additions & 0 deletions
39
...e-netbox-plugin/netbox_diode_plugin/diode_reconciler_sdk/reconciler/v1/device_type_pb2.py
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
4 changes: 4 additions & 0 deletions
4
...box-plugin/netbox_diode_plugin/diode_reconciler_sdk/reconciler/v1/device_type_pb2_grpc.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! | ||
"""Client and server classes corresponding to protobuf-defined services.""" | ||
import grpc | ||
|
36 changes: 36 additions & 0 deletions
36
...-netbox-plugin/netbox_diode_plugin/diode_reconciler_sdk/reconciler/v1/manufacturer_pb2.py
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
4 changes: 4 additions & 0 deletions
4
...ox-plugin/netbox_diode_plugin/diode_reconciler_sdk/reconciler/v1/manufacturer_pb2_grpc.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! | ||
"""Client and server classes corresponding to protobuf-defined services.""" | ||
import grpc | ||
|
36 changes: 36 additions & 0 deletions
36
diode-netbox-plugin/netbox_diode_plugin/diode_reconciler_sdk/reconciler/v1/platform_pb2.py
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
4 changes: 4 additions & 0 deletions
4
...netbox-plugin/netbox_diode_plugin/diode_reconciler_sdk/reconciler/v1/platform_pb2_grpc.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! | ||
"""Client and server classes corresponding to protobuf-defined services.""" | ||
import grpc | ||
|
Oops, something went wrong.