Skip to content

Commit 34a6358

Browse files
authored
Merge pull request #91 from opsmill/copilot/fix-87
Add Device42 to Infrahub sync example with demo server integration
2 parents 3ede767 + f7b1061 commit 34a6358

File tree

18 files changed

+214
-354
lines changed

18 files changed

+214
-354
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
name: from-device42
3+
4+
source:
5+
name: genericrestapi
6+
settings:
7+
url: "http://swaggerdemo.device42.com"
8+
auth_method: "basic"
9+
username: "guest"
10+
password: "device42_rocks!"
11+
api_endpoint: "/api/1.0"
12+
response_key_pattern: "objects"
13+
14+
destination:
15+
name: infrahub
16+
settings:
17+
url: "http://localhost:8000"
18+
19+
order: [
20+
"BuiltinTag",
21+
"OrganizationTenant",
22+
"LocationSite",
23+
]
24+
25+
schema_mapping:
26+
# Builtin Tags (Device42 tags)
27+
- name: BuiltinTag
28+
mapping: tags
29+
identifiers: ["name"]
30+
fields:
31+
- name: name
32+
mapping: name
33+
34+
# Organizations (Customers in Device42)
35+
- name: OrganizationTenant
36+
mapping: customers
37+
identifiers: ["name"]
38+
fields:
39+
- name: name
40+
mapping: name
41+
- name: description
42+
mapping: notes
43+
44+
# Locations (Buildings in Device42)
45+
- name: LocationSite
46+
mapping: buildings
47+
identifiers: ["name"]
48+
fields:
49+
- name: name
50+
mapping: name
51+
- name: tags
52+
mapping: tags
53+
reference: BuiltinTag
54+

examples/peeringdb_to_infrahub/genenericrestapi/__init__.py renamed to examples/device42_to_infrahub/genericrestapi/__init__.py

File renamed without changes.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from infrahub_sync.adapters.genericrestapi import GenericrestapiAdapter
2+
3+
from .sync_models import (
4+
BuiltinTag,
5+
LocationSite,
6+
OrganizationTenant,
7+
)
8+
9+
10+
# -------------------------------------------------------
11+
# AUTO-GENERATED FILE, DO NOT MODIFY
12+
# This file has been generated with the command `infrahub-sync generate`
13+
# All modifications will be lost the next time you reexecute this command
14+
# -------------------------------------------------------
15+
class GenericrestapiSync(GenericrestapiAdapter):
16+
BuiltinTag = BuiltinTag
17+
LocationSite = LocationSite
18+
OrganizationTenant = OrganizationTenant
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
from __future__ import annotations
2+
3+
from typing import Any
4+
5+
from infrahub_sync.adapters.genericrestapi import GenericrestapiModel
6+
7+
8+
# -------------------------------------------------------
9+
# AUTO-GENERATED FILE, DO NOT MODIFY
10+
# This file has been generated with the command `infrahub-sync generate`
11+
# All modifications will be lost the next time you reexecute this command
12+
# -------------------------------------------------------
13+
class BuiltinTag(GenericrestapiModel):
14+
_modelname = "BuiltinTag"
15+
_identifiers = ("name",)
16+
_attributes = ()
17+
name: str
18+
19+
local_id: str | None = None
20+
local_data: Any | None = None
21+
22+
23+
class LocationSite(GenericrestapiModel):
24+
_modelname = "LocationSite"
25+
_identifiers = ("name",)
26+
_attributes = ("tags",)
27+
name: str
28+
tags: list[str] | None = []
29+
30+
local_id: str | None = None
31+
local_data: Any | None = None
32+
33+
34+
class OrganizationTenant(GenericrestapiModel):
35+
_modelname = "OrganizationTenant"
36+
_identifiers = ("name",)
37+
_attributes = ("description",)
38+
description: str | None = None
39+
name: str
40+
41+
local_id: str | None = None
42+
local_data: Any | None = None

examples/peeringdb_to_infrahub/generic_rest_api/__init__.py renamed to examples/device42_to_infrahub/infrahub/__init__.py

File renamed without changes.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from infrahub_sync.adapters.infrahub import InfrahubAdapter
2+
3+
from .sync_models import (
4+
BuiltinTag,
5+
LocationSite,
6+
OrganizationTenant,
7+
)
8+
9+
10+
# -------------------------------------------------------
11+
# AUTO-GENERATED FILE, DO NOT MODIFY
12+
# This file has been generated with the command `infrahub-sync generate`
13+
# All modifications will be lost the next time you reexecute this command
14+
# -------------------------------------------------------
15+
class InfrahubSync(InfrahubAdapter):
16+
BuiltinTag = BuiltinTag
17+
LocationSite = LocationSite
18+
OrganizationTenant = OrganizationTenant
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
from __future__ import annotations
2+
3+
from typing import Any
4+
5+
from infrahub_sync.adapters.infrahub import InfrahubModel
6+
7+
8+
# -------------------------------------------------------
9+
# AUTO-GENERATED FILE, DO NOT MODIFY
10+
# This file has been generated with the command `infrahub-sync generate`
11+
# All modifications will be lost the next time you reexecute this command
12+
# -------------------------------------------------------
13+
class BuiltinTag(InfrahubModel):
14+
_modelname = "BuiltinTag"
15+
_identifiers = ("name",)
16+
_attributes = ()
17+
name: str
18+
19+
local_id: str | None = None
20+
local_data: Any | None = None
21+
22+
23+
class LocationSite(InfrahubModel):
24+
_modelname = "LocationSite"
25+
_identifiers = ("name",)
26+
_attributes = ("tags",)
27+
name: str
28+
tags: list[str] | None = []
29+
30+
local_id: str | None = None
31+
local_data: Any | None = None
32+
33+
34+
class OrganizationTenant(InfrahubModel):
35+
_modelname = "OrganizationTenant"
36+
_identifiers = ("name",)
37+
_attributes = ("description",)
38+
description: str | None = None
39+
name: str
40+
41+
local_id: str | None = None
42+
local_data: Any | None = None

examples/peeringdb_to_infrahub/genenericrestapi/sync_adapter.py

Lines changed: 0 additions & 28 deletions
This file was deleted.

examples/peeringdb_to_infrahub/genenericrestapi/sync_models.py

Lines changed: 0 additions & 141 deletions
This file was deleted.

examples/peeringdb_to_infrahub/generic_rest_api/sync_adapter.py

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
 (0)