Skip to content

Commit

Permalink
[plugins][feat] Proper name, icon and group for AWS, Azure and GCP (#…
Browse files Browse the repository at this point in the history
…2188)

Signed-off-by: Lukas Lösche <[email protected]>
Co-authored-by: Lukas Lösche <[email protected]>
  • Loading branch information
aquamatthias and lloesche authored Sep 13, 2024
1 parent e44bb35 commit 66cbd9e
Show file tree
Hide file tree
Showing 66 changed files with 1,327 additions and 233 deletions.
1 change: 1 addition & 0 deletions fixlib/fixlib/baseresources.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ class BaseResource(ABC):
kind: ClassVar[str] = "resource"
kind_display: ClassVar[str] = "Resource"
kind_description: ClassVar[str] = "A generic resource."
kind_service: ClassVar[Optional[str]] = None
phantom: ClassVar[bool] = False
reference_kinds: ClassVar[ModelReference] = {}
metadata: ClassVar[Dict[str, Any]] = {"icon": "resource", "group": "misc"}
Expand Down
2 changes: 2 additions & 0 deletions fixlib/fixlib/core/model_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,8 @@ def export_data_class(clazz: type) -> None:
metadata = m.copy()
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):
metadata["service"] = s
if with_description and (s := clazz.__dict__.get("kind_description", None)) and isinstance(s, str):
metadata["description"] = s

Expand Down
6 changes: 5 additions & 1 deletion plugins/aws/fix_plugin_aws/collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import logging
from concurrent.futures import Future, ThreadPoolExecutor
from datetime import datetime, timedelta, timezone
from typing import List, Type, Optional, ClassVar, Union, cast
from typing import List, Type, Optional, ClassVar, Union, cast, Dict, Any

from attrs import define

Expand Down Expand Up @@ -432,10 +432,14 @@ 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": "control"}


