capo-codeguruprofiler 0.1.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.
Files changed (180) hide show
  1. capo_codeguruprofiler/__init__.py +74 -0
  2. capo_codeguruprofiler/_async.py +25 -0
  3. capo_codeguruprofiler/_auth/_identity.py +16 -0
  4. capo_codeguruprofiler/_auth/_providers.py +886 -0
  5. capo_codeguruprofiler/_auth/_signers.py +88 -0
  6. capo_codeguruprofiler/_auth/_sigv4.py +434 -0
  7. capo_codeguruprofiler/_auth/_zapros_handler.py +80 -0
  8. capo_codeguruprofiler/_iter.py +113 -0
  9. capo_codeguruprofiler/_operations/code_guru_profiler/add_notification_channels.py +185 -0
  10. capo_codeguruprofiler/_operations/code_guru_profiler/batch_get_frame_metric_data.py +202 -0
  11. capo_codeguruprofiler/_operations/code_guru_profiler/configure_agent.py +177 -0
  12. capo_codeguruprofiler/_operations/code_guru_profiler/create_profiling_group.py +180 -0
  13. capo_codeguruprofiler/_operations/code_guru_profiler/delete_profiling_group.py +165 -0
  14. capo_codeguruprofiler/_operations/code_guru_profiler/describe_profiling_group.py +169 -0
  15. capo_codeguruprofiler/_operations/code_guru_profiler/get_findings_report_account_summary.py +164 -0
  16. capo_codeguruprofiler/_operations/code_guru_profiler/get_notification_configuration.py +168 -0
  17. capo_codeguruprofiler/_operations/code_guru_profiler/get_policy.py +161 -0
  18. capo_codeguruprofiler/_operations/code_guru_profiler/get_profile.py +196 -0
  19. capo_codeguruprofiler/_operations/code_guru_profiler/get_recommendations.py +196 -0
  20. capo_codeguruprofiler/_operations/code_guru_profiler/list_findings_reports.py +197 -0
  21. capo_codeguruprofiler/_operations/code_guru_profiler/list_profile_times.py +196 -0
  22. capo_codeguruprofiler/_operations/code_guru_profiler/list_profiling_groups.py +160 -0
  23. capo_codeguruprofiler/_operations/code_guru_profiler/list_tags_for_resource.py +158 -0
  24. capo_codeguruprofiler/_operations/code_guru_profiler/post_agent_profile.py +168 -0
  25. capo_codeguruprofiler/_operations/code_guru_profiler/put_permission.py +182 -0
  26. capo_codeguruprofiler/_operations/code_guru_profiler/remove_notification_channel.py +169 -0
  27. capo_codeguruprofiler/_operations/code_guru_profiler/remove_permission.py +175 -0
  28. capo_codeguruprofiler/_operations/code_guru_profiler/submit_feedback.py +170 -0
  29. capo_codeguruprofiler/_operations/code_guru_profiler/tag_resource.py +158 -0
  30. capo_codeguruprofiler/_operations/code_guru_profiler/untag_resource.py +156 -0
  31. capo_codeguruprofiler/_operations/code_guru_profiler/update_profiling_group.py +181 -0
  32. capo_codeguruprofiler/_pagination.py +21 -0
  33. capo_codeguruprofiler/_protocol/__init__.py +1 -0
  34. capo_codeguruprofiler/_protocol/errors.py +93 -0
  35. capo_codeguruprofiler/_protocol/eventstream.py +238 -0
  36. capo_codeguruprofiler/_protocol/serialize.py +47 -0
  37. capo_codeguruprofiler/_protocol/xml.py +33 -0
  38. capo_codeguruprofiler/_resources/code_guru_profiler/profiling_group.py +2257 -0
  39. capo_codeguruprofiler/_rule_engine/__init__.py +0 -0
  40. capo_codeguruprofiler/_rule_engine/_aws_partition.py +160 -0
  41. capo_codeguruprofiler/_rule_engine/_endpoint_rule_set.py +138 -0
  42. capo_codeguruprofiler/_rule_engine/_endpoint_runtime.py +389 -0
  43. capo_codeguruprofiler/_services/_aws_config.py +160 -0
  44. capo_codeguruprofiler/_services/_pipeline.py +198 -0
  45. capo_codeguruprofiler/_services/async_code_guru_profiler.py +377 -0
  46. capo_codeguruprofiler/_services/code_guru_profiler.py +373 -0
  47. capo_codeguruprofiler/errors/__init__.py +35 -0
  48. capo_codeguruprofiler/errors/_base.py +94 -0
  49. capo_codeguruprofiler/errors/conflict_exception.py +45 -0
  50. capo_codeguruprofiler/errors/internal_server_exception.py +47 -0
  51. capo_codeguruprofiler/errors/resource_not_found_exception.py +47 -0
  52. capo_codeguruprofiler/errors/service_quota_exceeded_exception.py +49 -0
  53. capo_codeguruprofiler/errors/throttling_exception.py +45 -0
  54. capo_codeguruprofiler/errors/validation_exception.py +45 -0
  55. capo_codeguruprofiler/py.typed +0 -0
  56. capo_codeguruprofiler/types/_prelude/blob.py +12 -0
  57. capo_codeguruprofiler/types/_prelude/timestamp.py +17 -0
  58. capo_codeguruprofiler/types/action_group.py +5 -0
  59. capo_codeguruprofiler/types/add_notification_channels_request.py +44 -0
  60. capo_codeguruprofiler/types/add_notification_channels_response.py +42 -0
  61. capo_codeguruprofiler/types/agent_configuration.py +58 -0
  62. capo_codeguruprofiler/types/agent_orchestration_config.py +28 -0
  63. capo_codeguruprofiler/types/agent_parameter_field.py +5 -0
  64. capo_codeguruprofiler/types/agent_parameters.py +27 -0
  65. capo_codeguruprofiler/types/agent_profile.py +15 -0
  66. capo_codeguruprofiler/types/aggregated_profile.py +15 -0
  67. capo_codeguruprofiler/types/aggregated_profile_time.py +45 -0
  68. capo_codeguruprofiler/types/aggregation_period.py +5 -0
  69. capo_codeguruprofiler/types/anomalies.py +29 -0
  70. capo_codeguruprofiler/types/anomaly.py +62 -0
  71. capo_codeguruprofiler/types/anomaly_instance.py +77 -0
  72. capo_codeguruprofiler/types/anomaly_instance_id.py +5 -0
  73. capo_codeguruprofiler/types/anomaly_instances.py +31 -0
  74. capo_codeguruprofiler/types/batch_get_frame_metric_data_request.py +56 -0
  75. capo_codeguruprofiler/types/batch_get_frame_metric_data_response.py +130 -0
  76. capo_codeguruprofiler/types/channel.py +58 -0
  77. capo_codeguruprofiler/types/channel_id.py +5 -0
  78. capo_codeguruprofiler/types/channel_uri.py +6 -0
  79. capo_codeguruprofiler/types/channels.py +29 -0
  80. capo_codeguruprofiler/types/client_token.py +5 -0
  81. capo_codeguruprofiler/types/compute_platform.py +5 -0
  82. capo_codeguruprofiler/types/configure_agent_request.py +50 -0
  83. capo_codeguruprofiler/types/configure_agent_response.py +43 -0
  84. capo_codeguruprofiler/types/create_profiling_group_request.py +81 -0
  85. capo_codeguruprofiler/types/create_profiling_group_response.py +45 -0
  86. capo_codeguruprofiler/types/delete_profiling_group_request.py +26 -0
  87. capo_codeguruprofiler/types/delete_profiling_group_response.py +18 -0
  88. capo_codeguruprofiler/types/describe_profiling_group_request.py +26 -0
  89. capo_codeguruprofiler/types/describe_profiling_group_response.py +45 -0
  90. capo_codeguruprofiler/types/event_publisher.py +5 -0
  91. capo_codeguruprofiler/types/event_publishers.py +19 -0
  92. capo_codeguruprofiler/types/feedback_type.py +5 -0
  93. capo_codeguruprofiler/types/findings_report_id.py +5 -0
  94. capo_codeguruprofiler/types/findings_report_summaries.py +35 -0
  95. capo_codeguruprofiler/types/findings_report_summary.py +73 -0
  96. capo_codeguruprofiler/types/fleet_instance_id.py +5 -0
  97. capo_codeguruprofiler/types/frame_metric.py +56 -0
  98. capo_codeguruprofiler/types/frame_metric_data.py +33 -0
  99. capo_codeguruprofiler/types/frame_metric_datum.py +56 -0
  100. capo_codeguruprofiler/types/frame_metric_value.py +5 -0
  101. capo_codeguruprofiler/types/frame_metric_values.py +30 -0
  102. capo_codeguruprofiler/types/frame_metrics.py +29 -0
  103. capo_codeguruprofiler/types/get_findings_report_account_summary_request.py +31 -0
  104. capo_codeguruprofiler/types/get_findings_report_account_summary_response.py +56 -0
  105. capo_codeguruprofiler/types/get_notification_configuration_request.py +26 -0
  106. capo_codeguruprofiler/types/get_notification_configuration_response.py +45 -0
  107. capo_codeguruprofiler/types/get_policy_request.py +26 -0
  108. capo_codeguruprofiler/types/get_policy_response.py +38 -0
  109. capo_codeguruprofiler/types/get_profile_request.py +39 -0
  110. capo_codeguruprofiler/types/get_profile_response.py +45 -0
  111. capo_codeguruprofiler/types/get_recommendations_request.py +34 -0
  112. capo_codeguruprofiler/types/get_recommendations_response.py +110 -0
  113. capo_codeguruprofiler/types/list_findings_reports_request.py +41 -0
  114. capo_codeguruprofiler/types/list_findings_reports_response.py +56 -0
  115. capo_codeguruprofiler/types/list_of_timestamps.py +33 -0
  116. capo_codeguruprofiler/types/list_profile_times_request.py +45 -0
  117. capo_codeguruprofiler/types/list_profile_times_response.py +50 -0
  118. capo_codeguruprofiler/types/list_profiling_groups_request.py +31 -0
  119. capo_codeguruprofiler/types/list_profiling_groups_response.py +77 -0
  120. capo_codeguruprofiler/types/list_tags_for_resource_request.py +24 -0
  121. capo_codeguruprofiler/types/list_tags_for_resource_response.py +34 -0
  122. capo_codeguruprofiler/types/locale.py +6 -0
  123. capo_codeguruprofiler/types/match.py +43 -0
  124. capo_codeguruprofiler/types/matches.py +29 -0
  125. capo_codeguruprofiler/types/max_depth.py +5 -0
  126. capo_codeguruprofiler/types/max_results.py +5 -0
  127. capo_codeguruprofiler/types/metadata.py +27 -0
  128. capo_codeguruprofiler/types/metadata_field.py +5 -0
  129. capo_codeguruprofiler/types/metric.py +54 -0
  130. capo_codeguruprofiler/types/metric_type.py +5 -0
  131. capo_codeguruprofiler/types/notification_configuration.py +36 -0
  132. capo_codeguruprofiler/types/order_by.py +5 -0
  133. capo_codeguruprofiler/types/pagination_token.py +5 -0
  134. capo_codeguruprofiler/types/pattern.py +95 -0
  135. capo_codeguruprofiler/types/percentage.py +5 -0
  136. capo_codeguruprofiler/types/period.py +5 -0
  137. capo_codeguruprofiler/types/post_agent_profile_request.py +51 -0
  138. capo_codeguruprofiler/types/post_agent_profile_response.py +18 -0
  139. capo_codeguruprofiler/types/principal.py +5 -0
  140. capo_codeguruprofiler/types/principals.py +17 -0
  141. capo_codeguruprofiler/types/profile_time.py +36 -0
  142. capo_codeguruprofiler/types/profile_times.py +29 -0
  143. capo_codeguruprofiler/types/profiling_group_arn.py +5 -0
  144. capo_codeguruprofiler/types/profiling_group_description.py +132 -0
  145. capo_codeguruprofiler/types/profiling_group_descriptions.py +37 -0
  146. capo_codeguruprofiler/types/profiling_group_name.py +5 -0
  147. capo_codeguruprofiler/types/profiling_group_names.py +19 -0
  148. capo_codeguruprofiler/types/profiling_status.py +83 -0
  149. capo_codeguruprofiler/types/put_permission_request.py +54 -0
  150. capo_codeguruprofiler/types/put_permission_response.py +38 -0
  151. capo_codeguruprofiler/types/recommendation.py +108 -0
  152. capo_codeguruprofiler/types/recommendations.py +31 -0
  153. capo_codeguruprofiler/types/remove_notification_channel_request.py +29 -0
  154. capo_codeguruprofiler/types/remove_notification_channel_response.py +42 -0
  155. capo_codeguruprofiler/types/remove_permission_request.py +32 -0
  156. capo_codeguruprofiler/types/remove_permission_response.py +38 -0
  157. capo_codeguruprofiler/types/revision_id.py +5 -0
  158. capo_codeguruprofiler/types/strings.py +14 -0
  159. capo_codeguruprofiler/types/submit_feedback_request.py +47 -0
  160. capo_codeguruprofiler/types/submit_feedback_response.py +18 -0
  161. capo_codeguruprofiler/types/tag_keys.py +14 -0
  162. capo_codeguruprofiler/types/tag_resource_request.py +40 -0
  163. capo_codeguruprofiler/types/tag_resource_response.py +18 -0
  164. capo_codeguruprofiler/types/tags_map.py +22 -0
  165. capo_codeguruprofiler/types/target_frame.py +14 -0
  166. capo_codeguruprofiler/types/target_frames.py +29 -0
  167. capo_codeguruprofiler/types/thread_states.py +14 -0
  168. capo_codeguruprofiler/types/timestamp.py +20 -0
  169. capo_codeguruprofiler/types/timestamp_structure.py +37 -0
  170. capo_codeguruprofiler/types/unprocessed_end_time_map.py +33 -0
  171. capo_codeguruprofiler/types/untag_resource_request.py +27 -0
  172. capo_codeguruprofiler/types/untag_resource_response.py +18 -0
  173. capo_codeguruprofiler/types/update_profiling_group_request.py +50 -0
  174. capo_codeguruprofiler/types/update_profiling_group_response.py +45 -0
  175. capo_codeguruprofiler/types/user_feedback.py +31 -0
  176. capo_codeguruprofiler-0.1.0.dist-info/METADATA +101 -0
  177. capo_codeguruprofiler-0.1.0.dist-info/RECORD +180 -0
  178. capo_codeguruprofiler-0.1.0.dist-info/WHEEL +5 -0
  179. capo_codeguruprofiler-0.1.0.dist-info/licenses/LICENSE +21 -0
  180. capo_codeguruprofiler-0.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,113 @@
