Skip to content

Commit

Permalink
[lib][chore] Rename internal properties with underscore (#2209)
Browse files Browse the repository at this point in the history
  • Loading branch information
aquamatthias authored Sep 24, 2024
1 parent 3136b95 commit 0dd8f24
Show file tree
Hide file tree
Showing 84 changed files with 2,587 additions and 2,563 deletions.
452 changes: 234 additions & 218 deletions fixlib/fixlib/baseresources.py

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions fixlib/fixlib/core/model_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,14 @@ def check_model_class(clazz: Type[BaseResource]) -> None:
kind = clazz.kind
if any(kind.startswith(a) for a in ["aws", "gcp", "azure", "microsoft"]): # only selected providers support this
props = vars(clazz)
if "kind_display" not in props:
raise AttributeError(f"Class {name} does not have a kind_display attribute")
assert clazz.kind_service is not None, f"Class {name} does not have a kind_service attribute"
if "_kind_display" not in props:
raise AttributeError(f"Class {name} does not have a _kind_display attribute")
assert clazz._kind_service is not None, f"Class {name} does not have a _kind_service attribute"

# make sure metadata is valid
if icon := clazz.metadata.get("icon"):
# make sure _metadata is valid
if icon := clazz._metadata.get("icon"):
assert icon in ResourceIcons, f"{name} has unknown icon {icon}"
if group := clazz.metadata.get("group"):
if group := clazz._metadata.get("group"):
assert group in ResourceGroups, f"{name} has unknown group {group}"


Expand Down
14 changes: 8 additions & 6 deletions fixlib/fixlib/core/model_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,9 @@ def json(
meta: Optional[Dict[str, str]],
**kwargs: Any,
) -> Json:
js = {"name": name, "kind": kind_str, "required": required, "description": description, **kwargs}
js = {"name": name, "kind": kind_str, "required": required, **kwargs}
if description:
js["description"] = description
if meta:
js["metadata"] = meta
return js
Expand Down Expand Up @@ -227,7 +229,7 @@ def json(
if succs := getattr(clazz, "successor_kinds", None):
for edge_type, values in succs.items():
successors[name][edge_type].extend(values)
if refs := getattr(clazz, "reference_kinds", None):
if refs := getattr(clazz, "_reference_kinds", None):
if succs := refs.get("successors", None):
for edge_type, values in succs.items():
successors[name][edge_type].extend(values)
Expand All @@ -247,19 +249,19 @@ def export_data_class(clazz: type) -> None:
root = any(sup == aggregate_root for sup in clazz.mro()) if aggregate_root else True
kind = model_name(clazz)
metadata: Json = {}
if (m := getattr(clazz, "metadata", None)) and isinstance(m, dict):
if (m := getattr(clazz, "_metadata", None)) and isinstance(m, dict):
metadata = m.copy()
if (s := clazz.__dict__.get("kind_display", None)) and isinstance(s, str):
if (s := clazz.__dict__.get("_kind_display", None)) and isinstance(s, str):
metadata["name"] = s
if (s := getattr(clazz, "kind_service", None)) and isinstance(s, str):
if (s := getattr(clazz, "_kind_service", None)) and isinstance(s, str):
metadata["service"] = s
if (slc := getattr(clazz, "categories", None)) and callable(slc) and (sl := slc()):
metadata["categories"] = sl
if ( # only export kind description on aggregate roots
with_kind_description
and (ar := aggregate_root)
and issubclass(clazz, ar)
and (s := clazz.__dict__.get("kind_description", None))
and (s := clazz.__dict__.get("_kind_description", None))
and isinstance(s, str)
):
metadata["description"] = s
Expand Down
2 changes: 1 addition & 1 deletion fixlib/test/core/model_export_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class DataClassExample(DataClassBase):
successor_kinds: ClassVar[Dict[str, List[str]]] = {
"default": ["example"],
}
reference_kinds: ClassVar[ModelReference] = {
_reference_kinds: ClassVar[ModelReference] = {
"successors": {"default": ["base"]},
"predecessors": {"delete": ["other"]},
}
Expand Down
16 changes: 8 additions & 8 deletions plugins/aws/fix_plugin_aws/collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,16 +460,16 @@ def add_accounts(parent: Union[AwsOrganizationalRoot, AwsOrganizationalUnit]) ->
@define(eq=False, slots=False)
class AwsOrganizationalRoot(BaseOrganizationalRoot, AwsResource):
kind: ClassVar[str] = "aws_organizational_root"
kind_display: ClassVar[str] = "AWS Organizational Root"
kind_description: ClassVar[str] = "An AWS Organizational Root is the root of an AWS Organization."
kind_service = "organizations"
metadata: ClassVar[Dict[str, Any]] = {"icon": "group", "group": "management"}
_kind_display: ClassVar[str] = "AWS Organizational Root"
_kind_description: ClassVar[str] = "An AWS Organizational Root is the root of an AWS Organization."
_kind_service = "organizations"
_metadata: ClassVar[Dict[str, Any]] = {"icon": "group", "group": "management"}


@define(eq=False, slots=False)
class AwsOrganizationalUnit(BaseOrganizationalUnit, AwsResource):
kind: ClassVar[str] = "aws_organizational_unit"
kind_display: ClassVar[str] = "AWS Organizational Unit"
kind_description: ClassVar[str] = "An AWS Organizational Unit is a container for AWS Accounts."
kind_service = "organizations"
metadata: ClassVar[Dict[str, Any]] = {"icon": "group", "group": "management"}
_kind_display: ClassVar[str] = "AWS Organizational Unit"
_kind_description: ClassVar[str] = "An AWS Organizational Unit is a container for AWS Accounts."
_kind_service = "organizations"
_metadata: ClassVar[Dict[str, Any]] = {"icon": "group", "group": "management"}
8 changes: 4 additions & 4 deletions plugins/aws/fix_plugin_aws/resource/acm.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ class AwsAcmExtendedKeyUsage:
@define(eq=False, slots=False)
class AwsAcmCertificate(AwsResource, BaseCertificate):
kind: ClassVar[str] = "aws_acm_certificate"
kind_display: ClassVar[str] = "AWS ACM Certificate"
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
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
kind_service: ClassVar[Optional[str]] = service_name
_kind_display: ClassVar[str] = "AWS ACM Certificate"
_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
_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
_kind_service: ClassVar[Optional[str]] = service_name
api_spec: ClassVar[AwsApiSpec] = AwsApiSpec("acm", "describe-certificate", "Certificate")
mapping: ClassVar[Dict[str, Bender]] = {
"id": S("CertificateArn") >> F(AwsResource.id_from_arn),
Expand Down
112 changes: 56 additions & 56 deletions plugins/aws/fix_plugin_aws/resource/amazonq.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,18 @@ def service_name(cls) -> str:
@define(eq=False, slots=False)
class AwsQBusinessApplication(AmazonQTaggable, AwsResource):
kind: ClassVar[str] = "aws_q_business_application"
kind_display: ClassVar[str] = "AWS QBusiness Application"
kind_description: ClassVar[str] = (
_kind_display: ClassVar[str] = "AWS QBusiness Application"
_kind_description: ClassVar[str] = (
"Represents a QBusiness application within the AWS QBusiness service. Applications"
" define a set of tasks and configuration for processing data within the QBusiness ecosystem."
)
kind_service: ClassVar[Optional[str]] = service_name
metadata: ClassVar[Dict[str, Any]] = {"icon": "application", "group": "ai"}
aws_metadata: ClassVar[Dict[str, Any]] = {
_kind_service: ClassVar[Optional[str]] = service_name
_metadata: ClassVar[Dict[str, Any]] = {"icon": "application", "group": "ai"}
_aws_metadata: ClassVar[Dict[str, Any]] = {
"provider_link_tpl": "https://{region_id}.console.aws.amazon.com/amazonq/business/applications/{id}/details?region={region}", # fmt: skip
"arn_tpl": "arn:{partition}:qbusiness:{region}:{account}:application/{id}",
}
reference_kinds: ClassVar[ModelReference] = {
_reference_kinds: ClassVar[ModelReference] = {
"successors": {
"default": [
"aws_q_business_conversation",
Expand Down Expand Up @@ -313,13 +313,13 @@ def collect_index_resources(
@define(eq=False, slots=False)
class AwsQBusinessConversation(AwsResource):
kind: ClassVar[str] = "aws_q_business_conversation"
kind_display: ClassVar[str] = "AWS QBusiness Conversation"
kind_description: ClassVar[str] = (
_kind_display: ClassVar[str] = "AWS QBusiness Conversation"
_kind_description: ClassVar[str] = (
"Represents a conversation within the AWS QBusiness service. Conversations are"
" interactions that involve a series of messages or data exchanges."
)
kind_service: ClassVar[Optional[str]] = service_name
metadata: ClassVar[Dict[str, Any]] = {"icon": "resource", "group": "ai"}
_kind_service: ClassVar[Optional[str]] = service_name
_metadata: ClassVar[Dict[str, Any]] = {"icon": "resource", "group": "ai"}
# Collected via AwsQBusinessApplication()
mapping: ClassVar[Dict[str, Bender]] = {
"id": S("conversationId"),
Expand Down Expand Up @@ -347,15 +347,15 @@ def service_name(cls) -> str:
@define(eq=False, slots=False)
class AwsQBusinessDataSource(AmazonQTaggable, AwsResource):
kind: ClassVar[str] = "aws_q_business_data_source"
kind_display: ClassVar[str] = "AWS QBusiness Data Source"
kind_description: ClassVar[str] = (
_kind_display: ClassVar[str] = "AWS QBusiness Data Source"
_kind_description: ClassVar[str] = (
"Represents a data source in the AWS QBusiness service. Data sources are the origins"
" from which data is ingested for processing or analysis within the QBusiness framework."
)
kind_service: ClassVar[Optional[str]] = service_name
metadata: ClassVar[Dict[str, Any]] = {"icon": "bucket", "group": "ai"}
_kind_service: ClassVar[Optional[str]] = service_name
_metadata: ClassVar[Dict[str, Any]] = {"icon": "bucket", "group": "ai"}
# Collected via AwsQBusinessApplication()
aws_metadata: ClassVar[Dict[str, Any]] = {
_aws_metadata: ClassVar[Dict[str, Any]] = {
"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
"arn_tpl": "arn:{partition}:qbusiness:{region}:{account}:application/{application_id}/index/{indice_id}/data-source/{id}",
"extra_args_for_arn": ["application_id", "indice_id"],
Expand Down Expand Up @@ -437,13 +437,13 @@ class AwsQBusinessDataSourceSyncJobMetrics:
@define(eq=False, slots=False)
class AwsQBusinessDataSourceSyncJob(AwsResource):
kind: ClassVar[str] = "aws_q_business_data_source_sync_job"
kind_display: ClassVar[str] = "AWS QBusiness Data Source Sync Job"
kind_description: ClassVar[str] = (
_kind_display: ClassVar[str] = "AWS QBusiness Data Source Sync Job"
_kind_description: ClassVar[str] = (
"Represents a data source synchronization job in the AWS QBusiness service. Sync jobs"
" ensure that data from data sources is up-to-date and correctly integrated into the system."
)
kind_service: ClassVar[Optional[str]] = service_name
metadata: ClassVar[Dict[str, Any]] = {"icon": "job", "group": "ai"}
_kind_service: ClassVar[Optional[str]] = service_name
_metadata: ClassVar[Dict[str, Any]] = {"icon": "job", "group": "ai"}
# Collected via AwsQBusinessApplication()
mapping: ClassVar[Dict[str, Bender]] = {
"id": S("executionId"),
Expand Down Expand Up @@ -479,13 +479,13 @@ def service_name(cls) -> str:
@define(eq=False, slots=False)
class AwsQBusinessDocument(AwsResource):
kind: ClassVar[str] = "aws_q_business_document"
kind_display: ClassVar[str] = "AWS QBusiness Document"
kind_description: ClassVar[str] = (
_kind_display: ClassVar[str] = "AWS QBusiness Document"
_kind_description: ClassVar[str] = (
"Represents a document within the AWS QBusiness service. Documents are structured pieces"
" of information that can be used for various purposes within the QBusiness ecosystem."
)
kind_service: ClassVar[Optional[str]] = service_name
metadata: ClassVar[Dict[str, Any]] = {"icon": "config", "group": "ai"}
_kind_service: ClassVar[Optional[str]] = service_name
_metadata: ClassVar[Dict[str, Any]] = {"icon": "config", "group": "ai"}
# Collected via AwsQBusinessApplication()
mapping: ClassVar[Dict[str, Bender]] = {
"id": S("documentId"),
Expand Down Expand Up @@ -519,14 +519,14 @@ def service_name(cls) -> str:
@define(eq=False, slots=False)
class AwsQBusinessIndice(AmazonQTaggable, AwsResource):
kind: ClassVar[str] = "aws_q_business_indice"
kind_display: ClassVar[str] = "AWS QBusiness Indice"
kind_description: ClassVar[str] = (
_kind_display: ClassVar[str] = "AWS QBusiness Indice"
_kind_description: ClassVar[str] = (
"Represents an index in the AWS QBusiness service. Indices are used to organize and"
" facilitate efficient searching and retrieval of data within the QBusiness framework."
)
kind_service: ClassVar[Optional[str]] = service_name
metadata: ClassVar[Dict[str, Any]] = {"icon": "config", "group": "ai"}
aws_metadata: ClassVar[Dict[str, Any]] = {
_kind_service: ClassVar[Optional[str]] = service_name
_metadata: ClassVar[Dict[str, Any]] = {"icon": "config", "group": "ai"}
_aws_metadata: ClassVar[Dict[str, Any]] = {
"arn_tpl": "arn:{partition}:qbusiness:{region}:{account}:application/{application_id}/index/{id}",
"extra_args_for_arn": ["application_id"],
}
Expand Down Expand Up @@ -700,13 +700,13 @@ class AwsQBusinessActionExecution:
@define(eq=False, slots=False)
class AwsQBusinessMessage(AwsResource):
kind: ClassVar[str] = "aws_q_business_message"
kind_display: ClassVar[str] = "AWS QBusiness Message"
kind_description: ClassVar[str] = (
_kind_display: ClassVar[str] = "AWS QBusiness Message"
_kind_description: ClassVar[str] = (
"Represents a message within the AWS QBusiness service. Messages are used for communication"
" or data exchange between various components or users within the QBusiness ecosystem."
)
kind_service: ClassVar[Optional[str]] = service_name
metadata: ClassVar[Dict[str, Any]] = {"icon": "config", "group": "ai"}
_kind_service: ClassVar[Optional[str]] = service_name
_metadata: ClassVar[Dict[str, Any]] = {"icon": "config", "group": "ai"}
# Collected via AwsQBusinessApplication()
mapping: ClassVar[Dict[str, Bender]] = {
"id": S("messageId"),
Expand Down Expand Up @@ -744,14 +744,14 @@ def service_name(cls) -> str:
@define(eq=False, slots=False)
class AwsQBusinessPlugin(AmazonQTaggable, AwsResource):
kind: ClassVar[str] = "aws_q_business_plugin"
kind_display: ClassVar[str] = "AWS QBusiness Plugin"
kind_description: ClassVar[str] = (
_kind_display: ClassVar[str] = "AWS QBusiness Plugin"
_kind_description: ClassVar[str] = (
"Represents a plugin in the AWS QBusiness service. Plugins extend the functionality of"
" the QBusiness framework by adding new features or capabilities."
)
kind_service: ClassVar[Optional[str]] = service_name
metadata: ClassVar[Dict[str, Any]] = {"icon": "resource", "group": "ai"}
aws_metadata: ClassVar[Dict[str, Any]] = {
_kind_service: ClassVar[Optional[str]] = service_name
_metadata: ClassVar[Dict[str, Any]] = {"icon": "resource", "group": "ai"}
_aws_metadata: ClassVar[Dict[str, Any]] = {
"arn_tpl": "arn:{partition}:qbusiness:{region}:{account}:application/{application_id}/plugin/{id}",
"extra_args_for_arn": ["application_id"],
}
Expand Down Expand Up @@ -810,14 +810,14 @@ def delete_resource(self, client: AwsClient, graph: Graph) -> bool:
@define(eq=False, slots=False)
class AwsQBusinessRetriever(AmazonQTaggable, AwsResource):
kind: ClassVar[str] = "aws_q_business_retriever"
kind_display: ClassVar[str] = "AWS Q Business Retriever"
kind_description: ClassVar[str] = (
_kind_display: ClassVar[str] = "AWS Q Business Retriever"
_kind_description: ClassVar[str] = (
"Represents a retriever in the AWS QBusiness service. Retrievers are used to fetch and"
" process data from various sources within the QBusiness ecosystem."
)
kind_service: ClassVar[Optional[str]] = service_name
metadata: ClassVar[Dict[str, Any]] = {"icon": "application", "group": "ai"}
aws_metadata: ClassVar[Dict[str, Any]] = {
_kind_service: ClassVar[Optional[str]] = service_name
_metadata: ClassVar[Dict[str, Any]] = {"icon": "application", "group": "ai"}
_aws_metadata: ClassVar[Dict[str, Any]] = {
"arn_tpl": "arn:{partition}:qbusiness:{region}:{account}:application/{application_id}/retriever/{id}",
"extra_args_for_arn": ["application_id"],
}
Expand Down Expand Up @@ -867,14 +867,14 @@ def delete_resource(self, client: AwsClient, graph: Graph) -> bool:
@define(eq=False, slots=False)
class AwsQBusinessWebExperience(AmazonQTaggable, AwsResource):
kind: ClassVar[str] = "aws_q_business_web_experience"
kind_display: ClassVar[str] = "AWS Q Business Web Experience"
kind_description: ClassVar[str] = (
_kind_display: ClassVar[str] = "AWS Q Business Web Experience"
_kind_description: ClassVar[str] = (
"Represents a web experience in the AWS QBusiness service. Web experiences define"
" interactive web-based applications or interfaces within the QBusiness ecosystem."
)
kind_service: ClassVar[Optional[str]] = service_name
metadata: ClassVar[Dict[str, Any]] = {"icon": "application", "group": "ai"}
aws_metadata: ClassVar[Dict[str, Any]] = {
_kind_service: ClassVar[Optional[str]] = service_name
_metadata: ClassVar[Dict[str, Any]] = {"icon": "application", "group": "ai"}
_aws_metadata: ClassVar[Dict[str, Any]] = {
"arn_tpl": "arn:{partition}:qbusiness:{region}:{account}:application/{application_id}/web-experience/{id}",
"extra_args_for_arn": ["application_id"],
}
Expand Down Expand Up @@ -935,15 +935,15 @@ class AwsQAppsCategory:
@define(eq=False, slots=False)
class AwsQAppsLibraryItem(AwsResource):
kind: ClassVar[str] = "aws_q_apps_library_item"
kind_display: ClassVar[str] = "AWS QApps Library Item"
kind_description: ClassVar[str] = (
_kind_display: ClassVar[str] = "AWS QApps Library Item"
_kind_description: ClassVar[str] = (
"Represents a library item in the AWS QApps service. Library items include resources"
" such as scripts, templates, or other components that can be used in QApps applications."
)
kind_service: ClassVar[Optional[str]] = service_name
metadata: ClassVar[Dict[str, Any]] = {"icon": "image", "group": "ai"}
_kind_service: ClassVar[Optional[str]] = service_name
_metadata: ClassVar[Dict[str, Any]] = {"icon": "image", "group": "ai"}
# Collected via AwsQBusinessApplication()
reference_kinds: ClassVar[ModelReference] = {
_reference_kinds: ClassVar[ModelReference] = {
"predecessors": {"default": ["aws_q_apps"]},
}
mapping: ClassVar[Dict[str, Bender]] = {
Expand Down Expand Up @@ -1016,13 +1016,13 @@ def service_name(cls) -> str:
@define(eq=False, slots=False)
class AwsQApps(AwsResource):
kind: ClassVar[str] = "aws_q_apps"
kind_display: ClassVar[str] = "AWS QApps"
kind_description: ClassVar[str] = (
_kind_display: ClassVar[str] = "AWS QApps"
_kind_description: ClassVar[str] = (
"Represents an application within the AWS QApps service. QApps applications include"
" various components and configurations for developing and deploying apps within the AWS environment."
)
kind_service: ClassVar[Optional[str]] = service_name
metadata: ClassVar[Dict[str, Any]] = {"icon": "application", "group": "ai"}
_kind_service: ClassVar[Optional[str]] = service_name
_metadata: ClassVar[Dict[str, Any]] = {"icon": "application", "group": "ai"}
# Collected via AwsQBusinessApplication()
mapping: ClassVar[Dict[str, Bender]] = {
"id": S("appId"),
Expand Down
Loading

0 comments on commit 0dd8f24

Please sign in to comment.