Skip to content

Commit 0dd8f24

Browse files
authored
[lib][chore] Rename internal properties with underscore (#2209)
1 parent 3136b95 commit 0dd8f24

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+2587
-2563
lines changed

fixlib/fixlib/baseresources.py

Lines changed: 234 additions & 218 deletions
Large diffs are not rendered by default.

fixlib/fixlib/core/model_check.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,14 +139,14 @@ def check_model_class(clazz: Type[BaseResource]) -> None:
139139
kind = clazz.kind
140140
if any(kind.startswith(a) for a in ["aws", "gcp", "azure", "microsoft"]): # only selected providers support this
141141
props = vars(clazz)
142-
if "kind_display" not in props:
143-
raise AttributeError(f"Class {name} does not have a kind_display attribute")
144-
assert clazz.kind_service is not None, f"Class {name} does not have a kind_service attribute"
142+
if "_kind_display" not in props:
143+
raise AttributeError(f"Class {name} does not have a _kind_display attribute")
144+
assert clazz._kind_service is not None, f"Class {name} does not have a _kind_service attribute"
145145

146-
# make sure metadata is valid
147-
if icon := clazz.metadata.get("icon"):
146+
# make sure _metadata is valid
147+
if icon := clazz._metadata.get("icon"):
148148
assert icon in ResourceIcons, f"{name} has unknown icon {icon}"
149-
if group := clazz.metadata.get("group"):
149+
if group := clazz._metadata.get("group"):
150150
assert group in ResourceGroups, f"{name} has unknown group {group}"
151151

152152

fixlib/fixlib/core/model_export.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,9 @@ def json(
193193
meta: Optional[Dict[str, str]],
194194
**kwargs: Any,
195195
) -> Json:
196-
js = {"name": name, "kind": kind_str, "required": required, "description": description, **kwargs}
196+
js = {"name": name, "kind": kind_str, "required": required, **kwargs}
197+
if description:
198+
js["description"] = description
197199
if meta:
198200
js["metadata"] = meta
199201
return js
@@ -227,7 +229,7 @@ def json(
227229
if succs := getattr(clazz, "successor_kinds", None):
228230
for edge_type, values in succs.items():
229231
successors[name][edge_type].extend(values)
230-
if refs := getattr(clazz, "reference_kinds", None):
232+
if refs := getattr(clazz, "_reference_kinds", None):
231233
if succs := refs.get("successors", None):
232234
for edge_type, values in succs.items():
233235
successors[name][edge_type].extend(values)
@@ -247,19 +249,19 @@ def export_data_class(clazz: type) -> None:
247249
root = any(sup == aggregate_root for sup in clazz.mro()) if aggregate_root else True
248250
kind = model_name(clazz)
249251
metadata: Json = {}
250-
if (m := getattr(clazz, "metadata", None)) and isinstance(m, dict):
252+
if (m := getattr(clazz, "_metadata", None)) and isinstance(m, dict):
251253
metadata = m.copy()
252-
if (s := clazz.__dict__.get("kind_display", None)) and isinstance(s, str):
254+
if (s := clazz.__dict__.get("_kind_display", None)) and isinstance(s, str):
253255
metadata["name"] = s
254-
if (s := getattr(clazz, "kind_service", None)) and isinstance(s, str):
256+
if (s := getattr(clazz, "_kind_service", None)) and isinstance(s, str):
255257
metadata["service"] = s
256258
if (slc := getattr(clazz, "categories", None)) and callable(slc) and (sl := slc()):
257259
metadata["categories"] = sl
258260
if ( # only export kind description on aggregate roots
259261
with_kind_description
260262
and (ar := aggregate_root)
261263
and issubclass(clazz, ar)
262-
and (s := clazz.__dict__.get("kind_description", None))
264+
and (s := clazz.__dict__.get("_kind_description", None))
263265
and isinstance(s, str)
264266
):
265267
metadata["description"] = s

fixlib/test/core/model_export_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class DataClassExample(DataClassBase):
4747
successor_kinds: ClassVar[Dict[str, List[str]]] = {
4848
"default": ["example"],
4949
}
50-
reference_kinds: ClassVar[ModelReference] = {
50+
_reference_kinds: ClassVar[ModelReference] = {
5151
"successors": {"default": ["base"]},
5252
"predecessors": {"delete": ["other"]},
5353
}

plugins/aws/fix_plugin_aws/collector.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -460,16 +460,16 @@ def add_accounts(parent: Union[AwsOrganizationalRoot, AwsOrganizationalUnit]) ->
460460
@define(eq=False, slots=False)
461461
class AwsOrganizationalRoot(BaseOrganizationalRoot, AwsResource):
462462
kind: ClassVar[str] = "aws_organizational_root"
463-
kind_display: ClassVar[str] = "AWS Organizational Root"
464-
kind_description: ClassVar[str] = "An AWS Organizational Root is the root of an AWS Organization."
465-
kind_service = "organizations"
466-
metadata: ClassVar[Dict[str, Any]] = {"icon": "group", "group": "management"}
463+
_kind_display: ClassVar[str] = "AWS Organizational Root"
464+
_kind_description: ClassVar[str] = "An AWS Organizational Root is the root of an AWS Organization."
465+
_kind_service = "organizations"
466+
_metadata: ClassVar[Dict[str, Any]] = {"icon": "group", "group": "management"}
467467

468468

469469
@define(eq=False, slots=False)
470470
class AwsOrganizationalUnit(BaseOrganizationalUnit, AwsResource):
471471
kind: ClassVar[str] = "aws_organizational_unit"
472-
kind_display: ClassVar[str] = "AWS Organizational Unit"
473-
kind_description: ClassVar[str] = "An AWS Organizational Unit is a container for AWS Accounts."
474-
kind_service = "organizations"
475-
metadata: ClassVar[Dict[str, Any]] = {"icon": "group", "group": "management"}
472+
_kind_display: ClassVar[str] = "AWS Organizational Unit"
473+
_kind_description: ClassVar[str] = "An AWS Organizational Unit is a container for AWS Accounts."
474+
_kind_service = "organizations"
475+
_metadata: ClassVar[Dict[str, Any]] = {"icon": "group", "group": "management"}

plugins/aws/fix_plugin_aws/resource/acm.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ class AwsAcmExtendedKeyUsage:
6969
@define(eq=False, slots=False)
7070
class AwsAcmCertificate(AwsResource, BaseCertificate):
7171
kind: ClassVar[str] = "aws_acm_certificate"
72-
kind_display: ClassVar[str] = "AWS ACM Certificate"
73-
aws_metadata: ClassVar[Dict[str, Any]] = {"provider_link_tpl": "https://{region_id}.console.aws.amazon.com/acm/home?region={region}#/certificates/{id}", "arn_tpl": "arn:{partition}:acm:{region}:{account}:certificate/{id}"} # fmt: skip
74-
kind_description: ClassVar[str] = "An AWS ACM Certificate is used to provision, manage, and deploy Secure Sockets Layer/Transport Layer Security (SSL/TLS) certificates for secure web traffic on AWS services." # fmt: skip
75-
kind_service: ClassVar[Optional[str]] = service_name
72+
_kind_display: ClassVar[str] = "AWS ACM Certificate"
73+
_aws_metadata: ClassVar[Dict[str, Any]] = {"provider_link_tpl": "https://{region_id}.console.aws.amazon.com/acm/home?region={region}#/certificates/{id}", "arn_tpl": "arn:{partition}:acm:{region}:{account}:certificate/{id}"} # fmt: skip
74+
_kind_description: ClassVar[str] = "An AWS ACM Certificate is used to provision, manage, and deploy Secure Sockets Layer/Transport Layer Security (SSL/TLS) certificates for secure web traffic on AWS services." # fmt: skip
75+
_kind_service: ClassVar[Optional[str]] = service_name
7676
api_spec: ClassVar[AwsApiSpec] = AwsApiSpec("acm", "describe-certificate", "Certificate")
7777
mapping: ClassVar[Dict[str, Bender]] = {
7878
"id": S("CertificateArn") >> F(AwsResource.id_from_arn),

plugins/aws/fix_plugin_aws/resource/amazonq.py

Lines changed: 56 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,18 @@ def service_name(cls) -> str:
4747
@define(eq=False, slots=False)
4848
class AwsQBusinessApplication(AmazonQTaggable, AwsResource):
4949
kind: ClassVar[str] = "aws_q_business_application"
50-
kind_display: ClassVar[str] = "AWS QBusiness Application"
51-
kind_description: ClassVar[str] = (
50+
_kind_display: ClassVar[str] = "AWS QBusiness Application"
51+
_kind_description: ClassVar[str] = (
5252
"Represents a QBusiness application within the AWS QBusiness service. Applications"
5353
" define a set of tasks and configuration for processing data within the QBusiness ecosystem."
5454
)
55-
kind_service: ClassVar[Optional[str]] = service_name
56-
metadata: ClassVar[Dict[str, Any]] = {"icon": "application", "group": "ai"}
57-
aws_metadata: ClassVar[Dict[str, Any]] = {
55+
_kind_service: ClassVar[Optional[str]] = service_name
56+
_metadata: ClassVar[Dict[str, Any]] = {"icon": "application", "group": "ai"}
57+
_aws_metadata: ClassVar[Dict[str, Any]] = {
5858
"provider_link_tpl": "https://{region_id}.console.aws.amazon.com/amazonq/business/applications/{id}/details?region={region}", # fmt: skip
5959
"arn_tpl": "arn:{partition}:qbusiness:{region}:{account}:application/{id}",
6060
}
61-
reference_kinds: ClassVar[ModelReference] = {
61+
_reference_kinds: ClassVar[ModelReference] = {
6262
"successors": {
6363
"default": [
6464
"aws_q_business_conversation",
@@ -313,13 +313,13 @@ def collect_index_resources(
313313
@define(eq=False, slots=False)
314314
class AwsQBusinessConversation(AwsResource):
315315
kind: ClassVar[str] = "aws_q_business_conversation"
316-
kind_display: ClassVar[str] = "AWS QBusiness Conversation"
317-
kind_description: ClassVar[str] = (
316+
_kind_display: ClassVar[str] = "AWS QBusiness Conversation"
317+
_kind_description: ClassVar[str] = (
318318
"Represents a conversation within the AWS QBusiness service. Conversations are"
319319
" interactions that involve a series of messages or data exchanges."
320320
)
321-
kind_service: ClassVar[Optional[str]] = service_name
322-
metadata: ClassVar[Dict[str, Any]] = {"icon": "resource", "group": "ai"}
321+
_kind_service: ClassVar[Optional[str]] = service_name
322+
_metadata: ClassVar[Dict[str, Any]] = {"icon": "resource", "group": "ai"}
323323
# Collected via AwsQBusinessApplication()
324324
mapping: ClassVar[Dict[str, Bender]] = {
325325
"id": S("conversationId"),
@@ -347,15 +347,15 @@ def service_name(cls) -> str:
347347
@define(eq=False, slots=False)
348348
class AwsQBusinessDataSource(AmazonQTaggable, AwsResource):
349349
kind: ClassVar[str] = "aws_q_business_data_source"
350-
kind_display: ClassVar[str] = "AWS QBusiness Data Source"
351-
kind_description: ClassVar[str] = (
350+
_kind_display: ClassVar[str] = "AWS QBusiness Data Source"
351+
_kind_description: ClassVar[str] = (
352352
"Represents a data source in the AWS QBusiness service. Data sources are the origins"
353353
" from which data is ingested for processing or analysis within the QBusiness framework."
354354
)
355-
kind_service: ClassVar[Optional[str]] = service_name
356-
metadata: ClassVar[Dict[str, Any]] = {"icon": "bucket", "group": "ai"}
355+
_kind_service: ClassVar[Optional[str]] = service_name
356+
_metadata: ClassVar[Dict[str, Any]] = {"icon": "bucket", "group": "ai"}
357357
# Collected via AwsQBusinessApplication()
358-
aws_metadata: ClassVar[Dict[str, Any]] = {
358+
_aws_metadata: ClassVar[Dict[str, Any]] = {
359359
"provider_link_tpl": "https://{region_id}.console.aws.amazon.com/amazonq/business/applications/{application_id}/indices/{indice_id}/datasources/{id}/details?region={region}", # fmt: skip
360360
"arn_tpl": "arn:{partition}:qbusiness:{region}:{account}:application/{application_id}/index/{indice_id}/data-source/{id}",
361361
"extra_args_for_arn": ["application_id", "indice_id"],
@@ -437,13 +437,13 @@ class AwsQBusinessDataSourceSyncJobMetrics:
437437
@define(eq=False, slots=False)
438438
class AwsQBusinessDataSourceSyncJob(AwsResource):
439439
kind: ClassVar[str] = "aws_q_business_data_source_sync_job"
440-
kind_display: ClassVar[str] = "AWS QBusiness Data Source Sync Job"
441-
kind_description: ClassVar[str] = (
440+
_kind_display: ClassVar[str] = "AWS QBusiness Data Source Sync Job"
441+
_kind_description: ClassVar[str] = (
442442
"Represents a data source synchronization job in the AWS QBusiness service. Sync jobs"
443443
" ensure that data from data sources is up-to-date and correctly integrated into the system."
444444
)
445-
kind_service: ClassVar[Optional[str]] = service_name
446-
metadata: ClassVar[Dict[str, Any]] = {"icon": "job", "group": "ai"}
445+
_kind_service: ClassVar[Optional[str]] = service_name
446+
_metadata: ClassVar[Dict[str, Any]] = {"icon": "job", "group": "ai"}
447447
# Collected via AwsQBusinessApplication()
448448
mapping: ClassVar[Dict[str, Bender]] = {
449449
"id": S("executionId"),
@@ -479,13 +479,13 @@ def service_name(cls) -> str:
479479
@define(eq=False, slots=False)
480480
class AwsQBusinessDocument(AwsResource):
481481
kind: ClassVar[str] = "aws_q_business_document"
482-
kind_display: ClassVar[str] = "AWS QBusiness Document"
483-
kind_description: ClassVar[str] = (
482+
_kind_display: ClassVar[str] = "AWS QBusiness Document"
483+
_kind_description: ClassVar[str] = (
484484
"Represents a document within the AWS QBusiness service. Documents are structured pieces"
485485
" of information that can be used for various purposes within the QBusiness ecosystem."
486486
)
487-
kind_service: ClassVar[Optional[str]] = service_name
488-
metadata: ClassVar[Dict[str, Any]] = {"icon": "config", "group": "ai"}
487+
_kind_service: ClassVar[Optional[str]] = service_name
488+
_metadata: ClassVar[Dict[str, Any]] = {"icon": "config", "group": "ai"}
489489
# Collected via AwsQBusinessApplication()
490490
mapping: ClassVar[Dict[str, Bender]] = {
491491
"id": S("documentId"),
@@ -519,14 +519,14 @@ def service_name(cls) -> str:
519519
@define(eq=False, slots=False)
520520
class AwsQBusinessIndice(AmazonQTaggable, AwsResource):
521521
kind: ClassVar[str] = "aws_q_business_indice"
522-
kind_display: ClassVar[str] = "AWS QBusiness Indice"
523-
kind_description: ClassVar[str] = (
522+
_kind_display: ClassVar[str] = "AWS QBusiness Indice"
523+
_kind_description: ClassVar[str] = (
524524
"Represents an index in the AWS QBusiness service. Indices are used to organize and"
525525
" facilitate efficient searching and retrieval of data within the QBusiness framework."
526526
)
527-
kind_service: ClassVar[Optional[str]] = service_name
528-
metadata: ClassVar[Dict[str, Any]] = {"icon": "config", "group": "ai"}
529-
aws_metadata: ClassVar[Dict[str, Any]] = {
527+
_kind_service: ClassVar[Optional[str]] = service_name
528+
_metadata: ClassVar[Dict[str, Any]] = {"icon": "config", "group": "ai"}
529+
_aws_metadata: ClassVar[Dict[str, Any]] = {
530530
"arn_tpl": "arn:{partition}:qbusiness:{region}:{account}:application/{application_id}/index/{id}",
531531
"extra_args_for_arn": ["application_id"],
532532
}
@@ -700,13 +700,13 @@ class AwsQBusinessActionExecution:
700700
@define(eq=False, slots=False)
701701
class AwsQBusinessMessage(AwsResource):
702702
kind: ClassVar[str] = "aws_q_business_message"
703-
kind_display: ClassVar[str] = "AWS QBusiness Message"
704-
kind_description: ClassVar[str] = (
703+
_kind_display: ClassVar[str] = "AWS QBusiness Message"
704+
_kind_description: ClassVar[str] = (
705705
"Represents a message within the AWS QBusiness service. Messages are used for communication"
706706
" or data exchange between various components or users within the QBusiness ecosystem."
707707
)
708-
kind_service: ClassVar[Optional[str]] = service_name
709-
metadata: ClassVar[Dict[str, Any]] = {"icon": "config", "group": "ai"}
708+
_kind_service: ClassVar[Optional[str]] = service_name
709+
_metadata: ClassVar[Dict[str, Any]] = {"icon": "config", "group": "ai"}
710710
# Collected via AwsQBusinessApplication()
711711
mapping: ClassVar[Dict[str, Bender]] = {
712712
"id": S("messageId"),
@@ -744,14 +744,14 @@ def service_name(cls) -> str:
744744
@define(eq=False, slots=False)
745745
class AwsQBusinessPlugin(AmazonQTaggable, AwsResource):
746746
kind: ClassVar[str] = "aws_q_business_plugin"
747-
kind_display: ClassVar[str] = "AWS QBusiness Plugin"
748-
kind_description: ClassVar[str] = (
747+
_kind_display: ClassVar[str] = "AWS QBusiness Plugin"
748+
_kind_description: ClassVar[str] = (
749749
"Represents a plugin in the AWS QBusiness service. Plugins extend the functionality of"
750750
" the QBusiness framework by adding new features or capabilities."
751751
)
752-
kind_service: ClassVar[Optional[str]] = service_name
753-
metadata: ClassVar[Dict[str, Any]] = {"icon": "resource", "group": "ai"}
754-
aws_metadata: ClassVar[Dict[str, Any]] = {
752+
_kind_service: ClassVar[Optional[str]] = service_name
753+
_metadata: ClassVar[Dict[str, Any]] = {"icon": "resource", "group": "ai"}
754+
_aws_metadata: ClassVar[Dict[str, Any]] = {
755755
"arn_tpl": "arn:{partition}:qbusiness:{region}:{account}:application/{application_id}/plugin/{id}",
756756
"extra_args_for_arn": ["application_id"],
757757
}
@@ -810,14 +810,14 @@ def delete_resource(self, client: AwsClient, graph: Graph) -> bool:
810810
@define(eq=False, slots=False)
811811
class AwsQBusinessRetriever(AmazonQTaggable, AwsResource):
812812
kind: ClassVar[str] = "aws_q_business_retriever"
813-
kind_display: ClassVar[str] = "AWS Q Business Retriever"
814-
kind_description: ClassVar[str] = (
813+
_kind_display: ClassVar[str] = "AWS Q Business Retriever"
814+
_kind_description: ClassVar[str] = (
815815
"Represents a retriever in the AWS QBusiness service. Retrievers are used to fetch and"
816816
" process data from various sources within the QBusiness ecosystem."
817817
)
818-
kind_service: ClassVar[Optional[str]] = service_name
819-
metadata: ClassVar[Dict[str, Any]] = {"icon": "application", "group": "ai"}
820-
aws_metadata: ClassVar[Dict[str, Any]] = {
818+
_kind_service: ClassVar[Optional[str]] = service_name
819+
_metadata: ClassVar[Dict[str, Any]] = {"icon": "application", "group": "ai"}
820+
_aws_metadata: ClassVar[Dict[str, Any]] = {
821821
"arn_tpl": "arn:{partition}:qbusiness:{region}:{account}:application/{application_id}/retriever/{id}",
822822
"extra_args_for_arn": ["application_id"],
823823
}
@@ -867,14 +867,14 @@ def delete_resource(self, client: AwsClient, graph: Graph) -> bool:
867867
@define(eq=False, slots=False)
868868
class AwsQBusinessWebExperience(AmazonQTaggable, AwsResource):
869869
kind: ClassVar[str] = "aws_q_business_web_experience"
870-
kind_display: ClassVar[str] = "AWS Q Business Web Experience"
871-
kind_description: ClassVar[str] = (
870+
_kind_display: ClassVar[str] = "AWS Q Business Web Experience"
871+
_kind_description: ClassVar[str] = (
872872
"Represents a web experience in the AWS QBusiness service. Web experiences define"
873873
" interactive web-based applications or interfaces within the QBusiness ecosystem."
874874
)
875-
kind_service: ClassVar[Optional[str]] = service_name
876-
metadata: ClassVar[Dict[str, Any]] = {"icon": "application", "group": "ai"}
877-
aws_metadata: ClassVar[Dict[str, Any]] = {
875+
_kind_service: ClassVar[Optional[str]] = service_name
876+
_metadata: ClassVar[Dict[str, Any]] = {"icon": "application", "group": "ai"}
877+
_aws_metadata: ClassVar[Dict[str, Any]] = {
878878
"arn_tpl": "arn:{partition}:qbusiness:{region}:{account}:application/{application_id}/web-experience/{id}",
879879
"extra_args_for_arn": ["application_id"],
880880
}
@@ -935,15 +935,15 @@ class AwsQAppsCategory:
935935
@define(eq=False, slots=False)
936936
class AwsQAppsLibraryItem(AwsResource):
937937
kind: ClassVar[str] = "aws_q_apps_library_item"
938-
kind_display: ClassVar[str] = "AWS QApps Library Item"
939-
kind_description: ClassVar[str] = (
938+
_kind_display: ClassVar[str] = "AWS QApps Library Item"
939+
_kind_description: ClassVar[str] = (
940940
"Represents a library item in the AWS QApps service. Library items include resources"
941941
" such as scripts, templates, or other components that can be used in QApps applications."
942942
)
943-
kind_service: ClassVar[Optional[str]] = service_name
944-
metadata: ClassVar[Dict[str, Any]] = {"icon": "image", "group": "ai"}
943+
_kind_service: ClassVar[Optional[str]] = service_name
944+
_metadata: ClassVar[Dict[str, Any]] = {"icon": "image", "group": "ai"}
945945
# Collected via AwsQBusinessApplication()
946-
reference_kinds: ClassVar[ModelReference] = {
946+
_reference_kinds: ClassVar[ModelReference] = {
947947
"predecessors": {"default": ["aws_q_apps"]},
948948
}
949949
mapping: ClassVar[Dict[str, Bender]] = {
@@ -1016,13 +1016,13 @@ def service_name(cls) -> str:
10161016
@define(eq=False, slots=False)
10171017
class AwsQApps(AwsResource):
10181018
kind: ClassVar[str] = "aws_q_apps"
1019-
kind_display: ClassVar[str] = "AWS QApps"
1020-
kind_description: ClassVar[str] = (
1019+
_kind_display: ClassVar[str] = "AWS QApps"
1020+
_kind_description: ClassVar[str] = (
10211021
"Represents an application within the AWS QApps service. QApps applications include"
10221022
" various components and configurations for developing and deploying apps within the AWS environment."
10231023
)
1024-
kind_service: ClassVar[Optional[str]] = service_name
1025-
metadata: ClassVar[Dict[str, Any]] = {"icon": "application", "group": "ai"}
1024+
_kind_service: ClassVar[Optional[str]] = service_name
1025+
_metadata: ClassVar[Dict[str, Any]] = {"icon": "application", "group": "ai"}
10261026
# Collected via AwsQBusinessApplication()
10271027
mapping: ClassVar[Dict[str, Bender]] = {
10281028
"id": S("appId"),

0 commit comments

Comments
 (0)