Skip to content

Commit 6a7fb18

Browse files
committed
Added additional attributes to the connector credentials & example
1 parent 89b6f44 commit 6a7fb18

File tree

4 files changed

+45
-13
lines changed

4 files changed

+45
-13
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ __pycache__
88
.secrets
99
requirements.txt
1010
/example
11+
job.log

tenint/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
from .models.configuration import Configuration, Settings # noqa F401
33
from .connector import Connector # noqa F401
44

5-
__version__ = "1.0.2"
5+
__version__ = "1.0.3"

tenint/models/credentials.py

+29-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
from typing import Any, Literal
1+
from typing import Annotated, Any, Literal
22

3-
from pydantic import AnyHttpUrl, BaseModel, ConfigDict, SecretStr, computed_field
3+
from pydantic import AnyHttpUrl, BaseModel, ConfigDict, Field, SecretStr, computed_field
44

55

66
def credential_schema(schema: dict[str, Any]) -> None:
@@ -50,9 +50,21 @@ class TenableCloudCredential(Credential):
5050
name: Literal["Tenable Cloud"] = "Tenable Cloud"
5151
slug: Literal["tvm"] = "tvm"
5252
description: str = "Tenable Cloud Credential"
53-
url: AnyHttpUrl = "https://cloud.tenable.com"
54-
access_key: str
55-
secret_key: SecretStr
53+
url: Annotated[
54+
AnyHttpUrl,
55+
Field(
56+
title="Cloud URL",
57+
description="Only needs to be modified when interacting with a FedRAMP cloud instance",
58+
),
59+
] = "https://cloud.tenable.com"
60+
access_key: Annotated[
61+
str,
62+
Field(title="API Access Key", description="Tenable Cloud API Access Key"),
63+
]
64+
secret_key: Annotated[
65+
SecretStr,
66+
Field(title="API Secret Key", description="Tenable Cloud API Secret Key"),
67+
]
5668

5769

5870
class TenableSCCredential(Credential):
@@ -64,6 +76,15 @@ class TenableSCCredential(Credential):
6476
name: Literal["Tenable Security Center"] = "Tenable Security Center"
6577
slug: Literal["tsc"] = "tsc"
6678
description: str = "Tenable Security Center Credential"
67-
url: AnyHttpUrl
68-
access_key: str
69-
secret_key: SecretStr
79+
url: Annotated[
80+
AnyHttpUrl,
81+
Field(title="Host URL", description="Security Center Application URL"),
82+
]
83+
access_key: Annotated[
84+
str,
85+
Field(title="API Access Key", description="Security Center API Access Key"),
86+
]
87+
secret_key: Annotated[
88+
SecretStr,
89+
Field(title="API Secret Key", description="Security Center API Secret Key"),
90+
]

tenint/templates/connector.py

+14-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import logging
2+
from typing import Annotated
23

3-
from pydantic import AnyHttpUrl
4+
from pydantic import AnyHttpUrl, Field
45

56
from tenint import Connector, Credential, Settings
67

@@ -9,12 +10,21 @@ class TestCredential(Credential):
910
prefix: str = "test"
1011
name: str = "Test Credential"
1112
slug: str = "test"
12-
api_key: str
13-
url: AnyHttpUrl = "https://httpbin.org/get"
13+
api_key: Annotated[
14+
str,
15+
Field(title="API Key", description="Application API Key"),
16+
]
17+
url: Annotated[
18+
AnyHttpUrl,
19+
Field(title="Application URL", description="Application URL"),
20+
] = "https://httpbin.org/get"
1421

1522

1623
class AppSettings(Settings):
17-
is_bool: bool = True
24+
is_bool: Annotated[
25+
bool,
26+
Field(title="Yes?", description="An example boolean flag"),
27+
] = True
1828

1929

2030
log = logging.getLogger("test-connector")

0 commit comments

Comments
 (0)