@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": "control"}
1 change: 1 addition & 0 deletions plugins/aws/fix_plugin_aws/resource/acm.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class AwsAcmCertificate(AwsResource, BaseCertificate):
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
28 changes: 26 additions & 2 deletions plugins/aws/fix_plugin_aws/resource/amazonq.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ class AwsQBusinessApplication(AmazonQTaggable, AwsResource):
"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": "generative_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}",
Expand Down Expand Up @@ -316,6 +318,8 @@ class AwsQBusinessConversation(AwsResource):
"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": "generative_ai"}
# Collected via AwsQBusinessApplication()
mapping: ClassVar[Dict[str, Bender]] = {
"id": S("conversationId"),
Expand Down Expand Up @@ -348,6 +352,8 @@ class AwsQBusinessDataSource(AmazonQTaggable, AwsResource):
"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": "generative_ai"}
# Collected via AwsQBusinessApplication()
aws_metadata: ClassVar[Dict[str, Any]] = {
"provider_link_tpl": "https://{region_id}.console.aws.amazon.com/amazonq/business/applications/{app_id}/indices/{indice_id}/datasources/{id}/details?region={region}", # fmt: skip
Expand Down Expand Up @@ -436,6 +442,8 @@ class AwsQBusinessDataSourceSyncJob(AwsResource):
"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": "generative_ai"}
# Collected via AwsQBusinessApplication()
mapping: ClassVar[Dict[str, Bender]] = {
"id": S("executionId"),
Expand Down Expand Up @@ -476,6 +484,8 @@ class AwsQBusinessDocument(AwsResource):
"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": "generative_ai"}
# Collected via AwsQBusinessApplication()
mapping: ClassVar[Dict[str, Bender]] = {
"id": S("documentId"),
Expand Down Expand Up @@ -514,6 +524,8 @@ class AwsQBusinessIndice(AmazonQTaggable, AwsResource):
"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": "generative_ai"}
aws_metadata: ClassVar[Dict[str, Any]] = {
"arn_tpl": "arn:{partition}:qbusiness:{region}:{account}:application/{application_id}/index/{id}",
"extra_args": ["application_id"],
Expand Down Expand Up @@ -693,6 +705,8 @@ class AwsQBusinessMessage(AwsResource):
"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": "generative_ai"}
# Collected via AwsQBusinessApplication()
mapping: ClassVar[Dict[str, Bender]] = {
"id": S("messageId"),
Expand Down Expand Up @@ -735,6 +749,8 @@ class AwsQBusinessPlugin(AmazonQTaggable, AwsResource):
"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": "generative_ai"}
aws_metadata: ClassVar[Dict[str, Any]] = {
"arn_tpl": "arn:{partition}:qbusiness:{region}:{account}:application/{application_id}/plugin/{id}",
"extra_args": ["application_id"],
Expand Down Expand Up @@ -794,11 +810,13 @@ 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 QBusiness Retriever"
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": "generative_ai"}
aws_metadata: ClassVar[Dict[str, Any]] = {
"arn_tpl": "arn:{partition}:qbusiness:{region}:{account}:application/{application_id}/retriever/{id}",
"extra_args": ["application_id"],
Expand Down Expand Up @@ -849,11 +867,13 @@ 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 QBusiness Web Experience"
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": "generative_ai"}
aws_metadata: ClassVar[Dict[str, Any]] = {
"arn_tpl": "arn:{partition}:qbusiness:{region}:{account}:application/{application_id}/web-experience/{id}",
"extra_args": ["application_id"],
Expand Down Expand Up @@ -920,6 +940,8 @@ class AwsQAppsLibraryItem(AwsResource):
"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": "generative_ai"}
# Collected via AwsQBusinessApplication()
reference_kinds: ClassVar[ModelReference] = {
"predecessors": {"default": ["aws_q_apps"]},
Expand Down Expand Up @@ -999,6 +1021,8 @@ class AwsQApps(AwsResource):
"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": "generative_ai"}
# Collected via AwsQBusinessApplication()
mapping: ClassVar[Dict[str, Bender]] = {
"id": S("appId"),
Expand Down
25 changes: 18 additions & 7 deletions plugins/aws/fix_plugin_aws/resource/apigateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,14 @@ class AwsApiGatewayMethod:
class AwsApiGatewayResource(AwsResource):
# collection of resource resources happens in AwsApiGatewayRestApi.collect()
kind: ClassVar[str] = "aws_apigateway_resource"
aws_metadata: ClassVar[Dict[str, Any]] = {"provider_link_tpl": None, "arn_tpl": "arn:{partition}:apigateway:{region}:{account}:/restapis/{id}/{name}"} # fmt: skip
kind_display: ClassVar[str] = "AWS API Gateway Resource"
kind_description: ClassVar[str] = (
"API Gateway Resource is a logical unit used in API Gateway to represent a"
" part of an API's resource hierarchy."
)
kind_service: ClassVar[Optional[str]] = service_name
metadata: ClassVar[Dict[str, Any]] = {"icon": "gateway", "group": "networking"}
aws_metadata: ClassVar[Dict[str, Any]] = {"provider_link_tpl": None, "arn_tpl": "arn:{partition}:apigateway:{region}:{account}:/restapis/{id}/{name}"} # fmt: skip
reference_kinds: ClassVar[ModelReference] = {"successors": {"default": ["aws_apigateway_authorizer"]}}
mapping: ClassVar[Dict[str, Bender]] = {
"id": S("id"),
Expand Down Expand Up @@ -247,13 +249,15 @@ def service_name(cls) -> str:
class AwsApiGatewayAuthorizer(AwsResource):
# collection of authorizer resources happens in AwsApiGatewayRestApi.collect()
kind: ClassVar[str] = "aws_apigateway_authorizer"
aws_metadata: ClassVar[Dict[str, Any]] = {"provider_link_tpl": "https://{region_id}.console.aws.amazon.com/apigateway/main/apis/{api_link}/authorizers/{id}?api={api_link}&region={region}", "arn_tpl": "arn:{partition}:apigateway:{region}:{account}:authorizer/{name}/{id}"} # fmt: skip
kind_display: ClassVar[str] = "AWS API Gateway Authorizer"
kind_description: ClassVar[str] = (
"API Gateway Authorizers are mechanisms that help control access to APIs"
" deployed on AWS API Gateway by authenticating and authorizing client"
" requests."
)
aws_metadata: ClassVar[Dict[str, Any]] = {"provider_link_tpl": "https://{region_id}.console.aws.amazon.com/apigateway/main/apis/{api_link}/authorizers/{id}?api={api_link}&region={region}", "arn_tpl": "arn:{partition}:apigateway:{region}:{account}:authorizer/{name}/{id}"} # fmt: skip
metadata: ClassVar[Dict[str, Any]] = {"icon": "access_control", "group": "networking"}
kind_service: ClassVar[Optional[str]] = service_name
reference_kinds: ClassVar[ModelReference] = {
"successors": {"default": ["aws_lambda_function"]},
"predecessors": {"default": ["aws_iam_role"], "delete": ["aws_lambda_function", "aws_iam_role"]},
Expand Down Expand Up @@ -339,13 +343,14 @@ class AwsApiGatewayCanarySetting:
class AwsApiGatewayStage(ApiGatewayTaggable, AwsResource):
# collection of stage resources happens in AwsApiGatewayRestApi.collect()
kind: ClassVar[str] = "aws_apigateway_stage"
aws_metadata: ClassVar[Dict[str, Any]] = {"provider_link_tpl": "https://{region_id}.console.aws.amazon.com/apigateway/main/apis/{api_link}/stages?api={api_link}&region={region}", "arn_tpl": "arn:{partition}:apigateway:{region}:{account}:/restapis/{id}/stages/{name}"} # fmt: skip

kind_display: ClassVar[str] = "AWS API Gateway Stage"
kind_description: ClassVar[str] = (
"API Gateway Stages are environment configurations for deploying and managing"
" APIs in the AWS API Gateway service."
)
kind_service: ClassVar[Optional[str]] = service_name
metadata: ClassVar[Dict[str, Any]] = {"icon": "gateway", "group": "networking"}
aws_metadata: ClassVar[Dict[str, Any]] = {"provider_link_tpl": "https://{region_id}.console.aws.amazon.com/apigateway/main/apis/{api_link}/stages?api={api_link}&region={region}", "arn_tpl": "arn:{partition}:apigateway:{region}:{account}:/restapis/{id}/stages/{name}"} # fmt: skip
mapping: ClassVar[Dict[str, Bender]] = {
"id": S("syntheticId"), # created by Fix to avoid collision with duplicate stage names
"name": S("stageName"),
Expand Down Expand Up @@ -402,12 +407,14 @@ def called_mutator_apis(cls) -> List[AwsApiSpec]:
class AwsApiGatewayDeployment(AwsResource):
# collection of deployment resources happens in AwsApiGatewayRestApi.collect()
kind: ClassVar[str] = "aws_apigateway_deployment"
aws_metadata: ClassVar[Dict[str, Any]] = {"provider_link_tpl": None, "arn_tpl": "arn:{partition}:apigateway:{region}:{account}:/restapis/{id}/deployments/{name}"} # fmt: skip
kind_display: ClassVar[str] = "AWS API Gateway Deployment"
kind_description: ClassVar[str] = (
"API Gateway Deployments represents a deployment of an API to an API Gateway stage."
" This allows the API to be invocable by end-users."
)
kind_service: ClassVar[Optional[str]] = service_name
metadata: ClassVar[Dict[str, Any]] = {"icon": "gateway", "group": "networking"}
aws_metadata: ClassVar[Dict[str, Any]] = {"provider_link_tpl": None, "arn_tpl": "arn:{partition}:apigateway:{region}:{account}:/restapis/{id}/deployments/{name}"} # fmt: skip
# edge to aws_apigateway_stage is established in AwsApiGatewayRestApi.collect()
reference_kinds: ClassVar[ModelReference] = {"successors": {"default": ["aws_apigateway_stage"]}}

Expand Down Expand Up @@ -463,11 +470,13 @@ class AwsApiGatewayEndpointConfiguration:
class AwsApiGatewayRestApi(ApiGatewayTaggable, AwsResource):
kind: ClassVar[str] = "aws_apigateway_rest_api"
kind_display: ClassVar[str] = "AWS API Gateway REST API"
aws_metadata: ClassVar[Dict[str, Any]] = {"provider_link_tpl": "https://{region_id}.console.aws.amazon.com/apigateway/main/apis/{id}/resources?api={id}&experience=rest&region={region}", "arn_tpl": "arn:{partition}:apigateway:{region}:{account}:restapi/{id}"} # fmt: skip
kind_description: ClassVar[str] = (
"API Gateway is a fully managed service that makes it easy for developers to"
" create, publish, and manage APIs at any scale."
)
kind_service: ClassVar[Optional[str]] = service_name
metadata: ClassVar[Dict[str, Any]] = {"icon": "gateway", "group": "networking"}
aws_metadata: ClassVar[Dict[str, Any]] = {"provider_link_tpl": "https://{region_id}.console.aws.amazon.com/apigateway/main/apis/{id}/resources?api={id}&experience=rest&region={region}", "arn_tpl": "arn:{partition}:apigateway:{region}:{account}:restapi/{id}"} # fmt: skip
api_spec: ClassVar[AwsApiSpec] = AwsApiSpec(
service_name, "get-rest-apis", "items", override_iam_permission="apigateway:GET"
)
Expand Down Expand Up @@ -618,12 +627,14 @@ class AwsApiGatewayMutualTlsAuthentication:
class AwsApiGatewayDomainName(ApiGatewayTaggable, AwsResource):
kind: ClassVar[str] = "aws_apigateway_domain_name"
kind_display: ClassVar[str] = "AWS API Gateway Domain Name"
aws_metadata: ClassVar[Dict[str, Any]] = {"provider_link_tpl": "https://{region_id}.console.aws.amazon.com/apigateway/main/publish/domain-names?api=unselected&domain={name}&&region={region}", "arn_tpl": "arn:aws:apigateway:{region}:{account}:domainname/{name}"} # fmt: skip
kind_description: ClassVar[str] = (
"API Gateway Domain Name is a custom domain name that you can associate with"
" your API in Amazon API Gateway, allowing you to have a more branded and"
" user-friendly endpoint for your API."
)
kind_service: ClassVar[Optional[str]] = service_name
metadata: ClassVar[Dict[str, Any]] = {"icon": "dns", "group": "networking"}
aws_metadata: ClassVar[Dict[str, Any]] = {"provider_link_tpl": "https://{region_id}.console.aws.amazon.com/apigateway/main/publish/domain-names?api=unselected&domain={name}&&region={region}", "arn_tpl": "arn:aws:apigateway:{region}:{account}:domainname/{name}"} # fmt: skip
api_spec: ClassVar[AwsApiSpec] = AwsApiSpec(
service_name, "get-domain-names", "items", override_iam_permission="apigateway:GET"
)
Expand Down
Loading

0 comments on commit 66cbd9e

Please sign in to comment.