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,160 @@
1
+ """Generated from Smithy shape ``com.amazonaws.codeguruprofiler#ListProfilingGroups``."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import json
6
+ from typing import Any
7
+
8
+ import zapros
9
+ from typing_extensions import Never
10
+
11
+ import capo_codeguruprofiler._auth._signers
12
+ import capo_codeguruprofiler._auth._sigv4
13
+ import capo_codeguruprofiler._protocol.eventstream
14
+ import capo_codeguruprofiler.errors.internal_server_exception
15
+ import capo_codeguruprofiler.errors.throttling_exception
16
+ import capo_codeguruprofiler.types.list_profiling_groups_request
17
+ import capo_codeguruprofiler.types.list_profiling_groups_response
18
+ import capo_codeguruprofiler.types.profiling_group_descriptions
19
+ import capo_codeguruprofiler.types.profiling_group_names
20
+ from capo_codeguruprofiler._protocol.errors import parse_error_metadata_json
21
+ from capo_codeguruprofiler._rule_engine._endpoint_rule_set import (
22
+ EndpointParams,
23
+ resolve,
24
+ )
25
+ from capo_codeguruprofiler._services._pipeline import (
26
+ AsyncOperationOptions,
27
+ OperationOptions,
28
+ )
29
+ from capo_codeguruprofiler.errors import UnknownServiceError
30
+
31
+
32
+ def handle_error(response: zapros.Response) -> Never:
33
+ data = json.loads(response.read())
34
+ code, message = parse_error_metadata_json(response, data)
35
+ match code:
36
+ case "InternalServerException":
37
+ raise capo_codeguruprofiler.errors.internal_server_exception.InternalServerException.from_json(
38
+ data, message
39
+ )
40
+ case "ThrottlingException":
41
+ raise capo_codeguruprofiler.errors.throttling_exception.ThrottlingException.from_json(
42
+ data, message
43
+ )
44
+ case _:
45
+ raise UnknownServiceError(code=code, message=message, response=response)
46
+
47
+
48
+ def handle_response(
49
+ response: zapros.Response,
50
+ ) -> capo_codeguruprofiler.types.list_profiling_groups_response.ListProfilingGroupsResponse:
51
+ out: capo_codeguruprofiler.types.list_profiling_groups_response.ListProfilingGroupsResponse = capo_codeguruprofiler.types.list_profiling_groups_response.deserialize_json(
52
+ json.loads(response.read())
53
+ )
54
+ return out
55
+
56
+
57
+ async def async_handle_response(
58
+ response: zapros.Response,
59
+ ) -> capo_codeguruprofiler.types.list_profiling_groups_response.ListProfilingGroupsResponse:
60
+ out: capo_codeguruprofiler.types.list_profiling_groups_response.ListProfilingGroupsResponse = capo_codeguruprofiler.types.list_profiling_groups_response.deserialize_json(
61
+ json.loads(await response.aread())
62
+ )
63
+ return out
64
+
65
+
66
+ def get_signer(
67
+ options: AsyncOperationOptions | OperationOptions,
68
+ auth_schemes: list[dict[str, Any]] | None = None,
69
+ ) -> capo_codeguruprofiler._auth._signers.Signer | None:
70
+ name_to_schema = {s["name"]: s for s in (auth_schemes or [])} # noqa: F841
71
+ if (
72
+ options.credentials_provider is not None
73
+ and name_to_schema
74
+ and not name_to_schema.keys() & {"sigv4", "sigv4-s3express"}
75
+ ):
76
+ raise RuntimeError(
77
+ "Endpoint requires an unsupported auth scheme: " + ", ".join(name_to_schema)
78
+ )
79
+ if options.credentials_provider is not None:
80
+ endpoint_scheme = name_to_schema.get("sigv4") or name_to_schema.get(
81
+ "sigv4-s3express"
82
+ )
83
+ if endpoint_scheme is not None or not name_to_schema:
84
+ sigv4_config = capo_codeguruprofiler._auth._sigv4.build_sigv4_auth_scheme(
85
+ "codeguru-profiler", options.region, endpoint_scheme
86
+ )
87
+ if sigv4_config is not None:
88
+ return capo_codeguruprofiler._auth._signers.SigV4Signer(
89
+ options.credentials_provider, auth_scheme=sigv4_config
90
+ )
91
+ raise RuntimeError("Auth was not resolved")
92
+
93
+
94
+ def build_request(
95
+ options: OperationOptions | AsyncOperationOptions,
96
+ input_: capo_codeguruprofiler.types.list_profiling_groups_request.ListProfilingGroupsRequest,
97
+ ) -> zapros.Request:
98
+ endpoint = resolve(
99
+ EndpointParams(
100
+ Region=options.region,
101
+ UseDualStack=options.use_dual_stack,
102
+ UseFIPS=options.use_fips,
103
+ Endpoint=options.endpoint,
104
+ )
105
+ ) # noqa: F841
106
+ url = endpoint.url.rstrip("/") + "/profilingGroups"
107
+ params: list[tuple[str, str]] = []
108
+ if "next_token" in input_:
109
+ params.append(("nextToken", input_["next_token"]))
110
+ if "max_results" in input_:
111
+ params.append(("maxResults", str(input_["max_results"])))
112
+ if "include_description" in input_:
113
+ params.append(
114
+ ("includeDescription", "true" if input_["include_description"] else "false")
115
+ )
116
+ headers: dict[str, str] = {k: ", ".join(v) for k, v in endpoint.headers.items()}
117
+ body: bytes | None = b""
118
+ signer = get_signer(options, auth_schemes=endpoint.properties.get("authSchemes"))
119
+ normalized_url = zapros.URL(url)
120
+ for k, v in params:
121
+ normalized_url.search_params.append(k, v)
122
+ return zapros.Request(
123
+ normalized_url, "GET", headers=headers, body=body, context={"signer": signer}
124
+ )
125
+
126
+
127
+ def list_profiling_groups(
128
+ options: OperationOptions,
129
+ input_: capo_codeguruprofiler.types.list_profiling_groups_request.ListProfilingGroupsRequest,
130
+ ) -> tuple[
131
+ capo_codeguruprofiler.types.list_profiling_groups_response.ListProfilingGroupsResponse,
132
+ zapros.Response,
133
+ ]:
134
+ response = options.client.handler.handle(build_request(options, input_))
135
+ try:
136
+ if response.status >= 300:
137
+ response.read()
138
+ handle_error(response)
139
+ return handle_response(response), response
140
+ except BaseException:
141
+ response.close()
142
+ raise
143
+
144
+
145
+ async def async_list_profiling_groups(
146
+ options: AsyncOperationOptions,
147
+ input_: capo_codeguruprofiler.types.list_profiling_groups_request.ListProfilingGroupsRequest,
148
+ ) -> tuple[
149
+ capo_codeguruprofiler.types.list_profiling_groups_response.ListProfilingGroupsResponse,
150
+ zapros.Response,
151
+ ]:
152
+ response = await options.client.handler.ahandle(build_request(options, input_))
153
+ try:
154
+ if response.status >= 300:
155
+ await response.aread()
156
+ handle_error(response)
157
+ return await async_handle_response(response), response
158
+ except BaseException:
159
+ await response.aclose()
160
+ raise
@@ -0,0 +1,158 @@
1
+ """Generated from Smithy shape ``com.amazonaws.codeguruprofiler#ListTagsForResource``."""
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.validation_exception
18
+ import capo_codeguruprofiler.types.list_tags_for_resource_request
19
+ import capo_codeguruprofiler.types.list_tags_for_resource_response
20
+ import capo_codeguruprofiler.types.tags_map
21
+ from capo_codeguruprofiler._protocol.errors import parse_error_metadata_json
22
+ from capo_codeguruprofiler._rule_engine._endpoint_rule_set import (
23
+ EndpointParams,
24
+ resolve,
25
+ )
26
+ from capo_codeguruprofiler._services._pipeline import (
27
+ AsyncOperationOptions,
28
+ OperationOptions,
29
+ )
30
+ from capo_codeguruprofiler.errors import UnknownServiceError
31
+
32
+
33
+ def handle_error(response: zapros.Response) -> Never:
34
+ data = json.loads(response.read())
35
+ code, message = parse_error_metadata_json(response, data)
36
+ match code:
37
+ case "InternalServerException":
38
+ raise capo_codeguruprofiler.errors.internal_server_exception.InternalServerException.from_json(
39
+ data, message
40
+ )
41
+ case "ResourceNotFoundException":
42
+ raise capo_codeguruprofiler.errors.resource_not_found_exception.ResourceNotFoundException.from_json(
43
+ data, message
44
+ )
45
+ case "ValidationException":
46
+ raise capo_codeguruprofiler.errors.validation_exception.ValidationException.from_json(
47
+ data, message
48
+ )
49
+ case _:
50
+ raise UnknownServiceError(code=code, message=message, response=response)
51
+
52
+
53
+ def handle_response(
54
+ response: zapros.Response,
55
+ ) -> capo_codeguruprofiler.types.list_tags_for_resource_response.ListTagsForResourceResponse:
56
+ out: capo_codeguruprofiler.types.list_tags_for_resource_response.ListTagsForResourceResponse = capo_codeguruprofiler.types.list_tags_for_resource_response.deserialize_json(
57
+ json.loads(response.read())
58
+ )
59
+ return out
60
+
61
+
62
+ async def async_handle_response(
63
+ response: zapros.Response,
64
+ ) -> capo_codeguruprofiler.types.list_tags_for_resource_response.ListTagsForResourceResponse:
65
+ out: capo_codeguruprofiler.types.list_tags_for_resource_response.ListTagsForResourceResponse = capo_codeguruprofiler.types.list_tags_for_resource_response.deserialize_json(
66
+ json.loads(await response.aread())
67
+ )
68
+ return out
69
+
70
+
71
+ def get_signer(
72
+ options: AsyncOperationOptions | OperationOptions,
73
+ auth_schemes: list[dict[str, Any]] | None = None,
74
+ ) -> capo_codeguruprofiler._auth._signers.Signer | None:
75
+ name_to_schema = {s["name"]: s for s in (auth_schemes or [])} # noqa: F841
76
+ if (
77
+ options.credentials_provider is not None
78
+ and name_to_schema
79
+ and not name_to_schema.keys() & {"sigv4", "sigv4-s3express"}
80
+ ):
81
+ raise RuntimeError(
82
+ "Endpoint requires an unsupported auth scheme: " + ", ".join(name_to_schema)
83
+ )
84
+ if options.credentials_provider is not None:
85
+ endpoint_scheme = name_to_schema.get("sigv4") or name_to_schema.get(
86
+ "sigv4-s3express"
87
+ )
88
+ if endpoint_scheme is not None or not name_to_schema:
89
+ sigv4_config = capo_codeguruprofiler._auth._sigv4.build_sigv4_auth_scheme(
90
+ "codeguru-profiler", options.region, endpoint_scheme
91
+ )
92
+ if sigv4_config is not None:
93
+ return capo_codeguruprofiler._auth._signers.SigV4Signer(
94
+ options.credentials_provider, auth_scheme=sigv4_config
95
+ )
96
+ raise RuntimeError("Auth was not resolved")
97
+
98
+
99
+ def build_request(
100
+ options: OperationOptions | AsyncOperationOptions,
101
+ input_: capo_codeguruprofiler.types.list_tags_for_resource_request.ListTagsForResourceRequest,
102
+ ) -> zapros.Request:
103
+ endpoint = resolve(
104
+ EndpointParams(
105
+ Region=options.region,
106
+ UseDualStack=options.use_dual_stack,
107
+ UseFIPS=options.use_fips,
108
+ Endpoint=options.endpoint,
109
+ )
110
+ ) # noqa: F841
111
+ url = endpoint.url.rstrip("/") + "/tags/{resourceArn}"
112
+ url = url.replace("{resourceArn}", quote(input_["resource_arn"], safe=""))
113
+ params: list[tuple[str, str]] = []
114
+ headers: dict[str, str] = {k: ", ".join(v) for k, v in endpoint.headers.items()}
115
+ body: bytes | None = b""
116
+ signer = get_signer(options, auth_schemes=endpoint.properties.get("authSchemes"))
117
+ normalized_url = zapros.URL(url)
118
+ for k, v in params:
119
+ normalized_url.search_params.append(k, v)
120
+ return zapros.Request(
121
+ normalized_url, "GET", headers=headers, body=body, context={"signer": signer}
122
+ )
123
+
124
+
125
+ def list_tags_for_resource(
126
+ options: OperationOptions,
127
+ input_: capo_codeguruprofiler.types.list_tags_for_resource_request.ListTagsForResourceRequest,
128
+ ) -> tuple[
129
+ capo_codeguruprofiler.types.list_tags_for_resource_response.ListTagsForResourceResponse,
130
+ zapros.Response,
131
+ ]:
132
+ response = options.client.handler.handle(build_request(options, input_))
133
+ try:
134
+ if response.status >= 300:
135
+ response.read()
136
+ handle_error(response)
137
+ return handle_response(response), response
138
+ except BaseException:
139
+ response.close()
140
+ raise
141
+
142
+
143
+ async def async_list_tags_for_resource(
144
+ options: AsyncOperationOptions,
145
+ input_: capo_codeguruprofiler.types.list_tags_for_resource_request.ListTagsForResourceRequest,
146
+ ) -> tuple[
147
+ capo_codeguruprofiler.types.list_tags_for_resource_response.ListTagsForResourceResponse,
148
+ zapros.Response,
149
+ ]:
150
+ response = await options.client.handler.ahandle(build_request(options, input_))
151
+ try:
152
+ if response.status >= 300:
153
+ await response.aread()
154
+ handle_error(response)
155
+ return await async_handle_response(response), response
156
+ except BaseException:
157
+ await response.aclose()
158
+ raise
@@ -0,0 +1,168 @@
1
+ """Generated from Smithy shape ``com.amazonaws.codeguruprofiler#PostAgentProfile``."""
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_profile
20
+ import capo_codeguruprofiler.types.post_agent_profile_request
21
+ import capo_codeguruprofiler.types.post_agent_profile_response
22
+ from capo_codeguruprofiler._protocol.errors import parse_error_metadata_json
23
+ from capo_codeguruprofiler._rule_engine._endpoint_rule_set import (
24
+ EndpointParams,
25
+ resolve,
26
+ )
27
+ from capo_codeguruprofiler._services._pipeline import (
28
+ AsyncOperationOptions,
29
+ OperationOptions,
30
+ )
31
+ from capo_codeguruprofiler.errors import UnknownServiceError
32
+
33
+
34
+ def handle_error(response: zapros.Response) -> Never:
35
+ data = json.loads(response.read())
36
+ code, message = parse_error_metadata_json(response, data)
37
+ match code:
38
+ case "InternalServerException":
39
+ raise capo_codeguruprofiler.errors.internal_server_exception.InternalServerException.from_json(
40
+ data, message
41
+ )
42
+ case "ResourceNotFoundException":
43
+ raise capo_codeguruprofiler.errors.resource_not_found_exception.ResourceNotFoundException.from_json(
44
+ data, message
45
+ )
46
+ case "ThrottlingException":
47
+ raise capo_codeguruprofiler.errors.throttling_exception.ThrottlingException.from_json(
48
+ data, message
49
+ )
50
+ case "ValidationException":
51
+ raise capo_codeguruprofiler.errors.validation_exception.ValidationException.from_json(
52
+ data, message
53
+ )
54
+ case _:
55
+ raise UnknownServiceError(code=code, message=message, response=response)
56
+
57
+
58
+ def handle_response(
59
+ response: zapros.Response,
60
+ ) -> capo_codeguruprofiler.types.post_agent_profile_response.PostAgentProfileResponse:
61
+ out: capo_codeguruprofiler.types.post_agent_profile_response.PostAgentProfileResponse = {} # type: ignore[typeddict-item]
62
+ return out
63
+
64
+
65
+ async def async_handle_response(
66
+ response: zapros.Response,
67
+ ) -> capo_codeguruprofiler.types.post_agent_profile_response.PostAgentProfileResponse:
68
+ out: capo_codeguruprofiler.types.post_agent_profile_response.PostAgentProfileResponse = {} # type: ignore[typeddict-item]
69
+ return out
70
+
71
+
72
+ def get_signer(
73
+ options: AsyncOperationOptions | OperationOptions,
74
+ auth_schemes: list[dict[str, Any]] | None = None,
75
+ ) -> capo_codeguruprofiler._auth._signers.Signer | None:
76
+ name_to_schema = {s["name"]: s for s in (auth_schemes or [])} # noqa: F841
77
+ if (
78
+ options.credentials_provider is not None
79
+ and name_to_schema
80
+ and not name_to_schema.keys() & {"sigv4", "sigv4-s3express"}
81
+ ):
82
+ raise RuntimeError(
83
+ "Endpoint requires an unsupported auth scheme: " + ", ".join(name_to_schema)
84
+ )
85
+ if options.credentials_provider is not None:
86
+ endpoint_scheme = name_to_schema.get("sigv4") or name_to_schema.get(
87
+ "sigv4-s3express"
88
+ )
89
+ if endpoint_scheme is not None or not name_to_schema:
90
+ sigv4_config = capo_codeguruprofiler._auth._sigv4.build_sigv4_auth_scheme(
91
+ "codeguru-profiler", options.region, endpoint_scheme
92
+ )
93
+ if sigv4_config is not None:
94
+ return capo_codeguruprofiler._auth._signers.SigV4Signer(
95
+ options.credentials_provider, auth_scheme=sigv4_config
96
+ )
97
+ raise RuntimeError("Auth was not resolved")
98
+
99
+
100
+ def build_request(
101
+ options: OperationOptions | AsyncOperationOptions,
102
+ input_: capo_codeguruprofiler.types.post_agent_profile_request.PostAgentProfileRequest,
103
+ ) -> zapros.Request:
104
+ endpoint = resolve(
105
+ EndpointParams(
106
+ Region=options.region,
107
+ UseDualStack=options.use_dual_stack,
108
+ UseFIPS=options.use_fips,
109
+ Endpoint=options.endpoint,
110
+ )
111
+ ) # noqa: F841
112
+ url = (
113
+ endpoint.url.rstrip("/") + "/profilingGroups/{profilingGroupName}/agentProfile"
114
+ )
115
+ url = url.replace(
116
+ "{profilingGroupName}", quote(input_["profiling_group_name"], safe="")
117
+ )
118
+ params: list[tuple[str, str]] = []
119
+ if "profile_token" in input_:
120
+ params.append(("profileToken", input_["profile_token"]))
121
+ headers: dict[str, str] = {k: ", ".join(v) for k, v in endpoint.headers.items()}
122
+ if "content_type" in input_:
123
+ headers["Content-Type"] = input_["content_type"]
124
+ body: bytes | None = input_["agent_profile"]
125
+ headers["content-type"] = "application/octet-stream"
126
+ signer = get_signer(options, auth_schemes=endpoint.properties.get("authSchemes"))
127
+ normalized_url = zapros.URL(url)
128
+ for k, v in params:
129
+ normalized_url.search_params.append(k, v)
130
+ return zapros.Request(
131
+ normalized_url, "POST", headers=headers, body=body, context={"signer": signer}
132
+ )
133
+
134
+
135
+ def post_agent_profile(
136
+ options: OperationOptions,
137
+ input_: capo_codeguruprofiler.types.post_agent_profile_request.PostAgentProfileRequest,
138
+ ) -> tuple[
139
+ capo_codeguruprofiler.types.post_agent_profile_response.PostAgentProfileResponse,
140
+ zapros.Response,
141
+ ]:
142
+ response = options.client.handler.handle(build_request(options, input_))
143
+ try:
144
+ if response.status >= 300:
145
+ response.read()
146
+ handle_error(response)
147
+ return handle_response(response), response
148
+ except BaseException:
149
+ response.close()
150
+ raise
151
+
152
+
153
+ async def async_post_agent_profile(
154
+ options: AsyncOperationOptions,
155
+ input_: capo_codeguruprofiler.types.post_agent_profile_request.PostAgentProfileRequest,
156
+ ) -> tuple[
157
+ capo_codeguruprofiler.types.post_agent_profile_response.PostAgentProfileResponse,
158
+ zapros.Response,
159
+ ]:
160
+ response = await options.client.handler.ahandle(build_request(options, input_))
161
+ try:
162
+ if response.status >= 300:
163
+ await response.aread()
164
+ handle_error(response)
165
+ return await async_handle_response(response), response
166
+ except BaseException:
167
+ await response.aclose()
168
+ raise
@@ -0,0 +1,182 @@
1
+ """Generated from Smithy shape ``com.amazonaws.codeguruprofiler#PutPermission``."""
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.throttling_exception
19
+ import capo_codeguruprofiler.errors.validation_exception
20
+ import capo_codeguruprofiler.types.principals
21
+ import capo_codeguruprofiler.types.put_permission_request
22
+ import capo_codeguruprofiler.types.put_permission_response
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 "ConflictException":
40
+ raise capo_codeguruprofiler.errors.conflict_exception.ConflictException.from_json(
41
+ data, message
42
+ )
43
+ case "InternalServerException":
44
+ raise capo_codeguruprofiler.errors.internal_server_exception.InternalServerException.from_json(
45
+ data, message
46
+ )
47
+ case "ResourceNotFoundException":
48
+ raise capo_codeguruprofiler.errors.resource_not_found_exception.ResourceNotFoundException.from_json(
49
+ data, message
50
+ )
51
+ case "ThrottlingException":
52
+ raise capo_codeguruprofiler.errors.throttling_exception.ThrottlingException.from_json(
53
+ data, message
54
+ )
55
+ case "ValidationException":
56
+ raise capo_codeguruprofiler.errors.validation_exception.ValidationException.from_json(
57
+ data, message
58
+ )
59
+ case _:
60
+ raise UnknownServiceError(code=code, message=message, response=response)
61
+
62
+
63
+ def handle_response(
64
+ response: zapros.Response,
65
+ ) -> capo_codeguruprofiler.types.put_permission_response.PutPermissionResponse:
66
+ out: capo_codeguruprofiler.types.put_permission_response.PutPermissionResponse = (
67
+ capo_codeguruprofiler.types.put_permission_response.deserialize_json(
68
+ json.loads(response.read())
69
+ )
70
+ )
71
+ return out
72
+
73
+
74
+ async def async_handle_response(
75
+ response: zapros.Response,
76
+ ) -> capo_codeguruprofiler.types.put_permission_response.PutPermissionResponse:
77
+ out: capo_codeguruprofiler.types.put_permission_response.PutPermissionResponse = (
78
+ capo_codeguruprofiler.types.put_permission_response.deserialize_json(
79
+ json.loads(await response.aread())
80
+ )
81
+ )
82
+ return out
83
+
84
+
85
+ def get_signer(
86
+ options: AsyncOperationOptions | OperationOptions,
87
+ auth_schemes: list[dict[str, Any]] | None = None,
88
+ ) -> capo_codeguruprofiler._auth._signers.Signer | None:
89
+ name_to_schema = {s["name"]: s for s in (auth_schemes or [])} # noqa: F841
90
+ if (
91
+ options.credentials_provider is not None
92
+ and name_to_schema
93
+ and not name_to_schema.keys() & {"sigv4", "sigv4-s3express"}
94
+ ):
95
+ raise RuntimeError(
96
+ "Endpoint requires an unsupported auth scheme: " + ", ".join(name_to_schema)
97
+ )
98
+ if options.credentials_provider is not None:
99
+ endpoint_scheme = name_to_schema.get("sigv4") or name_to_schema.get(
100
+ "sigv4-s3express"
101
+ )
102
+ if endpoint_scheme is not None or not name_to_schema:
103
+ sigv4_config = capo_codeguruprofiler._auth._sigv4.build_sigv4_auth_scheme(
104
+ "codeguru-profiler", options.region, endpoint_scheme
105
+ )
106
+ if sigv4_config is not None:
107
+ return capo_codeguruprofiler._auth._signers.SigV4Signer(
108
+ options.credentials_provider, auth_scheme=sigv4_config
109
+ )
110
+ raise RuntimeError("Auth was not resolved")
111
+
112
+
113
+ def build_request(
114
+ options: OperationOptions | AsyncOperationOptions,
115
+ input_: capo_codeguruprofiler.types.put_permission_request.PutPermissionRequest,
116
+ ) -> zapros.Request:
117
+ endpoint = resolve(
118
+ EndpointParams(
119
+ Region=options.region,
120
+ UseDualStack=options.use_dual_stack,
121
+ UseFIPS=options.use_fips,
122
+ Endpoint=options.endpoint,
123
+ )
124
+ ) # noqa: F841
125
+ url = (
126
+ endpoint.url.rstrip("/")
127
+ + "/profilingGroups/{profilingGroupName}/policy/{actionGroup}"
128
+ )
129
+ url = url.replace(
130
+ "{profilingGroupName}", quote(input_["profiling_group_name"], safe="")
131
+ )
132
+ url = url.replace("{actionGroup}", quote(input_["action_group"], safe=""))
133
+ params: list[tuple[str, str]] = []
134
+ headers: dict[str, str] = {k: ", ".join(v) for k, v in endpoint.headers.items()}
135
+ body: bytes | None = json.dumps(
136
+ capo_codeguruprofiler.types.put_permission_request.serialize_json(input_),
137
+ allow_nan=False,
138
+ ).encode()
139
+ headers["content-type"] = "application/json"
140
+ signer = get_signer(options, auth_schemes=endpoint.properties.get("authSchemes"))
141
+ normalized_url = zapros.URL(url)
142
+ for k, v in params:
143
+ normalized_url.search_params.append(k, v)
144
+ return zapros.Request(
145
+ normalized_url, "PUT", headers=headers, body=body, context={"signer": signer}
146
+ )
147
+
148
+
149
+ def put_permission(
150
+ options: OperationOptions,
151
+ input_: capo_codeguruprofiler.types.put_permission_request.PutPermissionRequest,
152
+ ) -> tuple[
153
+ capo_codeguruprofiler.types.put_permission_response.PutPermissionResponse,
154
+ zapros.Response,
155
+ ]:
156
+ response = options.client.handler.handle(build_request(options, input_))
157
+ try:
158
+ if response.status >= 300:
159
+ response.read()
160
+ handle_error(response)
161
+ return handle_response(response), response
162
+ except BaseException:
163
+ response.close()
164
+ raise
165
+
166
+
167
+ async def async_put_permission(
168
+ options: AsyncOperationOptions,
169
+ input_: capo_codeguruprofiler.types.put_permission_request.PutPermissionRequest,
170
+ ) -> tuple[
171
+ capo_codeguruprofiler.types.put_permission_response.PutPermissionResponse,
172
+ zapros.Response,
173
+ ]:
174
+ response = await options.client.handler.ahandle(build_request(options, input_))
175
+ try:
176
+ if response.status >= 300:
177
+ await response.aread()
178
+ handle_error(response)
179
+ return await async_handle_response(response), response
180
+ except BaseException:
181
+ await response.aclose()
182
+ raise