cartography 0.105.0__py3-none-any.whl → 0.106.0__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.
Potentially problematic release.
This version of cartography might be problematic. Click here for more details.
- cartography/_version.py +2 -2
- cartography/cli.py +78 -2
- cartography/client/core/tx.py +62 -0
- cartography/config.py +24 -0
- cartography/data/indexes.cypher +0 -34
- cartography/driftdetect/cli.py +3 -2
- cartography/graph/cleanupbuilder.py +47 -0
- cartography/graph/job.py +42 -0
- cartography/graph/querybuilder.py +136 -2
- cartography/graph/statement.py +1 -1
- cartography/intel/airbyte/__init__.py +105 -0
- cartography/intel/airbyte/connections.py +120 -0
- cartography/intel/airbyte/destinations.py +81 -0
- cartography/intel/airbyte/organizations.py +59 -0
- cartography/intel/airbyte/sources.py +78 -0
- cartography/intel/airbyte/tags.py +64 -0
- cartography/intel/airbyte/users.py +106 -0
- cartography/intel/airbyte/util.py +122 -0
- cartography/intel/airbyte/workspaces.py +63 -0
- cartography/intel/aws/codebuild.py +132 -0
- cartography/intel/aws/ecs.py +228 -380
- cartography/intel/aws/efs.py +261 -0
- cartography/intel/aws/identitycenter.py +14 -3
- cartography/intel/aws/inspector.py +96 -53
- cartography/intel/aws/rds.py +2 -1
- cartography/intel/aws/resources.py +4 -0
- cartography/intel/entra/__init__.py +11 -0
- cartography/intel/entra/applications.py +366 -0
- cartography/intel/entra/users.py +84 -42
- cartography/intel/kubernetes/__init__.py +30 -14
- cartography/intel/kubernetes/clusters.py +86 -0
- cartography/intel/kubernetes/namespaces.py +59 -57
- cartography/intel/kubernetes/pods.py +140 -77
- cartography/intel/kubernetes/secrets.py +95 -45
- cartography/intel/kubernetes/services.py +131 -67
- cartography/intel/kubernetes/util.py +125 -14
- cartography/intel/scaleway/__init__.py +127 -0
- cartography/intel/scaleway/iam/__init__.py +0 -0
- cartography/intel/scaleway/iam/apikeys.py +71 -0
- cartography/intel/scaleway/iam/applications.py +71 -0
- cartography/intel/scaleway/iam/groups.py +71 -0
- cartography/intel/scaleway/iam/users.py +71 -0
- cartography/intel/scaleway/instances/__init__.py +0 -0
- cartography/intel/scaleway/instances/flexibleips.py +86 -0
- cartography/intel/scaleway/instances/instances.py +92 -0
- cartography/intel/scaleway/projects.py +79 -0
- cartography/intel/scaleway/storage/__init__.py +0 -0
- cartography/intel/scaleway/storage/snapshots.py +86 -0
- cartography/intel/scaleway/storage/volumes.py +84 -0
- cartography/intel/scaleway/utils.py +37 -0
- cartography/models/airbyte/__init__.py +0 -0
- cartography/models/airbyte/connection.py +138 -0
- cartography/models/airbyte/destination.py +75 -0
- cartography/models/airbyte/organization.py +19 -0
- cartography/models/airbyte/source.py +75 -0
- cartography/models/airbyte/stream.py +74 -0
- cartography/models/airbyte/tag.py +69 -0
- cartography/models/airbyte/user.py +111 -0
- cartography/models/airbyte/workspace.py +46 -0
- cartography/models/aws/codebuild/__init__.py +0 -0
- cartography/models/aws/codebuild/project.py +49 -0
- cartography/models/aws/ecs/__init__.py +0 -0
- cartography/models/aws/ecs/clusters.py +64 -0
- cartography/models/aws/ecs/container_definitions.py +93 -0
- cartography/models/aws/ecs/container_instances.py +84 -0
- cartography/models/aws/ecs/containers.py +99 -0
- cartography/models/aws/ecs/services.py +117 -0
- cartography/models/aws/ecs/task_definitions.py +135 -0
- cartography/models/aws/ecs/tasks.py +110 -0
- cartography/models/aws/efs/__init__.py +0 -0
- cartography/models/aws/efs/access_point.py +77 -0
- cartography/models/aws/efs/file_system.py +60 -0
- cartography/models/aws/efs/mount_target.py +79 -0
- cartography/models/core/common.py +1 -0
- cartography/models/core/relationships.py +44 -0
- cartography/models/entra/app_role_assignment.py +115 -0
- cartography/models/entra/application.py +47 -0
- cartography/models/entra/user.py +17 -51
- cartography/models/kubernetes/__init__.py +0 -0
- cartography/models/kubernetes/clusters.py +26 -0
- cartography/models/kubernetes/containers.py +108 -0
- cartography/models/kubernetes/namespaces.py +51 -0
- cartography/models/kubernetes/pods.py +80 -0
- cartography/models/kubernetes/secrets.py +79 -0
- cartography/models/kubernetes/services.py +108 -0
- cartography/models/scaleway/__init__.py +0 -0
- cartography/models/scaleway/iam/__init__.py +0 -0
- cartography/models/scaleway/iam/apikey.py +96 -0
- cartography/models/scaleway/iam/application.py +52 -0
- cartography/models/scaleway/iam/group.py +95 -0
- cartography/models/scaleway/iam/user.py +60 -0
- cartography/models/scaleway/instance/__init__.py +0 -0
- cartography/models/scaleway/instance/flexibleip.py +52 -0
- cartography/models/scaleway/instance/instance.py +118 -0
- cartography/models/scaleway/organization.py +19 -0
- cartography/models/scaleway/project.py +48 -0
- cartography/models/scaleway/storage/__init__.py +0 -0
- cartography/models/scaleway/storage/snapshot.py +78 -0
- cartography/models/scaleway/storage/volume.py +51 -0
- cartography/sync.py +8 -4
- cartography/util.py +15 -10
- {cartography-0.105.0.dist-info → cartography-0.106.0.dist-info}/METADATA +5 -2
- {cartography-0.105.0.dist-info → cartography-0.106.0.dist-info}/RECORD +107 -35
- cartography/data/jobs/cleanup/kubernetes_import_cleanup.json +0 -70
- {cartography-0.105.0.dist-info → cartography-0.106.0.dist-info}/WHEEL +0 -0
- {cartography-0.105.0.dist-info → cartography-0.106.0.dist-info}/entry_points.txt +0 -0
- {cartography-0.105.0.dist-info → cartography-0.106.0.dist-info}/licenses/LICENSE +0 -0
- {cartography-0.105.0.dist-info → cartography-0.106.0.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
|
|
3
|
+
from cartography.models.core.common import PropertyRef
|
|
4
|
+
from cartography.models.core.nodes import CartographyNodeProperties
|
|
5
|
+
from cartography.models.core.nodes import CartographyNodeSchema
|
|
6
|
+
from cartography.models.core.relationships import CartographyRelProperties
|
|
7
|
+
from cartography.models.core.relationships import CartographyRelSchema
|
|
8
|
+
from cartography.models.core.relationships import LinkDirection
|
|
9
|
+
from cartography.models.core.relationships import make_target_node_matcher
|
|
10
|
+
from cartography.models.core.relationships import OtherRelationships
|
|
11
|
+
from cartography.models.core.relationships import TargetNodeMatcher
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@dataclass(frozen=True)
|
|
15
|
+
class ScalewayGroupProperties(CartographyNodeProperties):
|
|
16
|
+
id: PropertyRef = PropertyRef("id")
|
|
17
|
+
created_at: PropertyRef = PropertyRef("created_at")
|
|
18
|
+
updated_at: PropertyRef = PropertyRef("updated_at")
|
|
19
|
+
name: PropertyRef = PropertyRef("name")
|
|
20
|
+
description: PropertyRef = PropertyRef("description")
|
|
21
|
+
tags: PropertyRef = PropertyRef("tags", extra_index=True)
|
|
22
|
+
editable: PropertyRef = PropertyRef("editable")
|
|
23
|
+
deletable: PropertyRef = PropertyRef("deletable")
|
|
24
|
+
managed: PropertyRef = PropertyRef("managed")
|
|
25
|
+
lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@dataclass(frozen=True)
|
|
29
|
+
class ScalewayGroupToUserProperties(CartographyRelProperties):
|
|
30
|
+
lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
@dataclass(frozen=True)
|
|
34
|
+
# (:ScalewayUser)-[:MEMBER_OF]->(:ScalewayGroup)
|
|
35
|
+
class ScalewayGroupToUserRel(CartographyRelSchema):
|
|
36
|
+
target_node_label: str = "ScalewayUser"
|
|
37
|
+
target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
|
|
38
|
+
{"id": PropertyRef("user_ids", one_to_many=True)},
|
|
39
|
+
)
|
|
40
|
+
direction: LinkDirection = LinkDirection.INWARD
|
|
41
|
+
rel_label: str = "MEMBER_OF"
|
|
42
|
+
properties: ScalewayGroupToUserProperties = ScalewayGroupToUserProperties()
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
@dataclass(frozen=True)
|
|
46
|
+
class ScalewayGroupToApplicationProperties(CartographyRelProperties):
|
|
47
|
+
lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
@dataclass(frozen=True)
|
|
51
|
+
# (:ScalewayApplication)-[:MEMBER_OF]->(:ScalewayGroup)
|
|
52
|
+
class ScalewayGroupToApplicationRel(CartographyRelSchema):
|
|
53
|
+
target_node_label: str = "ScalewayApplication"
|
|
54
|
+
target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
|
|
55
|
+
{"id": PropertyRef("application_ids", one_to_many=True)},
|
|
56
|
+
)
|
|
57
|
+
direction: LinkDirection = LinkDirection.INWARD
|
|
58
|
+
rel_label: str = "MEMBER_OF"
|
|
59
|
+
properties: ScalewayGroupToApplicationProperties = (
|
|
60
|
+
ScalewayGroupToApplicationProperties()
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
@dataclass(frozen=True)
|
|
65
|
+
class ScalewayGroupToOrganizationRelProperties(CartographyRelProperties):
|
|
66
|
+
lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
@dataclass(frozen=True)
|
|
70
|
+
# (:ScalewayOrganization)-[:RESOURCE]->(:ScalewayGroup)
|
|
71
|
+
class ScalewayGroupToOrganizationRel(CartographyRelSchema):
|
|
72
|
+
target_node_label: str = "ScalewayOrganization"
|
|
73
|
+
target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
|
|
74
|
+
{"id": PropertyRef("ORG_ID", set_in_kwargs=True)},
|
|
75
|
+
)
|
|
76
|
+
direction: LinkDirection = LinkDirection.INWARD
|
|
77
|
+
rel_label: str = "RESOURCE"
|
|
78
|
+
properties: ScalewayGroupToOrganizationRelProperties = (
|
|
79
|
+
ScalewayGroupToOrganizationRelProperties()
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
@dataclass(frozen=True)
|
|
84
|
+
class ScalewayGroupSchema(CartographyNodeSchema):
|
|
85
|
+
label: str = "ScalewayGroup"
|
|
86
|
+
properties: ScalewayGroupProperties = ScalewayGroupProperties()
|
|
87
|
+
sub_resource_relationship: ScalewayGroupToOrganizationRel = (
|
|
88
|
+
ScalewayGroupToOrganizationRel()
|
|
89
|
+
)
|
|
90
|
+
other_relationships: OtherRelationships = OtherRelationships(
|
|
91
|
+
[
|
|
92
|
+
ScalewayGroupToUserRel(),
|
|
93
|
+
ScalewayGroupToApplicationRel(),
|
|
94
|
+
]
|
|
95
|
+
)
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
|
|
3
|
+
from cartography.models.core.common import PropertyRef
|
|
4
|
+
from cartography.models.core.nodes import CartographyNodeProperties
|
|
5
|
+
from cartography.models.core.nodes import CartographyNodeSchema
|
|
6
|
+
from cartography.models.core.relationships import CartographyRelProperties
|
|
7
|
+
from cartography.models.core.relationships import CartographyRelSchema
|
|
8
|
+
from cartography.models.core.relationships import LinkDirection
|
|
9
|
+
from cartography.models.core.relationships import make_target_node_matcher
|
|
10
|
+
from cartography.models.core.relationships import TargetNodeMatcher
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@dataclass(frozen=True)
|
|
14
|
+
class ScalewayUserNodeProperties(CartographyNodeProperties):
|
|
15
|
+
id: PropertyRef = PropertyRef("id")
|
|
16
|
+
email: PropertyRef = PropertyRef("email", extra_index=True)
|
|
17
|
+
username: PropertyRef = PropertyRef("username")
|
|
18
|
+
first_name: PropertyRef = PropertyRef("first_name")
|
|
19
|
+
last_name: PropertyRef = PropertyRef("last_name")
|
|
20
|
+
phone_number: PropertyRef = PropertyRef("phone_number")
|
|
21
|
+
locale: PropertyRef = PropertyRef("locale")
|
|
22
|
+
created_at: PropertyRef = PropertyRef("created_at")
|
|
23
|
+
updated_at: PropertyRef = PropertyRef("updated_at")
|
|
24
|
+
deletable: PropertyRef = PropertyRef("deletable")
|
|
25
|
+
last_login_at: PropertyRef = PropertyRef("last_login_at")
|
|
26
|
+
type: PropertyRef = PropertyRef("type")
|
|
27
|
+
status: PropertyRef = PropertyRef("status")
|
|
28
|
+
mfa: PropertyRef = PropertyRef("mfa")
|
|
29
|
+
account_root_user_id: PropertyRef = PropertyRef("account_root_user_id")
|
|
30
|
+
tags: PropertyRef = PropertyRef("tags")
|
|
31
|
+
locked: PropertyRef = PropertyRef("locked")
|
|
32
|
+
lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
@dataclass(frozen=True)
|
|
36
|
+
class ScalewayUserToOrganizationRelProperties(CartographyRelProperties):
|
|
37
|
+
lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
@dataclass(frozen=True)
|
|
41
|
+
# (:ScalewayOrganization)-[:RESOURCE]->(:ScalewayUser)
|
|
42
|
+
class ScalewayUserToOrganizationRel(CartographyRelSchema):
|
|
43
|
+
target_node_label: str = "ScalewayOrganization"
|
|
44
|
+
target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
|
|
45
|
+
{"id": PropertyRef("ORG_ID", set_in_kwargs=True)},
|
|
46
|
+
)
|
|
47
|
+
direction: LinkDirection = LinkDirection.INWARD
|
|
48
|
+
rel_label: str = "RESOURCE"
|
|
49
|
+
properties: ScalewayUserToOrganizationRelProperties = (
|
|
50
|
+
ScalewayUserToOrganizationRelProperties()
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
@dataclass(frozen=True)
|
|
55
|
+
class ScalewayUserSchema(CartographyNodeSchema):
|
|
56
|
+
label: str = "ScalewayUser"
|
|
57
|
+
properties: ScalewayUserNodeProperties = ScalewayUserNodeProperties()
|
|
58
|
+
sub_resource_relationship: ScalewayUserToOrganizationRel = (
|
|
59
|
+
ScalewayUserToOrganizationRel()
|
|
60
|
+
)
|
|
File without changes
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
|
|
3
|
+
from cartography.models.core.common import PropertyRef
|
|
4
|
+
from cartography.models.core.nodes import CartographyNodeProperties
|
|
5
|
+
from cartography.models.core.nodes import CartographyNodeSchema
|
|
6
|
+
from cartography.models.core.relationships import CartographyRelProperties
|
|
7
|
+
from cartography.models.core.relationships import CartographyRelSchema
|
|
8
|
+
from cartography.models.core.relationships import LinkDirection
|
|
9
|
+
from cartography.models.core.relationships import make_target_node_matcher
|
|
10
|
+
from cartography.models.core.relationships import TargetNodeMatcher
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@dataclass(frozen=True)
|
|
14
|
+
class ScalewayFlexibleIpProperties(CartographyNodeProperties):
|
|
15
|
+
id: PropertyRef = PropertyRef("id")
|
|
16
|
+
address: PropertyRef = PropertyRef("address")
|
|
17
|
+
reverse: PropertyRef = PropertyRef("reverse")
|
|
18
|
+
tags: PropertyRef = PropertyRef("tags")
|
|
19
|
+
type: PropertyRef = PropertyRef("type")
|
|
20
|
+
state: PropertyRef = PropertyRef("state")
|
|
21
|
+
prefix: PropertyRef = PropertyRef("prefix")
|
|
22
|
+
ipam_id: PropertyRef = PropertyRef("ipam_id")
|
|
23
|
+
zone: PropertyRef = PropertyRef("zone")
|
|
24
|
+
lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
@dataclass(frozen=True)
|
|
28
|
+
class ScalewayFlexibleIpToProjectRelProperties(CartographyRelProperties):
|
|
29
|
+
lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
@dataclass(frozen=True)
|
|
33
|
+
# (:ScalewayProject)-[:RESOURCE]->(:ScalewayFlexibleIp)
|
|
34
|
+
class ScalewayFlexibleIpToProjectRel(CartographyRelSchema):
|
|
35
|
+
target_node_label: str = "ScalewayProject"
|
|
36
|
+
target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
|
|
37
|
+
{"id": PropertyRef("PROJECT_ID", set_in_kwargs=True)},
|
|
38
|
+
)
|
|
39
|
+
direction: LinkDirection = LinkDirection.INWARD
|
|
40
|
+
rel_label: str = "RESOURCE"
|
|
41
|
+
properties: ScalewayFlexibleIpToProjectRelProperties = (
|
|
42
|
+
ScalewayFlexibleIpToProjectRelProperties()
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
@dataclass(frozen=True)
|
|
47
|
+
class ScalewayFlexibleIpSchema(CartographyNodeSchema):
|
|
48
|
+
label: str = "ScalewayFlexibleIp"
|
|
49
|
+
properties: ScalewayFlexibleIpProperties = ScalewayFlexibleIpProperties()
|
|
50
|
+
sub_resource_relationship: ScalewayFlexibleIpToProjectRel = (
|
|
51
|
+
ScalewayFlexibleIpToProjectRel()
|
|
52
|
+
)
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
|
|
3
|
+
from cartography.models.core.common import PropertyRef
|
|
4
|
+
from cartography.models.core.nodes import CartographyNodeProperties
|
|
5
|
+
from cartography.models.core.nodes import CartographyNodeSchema
|
|
6
|
+
from cartography.models.core.relationships import CartographyRelProperties
|
|
7
|
+
from cartography.models.core.relationships import CartographyRelSchema
|
|
8
|
+
from cartography.models.core.relationships import LinkDirection
|
|
9
|
+
from cartography.models.core.relationships import make_target_node_matcher
|
|
10
|
+
from cartography.models.core.relationships import OtherRelationships
|
|
11
|
+
from cartography.models.core.relationships import TargetNodeMatcher
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@dataclass(frozen=True)
|
|
15
|
+
class ScalewayInstanceProperties(CartographyNodeProperties):
|
|
16
|
+
id: PropertyRef = PropertyRef("id")
|
|
17
|
+
name: PropertyRef = PropertyRef("name")
|
|
18
|
+
tags: PropertyRef = PropertyRef("tags")
|
|
19
|
+
commercial_type: PropertyRef = PropertyRef("commercial_type")
|
|
20
|
+
creation_date: PropertyRef = PropertyRef("creation_date")
|
|
21
|
+
dynamic_ip_required: PropertyRef = PropertyRef("dynamic_ip_required")
|
|
22
|
+
routed_ip_enabled: PropertyRef = PropertyRef("routed_ip_enabled")
|
|
23
|
+
enable_ipv6: PropertyRef = PropertyRef("enable_ipv6")
|
|
24
|
+
hostname: PropertyRef = PropertyRef("hostname")
|
|
25
|
+
private_ip: PropertyRef = PropertyRef("private_ip")
|
|
26
|
+
mac_address: PropertyRef = PropertyRef("mac_address")
|
|
27
|
+
modification_date: PropertyRef = PropertyRef("modification_date")
|
|
28
|
+
state: PropertyRef = PropertyRef("state")
|
|
29
|
+
location_cluster_id: PropertyRef = PropertyRef("location.cluster_id")
|
|
30
|
+
location_hypervisor_id: PropertyRef = PropertyRef("location.hypervisor_id")
|
|
31
|
+
location_node_id: PropertyRef = PropertyRef("location.node_id")
|
|
32
|
+
location_platform_id: PropertyRef = PropertyRef("location.platform_id")
|
|
33
|
+
ipv6_address: PropertyRef = PropertyRef("ipv6.address")
|
|
34
|
+
ipv6_gateway: PropertyRef = PropertyRef("ipv6.gateway")
|
|
35
|
+
ipv6_netmask: PropertyRef = PropertyRef("ipv6.netmask")
|
|
36
|
+
boot_type: PropertyRef = PropertyRef("boot_type")
|
|
37
|
+
state_detail: PropertyRef = PropertyRef("state_detail")
|
|
38
|
+
arch: PropertyRef = PropertyRef("arch")
|
|
39
|
+
private_nics: PropertyRef = PropertyRef("private_nics")
|
|
40
|
+
zone: PropertyRef = PropertyRef("zone")
|
|
41
|
+
end_of_service: PropertyRef = PropertyRef("end_of_service")
|
|
42
|
+
lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
@dataclass(frozen=True)
|
|
46
|
+
class ScalewayInstanceToVolumeProperties(CartographyRelProperties):
|
|
47
|
+
lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
@dataclass(frozen=True)
|
|
51
|
+
# (:ScalewayVolume)<-[:MOUNTS]-(:ScalewayInstance)
|
|
52
|
+
class ScalewayInstanceToVolumeRel(CartographyRelSchema):
|
|
53
|
+
target_node_label: str = "ScalewayVolume"
|
|
54
|
+
target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
|
|
55
|
+
{"id": PropertyRef("volumes_id", one_to_many=True)},
|
|
56
|
+
)
|
|
57
|
+
direction: LinkDirection = LinkDirection.OUTWARD
|
|
58
|
+
rel_label: str = "MOUNTS"
|
|
59
|
+
properties: ScalewayInstanceToVolumeProperties = (
|
|
60
|
+
ScalewayInstanceToVolumeProperties()
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
@dataclass(frozen=True)
|
|
65
|
+
class ScalewayInstanceToFlexibleIpProperties(CartographyRelProperties):
|
|
66
|
+
lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
@dataclass(frozen=True)
|
|
70
|
+
# (:ScalewayFlexibleIp)-[:IDENTIFIES]->(:ScalewayInstance)
|
|
71
|
+
class ScalewayInstanceToFlexibleIpRel(CartographyRelSchema):
|
|
72
|
+
target_node_label: str = "ScalewayFlexibleIp"
|
|
73
|
+
target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
|
|
74
|
+
{"id": PropertyRef("public_ips", one_to_many=True)},
|
|
75
|
+
)
|
|
76
|
+
direction: LinkDirection = LinkDirection.INWARD
|
|
77
|
+
rel_label: str = "IDENTIFIES"
|
|
78
|
+
properties: ScalewayInstanceToFlexibleIpProperties = (
|
|
79
|
+
ScalewayInstanceToFlexibleIpProperties()
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
# TODO: Link to Image with image.id
|
|
84
|
+
# TODO: Link to SecurityGroup with security_group.id
|
|
85
|
+
# TODO: Link to PlacementGroup with placement_group.id
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
@dataclass(frozen=True)
|
|
89
|
+
class ScalewayInstanceToProjectRelProperties(CartographyRelProperties):
|
|
90
|
+
lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
@dataclass(frozen=True)
|
|
94
|
+
# (:ScalewayProject)-[:RESOURCE]->(:ScalewayInstance)
|
|
95
|
+
class ScalewayInstanceToProjectRel(CartographyRelSchema):
|
|
96
|
+
target_node_label: str = "ScalewayProject"
|
|
97
|
+
target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
|
|
98
|
+
{"id": PropertyRef("PROJECT_ID", set_in_kwargs=True)},
|
|
99
|
+
)
|
|
100
|
+
direction: LinkDirection = LinkDirection.INWARD
|
|
101
|
+
rel_label: str = "RESOURCE"
|
|
102
|
+
properties: ScalewayInstanceToProjectRelProperties = (
|
|
103
|
+
ScalewayInstanceToProjectRelProperties()
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
@dataclass(frozen=True)
|
|
108
|
+
class ScalewayInstanceSchema(CartographyNodeSchema):
|
|
109
|
+
label: str = "ScalewayInstance"
|
|
110
|
+
properties: ScalewayInstanceProperties = ScalewayInstanceProperties()
|
|
111
|
+
sub_resource_relationship: ScalewayInstanceToProjectRel = (
|
|
112
|
+
ScalewayInstanceToProjectRel()
|
|
113
|
+
)
|
|
114
|
+
other_relationships: OtherRelationships = OtherRelationships(
|
|
115
|
+
[
|
|
116
|
+
ScalewayInstanceToVolumeRel(),
|
|
117
|
+
]
|
|
118
|
+
)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
|
|
3
|
+
from cartography.models.core.common import PropertyRef
|
|
4
|
+
from cartography.models.core.nodes import CartographyNodeProperties
|
|
5
|
+
from cartography.models.core.nodes import CartographyNodeSchema
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@dataclass(frozen=True)
|
|
9
|
+
class ScalewayOrganizationNodeProperties(CartographyNodeProperties):
|
|
10
|
+
id: PropertyRef = PropertyRef("id")
|
|
11
|
+
lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@dataclass(frozen=True)
|
|
15
|
+
class ScalewayOrganizationSchema(CartographyNodeSchema):
|
|
16
|
+
label: str = "ScalewayOrganization"
|
|
17
|
+
properties: ScalewayOrganizationNodeProperties = (
|
|
18
|
+
ScalewayOrganizationNodeProperties()
|
|
19
|
+
)
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
|
|
3
|
+
from cartography.models.core.common import PropertyRef
|
|
4
|
+
from cartography.models.core.nodes import CartographyNodeProperties
|
|
5
|
+
from cartography.models.core.nodes import CartographyNodeSchema
|
|
6
|
+
from cartography.models.core.relationships import CartographyRelProperties
|
|
7
|
+
from cartography.models.core.relationships import CartographyRelSchema
|
|
8
|
+
from cartography.models.core.relationships import LinkDirection
|
|
9
|
+
from cartography.models.core.relationships import make_target_node_matcher
|
|
10
|
+
from cartography.models.core.relationships import TargetNodeMatcher
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@dataclass(frozen=True)
|
|
14
|
+
class ScalewayProjectNodeProperties(CartographyNodeProperties):
|
|
15
|
+
id: PropertyRef = PropertyRef("id")
|
|
16
|
+
name: PropertyRef = PropertyRef("name")
|
|
17
|
+
created_at: PropertyRef = PropertyRef("created_at")
|
|
18
|
+
updated_at: PropertyRef = PropertyRef("updated_at")
|
|
19
|
+
description: PropertyRef = PropertyRef("description")
|
|
20
|
+
lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
@dataclass(frozen=True)
|
|
24
|
+
class ScalewayProjectToOrganizationRelProperties(CartographyRelProperties):
|
|
25
|
+
lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@dataclass(frozen=True)
|
|
29
|
+
# (:ScalewayOrganization)-[:RESOURCE]->(:ScalewayProject)
|
|
30
|
+
class ScalewayProjectToOrganizationRel(CartographyRelSchema):
|
|
31
|
+
target_node_label: str = "ScalewayOrganization"
|
|
32
|
+
target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
|
|
33
|
+
{"id": PropertyRef("ORG_ID", set_in_kwargs=True)},
|
|
34
|
+
)
|
|
35
|
+
direction: LinkDirection = LinkDirection.INWARD
|
|
36
|
+
rel_label: str = "RESOURCE"
|
|
37
|
+
properties: ScalewayProjectToOrganizationRelProperties = (
|
|
38
|
+
ScalewayProjectToOrganizationRelProperties()
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
@dataclass(frozen=True)
|
|
43
|
+
class ScalewayProjectSchema(CartographyNodeSchema):
|
|
44
|
+
label: str = "ScalewayProject"
|
|
45
|
+
properties: ScalewayProjectNodeProperties = ScalewayProjectNodeProperties()
|
|
46
|
+
sub_resource_relationship: ScalewayProjectToOrganizationRel = (
|
|
47
|
+
ScalewayProjectToOrganizationRel()
|
|
48
|
+
)
|
|
File without changes
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
|
|
3
|
+
from cartography.models.core.common import PropertyRef
|
|
4
|
+
from cartography.models.core.nodes import CartographyNodeProperties
|
|
5
|
+
from cartography.models.core.nodes import CartographyNodeSchema
|
|
6
|
+
from cartography.models.core.relationships import CartographyRelProperties
|
|
7
|
+
from cartography.models.core.relationships import CartographyRelSchema
|
|
8
|
+
from cartography.models.core.relationships import LinkDirection
|
|
9
|
+
from cartography.models.core.relationships import make_target_node_matcher
|
|
10
|
+
from cartography.models.core.relationships import OtherRelationships
|
|
11
|
+
from cartography.models.core.relationships import TargetNodeMatcher
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@dataclass(frozen=True)
|
|
15
|
+
class ScalewayVolumeSnapshotNodeProperties(CartographyNodeProperties):
|
|
16
|
+
id: PropertyRef = PropertyRef("id")
|
|
17
|
+
name: PropertyRef = PropertyRef("name")
|
|
18
|
+
tags: PropertyRef = PropertyRef("tags")
|
|
19
|
+
volume_type: PropertyRef = PropertyRef("volume_type")
|
|
20
|
+
size: PropertyRef = PropertyRef("size")
|
|
21
|
+
state: PropertyRef = PropertyRef("state")
|
|
22
|
+
creation_date: PropertyRef = PropertyRef("creation_date")
|
|
23
|
+
modification_date: PropertyRef = PropertyRef("modification_date")
|
|
24
|
+
error_reason: PropertyRef = PropertyRef("error_reason")
|
|
25
|
+
zone: PropertyRef = PropertyRef("zone")
|
|
26
|
+
lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
@dataclass(frozen=True)
|
|
30
|
+
class ScalewayVolumeSnapshotToProjectRelProperties(CartographyRelProperties):
|
|
31
|
+
lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
@dataclass(frozen=True)
|
|
35
|
+
# (:ScalewayProject)-[:RESOURCE]->(:ScalewayVolumeSnapshot)
|
|
36
|
+
class ScalewayVolumeSnapshotToProjectRel(CartographyRelSchema):
|
|
37
|
+
target_node_label: str = "ScalewayProject"
|
|
38
|
+
target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
|
|
39
|
+
{"id": PropertyRef("PROJECT_ID", set_in_kwargs=True)},
|
|
40
|
+
)
|
|
41
|
+
direction: LinkDirection = LinkDirection.INWARD
|
|
42
|
+
rel_label: str = "RESOURCE"
|
|
43
|
+
properties: ScalewayVolumeSnapshotToProjectRelProperties = (
|
|
44
|
+
ScalewayVolumeSnapshotToProjectRelProperties()
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
@dataclass(frozen=True)
|
|
49
|
+
class ScalewayVolumeSnapshotToInstanceVolumeProperties(CartographyRelProperties):
|
|
50
|
+
lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
@dataclass(frozen=True)
|
|
54
|
+
# (:ScalewayVolume)-[:HAS]->(:ScalewayVolumeSnapshot)
|
|
55
|
+
class ScalewayVolumeSnapshotToInstanceVolumeRel(CartographyRelSchema):
|
|
56
|
+
target_node_label: str = "ScalewayVolume"
|
|
57
|
+
target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
|
|
58
|
+
{"id": PropertyRef("base_volume.id")},
|
|
59
|
+
)
|
|
60
|
+
direction: LinkDirection = LinkDirection.INWARD
|
|
61
|
+
rel_label: str = "HAS"
|
|
62
|
+
properties: ScalewayVolumeSnapshotToInstanceVolumeProperties = (
|
|
63
|
+
ScalewayVolumeSnapshotToInstanceVolumeProperties()
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
@dataclass(frozen=True)
|
|
68
|
+
class ScalewayVolumeSnapshotSchema(CartographyNodeSchema):
|
|
69
|
+
label: str = "ScalewayVolumeSnapshot"
|
|
70
|
+
properties: ScalewayVolumeSnapshotNodeProperties = (
|
|
71
|
+
ScalewayVolumeSnapshotNodeProperties()
|
|
72
|
+
)
|
|
73
|
+
sub_resource_relationship: ScalewayVolumeSnapshotToProjectRel = (
|
|
74
|
+
ScalewayVolumeSnapshotToProjectRel()
|
|
75
|
+
)
|
|
76
|
+
other_relationships: OtherRelationships = OtherRelationships(
|
|
77
|
+
rels=[ScalewayVolumeSnapshotToInstanceVolumeRel()],
|
|
78
|
+
)
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
|
|
3
|
+
from cartography.models.core.common import PropertyRef
|
|
4
|
+
from cartography.models.core.nodes import CartographyNodeProperties
|
|
5
|
+
from cartography.models.core.nodes import CartographyNodeSchema
|
|
6
|
+
from cartography.models.core.relationships import CartographyRelProperties
|
|
7
|
+
from cartography.models.core.relationships import CartographyRelSchema
|
|
8
|
+
from cartography.models.core.relationships import LinkDirection
|
|
9
|
+
from cartography.models.core.relationships import make_target_node_matcher
|
|
10
|
+
from cartography.models.core.relationships import TargetNodeMatcher
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@dataclass(frozen=True)
|
|
14
|
+
class ScalewayVolumeNodeProperties(CartographyNodeProperties):
|
|
15
|
+
id: PropertyRef = PropertyRef("id")
|
|
16
|
+
name: PropertyRef = PropertyRef("name")
|
|
17
|
+
export_uri: PropertyRef = PropertyRef("export_uri")
|
|
18
|
+
size: PropertyRef = PropertyRef("size")
|
|
19
|
+
volume_type: PropertyRef = PropertyRef("volume_type")
|
|
20
|
+
creation_date: PropertyRef = PropertyRef("creation_date")
|
|
21
|
+
modification_date: PropertyRef = PropertyRef("modification_date")
|
|
22
|
+
tags: PropertyRef = PropertyRef("tags")
|
|
23
|
+
state: PropertyRef = PropertyRef("state")
|
|
24
|
+
zone: PropertyRef = PropertyRef("zone")
|
|
25
|
+
lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@dataclass(frozen=True)
|
|
29
|
+
class ScalewayVolumeToProjectRelProperties(CartographyRelProperties):
|
|
30
|
+
lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
@dataclass(frozen=True)
|
|
34
|
+
# (:ScalewayProject)-[:RESOURCE]->(:ScalewayVolume)
|
|
35
|
+
class ScalewayVolumeToProjectRel(CartographyRelSchema):
|
|
36
|
+
target_node_label: str = "ScalewayProject"
|
|
37
|
+
target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
|
|
38
|
+
{"id": PropertyRef("PROJECT_ID", set_in_kwargs=True)},
|
|
39
|
+
)
|
|
40
|
+
direction: LinkDirection = LinkDirection.INWARD
|
|
41
|
+
rel_label: str = "RESOURCE"
|
|
42
|
+
properties: ScalewayVolumeToProjectRelProperties = (
|
|
43
|
+
ScalewayVolumeToProjectRelProperties()
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
@dataclass(frozen=True)
|
|
48
|
+
class ScalewayVolumeSchema(CartographyNodeSchema):
|
|
49
|
+
label: str = "ScalewayVolume"
|
|
50
|
+
properties: ScalewayVolumeNodeProperties = ScalewayVolumeNodeProperties()
|
|
51
|
+
sub_resource_relationship: ScalewayVolumeToProjectRel = ScalewayVolumeToProjectRel()
|
cartography/sync.py
CHANGED
|
@@ -13,6 +13,7 @@ import neo4j.exceptions
|
|
|
13
13
|
from neo4j import GraphDatabase
|
|
14
14
|
from statsd import StatsClient
|
|
15
15
|
|
|
16
|
+
import cartography.intel.airbyte
|
|
16
17
|
import cartography.intel.analysis
|
|
17
18
|
import cartography.intel.anthropic
|
|
18
19
|
import cartography.intel.aws
|
|
@@ -28,12 +29,15 @@ import cartography.intel.entra
|
|
|
28
29
|
import cartography.intel.gcp
|
|
29
30
|
import cartography.intel.github
|
|
30
31
|
import cartography.intel.gsuite
|
|
32
|
+
import cartography.intel.jamf
|
|
31
33
|
import cartography.intel.kandji
|
|
32
34
|
import cartography.intel.kubernetes
|
|
33
35
|
import cartography.intel.lastpass
|
|
34
36
|
import cartography.intel.oci
|
|
35
37
|
import cartography.intel.okta
|
|
36
38
|
import cartography.intel.openai
|
|
39
|
+
import cartography.intel.pagerduty
|
|
40
|
+
import cartography.intel.scaleway
|
|
37
41
|
import cartography.intel.semgrep
|
|
38
42
|
import cartography.intel.snipeit
|
|
39
43
|
import cartography.intel.tailscale
|
|
@@ -49,6 +53,7 @@ logger = logging.getLogger(__name__)
|
|
|
49
53
|
TOP_LEVEL_MODULES = OrderedDict(
|
|
50
54
|
{ # preserve order so that the default sync always runs `analysis` at the very end
|
|
51
55
|
"create-indexes": cartography.intel.create_indexes.run,
|
|
56
|
+
"airbyte": cartography.intel.airbyte.start_airbyte_ingestion,
|
|
52
57
|
"anthropic": cartography.intel.anthropic.start_anthropic_ingestion,
|
|
53
58
|
"aws": cartography.intel.aws.start_aws_ingestion,
|
|
54
59
|
"azure": cartography.intel.azure.start_azure_ingestion,
|
|
@@ -68,9 +73,12 @@ TOP_LEVEL_MODULES = OrderedDict(
|
|
|
68
73
|
"lastpass": cartography.intel.lastpass.start_lastpass_ingestion,
|
|
69
74
|
"bigfix": cartography.intel.bigfix.start_bigfix_ingestion,
|
|
70
75
|
"duo": cartography.intel.duo.start_duo_ingestion,
|
|
76
|
+
"scaleway": cartography.intel.scaleway.start_scaleway_ingestion,
|
|
71
77
|
"semgrep": cartography.intel.semgrep.start_semgrep_ingestion,
|
|
72
78
|
"snipeit": cartography.intel.snipeit.start_snipeit_ingestion,
|
|
73
79
|
"tailscale": cartography.intel.tailscale.start_tailscale_ingestion,
|
|
80
|
+
"jamf": cartography.intel.jamf.start_jamf_ingestion,
|
|
81
|
+
"pagerduty": cartography.intel.pagerduty.start_pagerduty_ingestion,
|
|
74
82
|
"trivy": cartography.intel.trivy.start_trivy_ingestion,
|
|
75
83
|
"analysis": cartography.intel.analysis.run,
|
|
76
84
|
}
|
|
@@ -203,10 +211,6 @@ class Sync:
|
|
|
203
211
|
return available_modules
|
|
204
212
|
|
|
205
213
|
|
|
206
|
-
# Used to avoid repeatedly calling Sync.list_intel_modules()
|
|
207
|
-
TOP_LEVEL_MODULES = Sync.list_intel_modules()
|
|
208
|
-
|
|
209
|
-
|
|
210
214
|
def run_with_config(sync: Sync, config: Union[Config, argparse.Namespace]) -> int:
|
|
211
215
|
"""
|
|
212
216
|
Execute the cartography.sync.Sync.run method with parameters built from the given configuration object.
|
cartography/util.py
CHANGED
|
@@ -5,6 +5,7 @@ from functools import partial
|
|
|
5
5
|
from functools import wraps
|
|
6
6
|
from importlib.resources import open_binary
|
|
7
7
|
from importlib.resources import read_text
|
|
8
|
+
from itertools import islice
|
|
8
9
|
from string import Template
|
|
9
10
|
from typing import Any
|
|
10
11
|
from typing import Awaitable
|
|
@@ -37,6 +38,7 @@ STATUS_SUCCESS = 0
|
|
|
37
38
|
STATUS_FAILURE = 1
|
|
38
39
|
STATUS_KEYBOARD_INTERRUPT = 130
|
|
39
40
|
DEFAULT_BATCH_SIZE = 1000
|
|
41
|
+
DEFAULT_MAX_PAGES = 10000
|
|
40
42
|
|
|
41
43
|
|
|
42
44
|
def run_analysis_job(
|
|
@@ -208,26 +210,28 @@ def aws_paginate(
|
|
|
208
210
|
client: boto3.client,
|
|
209
211
|
method_name: str,
|
|
210
212
|
object_name: str,
|
|
213
|
+
max_pages: int | None = DEFAULT_MAX_PAGES,
|
|
211
214
|
**kwargs: Any,
|
|
212
|
-
) ->
|
|
215
|
+
) -> Iterable[Dict]:
|
|
213
216
|
"""
|
|
214
217
|
Helper method for boilerplate boto3 pagination
|
|
215
218
|
The **kwargs will be forwarded to the paginator
|
|
216
219
|
"""
|
|
217
220
|
paginator = client.get_paginator(method_name)
|
|
218
|
-
items = []
|
|
219
|
-
i = 0
|
|
220
221
|
for i, page in enumerate(paginator.paginate(**kwargs), start=1):
|
|
221
222
|
if i % 100 == 0:
|
|
222
223
|
logger.info(f"fetching page number {i}")
|
|
223
224
|
if object_name in page:
|
|
224
|
-
items
|
|
225
|
+
items = page[object_name]
|
|
226
|
+
yield from items
|
|
225
227
|
else:
|
|
226
228
|
logger.warning(
|
|
227
229
|
f"""aws_paginate: Key "{object_name}" is not present, check if this is a typo.
|
|
228
230
|
If not, then the AWS datatype somehow does not have this key.""",
|
|
229
231
|
)
|
|
230
|
-
|
|
232
|
+
if max_pages is not None and i >= max_pages:
|
|
233
|
+
logger.warning(f"Reached max batch size of {max_pages} pages")
|
|
234
|
+
break
|
|
231
235
|
|
|
232
236
|
|
|
233
237
|
AWSGetFunc = TypeVar("AWSGetFunc", bound=Callable[..., Iterable])
|
|
@@ -353,17 +357,18 @@ def camel_to_snake(name: str) -> str:
|
|
|
353
357
|
return re.sub(r"(?<!^)(?=[A-Z])", "_", name).lower()
|
|
354
358
|
|
|
355
359
|
|
|
356
|
-
def batch(items: Iterable, size: int = DEFAULT_BATCH_SIZE) -> List[
|
|
360
|
+
def batch(items: Iterable, size: int = DEFAULT_BATCH_SIZE) -> Iterable[List[Any]]:
|
|
357
361
|
"""
|
|
358
|
-
Takes an Iterable of items and returns a
|
|
362
|
+
Takes an Iterable of items and returns a Generator of lists of the same items,
|
|
359
363
|
batched into chunks of the provided `size`.
|
|
360
364
|
|
|
361
365
|
Use:
|
|
362
366
|
x = [1,2,3,4,5,6,7,8]
|
|
363
|
-
batch(x, size=3) -> [
|
|
367
|
+
batch(x, size=3) -> Iterator yielding [1, 2, 3], [4, 5, 6], [7, 8]
|
|
364
368
|
"""
|
|
365
|
-
|
|
366
|
-
|
|
369
|
+
it = iter(items)
|
|
370
|
+
while chunk := list(islice(it, size)):
|
|
371
|
+
yield chunk
|
|
367
372
|
|
|
368
373
|
|
|
369
374
|
def is_throttling_exception(exc: Exception) -> bool:
|