1
+ """Iterator helpers used by generated streaming operations.
2
+
3
+ Hand-written, not regenerated.
4
+ """
5
+
6
+ from __future__ import annotations
7
+
8
+ from collections.abc import AsyncIterable, AsyncIterator, Callable, Iterable, Iterator
9
+ from typing import Generic, TypeVar, cast
10
+
11
+ T = TypeVar("T")
12
+ U = TypeVar("U")
13
+
14
+
15
+ class AnyIterator(AsyncIterator[T], Iterator[T], Generic[T]):
16
+ """A type that is both a synchronous and asynchronous iterator.
17
+
18
+ Streaming output fields use this so the same TypedDict type works for
19
+ both sync and async operation variants.
20
+ """
21
+
22
+ ...
23
+
24
+
25
+ class StaticAnyIterator(AnyIterator[T], Generic[T]):
26
+ """An :class:`AnyIterator` backed by static, in-memory content.
27
+
28
+ Used when streaming output is produced from already-materialized bytes
29
+ rather than a live stream. The ``content`` is yielded once and remains
30
+ accessible as a public attribute.
31
+ """
32
+
33
+ def __init__(self, content: T) -> None:
34
+ self.content = content
35
+ self._consumed = False
36
+
37
+ def __next__(self) -> T:
38
+ if self._consumed:
39
+ raise StopIteration
40
+ self._consumed = True
41
+ return self.content
42
+
43
+ async def __anext__(self) -> T:
44
+ if self._consumed:
45
+ raise StopAsyncIteration
46
+ self._consumed = True
47
+ return self.content
48
+
49
+
50
+ def map_sync_iterator(iterable: Iterable[T], fn: Callable[[T], U]) -> Iterator[U]:
51
+ """Map ``fn`` over a synchronous iterable, yielding results lazily."""
52
+ for item in iterable:
53
+ yield fn(item)
54
+
55
+
56
+ async def map_async_iterator(
57
+ async_iterable: AsyncIterable[T], fn: Callable[[T], U]
58
+ ) -> AsyncIterator[U]:
59
+ """Map ``fn`` over an asynchronous iterable, yielding results lazily."""
60
+ async for item in async_iterable:
61
+ yield fn(item)
62
+
63
+
64
+ def chain_sync_iterator(*iterables: Iterable[T]) -> Iterator[T]:
65
+ """Yield items from each iterable in order."""
66
+ for iterable in iterables:
67
+ yield from iterable
68
+
69
+
70
+ async def chain_async_iterator(
71
+ prefix: Iterable[T], rest: AsyncIterable[T]
72
+ ) -> AsyncIterator[T]:
73
+ """Yield the synchronous ``prefix`` items, then the async ``rest`` items."""
74
+ for item in prefix:
75
+ yield item
76
+ async for item in rest:
77
+ yield item
78
+
79
+
80
+ def ensure_async_iterator(value: AsyncIterator[T] | T) -> AnyIterator[T]:
81
+ """Return ``value`` as an :class:`AnyIterator`.
82
+
83
+ An async iterator is returned unchanged; a single value is wrapped in a
84
+ fresh single-item async iterator.
85
+ """
86
+ if isinstance(value, AsyncIterator):
87
+ return cast(AnyIterator[T], value)
88
+
89
+ return StaticAnyIterator(value)
90
+
91
+
92
+ def ensure_sync_iterator(value: Iterator[T] | T) -> AnyIterator[T]:
93
+ """Return ``value`` as an :class:`AnyIterator`.
94
+
95
+ A sync iterator is returned unchanged; a single value is wrapped in a
96
+ fresh single-item sync iterator.
97
+ """
98
+ if isinstance(value, Iterator):
99
+ return cast(AnyIterator[T], value)
100
+
101
+ return StaticAnyIterator(value)
102
+
103
+
104
+ __all__ = [
105
+ "AnyIterator",
106
+ "StaticAnyIterator",
107
+ "chain_async_iterator",
108
+ "chain_sync_iterator",
109
+ "ensure_async_iterator",
110
+ "ensure_sync_iterator",
111
+ "map_async_iterator",
112
+ "map_sync_iterator",
113
+ ]
@@ -0,0 +1,185 @@
1
+ """Generated from Smithy shape ``com.amazonaws.codeguruprofiler#AddNotificationChannels``."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import json
6
+ from typing import Any
7
+ from urllib.parse import quote
8
+
9
+ import zapros
10
+ from typing_extensions import Never
11
+
12
+ import capo_codeguruprofiler._auth._signers
13
+ import capo_codeguruprofiler._auth._sigv4
14
+ import capo_codeguruprofiler._protocol.eventstream
15
+ import capo_codeguruprofiler.errors.conflict_exception
16
+ import capo_codeguruprofiler.errors.internal_server_exception
17
+ import capo_codeguruprofiler.errors.resource_not_found_exception
18
+ import capo_codeguruprofiler.errors.service_quota_exceeded_exception
19
+ import capo_codeguruprofiler.errors.throttling_exception
20
+ import capo_codeguruprofiler.errors.validation_exception
21
+ import capo_codeguruprofiler.types.add_notification_channels_request
22
+ import capo_codeguruprofiler.types.add_notification_channels_response
23
+ import capo_codeguruprofiler.types.channels
24
+ import capo_codeguruprofiler.types.notification_configuration
25
+ from capo_codeguruprofiler._protocol.errors import parse_error_metadata_json
26
+ from capo_codeguruprofiler._rule_engine._endpoint_rule_set import (
27
+ EndpointParams,
28
+ resolve,
29
+ )
30
+ from capo_codeguruprofiler._services._pipeline import (
31
+ AsyncOperationOptions,
32
+ OperationOptions,
33
+ )
34
+ from capo_codeguruprofiler.errors import UnknownServiceError
35
+
36
+
37
+ def handle_error(response: zapros.Response) -> Never:
38
+ data = json.loads(response.read())
39
+ code, message = parse_error_metadata_json(response, data)
40
+ match code:
41
+ case "ConflictException":
42
+ raise capo_codeguruprofiler.errors.conflict_exception.ConflictException.from_json(
43
+ data, message
44
+ )
45
+ case "InternalServerException":
46
+ raise capo_codeguruprofiler.errors.internal_server_exception.InternalServerException.from_json(
47
+ data, message
48
+ )
49
+ case "ResourceNotFoundException":
50
+ raise capo_codeguruprofiler.errors.resource_not_found_exception.ResourceNotFoundException.from_json(
51
+ data, message
52
+ )
53
+ case "ServiceQuotaExceededException":
54
+ raise capo_codeguruprofiler.errors.service_quota_exceeded_exception.ServiceQuotaExceededException.from_json(
55
+ data, message
56
+ )
57
+ case "ThrottlingException":
58
+ raise capo_codeguruprofiler.errors.throttling_exception.ThrottlingException.from_json(
59
+ data, message
60
+ )
61
+ case "ValidationException":
62
+ raise capo_codeguruprofiler.errors.validation_exception.ValidationException.from_json(
63
+ data, message
64
+ )
65
+ case _:
66
+ raise UnknownServiceError(code=code, message=message, response=response)
67
+
68
+
69
+ def handle_response(
70
+ response: zapros.Response,
71
+ ) -> capo_codeguruprofiler.types.add_notification_channels_response.AddNotificationChannelsResponse:
72
+ out: capo_codeguruprofiler.types.add_notification_channels_response.AddNotificationChannelsResponse = capo_codeguruprofiler.types.add_notification_channels_response.deserialize_json(
73
+ json.loads(response.read())
74
+ )
75
+ return out
76
+
77
+
78
+ async def async_handle_response(
79
+ response: zapros.Response,
80
+ ) -> capo_codeguruprofiler.types.add_notification_channels_response.AddNotificationChannelsResponse:
81
+ out: capo_codeguruprofiler.types.add_notification_channels_response.AddNotificationChannelsResponse = capo_codeguruprofiler.types.add_notification_channels_response.deserialize_json(
82
+ json.loads(await response.aread())
83
+ )
84
+ return out
85
+
86
+
87
+ def get_signer(
88
+ options: AsyncOperationOptions | OperationOptions,
89
+ auth_schemes: list[dict[str, Any]] | None = None,
90
+ ) -> capo_codeguruprofiler._auth._signers.Signer | None:
91
+ name_to_schema = {s["name"]: s for s in (auth_schemes or [])} # noqa: F841
92
+ if (
93
+ options.credentials_provider is not None
94
+ and name_to_schema
95
+ and not name_to_schema.keys() & {"sigv4", "sigv4-s3express"}
96
+ ):
97
+ raise RuntimeError(
98
+ "Endpoint requires an unsupported auth scheme: " + ", ".join(name_to_schema)
99
+ )
100
+ if options.credentials_provider is not None:
101
+ endpoint_scheme = name_to_schema.get("sigv4") or name_to_schema.get(
102
+ "sigv4-s3express"
103
+ )
104
+ if endpoint_scheme is not None or not name_to_schema:
105
+ sigv4_config = capo_codeguruprofiler._auth._sigv4.build_sigv4_auth_scheme(
106
+ "codeguru-profiler", options.region, endpoint_scheme
107
+ )
108
+ if sigv4_config is not None:
109
+ return capo_codeguruprofiler._auth._signers.SigV4Signer(
110
+ options.credentials_provider, auth_scheme=sigv4_config
111
+ )
112
+ raise RuntimeError("Auth was not resolved")
113
+
114
+
115
+ def build_request(
116
+ options: OperationOptions | AsyncOperationOptions,
117
+ input_: capo_codeguruprofiler.types.add_notification_channels_request.AddNotificationChannelsRequest,
118
+ ) -> zapros.Request:
119
+ endpoint = resolve(
120
+ EndpointParams(
121
+ Region=options.region,
122
+ UseDualStack=options.use_dual_stack,
123
+ UseFIPS=options.use_fips,
124
+ Endpoint=options.endpoint,
125
+ )
126
+ ) # noqa: F841
127
+ url = (
128
+ endpoint.url.rstrip("/")
129
+ + "/profilingGroups/{profilingGroupName}/notificationConfiguration"
130
+ )
131
+ url = url.replace(
132
+ "{profilingGroupName}", quote(input_["profiling_group_name"], safe="")
133
+ )
134
+ params: list[tuple[str, str]] = []
135
+ headers: dict[str, str] = {k: ", ".join(v) for k, v in endpoint.headers.items()}
136
+ body: bytes | None = json.dumps(
137
+ capo_codeguruprofiler.types.add_notification_channels_request.serialize_json(
138
+ input_
139
+ ),
140
+ allow_nan=False,
141
+ ).encode()
142
+ headers["content-type"] = "application/json"
143
+ signer = get_signer(options, auth_schemes=endpoint.properties.get("authSchemes"))
144
+ normalized_url = zapros.URL(url)
145
+ for k, v in params:
146
+ normalized_url.search_params.append(k, v)
147
+ return zapros.Request(
148
+ normalized_url, "POST", headers=headers, body=body, context={"signer": signer}
149
+ )
150
+
151
+
152
+ def add_notification_channels(
153
+ options: OperationOptions,
154
+ input_: capo_codeguruprofiler.types.add_notification_channels_request.AddNotificationChannelsRequest,
155
+ ) -> tuple[
156
+ capo_codeguruprofiler.types.add_notification_channels_response.AddNotificationChannelsResponse,
157
+ zapros.Response,
158
+ ]:
159
+ response = options.client.handler.handle(build_request(options, input_))
160
+ try:
161
+ if response.status >= 300:
162
+ response.read()
163
+ handle_error(response)
164
+ return handle_response(response), response
165
+ except BaseException:
166
+ response.close()
167
+ raise
168
+
169
+
170
+ async def async_add_notification_channels(
171
+ options: AsyncOperationOptions,
172
+ input_: capo_codeguruprofiler.types.add_notification_channels_request.AddNotificationChannelsRequest,
173
+ ) -> tuple[
174
+ capo_codeguruprofiler.types.add_notification_channels_response.AddNotificationChannelsResponse,
175
+ zapros.Response,
176
+ ]:
177
+ response = await options.client.handler.ahandle(build_request(options, input_))
178
+ try:
179
+ if response.status >= 300:
180
+ await response.aread()
181
+ handle_error(response)
182
+ return await async_handle_response(response), response
183
+ except BaseException:
184
+ await response.aclose()
185
+ raise
@@ -0,0 +1,202 @@
1
+ """Generated from Smithy shape ``com.amazonaws.codeguruprofiler#BatchGetFrameMetricData``."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import json
6
+ from typing import Any
7
+ from urllib.parse import quote
8
+
9
+ import zapros
10
+ from typing_extensions import Never
11
+
12
+ import capo_codeguruprofiler._auth._signers
13
+ import capo_codeguruprofiler._auth._sigv4
14
+ import capo_codeguruprofiler._protocol.eventstream
15
+ import capo_codeguruprofiler.errors.internal_server_exception
16
+ import capo_codeguruprofiler.errors.resource_not_found_exception
17
+ import capo_codeguruprofiler.errors.throttling_exception
18
+ import capo_codeguruprofiler.errors.validation_exception
19
+ import capo_codeguruprofiler.types.batch_get_frame_metric_data_request
20
+ import capo_codeguruprofiler.types.batch_get_frame_metric_data_response
21
+ import capo_codeguruprofiler.types.frame_metric_data
22
+ import capo_codeguruprofiler.types.frame_metrics
23
+ import capo_codeguruprofiler.types.list_of_timestamps
24
+ import capo_codeguruprofiler.types.timestamp
25
+ import capo_codeguruprofiler.types.unprocessed_end_time_map
26
+ from capo_codeguruprofiler._protocol.errors import parse_error_metadata_json
27
+ from capo_codeguruprofiler._rule_engine._endpoint_rule_set import (
28
+ EndpointParams,
29
+ resolve,
30
+ )
31
+ from capo_codeguruprofiler._services._pipeline import (
32
+ AsyncOperationOptions,
33
+ OperationOptions,
34
+ )
35
+ from capo_codeguruprofiler.errors import UnknownServiceError
36
+
37
+
38
+ def handle_error(response: zapros.Response) -> Never:
39
+ data = json.loads(response.read())
40
+ code, message = parse_error_metadata_json(response, data)
41
+ match code:
42
+ case "InternalServerException":
43
+ raise capo_codeguruprofiler.errors.internal_server_exception.InternalServerException.from_json(
44
+ data, message
45
+ )
46
+ case "ResourceNotFoundException":
47
+ raise capo_codeguruprofiler.errors.resource_not_found_exception.ResourceNotFoundException.from_json(
48
+ data, message
49
+ )
50
+ case "ThrottlingException":
51
+ raise capo_codeguruprofiler.errors.throttling_exception.ThrottlingException.from_json(
52
+ data, message
53
+ )
54
+ case "ValidationException":
55
+ raise capo_codeguruprofiler.errors.validation_exception.ValidationException.from_json(
56
+ data, message
57
+ )
58
+ case _:
59
+ raise UnknownServiceError(code=code, message=message, response=response)
60
+
61
+
62
+ def handle_response(
63
+ response: zapros.Response,
64
+ ) -> capo_codeguruprofiler.types.batch_get_frame_metric_data_response.BatchGetFrameMetricDataResponse:
65
+ out: capo_codeguruprofiler.types.batch_get_frame_metric_data_response.BatchGetFrameMetricDataResponse = capo_codeguruprofiler.types.batch_get_frame_metric_data_response.deserialize_json(
66
+ json.loads(response.read())
67
+ )
68
+ return out
69
+
70
+
71
+ async def async_handle_response(
72
+ response: zapros.Response,
73
+ ) -> capo_codeguruprofiler.types.batch_get_frame_metric_data_response.BatchGetFrameMetricDataResponse:
74
+ out: capo_codeguruprofiler.types.batch_get_frame_metric_data_response.BatchGetFrameMetricDataResponse = capo_codeguruprofiler.types.batch_get_frame_metric_data_response.deserialize_json(
75
+ json.loads(await response.aread())
76
+ )
77
+ return out
78
+
79
+
80
+ def get_signer(
81
+ options: AsyncOperationOptions | OperationOptions,
82
+ auth_schemes: list[dict[str, Any]] | None = None,
83
+ ) -> capo_codeguruprofiler._auth._signers.Signer | None:
84
+ name_to_schema = {s["name"]: s for s in (auth_schemes or [])} # noqa: F841
85
+ if (
86
+ options.credentials_provider is not None
87
+ and name_to_schema
88
+ and not name_to_schema.keys() & {"sigv4", "sigv4-s3express"}
89
+ ):
90
+ raise RuntimeError(
91
+ "Endpoint requires an unsupported auth scheme: " + ", ".join(name_to_schema)
92
+ )
93
+ if options.credentials_provider is not None:
94
+ endpoint_scheme = name_to_schema.get("sigv4") or name_to_schema.get(
95
+ "sigv4-s3express"
96
+ )
97
+ if endpoint_scheme is not None or not name_to_schema:
98
+ sigv4_config = capo_codeguruprofiler._auth._sigv4.build_sigv4_auth_scheme(
99
+ "codeguru-profiler", options.region, endpoint_scheme
100
+ )
101
+ if sigv4_config is not None:
102
+ return capo_codeguruprofiler._auth._signers.SigV4Signer(
103
+ options.credentials_provider, auth_scheme=sigv4_config
104
+ )
105
+ raise RuntimeError("Auth was not resolved")
106
+
107
+
108
+ def build_request(
109
+ options: OperationOptions | AsyncOperationOptions,
110
+ input_: capo_codeguruprofiler.types.batch_get_frame_metric_data_request.BatchGetFrameMetricDataRequest,
111
+ ) -> zapros.Request:
112
+ endpoint = resolve(
113
+ EndpointParams(
114
+ Region=options.region,
115
+ UseDualStack=options.use_dual_stack,
116
+ UseFIPS=options.use_fips,
117
+ Endpoint=options.endpoint,
118
+ )
119
+ ) # noqa: F841
120
+ import capo_codeguruprofiler._protocol.serialize
121
+
122
+ url = (
123
+ endpoint.url.rstrip("/")
124
+ + "/profilingGroups/{profilingGroupName}/frames/-/metrics"
125
+ )
126
+ url = url.replace(
127
+ "{profilingGroupName}", quote(input_["profiling_group_name"], safe="")
128
+ )
129
+ params: list[tuple[str, str]] = []
130
+ if "start_time" in input_:
131
+ params.append(
132
+ (
133
+ "startTime",
134
+ capo_codeguruprofiler._protocol.serialize.fmt_date_time(
135
+ input_["start_time"]
136
+ ),
137
+ )
138
+ )
139
+ if "end_time" in input_:
140
+ params.append(
141
+ (
142
+ "endTime",
143
+ capo_codeguruprofiler._protocol.serialize.fmt_date_time(
144
+ input_["end_time"]
145
+ ),
146
+ )
147
+ )
148
+ if "period" in input_:
149
+ params.append(("period", input_["period"]))
150
+ if "target_resolution" in input_:
151
+ params.append(("targetResolution", input_["target_resolution"]))
152
+ headers: dict[str, str] = {k: ", ".join(v) for k, v in endpoint.headers.items()}
153
+ body: bytes | None = json.dumps(
154
+ capo_codeguruprofiler.types.batch_get_frame_metric_data_request.serialize_json(
155
+ input_
156
+ ),
157
+ allow_nan=False,
158
+ ).encode()
159
+ headers["content-type"] = "application/json"
160
+ signer = get_signer(options, auth_schemes=endpoint.properties.get("authSchemes"))
161
+ normalized_url = zapros.URL(url)
162
+ for k, v in params:
163
+ normalized_url.search_params.append(k, v)
164
+ return zapros.Request(
165
+ normalized_url, "POST", headers=headers, body=body, context={"signer": signer}
166
+ )
167
+
168
+
169
+ def batch_get_frame_metric_data(
170
+ options: OperationOptions,
171
+ input_: capo_codeguruprofiler.types.batch_get_frame_metric_data_request.BatchGetFrameMetricDataRequest,
172
+ ) -> tuple[
173
+ capo_codeguruprofiler.types.batch_get_frame_metric_data_response.BatchGetFrameMetricDataResponse,
174
+ zapros.Response,
175
+ ]:
176
+ response = options.client.handler.handle(build_request(options, input_))
177
+ try:
178
+ if response.status >= 300:
179
+ response.read()
180
+ handle_error(response)
181
+ return handle_response(response), response
182
+ except BaseException:
183
+ response.close()
184
+ raise
185
+
186
+
187
+ async def async_batch_get_frame_metric_data(
188
+ options: AsyncOperationOptions,
189
+ input_: capo_codeguruprofiler.types.batch_get_frame_metric_data_request.BatchGetFrameMetricDataRequest,
190
+ ) -> tuple[
191
+ capo_codeguruprofiler.types.batch_get_frame_metric_data_response.BatchGetFrameMetricDataResponse,
192
+ zapros.Response,
193
+ ]:
194
+ response = await options.client.handler.ahandle(build_request(options, input_))
195
+ try:
196
+ if response.status >= 300:
197
+ await response.aread()
198
+ handle_error(response)
199
+ return await async_handle_response(response), response
200
+ except BaseException:
201
+ await response.aclose()
202
+ raise
@@ -0,0 +1,177 @@
1
+ """Generated from Smithy shape ``com.amazonaws.codeguruprofiler#ConfigureAgent``."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import json
6
+ from typing import Any
7
+ from urllib.parse import quote
8
+
9
+ import zapros
10
+ from typing_extensions import Never
11
+
12
+ import capo_codeguruprofiler._auth._signers
13
+ import capo_codeguruprofiler._auth._sigv4
14
+ import capo_codeguruprofiler._protocol.eventstream
15
+ import capo_codeguruprofiler.errors.internal_server_exception
16
+ import capo_codeguruprofiler.errors.resource_not_found_exception
17
+ import capo_codeguruprofiler.errors.throttling_exception
18
+ import capo_codeguruprofiler.errors.validation_exception
19
+ import capo_codeguruprofiler.types.agent_configuration
20
+ import capo_codeguruprofiler.types.configure_agent_request
21
+ import capo_codeguruprofiler.types.configure_agent_response
22
+ import capo_codeguruprofiler.types.metadata
23
+ from capo_codeguruprofiler._protocol.errors import parse_error_metadata_json
24
+ from capo_codeguruprofiler._rule_engine._endpoint_rule_set import (
25
+ EndpointParams,
26
+ resolve,
27
+ )
28
+ from capo_codeguruprofiler._services._pipeline import (
29
+ AsyncOperationOptions,
30
+ OperationOptions,
31
+ )
32
+ from capo_codeguruprofiler.errors import UnknownServiceError
33
+
34
+
35
+ def handle_error(response: zapros.Response) -> Never:
36
+ data = json.loads(response.read())
37
+ code, message = parse_error_metadata_json(response, data)
38
+ match code:
39
+ case "InternalServerException":
40
+ raise capo_codeguruprofiler.errors.internal_server_exception.InternalServerException.from_json(
41
+ data, message
42
+ )
43
+ case "ResourceNotFoundException":
44
+ raise capo_codeguruprofiler.errors.resource_not_found_exception.ResourceNotFoundException.from_json(
45
+ data, message
46
+ )
47
+ case "ThrottlingException":
48
+ raise capo_codeguruprofiler.errors.throttling_exception.ThrottlingException.from_json(
49
+ data, message
50
+ )
51
+ case "ValidationException":
52
+ raise capo_codeguruprofiler.errors.validation_exception.ValidationException.from_json(
53
+ data, message
54
+ )
55
+ case _:
56
+ raise UnknownServiceError(code=code, message=message, response=response)
57
+
58
+
59
+ def handle_response(
60
+ response: zapros.Response,
61
+ ) -> capo_codeguruprofiler.types.configure_agent_response.ConfigureAgentResponse:
62
+ out: capo_codeguruprofiler.types.configure_agent_response.ConfigureAgentResponse = {
63
+ "configuration": capo_codeguruprofiler.types.agent_configuration.deserialize_json(
64
+ json.loads(response.read())
65
+ )
66
+ } # type: ignore[typeddict-item]
67
+ return out
68
+
69
+
70
+ async def async_handle_response(
71
+ response: zapros.Response,
72
+ ) -> capo_codeguruprofiler.types.configure_agent_response.ConfigureAgentResponse:
73
+ out: capo_codeguruprofiler.types.configure_agent_response.ConfigureAgentResponse = {
74
+ "configuration": capo_codeguruprofiler.types.agent_configuration.deserialize_json(
75
+ json.loads(await response.aread())
76
+ )
77
+ } # type: ignore[typeddict-item]
78
+ return out
79
+
80
+
81
+ def get_signer(
82
+ options: AsyncOperationOptions | OperationOptions,
83
+ auth_schemes: list[dict[str, Any]] | None = None,
84
+ ) -> capo_codeguruprofiler._auth._signers.Signer | None:
85
+ name_to_schema = {s["name"]: s for s in (auth_schemes or [])} # noqa: F841
86
+ if (
87
+ options.credentials_provider is not None
88
+ and name_to_schema
89
+ and not name_to_schema.keys() & {"sigv4", "sigv4-s3express"}
90
+ ):
91
+ raise RuntimeError(
92
+ "Endpoint requires an unsupported auth scheme: " + ", ".join(name_to_schema)
93
+ )
94
+ if options.credentials_provider is not None:
95
+ endpoint_scheme = name_to_schema.get("sigv4") or name_to_schema.get(
96
+ "sigv4-s3express"
97
+ )
98
+ if endpoint_scheme is not None or not name_to_schema:
99
+ sigv4_config = capo_codeguruprofiler._auth._sigv4.build_sigv4_auth_scheme(
100
+ "codeguru-profiler", options.region, endpoint_scheme
101
+ )
102
+ if sigv4_config is not None:
103
+ return capo_codeguruprofiler._auth._signers.SigV4Signer(
104
+ options.credentials_provider, auth_scheme=sigv4_config
105
+ )
106
+ raise RuntimeError("Auth was not resolved")
107
+
108
+
109
+ def build_request(
110
+ options: OperationOptions | AsyncOperationOptions,
111
+ input_: capo_codeguruprofiler.types.configure_agent_request.ConfigureAgentRequest,
112
+ ) -> zapros.Request:
113
+ endpoint = resolve(
114
+ EndpointParams(
115
+ Region=options.region,
116
+ UseDualStack=options.use_dual_stack,
117
+ UseFIPS=options.use_fips,
118
+ Endpoint=options.endpoint,
119
+ )
120
+ ) # noqa: F841
121
+ url = (
122
+ endpoint.url.rstrip("/")
123
+ + "/profilingGroups/{profilingGroupName}/configureAgent"
124
+ )
125
+ url = url.replace(
126
+ "{profilingGroupName}", quote(input_["profiling_group_name"], safe="")
127
+ )
128
+ params: list[tuple[str, str]] = []
129
+ headers: dict[str, str] = {k: ", ".join(v) for k, v in endpoint.headers.items()}
130
+ body: bytes | None = json.dumps(
131
+ capo_codeguruprofiler.types.configure_agent_request.serialize_json(input_),
132
+ allow_nan=False,
133
+ ).encode()
134
+ headers["content-type"] = "application/json"
135
+ signer = get_signer(options, auth_schemes=endpoint.properties.get("authSchemes"))
136
+ normalized_url = zapros.URL(url)
137
+ for k, v in params:
138
+ normalized_url.search_params.append(k, v)
139
+ return zapros.Request(
140
+ normalized_url, "POST", headers=headers, body=body, context={"signer": signer}
141
+ )
142
+
143
+
144
+ def configure_agent(
145
+ options: OperationOptions,
146
+ input_: capo_codeguruprofiler.types.configure_agent_request.ConfigureAgentRequest,
147
+ ) -> tuple[
148
+ capo_codeguruprofiler.types.configure_agent_response.ConfigureAgentResponse,
149
+ zapros.Response,
150
+ ]:
151
+ response = options.client.handler.handle(build_request(options, input_))
152
+ try:
153
+ if response.status >= 300:
154
+ response.read()
155
+ handle_error(response)
156
+ return handle_response(response), response
157
+ except BaseException:
158
+ response.close()
159
+ raise
160
+
161
+
162
+ async def async_configure_agent(
163
+ options: AsyncOperationOptions,
164
+ input_: capo_codeguruprofiler.types.configure_agent_request.ConfigureAgentRequest,
165
+ ) -> tuple[
166
+ capo_codeguruprofiler.types.configure_agent_response.ConfigureAgentResponse,
167
+ zapros.Response,
168
+ ]:
169
+ response = await options.client.handler.ahandle(build_request(options, input_))
170
+ try:
171
+ if response.status >= 300:
172
+ await response.aread()
173
+ handle_error(response)
174
+ return await async_handle_response(response), response
175
+ except BaseException:
176
+ await response.aclose()
177
+ raise