centra-sdk 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- centra_sdk-0.1.0/PKG-INFO +21 -0
- centra_sdk-0.1.0/README.md +2 -0
- centra_sdk-0.1.0/pyproject.toml +27 -0
- centra_sdk-0.1.0/src/centra_sdk/dependencies.py +45 -0
- centra_sdk-0.1.0/src/centra_sdk/handler_registry.py +138 -0
- centra_sdk-0.1.0/src/centra_sdk/main.py +45 -0
- centra_sdk-0.1.0/src/centra_sdk/models/connector/__init__.py +3 -0
- centra_sdk-0.1.0/src/centra_sdk/models/connector/v1/__init__.py +3 -0
- centra_sdk-0.1.0/src/centra_sdk/models/connector/v1/common/__init__.py +3 -0
- centra_sdk-0.1.0/src/centra_sdk/models/connector/v1/common/common.py +15 -0
- centra_sdk-0.1.0/src/centra_sdk/models/connector/v1/common/inventory.py +250 -0
- centra_sdk-0.1.0/src/centra_sdk/models/connector/v1/consumer/__init__.py +3 -0
- centra_sdk-0.1.0/src/centra_sdk/models/connector/v1/consumer/agents.py +21 -0
- centra_sdk-0.1.0/src/centra_sdk/models/connector/v1/consumer/enforcement.py +252 -0
- centra_sdk-0.1.0/src/centra_sdk/models/connector/v1/k8s/__init__.py +3 -0
- centra_sdk-0.1.0/src/centra_sdk/models/connector/v1/k8s/k8s_inventory.py +191 -0
- centra_sdk-0.1.0/src/centra_sdk/models/connector/v1/operations/__init__.py +3 -0
- centra_sdk-0.1.0/src/centra_sdk/models/connector/v1/operations/config.py +54 -0
- centra_sdk-0.1.0/src/centra_sdk/models/connector/v1/operations/health.py +201 -0
- centra_sdk-0.1.0/src/centra_sdk/models/connector/v1/operations/info.py +77 -0
- centra_sdk-0.1.0/src/centra_sdk/models/connector/v1/operations/log.py +35 -0
- centra_sdk-0.1.0/src/centra_sdk/models/connector/v1/operations/onboard.py +179 -0
- centra_sdk-0.1.0/src/centra_sdk/models/connector/v1/provider/__init__.py +3 -0
- centra_sdk-0.1.0/src/centra_sdk/models/connector/v1/provider/inventory.py +91 -0
- centra_sdk-0.1.0/src/centra_sdk/models/connector/v1/provider/lookup.py +42 -0
- centra_sdk-0.1.0/src/centra_sdk/models/connector/v1/provider/reveal.py +204 -0
- centra_sdk-0.1.0/src/centra_sdk/models/connector/version.py +28 -0
- centra_sdk-0.1.0/src/centra_sdk/routers/agents.py +91 -0
- centra_sdk-0.1.0/src/centra_sdk/routers/control.py +65 -0
- centra_sdk-0.1.0/src/centra_sdk/routers/enforcement.py +115 -0
- centra_sdk-0.1.0/src/centra_sdk/routers/health.py +175 -0
- centra_sdk-0.1.0/src/centra_sdk/routers/info.py +121 -0
- centra_sdk-0.1.0/src/centra_sdk/routers/inventory.py +267 -0
- centra_sdk-0.1.0/src/centra_sdk/routers/logging.py +143 -0
- centra_sdk-0.1.0/src/centra_sdk/routers/onboarding.py +95 -0
- centra_sdk-0.1.0/src/centra_sdk/routers/operations.py +119 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: centra-sdk
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary:
|
|
5
|
+
License: MIT
|
|
6
|
+
Author: ivasylenko
|
|
7
|
+
Author-email: ivasylen@akamai.com
|
|
8
|
+
Requires-Python: >=3.12
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
13
|
+
Requires-Dist: fastapi (>=0.116.1,<0.117.0)
|
|
14
|
+
Requires-Dist: uvicorn (>=0.35.0,<0.36.0)
|
|
15
|
+
Project-URL: Homepage, https://github.com/guardicore/contracts
|
|
16
|
+
Project-URL: Repository, https://github.com/guardicore/contracts
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
|
|
19
|
+
## Contracts SDK
|
|
20
|
+
That is an SDK for Centra Connectors
|
|
21
|
+
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "centra-sdk"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = ""
|
|
5
|
+
authors = [
|
|
6
|
+
{name = "ivasylenko",email = "ivasylen@akamai.com"}
|
|
7
|
+
]
|
|
8
|
+
license = { text = "MIT" }
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.12"
|
|
11
|
+
dependencies = [
|
|
12
|
+
"fastapi (>=0.116.1,<0.117.0)",
|
|
13
|
+
"uvicorn (>=0.35.0,<0.36.0)"
|
|
14
|
+
]
|
|
15
|
+
|
|
16
|
+
[tool.poetry]
|
|
17
|
+
packages = [{include = "centra_sdk", from = "src"}]
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
[build-system]
|
|
21
|
+
requires = ["poetry-core>=2.0.0,<3.0.0"]
|
|
22
|
+
build-backend = "poetry.core.masonry.api"
|
|
23
|
+
|
|
24
|
+
[project.urls]
|
|
25
|
+
homepage = "https://github.com/guardicore/contracts"
|
|
26
|
+
repository = "https://github.com/guardicore/contracts"
|
|
27
|
+
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# generated by fastapi-codegen:
|
|
2
|
+
# filename: connector
|
|
3
|
+
# timestamp: 2025-07-31T14:14:32+00:00
|
|
4
|
+
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
|
|
7
|
+
from typing import Optional, Union
|
|
8
|
+
from uuid import UUID
|
|
9
|
+
|
|
10
|
+
from pydantic import conint
|
|
11
|
+
|
|
12
|
+
from .models.connector.v1.common.inventory import InventoryItem
|
|
13
|
+
from .models.connector.v1.consumer.agents import AgentsInfo
|
|
14
|
+
from .models.connector.v1.consumer.enforcement import (
|
|
15
|
+
Action,
|
|
16
|
+
EnforcementPolicy,
|
|
17
|
+
EnforcementPolicyInventory,
|
|
18
|
+
)
|
|
19
|
+
from .models.connector.v1.operations.config import (
|
|
20
|
+
InternalConfig,
|
|
21
|
+
InternalConfigMetadata,
|
|
22
|
+
)
|
|
23
|
+
from .models.connector.v1.operations.health import (
|
|
24
|
+
V1OperationsFlagsGetResponse,
|
|
25
|
+
V1OperationsHealthGetResponse,
|
|
26
|
+
V1OperationsMetricsGetResponse,
|
|
27
|
+
)
|
|
28
|
+
from .models.connector.v1.operations.info import EnvUnits, IntegrationEnvInfo
|
|
29
|
+
from .models.connector.v1.operations.log import LogStart, LogStatus
|
|
30
|
+
from .models.connector.v1.operations.onboard import (
|
|
31
|
+
Onboard,
|
|
32
|
+
StatusRequest,
|
|
33
|
+
StatusResponse,
|
|
34
|
+
)
|
|
35
|
+
from .models.connector.v1.provider.inventory import (
|
|
36
|
+
Inventory,
|
|
37
|
+
InventoryAssetType,
|
|
38
|
+
InventoryReporterType,
|
|
39
|
+
Labels,
|
|
40
|
+
NetworkTopology,
|
|
41
|
+
V1ProviderInventoryIdAssetsAssetTypePostResponse,
|
|
42
|
+
V1ProviderInventoryIdAssetsAssetTypePostResponse1,
|
|
43
|
+
)
|
|
44
|
+
from .models.connector.v1.provider.lookup import LookupRequest
|
|
45
|
+
from .models.connector.version import VersionHandshakeData
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
# generated by fastapi-codegen:
|
|
2
|
+
# filename: connector
|
|
3
|
+
# timestamp: 2025-07-31T14:14:32+00:00
|
|
4
|
+
|
|
5
|
+
# generated by fastapi-codegen:
|
|
6
|
+
# filename: connector
|
|
7
|
+
# timestamp: 2025-07-30T11:25:18+00:00
|
|
8
|
+
|
|
9
|
+
import logging
|
|
10
|
+
from typing import Any, Callable, Dict, Generic, Optional, TypeVar
|
|
11
|
+
|
|
12
|
+
from fastapi import HTTPException
|
|
13
|
+
from fastapi.encoders import jsonable_encoder
|
|
14
|
+
from fastapi.responses import JSONResponse
|
|
15
|
+
|
|
16
|
+
T = TypeVar('T', bound=Callable)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
logger = logging.getLogger(__name__)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class HandlerRegistry(Generic[T]):
|
|
23
|
+
"""A more sophisticated handler registry with decorator support and logging."""
|
|
24
|
+
|
|
25
|
+
def __init__(self, name: str = "default"):
|
|
26
|
+
self.name = name
|
|
27
|
+
self._handlers: Dict[str, T] = {}
|
|
28
|
+
|
|
29
|
+
def register(self, tag: str) -> Callable[[T], T]:
|
|
30
|
+
"""Decorator to register a handler.
|
|
31
|
+
|
|
32
|
+
Usage:
|
|
33
|
+
registry = HandlerRegistry()
|
|
34
|
+
|
|
35
|
+
@registry.register("my_handler")
|
|
36
|
+
def my_handler():
|
|
37
|
+
pass
|
|
38
|
+
"""
|
|
39
|
+
|
|
40
|
+
def decorator(handler: T) -> T:
|
|
41
|
+
self.set_handler(tag, handler)
|
|
42
|
+
return handler
|
|
43
|
+
|
|
44
|
+
return decorator
|
|
45
|
+
|
|
46
|
+
def set_handler(self, tag: str, handler: T) -> None:
|
|
47
|
+
"""Register a handler for the given tag."""
|
|
48
|
+
if not tag:
|
|
49
|
+
raise ValueError("Tag cannot be empty")
|
|
50
|
+
if not callable(handler):
|
|
51
|
+
raise TypeError("Handler must be callable")
|
|
52
|
+
|
|
53
|
+
if tag in self._handlers:
|
|
54
|
+
logger.warning(
|
|
55
|
+
f"Overriding existing handler for tag '{tag}' in registry '{self.name}'"
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
self._handlers[tag] = handler()
|
|
59
|
+
logger.debug(
|
|
60
|
+
f"Registered handler '{handler.__name__}' for tag '{tag}' in registry '{self.name}'"
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
def get_handler(self, tag: str) -> Optional[T]:
|
|
64
|
+
"""Retrieve a handler for the given tag."""
|
|
65
|
+
handler = self._handlers.get(tag)
|
|
66
|
+
if handler is None:
|
|
67
|
+
logger.warning(
|
|
68
|
+
f"No handler found for tag '{tag}' in registry '{self.name}'"
|
|
69
|
+
)
|
|
70
|
+
return handler
|
|
71
|
+
|
|
72
|
+
def has_handler(self, tag: str) -> bool:
|
|
73
|
+
"""Check if a handler exists for the given tag."""
|
|
74
|
+
return tag in self._handlers
|
|
75
|
+
|
|
76
|
+
def remove_handler(self, tag: str) -> bool:
|
|
77
|
+
"""Remove a handler for the given tag."""
|
|
78
|
+
if tag in self._handlers:
|
|
79
|
+
del self._handlers[tag]
|
|
80
|
+
logger.debug(f"Removed handler for tag '{tag}' from registry '{self.name}'")
|
|
81
|
+
return True
|
|
82
|
+
return False
|
|
83
|
+
|
|
84
|
+
def clear_handlers(self) -> None:
|
|
85
|
+
"""Remove all registered handlers."""
|
|
86
|
+
count = len(self._handlers)
|
|
87
|
+
self._handlers.clear()
|
|
88
|
+
logger.debug(f"Cleared {count} handlers from registry '{self.name}'")
|
|
89
|
+
|
|
90
|
+
def get_all_tags(self) -> list[str]:
|
|
91
|
+
"""Get all registered tags."""
|
|
92
|
+
return list(self._handlers.keys())
|
|
93
|
+
|
|
94
|
+
def __len__(self) -> int:
|
|
95
|
+
"""Return the number of registered handlers."""
|
|
96
|
+
return len(self._handlers)
|
|
97
|
+
|
|
98
|
+
def __contains__(self, tag: str) -> bool:
|
|
99
|
+
"""Check if a tag is registered (supports 'in' operator)."""
|
|
100
|
+
return tag in self._handlers
|
|
101
|
+
|
|
102
|
+
def __repr__(self) -> str:
|
|
103
|
+
return f"HandlerRegistry(name='{self.name}', handlers={len(self._handlers)})"
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
# Global instance for backward compatibility
|
|
107
|
+
default_registry = HandlerRegistry("global")
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
# Convenience functions that delegate to the global registry
|
|
111
|
+
def set_handler(tag: str, handler: Callable) -> None:
|
|
112
|
+
"""Register a handler globally."""
|
|
113
|
+
default_registry.set_handler(tag, handler)
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def get_handler(tag: str) -> Optional[Callable]:
|
|
117
|
+
"""Get a handler from the global registry."""
|
|
118
|
+
return default_registry.get_handler(tag)
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def register(tag: str) -> Callable:
|
|
122
|
+
"""Decorator to register a handler globally."""
|
|
123
|
+
return default_registry.register(tag)
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
def call_handler(tag: str, func_name: str, *args, **kwargs) -> Any:
|
|
127
|
+
"""Decorator to call a handler."""
|
|
128
|
+
|
|
129
|
+
handler = default_registry.get_handler(tag)
|
|
130
|
+
if handler:
|
|
131
|
+
handler_func = getattr(handler, func_name, None)
|
|
132
|
+
if not handler_func:
|
|
133
|
+
logger.warning(f"No handler found for '{tag}#{func_name}'")
|
|
134
|
+
else:
|
|
135
|
+
content = handler_func(*args, **kwargs)
|
|
136
|
+
if content:
|
|
137
|
+
return JSONResponse(content=jsonable_encoder(content), status_code=200)
|
|
138
|
+
raise HTTPException(status_code=404, detail=f"failed to handle {tag}#{func_name}")
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# generated by fastapi-codegen:
|
|
2
|
+
# filename: connector
|
|
3
|
+
# timestamp: 2025-07-31T14:14:32+00:00
|
|
4
|
+
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
|
|
7
|
+
from fastapi import FastAPI
|
|
8
|
+
|
|
9
|
+
from .routers import (
|
|
10
|
+
agents,
|
|
11
|
+
control,
|
|
12
|
+
enforcement,
|
|
13
|
+
health,
|
|
14
|
+
info,
|
|
15
|
+
inventory,
|
|
16
|
+
logging,
|
|
17
|
+
onboarding,
|
|
18
|
+
operations,
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
app = FastAPI(
|
|
22
|
+
title='Version Handshake API',
|
|
23
|
+
description='Version API , Centra Integration Controller rely on to integrate with 3rd party platforms.\n\nSome useful links:\n- [Contracts OpenApi spec](https://github.com/guardicore/contracts)',
|
|
24
|
+
license={
|
|
25
|
+
'name': 'Apache 2.0',
|
|
26
|
+
'url': 'https://www.apache.org/licenses/LICENSE-2.0.html',
|
|
27
|
+
},
|
|
28
|
+
version='1.10.0',
|
|
29
|
+
servers=[{'url': 'http://127.0.0.1:8000'}],
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
app.include_router(agents.router)
|
|
33
|
+
app.include_router(control.router)
|
|
34
|
+
app.include_router(enforcement.router)
|
|
35
|
+
app.include_router(health.router)
|
|
36
|
+
app.include_router(info.router)
|
|
37
|
+
app.include_router(inventory.router)
|
|
38
|
+
app.include_router(logging.router)
|
|
39
|
+
app.include_router(onboarding.router)
|
|
40
|
+
app.include_router(operations.router)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
@app.get("/")
|
|
44
|
+
async def root():
|
|
45
|
+
return {"message": "Gateway of the App"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# generated by fastapi-codegen:
|
|
2
|
+
# filename: /home/ivasylen/sdk_project/contracts/guardicore/connector
|
|
3
|
+
# timestamp: 2025-07-31T14:14:32+00:00
|
|
4
|
+
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
|
|
7
|
+
from enum import Enum
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class Connector(Enum):
|
|
11
|
+
CLOUD_AZURE = 'cloud_azure'
|
|
12
|
+
CLOUD_AWS = 'cloud_aws'
|
|
13
|
+
PACKETFENCE = 'packetfence'
|
|
14
|
+
ALGOSEC = 'algosec'
|
|
15
|
+
PENSANDO = 'pensando'
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
# generated by fastapi-codegen:
|
|
2
|
+
# filename: /home/ivasylen/sdk_project/contracts/guardicore/connector
|
|
3
|
+
# timestamp: 2025-07-31T14:14:32+00:00
|
|
4
|
+
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
|
|
7
|
+
from enum import Enum
|
|
8
|
+
from typing import Any, Dict, List, Optional, Union
|
|
9
|
+
|
|
10
|
+
from pydantic import AwareDatetime, BaseModel, ConfigDict, Field
|
|
11
|
+
|
|
12
|
+
from ..k8s.k8s_inventory import K8SData
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class ItemType(Enum):
|
|
16
|
+
ASSET = 'asset'
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class Label(BaseModel):
|
|
20
|
+
model_config = ConfigDict(
|
|
21
|
+
populate_by_name=True,
|
|
22
|
+
)
|
|
23
|
+
key: str
|
|
24
|
+
value: str
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class Type(Enum):
|
|
28
|
+
VM = 'VM'
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class AzureNetworkTopology(BaseModel):
|
|
32
|
+
model_config = ConfigDict(
|
|
33
|
+
populate_by_name=True,
|
|
34
|
+
)
|
|
35
|
+
subscription: Optional[str] = None
|
|
36
|
+
resource_group: Optional[str] = Field(None, alias='resource-group')
|
|
37
|
+
region: Optional[str] = None
|
|
38
|
+
resource_id: Optional[str] = Field(
|
|
39
|
+
None,
|
|
40
|
+
alias='resource-id',
|
|
41
|
+
examples=[
|
|
42
|
+
'/subscriptions/6974b4cf-6bf8-4454-8d22-a8f33084d699/resourceGroups/DEMO_SETUP/providers/Microsoft.Compute/virtualMachines/spoke1-vm'
|
|
43
|
+
],
|
|
44
|
+
)
|
|
45
|
+
instance_count: Optional[int] = Field(None, alias='instance-count')
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class AWSNetworkTopology(BaseModel):
|
|
49
|
+
model_config = ConfigDict(
|
|
50
|
+
populate_by_name=True,
|
|
51
|
+
)
|
|
52
|
+
account_id: Optional[str] = Field(None, alias='account-id')
|
|
53
|
+
resource_group: Optional[str] = Field(None, alias='resource-group')
|
|
54
|
+
region: Optional[str] = None
|
|
55
|
+
availability_zones: Optional[List[str]] = Field(
|
|
56
|
+
None, alias='availability-zones', examples=[['us-east-1a', 'us-east-1b']]
|
|
57
|
+
)
|
|
58
|
+
resource_arn: Optional[str] = Field(
|
|
59
|
+
None,
|
|
60
|
+
alias='resource-arn',
|
|
61
|
+
examples=[
|
|
62
|
+
'arn:aws:lambda:ap-south-1:905418309376:function:GcappOnboardingServicevnjto4fk7zaw'
|
|
63
|
+
],
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
class AzureNetworkAccess(BaseModel):
|
|
68
|
+
model_config = ConfigDict(
|
|
69
|
+
populate_by_name=True,
|
|
70
|
+
)
|
|
71
|
+
public_access_enabled: Optional[bool] = Field(None, alias='public-access-enabled')
|
|
72
|
+
private_access_enabled: Optional[bool] = Field(None, alias='private-access-enabled')
|
|
73
|
+
service_endpoint_enabled: Optional[bool] = Field(
|
|
74
|
+
None, alias='service-endpoint-enabled'
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
class AWSNetworkAccess(BaseModel):
|
|
79
|
+
model_config = ConfigDict(
|
|
80
|
+
populate_by_name=True,
|
|
81
|
+
)
|
|
82
|
+
public_access_enabled: Optional[bool] = Field(None, alias='public-access-enabled')
|
|
83
|
+
private_access_enabled: Optional[bool] = Field(None, alias='private-access-enabled')
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
class NetworkInterfaceData(BaseModel):
|
|
87
|
+
model_config = ConfigDict(
|
|
88
|
+
populate_by_name=True,
|
|
89
|
+
)
|
|
90
|
+
id: Optional[str] = Field(
|
|
91
|
+
None, description='nic id, managed as resource id in Azure'
|
|
92
|
+
)
|
|
93
|
+
mac_address: str = Field(..., alias='mac-address')
|
|
94
|
+
network: str
|
|
95
|
+
subnet_id: str = Field(..., alias='subnet-id')
|
|
96
|
+
private_ip_addresses: Optional[List[str]] = Field(
|
|
97
|
+
None, alias='private-ip-addresses'
|
|
98
|
+
)
|
|
99
|
+
public_ip_addresses: Optional[List[str]] = Field(None, alias='public-ip-addresses')
|
|
100
|
+
vlan: Optional[int] = None
|
|
101
|
+
vrf: Optional[str] = None
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
class OnlineStatus(Enum):
|
|
105
|
+
ONLINE = 'online'
|
|
106
|
+
OFFLINE = 'offline'
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
class PowerState(Enum):
|
|
110
|
+
RUNNING = 'running'
|
|
111
|
+
STOPPED = 'stopped'
|
|
112
|
+
RESTARTING = 'restarting'
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
class RegistrationStatus(Enum):
|
|
116
|
+
REGISTERED = 'registered'
|
|
117
|
+
UNREGISTERED = 'unregistered'
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
class Type1(Enum):
|
|
121
|
+
MS = 'MS'
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
class ManagedServiceData(BaseModel):
|
|
125
|
+
model_config = ConfigDict(
|
|
126
|
+
populate_by_name=True,
|
|
127
|
+
)
|
|
128
|
+
type: Type1
|
|
129
|
+
nics: Optional[List[NetworkInterfaceData]] = None
|
|
130
|
+
network_topology: Optional[
|
|
131
|
+
Union[AzureNetworkTopology, AWSNetworkTopology, Dict[str, Any]]
|
|
132
|
+
] = Field(None, alias='network-topology')
|
|
133
|
+
network_access: Optional[
|
|
134
|
+
Union[AzureNetworkAccess, AWSNetworkAccess, Dict[str, Any]]
|
|
135
|
+
] = Field(None, alias='network-access')
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
class APISec(BaseModel):
|
|
139
|
+
model_config = ConfigDict(
|
|
140
|
+
populate_by_name=True,
|
|
141
|
+
)
|
|
142
|
+
datatypes_tags: Optional[List[str]] = Field([], alias='datatypes-tags')
|
|
143
|
+
hosts: Optional[List[str]] = []
|
|
144
|
+
internet_facing: Optional[List[str]] = Field([], alias='internet-facing')
|
|
145
|
+
authentication: Optional[List[str]] = []
|
|
146
|
+
max_risk_score: Optional[float] = Field(0.0, alias='max-risk-score')
|
|
147
|
+
infrastructure_tags: Optional[Dict[str, Any]] = Field(
|
|
148
|
+
{}, alias='infrastructure-tags'
|
|
149
|
+
)
|
|
150
|
+
api_tag: Optional[List[str]] = Field([], alias='api-tag')
|
|
151
|
+
api_groups: Optional[List[str]] = Field([], alias='api-groups')
|
|
152
|
+
nn_ur: Optional[str] = Field('', alias='nn-ur')
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
class Type2(Enum):
|
|
156
|
+
IOT = 'IOT'
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
class IOTRegistrationStatus(BaseModel):
|
|
160
|
+
model_config = ConfigDict(
|
|
161
|
+
populate_by_name=True,
|
|
162
|
+
)
|
|
163
|
+
reg_status: Optional[RegistrationStatus] = Field(None, alias='reg-status')
|
|
164
|
+
reg_date: Optional[AwareDatetime] = Field(None, alias='reg-date')
|
|
165
|
+
unreg_date: Optional[AwareDatetime] = Field(None, alias='unreg-date')
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
class HardwareInfo(BaseModel):
|
|
169
|
+
model_config = ConfigDict(
|
|
170
|
+
populate_by_name=True,
|
|
171
|
+
)
|
|
172
|
+
hw_class: Optional[str] = Field('unknown', alias='hw-class')
|
|
173
|
+
hw_manufacturer: Optional[str] = Field('unknown', alias='hw-manufacturer')
|
|
174
|
+
hw_type: Optional[str] = Field('unknown', alias='hw-type')
|
|
175
|
+
bios_uuid: Optional[str] = Field('unknown', alias='bios-uuid')
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
class VMData(BaseModel):
|
|
179
|
+
model_config = ConfigDict(
|
|
180
|
+
populate_by_name=True,
|
|
181
|
+
)
|
|
182
|
+
type: Type
|
|
183
|
+
os_details: Optional[Dict[str, Any]] = Field(None, alias='os-details')
|
|
184
|
+
hw_details: Optional[HardwareInfo] = Field(None, alias='hw-details')
|
|
185
|
+
nics: Optional[List[NetworkInterfaceData]] = None
|
|
186
|
+
network_topology: Optional[
|
|
187
|
+
Union[AzureNetworkTopology, AWSNetworkTopology, Dict[str, Any]]
|
|
188
|
+
] = Field(None, alias='network-topology')
|
|
189
|
+
power_state: Optional[PowerState] = Field(None, alias='power-state')
|
|
190
|
+
api_sec: Optional[APISec] = Field(None, alias='api-sec')
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
class IOT(BaseModel):
|
|
194
|
+
model_config = ConfigDict(
|
|
195
|
+
populate_by_name=True,
|
|
196
|
+
)
|
|
197
|
+
type: Type2
|
|
198
|
+
os_details: Optional[Dict[str, Any]] = Field(None, alias='os-details')
|
|
199
|
+
hw_details: HardwareInfo = Field(..., alias='hw-details')
|
|
200
|
+
nics: Optional[List[NetworkInterfaceData]] = None
|
|
201
|
+
power_state: Optional[PowerState] = Field(None, alias='power-state')
|
|
202
|
+
online_status: Optional[OnlineStatus] = Field(None, alias='online-status')
|
|
203
|
+
registration_status: Optional[IOTRegistrationStatus] = Field(
|
|
204
|
+
None, alias='registration-status'
|
|
205
|
+
)
|
|
206
|
+
device_score: Optional[str] = Field(None, alias='device-score')
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
class InventoryItem(BaseModel):
|
|
210
|
+
model_config = ConfigDict(
|
|
211
|
+
populate_by_name=True,
|
|
212
|
+
)
|
|
213
|
+
item_type: Optional[ItemType] = Field(
|
|
214
|
+
'asset',
|
|
215
|
+
alias='item-type',
|
|
216
|
+
description='inventory item type - currently asset only',
|
|
217
|
+
)
|
|
218
|
+
item_id: Optional[str] = Field(
|
|
219
|
+
None, alias='item-id', description='inventory item id assigned by Centra'
|
|
220
|
+
)
|
|
221
|
+
external_ids: Optional[List[str]] = Field(
|
|
222
|
+
None,
|
|
223
|
+
alias='external-ids',
|
|
224
|
+
description='list of external IDs that are managed by external asset management systems such as Azure resource management',
|
|
225
|
+
)
|
|
226
|
+
entity_type: Optional[str] = Field(
|
|
227
|
+
None,
|
|
228
|
+
alias='entity-type',
|
|
229
|
+
description='asset type such as Virtual Machine or Azure SQL Server',
|
|
230
|
+
)
|
|
231
|
+
entity_category: Optional[str] = Field(
|
|
232
|
+
None,
|
|
233
|
+
alias='entity-category',
|
|
234
|
+
description='asset category such as Compute or Database',
|
|
235
|
+
)
|
|
236
|
+
entity_name: Optional[str] = Field(
|
|
237
|
+
None, alias='entity-name', description='asset name'
|
|
238
|
+
)
|
|
239
|
+
entity_data: Optional[
|
|
240
|
+
Union[VMData, IOT, ManagedServiceData, K8SData, Dict[str, Any]]
|
|
241
|
+
] = Field(
|
|
242
|
+
None,
|
|
243
|
+
alias='entity-data',
|
|
244
|
+
description='additional entity data depending on its type',
|
|
245
|
+
union_mode='left_to_right',
|
|
246
|
+
)
|
|
247
|
+
labels: Optional[List[Label]] = None
|
|
248
|
+
metadata_attributes: Optional[Dict[str, Any]] = Field(
|
|
249
|
+
None, alias='metadata-attributes'
|
|
250
|
+
)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# generated by fastapi-codegen:
|
|
2
|
+
# filename: /home/ivasylen/sdk_project/contracts/guardicore/connector
|
|
3
|
+
# timestamp: 2025-07-31T14:14:32+00:00
|
|
4
|
+
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
|
|
7
|
+
from typing import List, Optional
|
|
8
|
+
|
|
9
|
+
from pydantic import BaseModel, ConfigDict, Field
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class AgentsInfo(BaseModel):
|
|
13
|
+
model_config = ConfigDict(
|
|
14
|
+
populate_by_name=True,
|
|
15
|
+
)
|
|
16
|
+
mac_addresses: Optional[List[str]] = Field(
|
|
17
|
+
None,
|
|
18
|
+
alias='mac-addresses',
|
|
19
|
+
description='Known agents MAC addresses without separator',
|
|
20
|
+
examples=[['000000000000', '112233445566']],
|
|
21
|
+
)
|