qontract-reconcile 0.10.1rc837__py3-none-any.whl → 0.10.1rc839__py3-none-any.whl

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.
Files changed (47) hide show
  1. {qontract_reconcile-0.10.1rc837.dist-info → qontract_reconcile-0.10.1rc839.dist-info}/METADATA +1 -1
  2. {qontract_reconcile-0.10.1rc837.dist-info → qontract_reconcile-0.10.1rc839.dist-info}/RECORD +47 -33
  3. reconcile/gql_definitions/advanced_upgrade_service/aus_clusters.py +1 -0
  4. reconcile/gql_definitions/advanced_upgrade_service/aus_organization.py +1 -0
  5. reconcile/gql_definitions/aws_saml_idp/aws_accounts.py +1 -0
  6. reconcile/gql_definitions/aws_saml_roles/aws_accounts.py +1 -0
  7. reconcile/gql_definitions/cluster_auth_rhidp/clusters.py +1 -0
  8. reconcile/gql_definitions/cna/queries/cna_provisioners.py +1 -0
  9. reconcile/gql_definitions/common/clusters.py +3 -0
  10. reconcile/gql_definitions/common/clusters_with_peering.py +1 -0
  11. reconcile/gql_definitions/common/ocm_environments.py +1 -0
  12. reconcile/gql_definitions/common/pagerduty_instances.py +2 -0
  13. reconcile/gql_definitions/common/quay_instances.py +64 -0
  14. reconcile/gql_definitions/common/slack_workspaces.py +62 -0
  15. reconcile/gql_definitions/dynatrace_token_provider/dynatrace_bootstrap_tokens.py +6 -0
  16. reconcile/gql_definitions/fragments/aws_account_common.py +1 -0
  17. reconcile/gql_definitions/fragments/ocm_environment.py +1 -0
  18. reconcile/gql_definitions/gitlab_members/gitlab_instances.py +4 -0
  19. reconcile/gql_definitions/glitchtip/glitchtip_instance.py +2 -0
  20. reconcile/gql_definitions/jenkins_configs/jenkins_instances.py +79 -0
  21. reconcile/gql_definitions/jira/jira_servers.py +4 -0
  22. reconcile/gql_definitions/ocm_labels/clusters.py +1 -0
  23. reconcile/gql_definitions/openshift_cluster_bots/clusters.py +1 -0
  24. reconcile/gql_definitions/rhidp/organizations.py +1 -0
  25. reconcile/gql_definitions/statuspage/statuspages.py +4 -0
  26. reconcile/gql_definitions/terraform_cloudflare_resources/terraform_cloudflare_accounts.py +2 -0
  27. reconcile/gql_definitions/terraform_tgw_attachments/aws_accounts.py +1 -0
  28. reconcile/gql_definitions/unleash_feature_toggles/feature_toggles.py +2 -0
  29. reconcile/gql_definitions/vault_instances/vault_instances.py +2 -0
  30. reconcile/statuspage/page.py +10 -7
  31. reconcile/test/test_gitlab_members.py +2 -0
  32. reconcile/test/test_terraform_cloudflare_resources.py +1 -0
  33. reconcile/typed_queries/cloudflare.py +10 -0
  34. reconcile/typed_queries/dynatrace.py +10 -0
  35. reconcile/typed_queries/glitchtip.py +10 -0
  36. reconcile/typed_queries/jenkins.py +11 -0
  37. reconcile/typed_queries/jira.py +7 -0
  38. reconcile/typed_queries/ocm.py +8 -0
  39. reconcile/typed_queries/quay.py +7 -0
  40. reconcile/typed_queries/slack.py +7 -0
  41. reconcile/typed_queries/unleash.py +10 -0
  42. reconcile/typed_queries/vault.py +10 -0
  43. tools/cli_commands/systems_and_tools.py +319 -0
  44. tools/qontract_cli.py +8 -0
  45. {qontract_reconcile-0.10.1rc837.dist-info → qontract_reconcile-0.10.1rc839.dist-info}/WHEEL +0 -0
  46. {qontract_reconcile-0.10.1rc837.dist-info → qontract_reconcile-0.10.1rc839.dist-info}/entry_points.txt +0 -0
  47. {qontract_reconcile-0.10.1rc837.dist-info → qontract_reconcile-0.10.1rc839.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,79 @@
1
+ """
2
+ Generated by qenerate plugin=pydantic_v1. DO NOT MODIFY MANUALLY!
3
+ """
4
+ from collections.abc import Callable # noqa: F401 # pylint: disable=W0611
5
+ from datetime import datetime # noqa: F401 # pylint: disable=W0611
6
+ from enum import Enum # noqa: F401 # pylint: disable=W0611
7
+ from typing import ( # noqa: F401 # pylint: disable=W0611
8
+ Any,
9
+ Optional,
10
+ Union,
11
+ )
12
+
13
+ from pydantic import ( # noqa: F401 # pylint: disable=W0611
14
+ BaseModel,
15
+ Extra,
16
+ Field,
17
+ Json,
18
+ )
19
+
20
+ from reconcile.gql_definitions.fragments.vault_secret import VaultSecret
21
+
22
+
23
+ DEFINITION = """
24
+ fragment VaultSecret on VaultSecret_v1 {
25
+ path
26
+ field
27
+ version
28
+ format
29
+ }
30
+
31
+ query JenkinsInstances {
32
+ instances: jenkins_instances_v1 {
33
+ name
34
+ description
35
+ serverUrl
36
+ token {
37
+ ... VaultSecret
38
+ }
39
+ deleteMethod
40
+ }
41
+ }
42
+ """
43
+
44
+
45
+ class ConfiguredBaseModel(BaseModel):
46
+ class Config:
47
+ smart_union=True
48
+ extra=Extra.forbid
49
+
50
+
51
+ class JenkinsInstanceV1(ConfiguredBaseModel):
52
+ name: str = Field(..., alias="name")
53
+ description: str = Field(..., alias="description")
54
+ server_url: str = Field(..., alias="serverUrl")
55
+ token: VaultSecret = Field(..., alias="token")
56
+ delete_method: Optional[str] = Field(..., alias="deleteMethod")
57
+
58
+
59
+ class JenkinsInstancesQueryData(ConfiguredBaseModel):
60
+ instances: Optional[list[JenkinsInstanceV1]] = Field(..., alias="instances")
61
+
62
+
63
+ def query(query_func: Callable, **kwargs: Any) -> JenkinsInstancesQueryData:
64
+ """
65
+ This is a convenience function which queries and parses the data into
66
+ concrete types. It should be compatible with most GQL clients.
67
+ You do not have to use it to consume the generated data classes.
68
+ Alternatively, you can also mime and alternate the behavior
69
+ of this function in the caller.
70
+
71
+ Parameters:
72
+ query_func (Callable): Function which queries your GQL Server
73
+ kwargs: optional arguments that will be passed to the query function
74
+
75
+ Returns:
76
+ JenkinsInstancesQueryData: queried data parsed into generated classes
77
+ """
78
+ raw_data: dict[Any, Any] = query_func(DEFINITION, **kwargs)
79
+ return JenkinsInstancesQueryData(**raw_data)
@@ -21,6 +21,8 @@ from pydantic import ( # noqa: F401 # pylint: disable=W0611
21
21
  DEFINITION = """
22
22
  query JiraServers {
23
23
  jira_servers: jira_servers_v1 {
24
+ name
25
+ description
24
26
  serverUrl
25
27
  username
26
28
  token {
@@ -48,6 +50,8 @@ class VaultSecretV1(ConfiguredBaseModel):
48
50
 
49
51
 
50
52
  class JiraServerV1(ConfiguredBaseModel):
53
+ name: str = Field(..., alias="name")
54
+ description: str = Field(..., alias="description")
51
55
  server_url: str = Field(..., alias="serverUrl")
52
56
  username: str = Field(..., alias="username")
53
57
  token: VaultSecretV1 = Field(..., alias="token")
@@ -23,6 +23,7 @@ from reconcile.gql_definitions.fragments.ocm_environment import OCMEnvironment
23
23
  DEFINITION = """
24
24
  fragment OCMEnvironment on OpenShiftClusterManagerEnvironment_v1 {
25
25
  name
26
+ description
26
27
  labels
27
28
  url
28
29
  accessTokenClientId
@@ -24,6 +24,7 @@ from reconcile.gql_definitions.fragments.vault_secret import VaultSecret
24
24
  DEFINITION = """
25
25
  fragment OCMEnvironment on OpenShiftClusterManagerEnvironment_v1 {
26
26
  name
27
+ description
27
28
  labels
28
29
  url
29
30
  accessTokenClientId
@@ -28,6 +28,7 @@ fragment DisableAutomations on DisableClusterAutomations_v1 {
28
28
 
29
29
  fragment OCMEnvironment on OpenShiftClusterManagerEnvironment_v1 {
30
30
  name
31
+ description
31
32
  labels
32
33
  url
33
34
  accessTokenClientId
@@ -31,7 +31,9 @@ fragment VaultSecret on VaultSecret_v1 {
31
31
  query StatusPages {
32
32
  status_pages: status_page_v1 {
33
33
  name
34
+ description
34
35
  pageId
36
+ url
35
37
  apiUrl
36
38
  credentials {
37
39
  ...VaultSecret
@@ -145,7 +147,9 @@ class MaintenanceV1(ConfiguredBaseModel):
145
147
 
146
148
  class StatusPageV1(ConfiguredBaseModel):
147
149
  name: str = Field(..., alias="name")
150
+ description: str = Field(..., alias="description")
148
151
  page_id: str = Field(..., alias="pageId")
152
+ url: Optional[str] = Field(..., alias="url")
149
153
  api_url: str = Field(..., alias="apiUrl")
150
154
  credentials: VaultSecret = Field(..., alias="credentials")
151
155
  components: Optional[list[StatusPageComponentV1]] = Field(..., alias="components")
@@ -31,6 +31,7 @@ fragment VaultSecret on VaultSecret_v1 {
31
31
  query TerraformCloudflareAccounts {
32
32
  accounts: cloudflare_accounts_v1 {
33
33
  name
34
+ description
34
35
  providerVersion
35
36
  apiCredentials {
36
37
  ... VaultSecret
@@ -94,6 +95,7 @@ class DeletionApprovalV1(ConfiguredBaseModel):
94
95
 
95
96
  class CloudflareAccountV1(ConfiguredBaseModel):
96
97
  name: str = Field(..., alias="name")
98
+ description: Optional[str] = Field(..., alias="description")
97
99
  provider_version: str = Field(..., alias="providerVersion")
98
100
  api_credentials: VaultSecret = Field(..., alias="apiCredentials")
99
101
  terraform_state_account: AWSAccountV1 = Field(..., alias="terraformStateAccount")
@@ -25,6 +25,7 @@ DEFINITION = """
25
25
  fragment AWSAccountCommon on AWSAccount_v1 {
26
26
  path
27
27
  name
28
+ description
28
29
  uid
29
30
  terraformUsername
30
31
  consoleUrl
@@ -31,6 +31,7 @@ fragment VaultSecret on VaultSecret_v1 {
31
31
  query UnleashFeatureToggles {
32
32
  instances: unleash_instances_v1 {
33
33
  name
34
+ description
34
35
  url
35
36
  adminToken {
36
37
  ...VaultSecret
@@ -82,6 +83,7 @@ class UnleashProjectV1(ConfiguredBaseModel):
82
83
 
83
84
  class UnleashInstanceV1(ConfiguredBaseModel):
84
85
  name: str = Field(..., alias="name")
86
+ description: str = Field(..., alias="description")
85
87
  url: str = Field(..., alias="url")
86
88
  admin_token: Optional[VaultSecret] = Field(..., alias="adminToken")
87
89
  allow_unmanaged_feature_toggles: Optional[bool] = Field(..., alias="allowUnmanagedFeatureToggles")
@@ -31,6 +31,7 @@ fragment VaultSecret on VaultSecret_v1 {
31
31
  query VaultInstances {
32
32
  vault_instances: vault_instances_v1 {
33
33
  name
34
+ description
34
35
  address
35
36
  auth {
36
37
  provider
@@ -215,6 +216,7 @@ class VaultReplicationConfigV1(ConfiguredBaseModel):
215
216
 
216
217
  class VaultInstanceV1(ConfiguredBaseModel):
217
218
  name: str = Field(..., alias="name")
219
+ description: str = Field(..., alias="description")
218
220
  address: str = Field(..., alias="address")
219
221
  auth: Union[VaultInstanceAuthApproleV1, VaultInstanceAuthV1] = Field(..., alias="auth")
220
222
  replication: Optional[list[VaultReplicationConfigV1]] = Field(..., alias="replication")
@@ -145,13 +145,16 @@ class StatusMaintenance(BaseModel):
145
145
  for c in page_components
146
146
  if c.app.name in affected_services
147
147
  ]
148
- statuspage_announcements = [
149
- StatusMaintenanceAnnouncement.init_from_announcement(
150
- cast(MaintenanceStatuspageAnnouncementV1, m)
151
- )
152
- for m in maintenance.announcements or []
153
- if m.provider == PROVIDER_NAME
154
- ]
148
+ if affected_components:
149
+ statuspage_announcements = [
150
+ StatusMaintenanceAnnouncement.init_from_announcement(
151
+ cast(MaintenanceStatuspageAnnouncementV1, m)
152
+ )
153
+ for m in maintenance.announcements or []
154
+ if m.provider == PROVIDER_NAME
155
+ ]
156
+ else:
157
+ statuspage_announcements = [StatusMaintenanceAnnouncement()]
155
158
  if len(statuspage_announcements) != 1:
156
159
  raise ValueError(
157
160
  f"Maintenanace announcements must include exactly one item of provider {PROVIDER_NAME}"
@@ -27,6 +27,8 @@ from reconcile.utils.pagerduty_api import PagerDutyMap
27
27
  @pytest.fixture()
28
28
  def instance(vault_secret: VaultSecret) -> GitlabInstanceV1:
29
29
  return GitlabInstanceV1(
30
+ name="gitlab",
31
+ description="gitlab",
30
32
  url="http://foobar.com",
31
33
  token=vault_secret,
32
34
  sslVerify=False,
@@ -213,6 +213,7 @@ def mock_cloudflare_accounts(mocker):
213
213
  accounts=[
214
214
  CFAccountV1(
215
215
  name="cfaccount",
216
+ description="cfaccount",
216
217
  providerVersion="0.33.x",
217
218
  apiCredentials=VaultSecret(
218
219
  path="cf-account-path",
@@ -0,0 +1,10 @@
1
+ from reconcile.gql_definitions.terraform_cloudflare_resources.terraform_cloudflare_accounts import (
2
+ CloudflareAccountV1,
3
+ query,
4
+ )
5
+ from reconcile.utils import gql
6
+
7
+
8
+ def get_cloudflare_accounts() -> list[CloudflareAccountV1]:
9
+ data = query(gql.get_api().query)
10
+ return list(data.accounts or [])
@@ -0,0 +1,10 @@
1
+ from reconcile.gql_definitions.dynatrace_token_provider.dynatrace_bootstrap_tokens import (
2
+ DynatraceEnvironmentV1,
3
+ query,
4
+ )
5
+ from reconcile.utils import gql
6
+
7
+
8
+ def get_dynatrace_environments() -> list[DynatraceEnvironmentV1]:
9
+ data = query(gql.get_api().query)
10
+ return list(data.environments or [])
@@ -0,0 +1,10 @@
1
+ from reconcile.gql_definitions.glitchtip.glitchtip_instance import (
2
+ GlitchtipInstanceV1,
3
+ query,
4
+ )
5
+ from reconcile.utils import gql
6
+
7
+
8
+ def get_glitchtip_instances() -> list[GlitchtipInstanceV1]:
9
+ data = query(gql.get_api().query)
10
+ return list(data.instances or [])
@@ -0,0 +1,11 @@
1
+ from reconcile.gql_definitions.jenkins_configs.jenkins_instances import (
2
+ JenkinsInstanceV1,
3
+ query,
4
+ )
5
+ from reconcile.utils import gql
6
+
7
+
8
+ def get_jenkins_instances() -> list[JenkinsInstanceV1]:
9
+ gqlapi = gql.get_api()
10
+ data = query(gqlapi.query)
11
+ return list(data.instances or [])
@@ -0,0 +1,7 @@
1
+ from reconcile.gql_definitions.jira.jira_servers import JiraServerV1, query
2
+ from reconcile.utils import gql
3
+
4
+
5
+ def get_jira_servers() -> list[JiraServerV1]:
6
+ data = query(gql.get_api().query)
7
+ return list(data.jira_servers or [])
@@ -0,0 +1,8 @@
1
+ from reconcile.gql_definitions.common.ocm_environments import query
2
+ from reconcile.gql_definitions.fragments.ocm_environment import OCMEnvironment
3
+ from reconcile.utils import gql
4
+
5
+
6
+ def get_ocm_environments() -> list[OCMEnvironment]:
7
+ data = query(gql.get_api().query)
8
+ return list(data.environments or [])
@@ -0,0 +1,7 @@
1
+ from reconcile.gql_definitions.common.quay_instances import QuayInstanceV1, query
2
+ from reconcile.utils import gql
3
+
4
+
5
+ def get_quay_instances() -> list[QuayInstanceV1]:
6
+ data = query(gql.get_api().query)
7
+ return list(data.instances or [])
@@ -0,0 +1,7 @@
1
+ from reconcile.gql_definitions.common.slack_workspaces import SlackWorkspaceV1, query
2
+ from reconcile.utils import gql
3
+
4
+
5
+ def get_slack_workspaces() -> list[SlackWorkspaceV1]:
6
+ data = query(gql.get_api().query)
7
+ return list(data.workspaces or [])
@@ -0,0 +1,10 @@
1
+ from reconcile.gql_definitions.unleash_feature_toggles.feature_toggles import (
2
+ UnleashInstanceV1,
3
+ query,
4
+ )
5
+ from reconcile.utils import gql
6
+
7
+
8
+ def get_unleash_instances() -> list[UnleashInstanceV1]:
9
+ data = query(gql.get_api().query)
10
+ return list(data.instances or [])
@@ -0,0 +1,10 @@
1
+ from reconcile.gql_definitions.vault_instances.vault_instances import (
2
+ VaultInstanceV1,
3
+ query,
4
+ )
5
+ from reconcile.utils import gql
6
+
7
+
8
+ def get_vault_instances() -> list[VaultInstanceV1]:
9
+ data = query(gql.get_api().query)
10
+ return list(data.vault_instances or [])
@@ -0,0 +1,319 @@
1
+ #!/usr/bin/env python3
2
+ # ruff: noqa: PLC0415 - `import` should be at the top-level of a file
3
+
4
+ from typing import (
5
+ Any,
6
+ Self,
7
+ )
8
+
9
+ from pydantic import BaseModel
10
+
11
+ from reconcile.gql_definitions.common.clusters import ClusterV1
12
+ from reconcile.gql_definitions.common.pagerduty_instances import (
13
+ PagerDutyInstanceV1,
14
+ )
15
+ from reconcile.gql_definitions.common.quay_instances import QuayInstanceV1
16
+ from reconcile.gql_definitions.common.slack_workspaces import SlackWorkspaceV1
17
+ from reconcile.gql_definitions.dynatrace_token_provider.dynatrace_bootstrap_tokens import (
18
+ DynatraceEnvironmentV1,
19
+ )
20
+ from reconcile.gql_definitions.fragments.ocm_environment import OCMEnvironment
21
+ from reconcile.gql_definitions.gitlab_members.gitlab_instances import GitlabInstanceV1
22
+ from reconcile.gql_definitions.glitchtip.glitchtip_instance import GlitchtipInstanceV1
23
+ from reconcile.gql_definitions.jenkins_configs.jenkins_instances import (
24
+ JenkinsInstanceV1,
25
+ )
26
+ from reconcile.gql_definitions.jira.jira_servers import JiraServerV1
27
+ from reconcile.gql_definitions.statuspage.statuspages import StatusPageV1
28
+ from reconcile.gql_definitions.terraform_cloudflare_resources.terraform_cloudflare_accounts import (
29
+ CloudflareAccountV1,
30
+ )
31
+ from reconcile.gql_definitions.terraform_tgw_attachments.aws_accounts import (
32
+ AWSAccountV1,
33
+ )
34
+ from reconcile.gql_definitions.unleash_feature_toggles.feature_toggles import (
35
+ UnleashInstanceV1,
36
+ )
37
+ from reconcile.gql_definitions.vault_instances.vault_instances import VaultInstanceV1
38
+ from reconcile.statuspage.integration import get_status_pages
39
+ from reconcile.typed_queries.cloudflare import get_cloudflare_accounts
40
+ from reconcile.typed_queries.clusters import get_clusters
41
+ from reconcile.typed_queries.dynatrace import get_dynatrace_environments
42
+ from reconcile.typed_queries.gitlab_instances import get_gitlab_instances
43
+ from reconcile.typed_queries.glitchtip import get_glitchtip_instances
44
+ from reconcile.typed_queries.jenkins import get_jenkins_instances
45
+ from reconcile.typed_queries.jira import get_jira_servers
46
+ from reconcile.typed_queries.ocm import get_ocm_environments
47
+ from reconcile.typed_queries.pagerduty_instances import get_pagerduty_instances
48
+ from reconcile.typed_queries.quay import get_quay_instances
49
+ from reconcile.typed_queries.slack import get_slack_workspaces
50
+ from reconcile.typed_queries.terraform_tgw_attachments.aws_accounts import (
51
+ get_aws_accounts,
52
+ )
53
+ from reconcile.typed_queries.unleash import get_unleash_instances
54
+ from reconcile.typed_queries.vault import get_vault_instances
55
+ from reconcile.utils import (
56
+ gql,
57
+ )
58
+
59
+
60
+ class SystemTool(BaseModel):
61
+ system_type: str
62
+ system_id: str
63
+ name: str
64
+ url: str
65
+ description: str
66
+
67
+ @classmethod
68
+ def init_from_model(cls, model: Any) -> Self:
69
+ match model:
70
+ case GitlabInstanceV1():
71
+ return cls.init_from_gitlab(model)
72
+ case JenkinsInstanceV1():
73
+ return cls.init_from_jenkins(model)
74
+ case ClusterV1():
75
+ return cls.init_from_cluster(model)
76
+ case AWSAccountV1():
77
+ return cls.init_from_aws_account(model)
78
+ case DynatraceEnvironmentV1():
79
+ return cls.init_from_dynatrace_environment(model)
80
+ case GlitchtipInstanceV1():
81
+ return cls.init_from_glitchtip_instance(model)
82
+ case JiraServerV1():
83
+ return cls.init_from_jira_server(model)
84
+ case OCMEnvironment():
85
+ return cls.init_from_ocm_environment(model)
86
+ case PagerDutyInstanceV1():
87
+ return cls.init_from_pagerduty_instance(model)
88
+ case QuayInstanceV1():
89
+ return cls.init_from_quay_instance(model)
90
+ case SlackWorkspaceV1():
91
+ return cls.init_from_slack_workspace(model)
92
+ case StatusPageV1():
93
+ return cls.init_from_status_page(model)
94
+ case UnleashInstanceV1():
95
+ return cls.init_from_unleash_instance(model)
96
+ case VaultInstanceV1():
97
+ return cls.init_from_vault_instance(model)
98
+ case CloudflareAccountV1():
99
+ return cls.init_from_cloudflare_account(model)
100
+ case _:
101
+ raise NotImplementedError(f"unsupported: {model}")
102
+
103
+ @classmethod
104
+ def init_from_gitlab(cls, g: GitlabInstanceV1) -> Self:
105
+ return cls(
106
+ system_type="gitlab",
107
+ system_id=g.name,
108
+ name=g.name,
109
+ url=g.url,
110
+ description=g.description,
111
+ )
112
+
113
+ @classmethod
114
+ def init_from_jenkins(cls, j: JenkinsInstanceV1) -> Self:
115
+ return cls(
116
+ system_type="jenkins",
117
+ system_id=j.name,
118
+ name=j.name,
119
+ url=j.server_url,
120
+ description=j.description,
121
+ )
122
+
123
+ @classmethod
124
+ def init_from_cluster(cls, c: ClusterV1) -> Self:
125
+ return cls(
126
+ system_type="openshift",
127
+ system_id=c.spec.q_id if c.spec else "",
128
+ name=c.name,
129
+ url=c.server_url,
130
+ description=c.description,
131
+ )
132
+
133
+ @classmethod
134
+ def init_from_aws_account(cls, a: AWSAccountV1) -> Self:
135
+ return cls(
136
+ system_type="aws",
137
+ system_id=a.uid,
138
+ name=a.name,
139
+ url=a.console_url,
140
+ description=a.description,
141
+ )
142
+
143
+ @classmethod
144
+ def init_from_dynatrace_environment(cls, dt: DynatraceEnvironmentV1) -> Self:
145
+ return cls(
146
+ system_type="dynatrace",
147
+ system_id=dt.environment_id,
148
+ name=dt.name,
149
+ url=dt.environment_url,
150
+ description=dt.description,
151
+ )
152
+
153
+ @classmethod
154
+ def init_from_glitchtip_instance(cls, g: GlitchtipInstanceV1) -> Self:
155
+ return cls(
156
+ system_type="glitchtip",
157
+ system_id=g.name,
158
+ name=g.name,
159
+ url=g.console_url,
160
+ description=g.description,
161
+ )
162
+
163
+ @classmethod
164
+ def init_from_jira_server(cls, j: JiraServerV1) -> Self:
165
+ return cls(
166
+ system_type="jira",
167
+ system_id=j.name,
168
+ name=j.name,
169
+ url=j.server_url,
170
+ description=j.description,
171
+ )
172
+
173
+ @classmethod
174
+ def init_from_ocm_environment(cls, o: OCMEnvironment) -> Self:
175
+ return cls(
176
+ system_type="ocm",
177
+ system_id=o.name,
178
+ name=o.name,
179
+ url=o.url,
180
+ description=o.description,
181
+ )
182
+
183
+ @classmethod
184
+ def init_from_pagerduty_instance(cls, p: PagerDutyInstanceV1) -> Self:
185
+ return cls(
186
+ system_type="pagerduty",
187
+ system_id=p.name,
188
+ name=p.name,
189
+ url=p.description, # no url
190
+ description=p.description,
191
+ )
192
+
193
+ @classmethod
194
+ def init_from_quay_instance(cls, q: QuayInstanceV1) -> Self:
195
+ return cls(
196
+ system_type="quay",
197
+ system_id=q.name,
198
+ name=q.name,
199
+ url=f"https://{q.name}.pagerduty.com",
200
+ description=q.description,
201
+ )
202
+
203
+ @classmethod
204
+ def init_from_slack_workspace(cls, s: SlackWorkspaceV1) -> Self:
205
+ return cls(
206
+ system_type="slack",
207
+ system_id=s.name,
208
+ name=s.name,
209
+ url=f"https://{s.name}.slack.com",
210
+ description=s.description,
211
+ )
212
+
213
+ @classmethod
214
+ def init_from_status_page(cls, s: StatusPageV1) -> Self:
215
+ return cls(
216
+ system_type="statuspage",
217
+ system_id=s.name,
218
+ name=s.name,
219
+ url=s.url,
220
+ description=s.description,
221
+ )
222
+
223
+ @classmethod
224
+ def init_from_unleash_instance(cls, u: UnleashInstanceV1) -> Self:
225
+ return cls(
226
+ system_type="unleash",
227
+ system_id=u.name,
228
+ name=u.name,
229
+ url=u.url,
230
+ description=u.description,
231
+ )
232
+
233
+ @classmethod
234
+ def init_from_vault_instance(cls, v: VaultInstanceV1) -> Self:
235
+ return cls(
236
+ system_type="vault",
237
+ system_id=v.name,
238
+ name=v.name,
239
+ url=v.address,
240
+ description=v.description,
241
+ )
242
+
243
+ @classmethod
244
+ def init_from_cloudflare_account(cls, a: CloudflareAccountV1) -> Self:
245
+ return cls(
246
+ system_type="cloudflare",
247
+ system_id=a.name,
248
+ name=a.name,
249
+ url="https://dash.cloudflare.com/",
250
+ description=a.description,
251
+ )
252
+
253
+
254
+ class SystemToolInventory:
255
+ def __init__(self) -> None:
256
+ self.systems_and_tools: list[SystemTool] = []
257
+
258
+ def append(self, model: Any) -> None:
259
+ self.systems_and_tools.append(SystemTool.init_from_model(model))
260
+
261
+ def update(self, models: list[Any]) -> None:
262
+ for m in models:
263
+ self.append(m)
264
+
265
+ @property
266
+ def data(self) -> list[dict[str, Any]]:
267
+ return [
268
+ {
269
+ "type": st.system_type,
270
+ "id": st.system_id,
271
+ "name": st.name,
272
+ "url": st.url,
273
+ "description": st.description.replace("\n", "\\n"),
274
+ }
275
+ for st in self.systems_and_tools
276
+ ]
277
+
278
+ @property
279
+ def columns(self) -> list[str]:
280
+ return [
281
+ "type",
282
+ "id",
283
+ "name",
284
+ "url",
285
+ "description",
286
+ ]
287
+
288
+
289
+ def get_systems_and_tools_inventory() -> SystemToolInventory:
290
+ gql_api = gql.get_api()
291
+ inventory = SystemToolInventory()
292
+
293
+ inventory.update(get_gitlab_instances())
294
+ inventory.update(get_jenkins_instances())
295
+ inventory.update(get_clusters())
296
+ inventory.update(get_aws_accounts(gql_api))
297
+ inventory.update(get_dynatrace_environments())
298
+ inventory.update(get_glitchtip_instances())
299
+ inventory.update(get_jira_servers())
300
+ inventory.update(get_ocm_environments())
301
+ inventory.update(get_pagerduty_instances(gql_api.query))
302
+ inventory.update(get_quay_instances())
303
+ inventory.update(get_slack_workspaces())
304
+ inventory.update(get_status_pages())
305
+ inventory.update(get_unleash_instances())
306
+ inventory.update(get_vault_instances())
307
+ inventory.update(get_cloudflare_accounts())
308
+
309
+ inventory.systems_and_tools.append(
310
+ SystemTool(
311
+ system_type="github",
312
+ system_id="github",
313
+ name="github",
314
+ url="https://github.com",
315
+ description="github",
316
+ )
317
+ )
318
+
319
+ return inventory