Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: OBS-407 - netbox plugin: diode reconciler sdk #48

Merged
merged 18 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
2db89af
feat: OBS-407 - reconciler proto to python
mfiedorowicz Feb 28, 2024
b7d059b
feat: OBS-407 - vendor validate.proto from envoyproxy/protoc-gen-vali…
mfiedorowicz Feb 28, 2024
e12c6bf
feat: OBS-407 - fix validate pkg imports in reconcilerpb
mfiedorowicz Feb 28, 2024
8e74f3e
feat: OBS-407 - generate python diode reconciler sdk for netbox plugin
mfiedorowicz Feb 28, 2024
37a9098
feat: OBS-407 - add dependencies for diode-netbox-plugin
mfiedorowicz Feb 28, 2024
a6e0894
feat: OBS-407 - fix python diode reconciler sdk
mfiedorowicz Feb 28, 2024
58591ab
feat: OBS-407 - tidy up dependencies for diode-netbox-plugin
mfiedorowicz Feb 28, 2024
c804792
feat: OBS-407 - format reconciler and validate proto
mfiedorowicz Feb 28, 2024
cadc342
feat: OBS-407 - protobuf lint: ignore validate pkg
mfiedorowicz Feb 28, 2024
767cb51
feat: OBS-407 - proto: format before generate
mfiedorowicz Feb 28, 2024
2c86637
feat: OBS-407 - basic diode reconciler sdk client
mfiedorowicz Feb 28, 2024
160cff1
feat: OBS-407 - ruff: ignore diode_reconciler_sdk generated code
mfiedorowicz Feb 28, 2024
e22b07f
feat: OBS-407 - docker: docker overlay to install netbox_diode_plugin…
mfiedorowicz Feb 28, 2024
70b584c
feat: OBS-407 - add simple auth metadata to diode-reconiciler-sdk on …
mfiedorowicz Feb 28, 2024
95cc59e
feat: OBS-407 - fix tests for diode reconciler sdk
mfiedorowicz Feb 29, 2024
824a2ff
feat: OBS-407 - tidy up diode reconciler sdk python
mfiedorowicz Feb 29, 2024
d116018
feat: OBS-407 - tidy up diode reconciler sdk python
mfiedorowicz Feb 29, 2024
53c641f
feat: OBS-407 - ruff --fix diode reconciler sdk python
mfiedorowicz Feb 29, 2024
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
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."""
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)
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."""
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."""

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

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

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

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

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

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

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

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

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

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

Loading
Loading