code
stringlengths
66
870k
docstring
stringlengths
19
26.7k
func_name
stringlengths
1
138
language
stringclasses
1 value
repo
stringlengths
7
68
path
stringlengths
5
324
url
stringlengths
46
389
license
stringclasses
7 values
def load_events(self, event_ids: Union[List[Any], Dict]): """ Implementation of ObservabilityPuller.load_events method with AsyncContext. It will create tasks by calling load_events methods of all given pullers, and execute them in async """ async_context = AsyncContext() ...
Implementation of ObservabilityPuller.load_events method with AsyncContext. It will create tasks by calling load_events methods of all given pullers, and execute them in async
load_events
python
aws/aws-sam-cli
samcli/lib/observability/observability_info_puller.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/observability/observability_info_puller.py
Apache-2.0
def __init__(self, cw_log_group: str, event: dict, resource_name: Optional[str] = None): """ Parameters ---------- cw_log_group : str Name of the CloudWatch log group event : dict Event dictionary of the CloudWatch log event resource_name : Optiona...
Parameters ---------- cw_log_group : str Name of the CloudWatch log group event : dict Event dictionary of the CloudWatch log event resource_name : Optional[str] Resource name that is related to this CloudWatch log event
__init__
python
aws/aws-sam-cli
samcli/lib/observability/cw_logs/cw_log_event.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/observability/cw_logs/cw_log_event.py
Apache-2.0
def __init__(self, colored: Colored, keyword=None): """ Parameters ---------- colored : Colored Colored class that will be used to highlight the keywords in log event keyword : str Keyword that will be highlighted """ self._keyword = keywor...
Parameters ---------- colored : Colored Colored class that will be used to highlight the keywords in log event keyword : str Keyword that will be highlighted
__init__
python
aws/aws-sam-cli
samcli/lib/observability/cw_logs/cw_log_formatters.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/observability/cw_logs/cw_log_formatters.py
Apache-2.0
def for_lambda_function(boto_client_provider: BotoProviderType, function_name: str) -> str: """ Returns the CloudWatch Log Group Name created by default for the AWS Lambda function with given name Parameters ---------- boto_client_provider: BotoProviderType Boto clie...
Returns the CloudWatch Log Group Name created by default for the AWS Lambda function with given name Parameters ---------- boto_client_provider: BotoProviderType Boto client provider which contains region and other configurations function_name : str Name...
for_lambda_function
python
aws/aws-sam-cli
samcli/lib/observability/cw_logs/cw_log_group_provider.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/observability/cw_logs/cw_log_group_provider.py
Apache-2.0
def for_apigw_rest_api(rest_api_id: str, stage: str = "Prod") -> str: """ Returns the CloudWatch Log Group Name created by default for the AWS Api gateway rest api with given id Parameters ---------- rest_api_id : str Id of the rest api stage: str ...
Returns the CloudWatch Log Group Name created by default for the AWS Api gateway rest api with given id Parameters ---------- rest_api_id : str Id of the rest api stage: str Stage of the rest api (the default value is "Prod") Returns ---...
for_apigw_rest_api
python
aws/aws-sam-cli
samcli/lib/observability/cw_logs/cw_log_group_provider.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/observability/cw_logs/cw_log_group_provider.py
Apache-2.0
def for_apigwv2_http_api( boto_client_provider: BotoProviderType, http_api_id: str, stage: str = "$default" ) -> Optional[str]: """ Returns the CloudWatch Log Group Name created by default for the AWS Api gatewayv2 http api with given id Parameters ---------- boto_cl...
Returns the CloudWatch Log Group Name created by default for the AWS Api gatewayv2 http api with given id Parameters ---------- boto_client_provider: BotoProviderType Boto client provider which contains region and other configurations http_api_id : str I...
for_apigwv2_http_api
python
aws/aws-sam-cli
samcli/lib/observability/cw_logs/cw_log_group_provider.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/observability/cw_logs/cw_log_group_provider.py
Apache-2.0
def for_step_functions( boto_client_provider: BotoProviderType, step_function_name: str, ) -> Optional[str]: """ Calls describe_state_machine API to get details of the State Machine, then extracts logging information to find the configured CW log group. If nothing is ...
Calls describe_state_machine API to get details of the State Machine, then extracts logging information to find the configured CW log group. If nothing is configured it will return None Parameters ---------- boto_client_provider : BotoProviderType Boto clien...
for_step_functions
python
aws/aws-sam-cli
samcli/lib/observability/cw_logs/cw_log_group_provider.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/observability/cw_logs/cw_log_group_provider.py
Apache-2.0
def __init__( self, logs_client: Any, consumer: ObservabilityEventConsumer, cw_log_group: str, resource_name: Optional[str] = None, max_retries: int = 1000, poll_interval: int = 1, ): """ Parameters ---------- logs_client: Cloud...
Parameters ---------- logs_client: CloudWatchLogsClient boto3 logs client instance consumer : ObservabilityEventConsumer Consumer instance that will process pulled events cw_log_group : str CloudWatch log group name resource_name : Opt...
__init__
python
aws/aws-sam-cli
samcli/lib/observability/cw_logs/cw_log_puller.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/observability/cw_logs/cw_log_puller.py
Apache-2.0
def _construct_segments(self, event_dict): """ Each event is represented by segment, and it is like a Tree model (each segment also have subsegments). """ raw_segments = event_dict.get("Segments", []) for raw_segment in raw_segments: segment_document = raw_segment.get...
Each event is represented by segment, and it is like a Tree model (each segment also have subsegments).
_construct_segments
python
aws/aws-sam-cli
samcli/lib/observability/xray_traces/xray_events.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/observability/xray_traces/xray_events.py
Apache-2.0
def get_latest_event_time(self): """ Returns the latest event time for this specific XRayTraceEvent by calling get_latest_event_time for each segment """ latest_event_time = 0 for segment in self.segments: segment_latest_event_time = segment.get_latest_event_time() ...
Returns the latest event time for this specific XRayTraceEvent by calling get_latest_event_time for each segment
get_latest_event_time
python
aws/aws-sam-cli
samcli/lib/observability/xray_traces/xray_events.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/observability/xray_traces/xray_events.py
Apache-2.0
def get_latest_event_time(self): """ Gets the latest event time by comparing all timestamps (end_time) from current segment and all sub-segments """ latest_event_time = self.end_time for sub_segment in self.sub_segments: sub_segment_latest_time = sub_segment.get_lates...
Gets the latest event time by comparing all timestamps (end_time) from current segment and all sub-segments
get_latest_event_time
python
aws/aws-sam-cli
samcli/lib/observability/xray_traces/xray_events.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/observability/xray_traces/xray_events.py
Apache-2.0
def _construct_edge_ids(self, edges): """ covert the edges information to a list of edge reference ids """ edge_ids: List[int] = [] for edge in edges: edge_ids.append(edge.get("ReferenceId", -1)) self.edge_ids = edge_ids
covert the edges information to a list of edge reference ids
_construct_edge_ids
python
aws/aws-sam-cli
samcli/lib/observability/xray_traces/xray_events.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/observability/xray_traces/xray_events.py
Apache-2.0
def _set_summary_statistics(self, summary_statistics): """ get some useful information from summary statistics """ if not summary_statistics: return self.ok_count = summary_statistics.get("OkCount", 0) error_statistics = summary_statistics.get("ErrorStatistics...
get some useful information from summary statistics
_set_summary_statistics
python
aws/aws-sam-cli
samcli/lib/observability/xray_traces/xray_events.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/observability/xray_traces/xray_events.py
Apache-2.0
def format_segments(self, segments: List[XRayTraceSegment], level: int = 0) -> str: """ Prints given segment information back to console. Parameters ---------- segments : List[XRayTraceEvent] List of segments which will be printed into console level : int ...
Prints given segment information back to console. Parameters ---------- segments : List[XRayTraceEvent] List of segments which will be printed into console level : int Optional level value which will be used to make the indentation of each segment. Defau...
format_segments
python
aws/aws-sam-cli
samcli/lib/observability/xray_traces/xray_event_mappers.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/observability/xray_traces/xray_event_mappers.py
Apache-2.0
def format_services(self, services: List[XRayGraphServiceInfo]) -> str: """ Prints given services information back to console. Parameters ---------- services : List[XRayGraphServiceInfo] List of services which will be printed into console """ formatte...
Prints given services information back to console. Parameters ---------- services : List[XRayGraphServiceInfo] List of services which will be printed into console
format_services
python
aws/aws-sam-cli
samcli/lib/observability/xray_traces/xray_event_mappers.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/observability/xray_traces/xray_event_mappers.py
Apache-2.0
def format_summary_statistics(service: XRayGraphServiceInfo, level) -> str: """ Prints given summary statistics information back to console. Parameters ---------- service: XRayGraphServiceInfo summary statistics of the service which will be printed into console ...
Prints given summary statistics information back to console. Parameters ---------- service: XRayGraphServiceInfo summary statistics of the service which will be printed into console level : int Optional level value which will be used to make the indentat...
format_summary_statistics
python
aws/aws-sam-cli
samcli/lib/observability/xray_traces/xray_event_mappers.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/observability/xray_traces/xray_event_mappers.py
Apache-2.0
def __init__( self, max_retries: int = 1000, poll_interval: int = 1, ): """ Parameters ---------- max_retries : int Optional maximum number of retries which can be used to pull information. Default value is 1000 poll_interval : int ...
Parameters ---------- max_retries : int Optional maximum number of retries which can be used to pull information. Default value is 1000 poll_interval : int Optional interval value that will be used to wait between calls in tail operation. Default value is 1 ...
__init__
python
aws/aws-sam-cli
samcli/lib/observability/xray_traces/xray_event_puller.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/observability/xray_traces/xray_event_puller.py
Apache-2.0
def __init__( self, xray_client: Any, consumer: ObservabilityEventConsumer, max_retries: int = 1000, poll_interval: int = 1 ): """ Parameters ---------- xray_client : boto3.client XRay boto3 client instance consumer : ObservabilityEventConsumer ...
Parameters ---------- xray_client : boto3.client XRay boto3 client instance consumer : ObservabilityEventConsumer Consumer instance which will process pulled events max_retries : int Optional maximum number of retries which can be used to pul...
__init__
python
aws/aws-sam-cli
samcli/lib/observability/xray_traces/xray_event_puller.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/observability/xray_traces/xray_event_puller.py
Apache-2.0
def __init__( self, xray_client: Any, consumer: ObservabilityEventConsumer, max_retries: int = 1000, poll_interval: int = 1 ): """ Parameters ---------- xray_client : boto3.client XRay boto3 client instance consumer : ObservabilityEventConsumer ...
Parameters ---------- xray_client : boto3.client XRay boto3 client instance consumer : ObservabilityEventConsumer Consumer instance which will process pulled events max_retries : int Optional maximum number of retries which can be used to pul...
__init__
python
aws/aws-sam-cli
samcli/lib/observability/xray_traces/xray_service_graph_event_puller.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/observability/xray_traces/xray_service_graph_event_puller.py
Apache-2.0
def do_export(self, resource_id, resource_dict, parent_dir): """ If the nested stack template is valid, this method will export on the nested template, upload the exported template to S3 and set property to URL of the uploaded S3 template """ template_path = resource_dic...
If the nested stack template is valid, this method will export on the nested template, upload the exported template to S3 and set property to URL of the uploaded S3 template
do_export
python
aws/aws-sam-cli
samcli/lib/package/artifact_exporter.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/package/artifact_exporter.py
Apache-2.0
def do_export(self, resource_id, resource_dict, parent_dir): """ If the stack template is valid, this method will upload the template to S3 and set property to URL of the uploaded S3 template """ template_path = resource_dict.get(self.PROPERTY_NAME, None) if tem...
If the stack template is valid, this method will upload the template to S3 and set property to URL of the uploaded S3 template
do_export
python
aws/aws-sam-cli
samcli/lib/package/artifact_exporter.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/package/artifact_exporter.py
Apache-2.0
def __init__( self, template_path: str, parent_dir: str, uploaders: Uploaders, code_signer: CodeSigner, resources_to_export=frozenset( RESOURCES_EXPORT_LIST + [CloudFormationStackResource, CloudFormationStackSetResource, ServerlessApplicationResour...
Reads the template and makes it ready for export
__init__
python
aws/aws-sam-cli
samcli/lib/package/artifact_exporter.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/package/artifact_exporter.py
Apache-2.0
def _export_global_artifacts(self, template_dict: Dict) -> Dict: """ Template params such as AWS::Include transforms are not specific to any resource type but contain artifacts that should be exported, here we iterate through the template dict and export params with a handler def...
Template params such as AWS::Include transforms are not specific to any resource type but contain artifacts that should be exported, here we iterate through the template dict and export params with a handler defined in GLOBAL_EXPORT_DICT
_export_global_artifacts
python
aws/aws-sam-cli
samcli/lib/package/artifact_exporter.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/package/artifact_exporter.py
Apache-2.0
def _export_metadata(self): """ Exports the local artifacts referenced by the metadata section in the given template to an export destination. """ if "Metadata" not in self.template_dict: return for metadata_type, metadata_dict in self.template_dict["Metadata...
Exports the local artifacts referenced by the metadata section in the given template to an export destination.
_export_metadata
python
aws/aws-sam-cli
samcli/lib/package/artifact_exporter.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/package/artifact_exporter.py
Apache-2.0
def _apply_global_values(self): """ Takes values from the "Global" parameters and applies them to resources where needed for packaging. This transform method addresses issue 1706, where CodeUri is expected to be allowed as a global param for packaging, even when there may not be a build...
Takes values from the "Global" parameters and applies them to resources where needed for packaging. This transform method addresses issue 1706, where CodeUri is expected to be allowed as a global param for packaging, even when there may not be a build step (such as the source being an S3 file)...
_apply_global_values
python
aws/aws-sam-cli
samcli/lib/package/artifact_exporter.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/package/artifact_exporter.py
Apache-2.0
def export(self) -> Dict: """ Exports the local artifacts referenced by the given template to an export destination. :return: The template with references to artifacts that have been exported to an export destination. """ self._export_metadata() if "Reso...
Exports the local artifacts referenced by the given template to an export destination. :return: The template with references to artifacts that have been exported to an export destination.
export
python
aws/aws-sam-cli
samcli/lib/package/artifact_exporter.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/package/artifact_exporter.py
Apache-2.0
def delete(self, retain_resources: List): """ Deletes all the artifacts referenced by the given Cloudformation template """ if "Resources" not in self.template_dict: return self._apply_global_values() for resource_id, resource in self.template_dict["Resource...
Deletes all the artifacts referenced by the given Cloudformation template
delete
python
aws/aws-sam-cli
samcli/lib/package/artifact_exporter.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/package/artifact_exporter.py
Apache-2.0
def get_ecr_repos(self): """ Get all the ecr repos from the template """ ecr_repos = {} if "Resources" not in self.template_dict: return ecr_repos self._apply_global_values() for resource_id, resource in self.template_dict["Resources"].items(): ...
Get all the ecr repos from the template
get_ecr_repos
python
aws/aws-sam-cli
samcli/lib/package/artifact_exporter.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/package/artifact_exporter.py
Apache-2.0
def get_s3_info(self): """ Iterates the template_dict resources with S3 EXPORT_DESTINATION to get the s3_bucket and s3_prefix information for the purpose of deletion. Method finds the first resource with s3 information, extracts the information and then terminates. It is safe to ...
Iterates the template_dict resources with S3 EXPORT_DESTINATION to get the s3_bucket and s3_prefix information for the purpose of deletion. Method finds the first resource with s3 information, extracts the information and then terminates. It is safe to assume that all the packaged files...
get_s3_info
python
aws/aws-sam-cli
samcli/lib/package/artifact_exporter.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/package/artifact_exporter.py
Apache-2.0
def sign_package(self, resource_id, s3_url, s3_version): """ Signs artifact which is named with resource_id, its location is s3_url and its s3 object version is s3_version """ # extract code signing config for the resource signing_profile_for_resource = self.signing_profi...
Signs artifact which is named with resource_id, its location is s3_url and its s3 object version is s3_version
sign_package
python
aws/aws-sam-cli
samcli/lib/package/code_signer.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/package/code_signer.py
Apache-2.0
def _wait_for_signing_job_to_complete(self, code_sign_job_id): """ Creates a waiter object to wait signing job to complete Checks job status for every 5 second """ try: waiter = self.signer_client.get_waiter("successful_signing_job") waiter.wait(jobId=code...
Creates a waiter object to wait signing job to complete Checks job status for every 5 second
_wait_for_signing_job_to_complete
python
aws/aws-sam-cli
samcli/lib/package/code_signer.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/package/code_signer.py
Apache-2.0
def _initiate_code_signing(self, profile_name, profile_owner, s3_bucket, s3_key, s3_target_prefix, s3_version): """ Initiates code signing job and returns the initiated jobId Raises exception if initiation fails """ try: param_source = {"s3": {"bucketName": s3_bucket,...
Initiates code signing job and returns the initiated jobId Raises exception if initiation fails
_initiate_code_signing
python
aws/aws-sam-cli
samcli/lib/package/code_signer.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/package/code_signer.py
Apache-2.0
def login(self): """ Logs into the supplied ECR with credentials. """ try: token = self.ecr_client.get_authorization_token() except botocore.exceptions.ClientError as ex: raise ECRAuthorizationError(msg=ex.response["Error"]["Message"]) from ex use...
Logs into the supplied ECR with credentials.
login
python
aws/aws-sam-cli
samcli/lib/package/ecr_uploader.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/package/ecr_uploader.py
Apache-2.0
def upload(self, image, resource_name): """ Uploads given local image to ECR. :param image: locally tagged docker image that would be uploaded to ECR. :param resource_name: logical ID of the resource to be uploaded to ECR. :return: remote ECR image path that has been uploaded. ...
Uploads given local image to ECR. :param image: locally tagged docker image that would be uploaded to ECR. :param resource_name: logical ID of the resource to be uploaded to ECR. :return: remote ECR image path that has been uploaded.
upload
python
aws/aws-sam-cli
samcli/lib/package/ecr_uploader.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/package/ecr_uploader.py
Apache-2.0
def delete_artifact(self, image_uri: str, resource_id: str, property_name: str): """ Delete the given ECR image by extracting the repository and image_tag from image_uri :param image_uri: image_uri of the image to be deleted :param resource_id: id of the resource for which the i...
Delete the given ECR image by extracting the repository and image_tag from image_uri :param image_uri: image_uri of the image to be deleted :param resource_id: id of the resource for which the image is deleted :param property_name: provided property_name for the resource ...
delete_artifact
python
aws/aws-sam-cli
samcli/lib/package/ecr_uploader.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/package/ecr_uploader.py
Apache-2.0
def delete_ecr_repository(self, physical_id: str): """ Delete ECR repository using the physical_id :param: physical_id of the repository to be deleted """ try: click.echo(f"\t- Deleting ECR repository {physical_id}") self.ecr_client.delete_repository(repo...
Delete ECR repository using the physical_id :param: physical_id of the repository to be deleted
delete_ecr_repository
python
aws/aws-sam-cli
samcli/lib/package/ecr_uploader.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/package/ecr_uploader.py
Apache-2.0
def tag_translation(image, docker_image_id=None, gen_tag="latest"): """ Translates a given local image structure such as `helloworld:v1` into just a tag structure such as `helloworld-v1` , this tag will then be applied to an image that is to be uploaded to a remote registry. :param docker_image_id:...
Translates a given local image structure such as `helloworld:v1` into just a tag structure such as `helloworld-v1` , this tag will then be applied to an image that is to be uploaded to a remote registry. :param docker_image_id: an Id associated with a docker image. :param image: an image reference...
tag_translation
python
aws/aws-sam-cli
samcli/lib/package/image_utils.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/package/image_utils.py
Apache-2.0
def get_uploaded_s3_object_name( precomputed_md5: Optional[str] = None, file_content: Optional[str] = None, file_path: Optional[str] = None, extension: Optional[str] = None, ) -> str: """ Generate the file name that will be used while creating the S3 Object based on the file hash value. This...
Generate the file name that will be used while creating the S3 Object based on the file hash value. This method expect either the precomuted hash value of the file, or the file content, or the file path Parameters ---------- precomputed_md5: str the precomputed hash value of the file. ...
get_uploaded_s3_object_name
python
aws/aws-sam-cli
samcli/lib/package/local_files_utils.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/package/local_files_utils.py
Apache-2.0
def do_export( self, resource_id, resource_dict, parent_dir, property_path: Optional[str] = None, local_path: Optional[str] = None, ): """ Default export action is to upload artifacts and set the property to S3 URL of the uploaded object ...
Default export action is to upload artifacts and set the property to S3 URL of the uploaded object If code signing configuration is provided for function/layer, uploaded artifact will be replaced by signed artifact location
do_export
python
aws/aws-sam-cli
samcli/lib/package/packageable_resources.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/package/packageable_resources.py
Apache-2.0
def delete(self, resource_id, resource_dict): """ Delete the S3 artifact using S3 url referenced by PROPERTY_NAME """ if resource_dict is None: return s3_info = self.get_property_value(resource_dict) if s3_info["Key"]: self.uploader.delete_artifac...
Delete the S3 artifact using S3 url referenced by PROPERTY_NAME
delete
python
aws/aws-sam-cli
samcli/lib/package/packageable_resources.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/package/packageable_resources.py
Apache-2.0
def get_property_value(self, resource_dict): """ Get the s3 property value for this resource """ if resource_dict is None: return {"Bucket": None, "Key": None} resource_path = jmespath.search(self.PROPERTY_NAME, resource_dict) # In the case where resource_pat...
Get the s3 property value for this resource
get_property_value
python
aws/aws-sam-cli
samcli/lib/package/packageable_resources.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/package/packageable_resources.py
Apache-2.0
def do_export(self, resource_id, resource_dict, parent_dir): """ Default export action is to upload artifacts and set the property to dictionary where the key is EXPORT_PROPERTY_CODE_KEY and value is set to an uploaded URL. """ uploaded_url = upload_local_image_artifacts(...
Default export action is to upload artifacts and set the property to dictionary where the key is EXPORT_PROPERTY_CODE_KEY and value is set to an uploaded URL.
do_export
python
aws/aws-sam-cli
samcli/lib/package/packageable_resources.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/package/packageable_resources.py
Apache-2.0
def delete(self, resource_id, resource_dict): """ Delete the ECR artifact using ECR url in PROPERTY_NAME referenced by EXPORT_PROPERTY_CODE_KEY """ if resource_dict is None: return remote_path = resource_dict.get(self.PROPERTY_NAME, {}).get(self.EXPORT_PROPERTY_CODE_...
Delete the ECR artifact using ECR url in PROPERTY_NAME referenced by EXPORT_PROPERTY_CODE_KEY
delete
python
aws/aws-sam-cli
samcli/lib/package/packageable_resources.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/package/packageable_resources.py
Apache-2.0
def do_export(self, resource_id, resource_dict, parent_dir): """ Default export action is to upload artifacts and set the property to URL of the uploaded object """ uploaded_url = upload_local_image_artifacts( resource_id, resource_dict, self.PROPERTY_NAME, parent_dir...
Default export action is to upload artifacts and set the property to URL of the uploaded object
do_export
python
aws/aws-sam-cli
samcli/lib/package/packageable_resources.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/package/packageable_resources.py
Apache-2.0
def delete(self, resource_id, resource_dict): """ Delete the ECR artifact using ECR url referenced by property_name """ if resource_dict is None: return remote_path = resource_dict.get(self.PROPERTY_NAME) # In the case where remote_path is pointing to an intr...
Delete the ECR artifact using ECR url referenced by property_name
delete
python
aws/aws-sam-cli
samcli/lib/package/packageable_resources.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/package/packageable_resources.py
Apache-2.0
def do_export(self, resource_id, resource_dict, parent_dir): """ Upload to S3 and set property to an dict representing the S3 url of the uploaded object """ artifact_s3_url = upload_local_artifacts( self.RESOURCE_TYPE, resource_id, resource_dict, self.PROPERTY_NAME, ...
Upload to S3 and set property to an dict representing the S3 url of the uploaded object
do_export
python
aws/aws-sam-cli
samcli/lib/package/packageable_resources.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/package/packageable_resources.py
Apache-2.0
def delete(self, resource_id, resource_dict): """ Delete the S3 artifact using S3 url in the dict PROPERTY_NAME using the bucket at BUCKET_NAME_PROPERTY and key at OBJECT_KEY_PROPERTY """ if resource_dict is None: return s3_info = self.get_property_value(reso...
Delete the S3 artifact using S3 url in the dict PROPERTY_NAME using the bucket at BUCKET_NAME_PROPERTY and key at OBJECT_KEY_PROPERTY
delete
python
aws/aws-sam-cli
samcli/lib/package/packageable_resources.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/package/packageable_resources.py
Apache-2.0
def get_property_value(self, resource_dict): """ Get the s3 property value for this resource """ if resource_dict is None: return {"Bucket": None, "Key": None} resource_path = resource_dict.get(self.PROPERTY_NAME, {}) s3_bucket = resource_path.get(self.BUCKET...
Get the s3 property value for this resource
get_property_value
python
aws/aws-sam-cli
samcli/lib/package/packageable_resources.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/package/packageable_resources.py
Apache-2.0
def apply(self, zip_info: zipfile.ZipInfo): """ Parameters ---------- zip_info: zipfile.ZipInfo object of zipfile.ZipInfo Returns ------- zipfile.ZipInfo modified object with `external_attr` set to member permissions. """ ...
Parameters ---------- zip_info: zipfile.ZipInfo object of zipfile.ZipInfo Returns ------- zipfile.ZipInfo modified object with `external_attr` set to member permissions.
apply
python
aws/aws-sam-cli
samcli/lib/package/permissions.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/package/permissions.py
Apache-2.0
def apply(self, zip_info: zipfile.ZipInfo): """ Parameters ---------- zip_info: zipfile.ZipInfo object of zipfile.ZipInfo Returns ------- zipfile.ZipInfo modified object with `external_attr` set to member permissions. """ ...
Parameters ---------- zip_info: zipfile.ZipInfo object of zipfile.ZipInfo Returns ------- zipfile.ZipInfo modified object with `external_attr` set to member permissions.
apply
python
aws/aws-sam-cli
samcli/lib/package/permissions.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/package/permissions.py
Apache-2.0
def apply(self, zip_info: zipfile.ZipInfo): """ Parameters ---------- zip_info: zipfile.ZipInfo object of zipfile.ZipInfo Returns ------- zipfile.ZipInfo modified object with `external_attr` added with member permissions if co...
Parameters ---------- zip_info: zipfile.ZipInfo object of zipfile.ZipInfo Returns ------- zipfile.ZipInfo modified object with `external_attr` added with member permissions if conditions are satisfied.
apply
python
aws/aws-sam-cli
samcli/lib/package/permissions.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/package/permissions.py
Apache-2.0
def apply(self, zip_info: zipfile.ZipInfo): """ Parameters ---------- zip_info: zipfile.ZipInfo object of zipfile.ZipInfo Returns ------- zipfile.ZipInfo modified object with `external_attr` added with member permissions if co...
Parameters ---------- zip_info: zipfile.ZipInfo object of zipfile.ZipInfo Returns ------- zipfile.ZipInfo modified object with `external_attr` added with member permissions if conditions are satisfied.
apply
python
aws/aws-sam-cli
samcli/lib/package/permissions.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/package/permissions.py
Apache-2.0
def upload(self, file_name: str, remote_path: str) -> str: """ Uploads given file to S3 :param file_name: Path to the file that will be uploaded :param remote_path: be uploaded :return: VersionId of the latest upload """ if self.prefix: remote_path =...
Uploads given file to S3 :param file_name: Path to the file that will be uploaded :param remote_path: be uploaded :return: VersionId of the latest upload
upload
python
aws/aws-sam-cli
samcli/lib/package/s3_uploader.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/package/s3_uploader.py
Apache-2.0
def upload_with_dedup( self, file_name: str, extension: Optional[str] = None, precomputed_md5: Optional[str] = None ) -> str: """ Makes and returns name of the S3 object based on the file's MD5 sum :param file_name: file to upload :param extension: String of file extension t...
Makes and returns name of the S3 object based on the file's MD5 sum :param file_name: file to upload :param extension: String of file extension to append to the object :param precomputed_md5: Specified md5 hash for the file to be uploaded. :return: S3 URL of the uploaded object...
upload_with_dedup
python
aws/aws-sam-cli
samcli/lib/package/s3_uploader.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/package/s3_uploader.py
Apache-2.0
def delete_artifact(self, remote_path: str, is_key: bool = False) -> bool: """ Deletes a given file from S3 :param remote_path: Path to the file that will be deleted :param is_key: If the given remote_path is the key or a file_name :return: metadata dict of the deleted object ...
Deletes a given file from S3 :param remote_path: Path to the file that will be deleted :param is_key: If the given remote_path is the key or a file_name :return: metadata dict of the deleted object
delete_artifact
python
aws/aws-sam-cli
samcli/lib/package/s3_uploader.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/package/s3_uploader.py
Apache-2.0
def delete_prefix_artifacts(self): """ Deletes all the files from the prefix in S3 """ if not self.bucket_name: LOG.error("Bucket not specified") raise BucketNotSpecifiedError() if self.prefix: # Note: list_objects_v2 api uses prefix to fetch t...
Deletes all the files from the prefix in S3
delete_prefix_artifacts
python
aws/aws-sam-cli
samcli/lib/package/s3_uploader.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/package/s3_uploader.py
Apache-2.0
def file_exists(self, remote_path: str) -> bool: """ Check if the file we are trying to upload already exists in S3 :param remote_path: :return: True, if file exists. False, otherwise """ try: # Find the object that matches this ETag if not self....
Check if the file we are trying to upload already exists in S3 :param remote_path: :return: True, if file exists. False, otherwise
file_exists
python
aws/aws-sam-cli
samcli/lib/package/s3_uploader.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/package/s3_uploader.py
Apache-2.0
def to_path_style_s3_url(self, key: str, version: Optional[str] = None) -> str: """ This link describes the format of Path Style URLs http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingBucket.html#access-bucket-intro """ base = self.s3.meta.endpoint_url result = "{0}/{1}...
This link describes the format of Path Style URLs http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingBucket.html#access-bucket-intro
to_path_style_s3_url
python
aws/aws-sam-cli
samcli/lib/package/s3_uploader.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/package/s3_uploader.py
Apache-2.0
def get_version_of_artifact(self, s3_url: str) -> str: """ Returns version information of the S3 object that is given as S3 URL """ parsed_s3_url = parse_s3_url(s3_url) s3_bucket = parsed_s3_url["Bucket"] s3_key = parsed_s3_url["Key"] s3_object_tagging = self.s3.g...
Returns version information of the S3 object that is given as S3 URL
get_version_of_artifact
python
aws/aws-sam-cli
samcli/lib/package/s3_uploader.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/package/s3_uploader.py
Apache-2.0
def is_s3_protocol_url(url): """ Check whether url is a valid path in the form of "s3://..." """ try: parse_s3_url(url) return True except ValueError: return False
Check whether url is a valid path in the form of "s3://..."
is_s3_protocol_url
python
aws/aws-sam-cli
samcli/lib/package/utils.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/package/utils.py
Apache-2.0
def upload_local_image_artifacts(resource_id, resource_dict, property_name, parent_dir, uploader): """ Upload local artifacts referenced by the property at given resource and return ECR URL of the uploaded object. It is the responsibility of callers to ensure property value is a valid image. If pat...
Upload local artifacts referenced by the property at given resource and return ECR URL of the uploaded object. It is the responsibility of callers to ensure property value is a valid image. If path is already a path to S3 object, this method does nothing. :param resource_id: Id of the CloudFo...
upload_local_image_artifacts
python
aws/aws-sam-cli
samcli/lib/package/utils.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/package/utils.py
Apache-2.0
def zip_folder(folder_path, zip_method): """ Zip the entire folder and return a file to the zip. Use this inside a "with" statement to cleanup the zipfile after it is used. Parameters ---------- folder_path : str The path of the folder to zip zip_method : Callable Callable f...
Zip the entire folder and return a file to the zip. Use this inside a "with" statement to cleanup the zipfile after it is used. Parameters ---------- folder_path : str The path of the folder to zip zip_method : Callable Callable function that takes in a file name and source_pat...
zip_folder
python
aws/aws-sam-cli
samcli/lib/package/utils.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/package/utils.py
Apache-2.0
def make_zip_with_permissions(file_name, source_root, permission_mappers: List[PermissionMapper]): """ Create a zip file from the source directory Parameters ---------- file_name : str The basename of the zip file, without .zip source_root : str The path to the source directory ...
Create a zip file from the source directory Parameters ---------- file_name : str The basename of the zip file, without .zip source_root : str The path to the source directory permission_mappers : list permission objects that need to match an interface such that they ha...
make_zip_with_permissions
python
aws/aws-sam-cli
samcli/lib/package/utils.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/package/utils.py
Apache-2.0
def name(self) -> Optional[str]: """ extracts and returns the resource name from its ARN Raises ------ ValueError if the ARN is invalid """ if not self.arn: return None arn_parts: ARNParts = ARNParts(arn=self.arn) return arn_parts.resou...
extracts and returns the resource name from its ARN Raises ------ ValueError if the ARN is invalid
name
python
aws/aws-sam-cli
samcli/lib/pipeline/bootstrap/resource.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/pipeline/bootstrap/resource.py
Apache-2.0
def get_uri(self) -> Optional[str]: """ extracts and returns the URI of the given ECR image repository from its ARN see https://docs.aws.amazon.com/AmazonECR/latest/userguide/Registries.html Raises ------ ValueError if the ARN is invalid """ if not self.ar...
extracts and returns the URI of the given ECR image repository from its ARN see https://docs.aws.amazon.com/AmazonECR/latest/userguide/Registries.html Raises ------ ValueError if the ARN is invalid
get_uri
python
aws/aws-sam-cli
samcli/lib/pipeline/bootstrap/resource.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/pipeline/bootstrap/resource.py
Apache-2.0
def _get_secure_ssl_context() -> SSL.Context: """ Returns a SSL Context with secure settings """ ctx = SSL.Context(SSL.TLS_METHOD) ctx.set_options(SSL.OP_NO_TLSv1) ctx.set_options(SSL.OP_NO_TLSv1_1) ctx.set_options(SSL.OP_NO_SSLv2) ctx.set_options(SSL.OP_NO_SSLv3) return ctx
Returns a SSL Context with secure settings
_get_secure_ssl_context
python
aws/aws-sam-cli
samcli/lib/pipeline/bootstrap/stage.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/pipeline/bootstrap/stage.py
Apache-2.0
def _should_create_new_provider(self, stack_name: str) -> bool: """ Checks if there is an existing Identity Provider in the account already whos ARN contains the URL provided by the user. OIDC Provider arns are of the following format arn:aws:iam:::oidc-provider/api.bitbucket.or...
Checks if there is an existing Identity Provider in the account already whos ARN contains the URL provided by the user. OIDC Provider arns are of the following format arn:aws:iam:::oidc-provider/api.bitbucket.org/2.0/workspaces//pipelines-config/identity/oidc we can check if th...
_should_create_new_provider
python
aws/aws-sam-cli
samcli/lib/pipeline/bootstrap/stage.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/pipeline/bootstrap/stage.py
Apache-2.0
def generate_thumbprint(oidc_provider_url: Optional[str]) -> Optional[str]: """ retrieves the certificate of the top intermidate cerficate authority that signed the certificate used by the external identity provider and then returns the SHA1 hash of it. For more information on why the th...
retrieves the certificate of the top intermidate cerficate authority that signed the certificate used by the external identity provider and then returns the SHA1 hash of it. For more information on why the thumbprint is needed and the steps required to obtain it see the following page h...
generate_thumbprint
python
aws/aws-sam-cli
samcli/lib/pipeline/bootstrap/stage.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/pipeline/bootstrap/stage.py
Apache-2.0
def bootstrap(self, confirm_changeset: bool = True) -> bool: """ Deploys the CFN template(./stage_resources.yaml) which deploys: * Pipeline IAM User or IAM OIDC Identity Provider * Pipeline execution IAM role * CloudFormation execution IAM role * Artifacts...
Deploys the CFN template(./stage_resources.yaml) which deploys: * Pipeline IAM User or IAM OIDC Identity Provider * Pipeline execution IAM role * CloudFormation execution IAM role * Artifacts' S3 Bucket * ECR image repository to the AWS accoun...
bootstrap
python
aws/aws-sam-cli
samcli/lib/pipeline/bootstrap/stage.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/pipeline/bootstrap/stage.py
Apache-2.0
def _get_pipeline_user_secret_pair( secret_manager_arn: str, profile: Optional[str], region: Optional[str] ) -> Tuple[str, str]: """ Helper method to fetch pipeline user's AWS Credentials from secrets manager. SecretString need to be in following JSON format: { "aws...
Helper method to fetch pipeline user's AWS Credentials from secrets manager. SecretString need to be in following JSON format: { "aws_access_key_id": "AWSSECRETACCESSKEY123", "aws_secret_access_key": "mYSuperSecretDummyKey" } Parameters ---------- ...
_get_pipeline_user_secret_pair
python
aws/aws-sam-cli
samcli/lib/pipeline/bootstrap/stage.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/pipeline/bootstrap/stage.py
Apache-2.0
def save_config(self, config_dir: str, filename: str, cmd_names: List[str]) -> None: """ save the Artifacts bucket name, ECR image repository URI and ARNs of pipeline_user, pipeline_execution_role and cloudformation_execution_role to the given filename and directory. Parameters ...
save the Artifacts bucket name, ECR image repository URI and ARNs of pipeline_user, pipeline_execution_role and cloudformation_execution_role to the given filename and directory. Parameters ---------- config_dir: str the directory of the toml file to save to ...
save_config
python
aws/aws-sam-cli
samcli/lib/pipeline/bootstrap/stage.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/pipeline/bootstrap/stage.py
Apache-2.0
def save_config_safe(self, config_dir: str, filename: str, cmd_names: List[str]) -> None: """ A safe version of save_config method that doesn't raise any exception """ try: self.save_config(config_dir, filename, cmd_names) except Exception: pass
A safe version of save_config method that doesn't raise any exception
save_config_safe
python
aws/aws-sam-cli
samcli/lib/pipeline/bootstrap/stage.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/pipeline/bootstrap/stage.py
Apache-2.0
def print_resources_summary(self) -> None: """prints to the screen(console) the ARNs of the created and provided resources.""" provided_resources = [] created_resources = [] for resource in self._get_resources(): if resource.is_user_provided: provided_resourc...
prints to the screen(console) the ARNs of the created and provided resources.
print_resources_summary
python
aws/aws-sam-cli
samcli/lib/pipeline/bootstrap/stage.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/pipeline/bootstrap/stage.py
Apache-2.0
def __iter__(self) -> Iterator[Tuple[str, List[Route]]]: """ Iterator to iterate through all the routes stored in the collector. In each iteration, this yields the LogicalId of the route resource and a list of routes available in this resource. Yields ------- str ...
Iterator to iterate through all the routes stored in the collector. In each iteration, this yields the LogicalId of the route resource and a list of routes available in this resource. Yields ------- str LogicalID of the AWS::Serverless::Api or AWS::ApiGateway::RestAp...
__iter__
python
aws/aws-sam-cli
samcli/lib/providers/api_collector.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/providers/api_collector.py
Apache-2.0
def _link_authorizers(self) -> None: """ Links the routes to the correct authorizer object """ for apigw_id, routes in self._route_per_resource.items(): authorizers = self._authorizers_per_resources.get(apigw_id, {}) default_authorizer = self._default_authorizer_...
Links the routes to the correct authorizer object
_link_authorizers
python
aws/aws-sam-cli
samcli/lib/providers/api_collector.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/providers/api_collector.py
Apache-2.0
def all_routes(self) -> List[Route]: """ Gets all the routes within the _route_per_resource Return ------- All the routes within the _route_per_resource """ routes = [] for logical_id in self._route_per_resource.keys(): routes.extend(self._get...
Gets all the routes within the _route_per_resource Return ------- All the routes within the _route_per_resource
all_routes
python
aws/aws-sam-cli
samcli/lib/providers/api_collector.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/providers/api_collector.py
Apache-2.0
def get_api(self) -> Api: """ Creates the api using the parts from the ApiCollector. The routes are also deduped so that there is no duplicate routes with the same function name, path, but different method. The normalised_routes are the routes that have been processed. By default, this ...
Creates the api using the parts from the ApiCollector. The routes are also deduped so that there is no duplicate routes with the same function name, path, but different method. The normalised_routes are the routes that have been processed. By default, this will get all the routes. Howe...
get_api
python
aws/aws-sam-cli
samcli/lib/providers/api_collector.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/providers/api_collector.py
Apache-2.0
def normalize_cors_methods(routes: List[Route], cors: Optional[Cors]) -> List[Route]: """ Adds OPTIONS method to all the route methods if cors exists Parameters ----------- routes: list(samcli.local.apigw.local_apigw_service.Route) List of Routes cors: samcl...
Adds OPTIONS method to all the route methods if cors exists Parameters ----------- routes: list(samcli.local.apigw.local_apigw_service.Route) List of Routes cors: samcli.commands.local.lib.provider.Cors the cors object for the api Return ...
normalize_cors_methods
python
aws/aws-sam-cli
samcli/lib/providers/api_collector.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/providers/api_collector.py
Apache-2.0
def dedupe_function_routes(routes: List[Route]) -> List[Route]: """ Remove duplicate routes that have the same function_name and method route: list(Route) List of Routes Return ------- A list of routes without duplicate routes with the same stack_path, fu...
Remove duplicate routes that have the same function_name and method route: list(Route) List of Routes Return ------- A list of routes without duplicate routes with the same stack_path, function_name and method
dedupe_function_routes
python
aws/aws-sam-cli
samcli/lib/providers/api_collector.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/providers/api_collector.py
Apache-2.0
def add_binary_media_types(self, logical_id: str, binary_media_types: Optional[List[str]]) -> None: """ Stores the binary media type configuration for the API with given logical ID Parameters ---------- logical_id : str LogicalId of the AWS::Serverless::Api resource ...
Stores the binary media type configuration for the API with given logical ID Parameters ---------- logical_id : str LogicalId of the AWS::Serverless::Api resource binary_media_types : list of str List of binary media types supported by this resource ...
add_binary_media_types
python
aws/aws-sam-cli
samcli/lib/providers/api_collector.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/providers/api_collector.py
Apache-2.0
def normalize_binary_media_type(value: Union[str, Dict]) -> Optional[str]: """ Converts binary media types values to the canonical format. Ex: image~1gif -> image/gif. If the value is not a string, then this method just returns None Parameters ---------- value ...
Converts binary media types values to the canonical format. Ex: image~1gif -> image/gif. If the value is not a string, then this method just returns None Parameters ---------- value Value to be normalized. Expect to be a string. However, it is possible th...
normalize_binary_media_type
python
aws/aws-sam-cli
samcli/lib/providers/api_collector.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/providers/api_collector.py
Apache-2.0
def __init__(self, stacks: List[Stack], cwd: Optional[str] = None, disable_authorizer: Optional[bool] = False): """ Initialize the class with template data. The template_dict is assumed to be valid, normalized and a dictionary. template_dict should be normalized by running any and all pr...
Initialize the class with template data. The template_dict is assumed to be valid, normalized and a dictionary. template_dict should be normalized by running any and all pre-processing before passing to this class. This class does not perform any syntactic validation of the template. ...
__init__
python
aws/aws-sam-cli
samcli/lib/providers/api_provider.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/providers/api_provider.py
Apache-2.0
def _extract_api(self) -> Api: """ Extracts all the routes by running through the one providers. The provider that has the first type matched will be run across all the resources Parameters ---------- Returns --------- An Api from the parsed template ...
Extracts all the routes by running through the one providers. The provider that has the first type matched will be run across all the resources Parameters ---------- Returns --------- An Api from the parsed template
_extract_api
python
aws/aws-sam-cli
samcli/lib/providers/api_provider.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/providers/api_provider.py
Apache-2.0
def find_api_provider(stacks: List[Stack]) -> CfnBaseApiProvider: """ Finds the ApiProvider given the first api type of the resource Parameters ----------- stacks: List[Stack] List of stacks apis are extracted from Return ---------- Instance ...
Finds the ApiProvider given the first api type of the resource Parameters ----------- stacks: List[Stack] List of stacks apis are extracted from Return ---------- Instance of the ApiProvider that will be run on the template with a default of SamApiP...
find_api_provider
python
aws/aws-sam-cli
samcli/lib/providers/api_provider.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/providers/api_provider.py
Apache-2.0
def extract_resources( self, stacks: List[Stack], collector: ApiCollector, cwd: Optional[str] = None, disable_authorizer: Optional[bool] = False, ) -> None: """ Extract the Route Object from a given resource and adds it to the RouteCollector. Paramete...
Extract the Route Object from a given resource and adds it to the RouteCollector. Parameters ---------- stacks: List[Stack] List of stacks apis are extracted from collector: samcli.lib.providers.api_collector.ApiCollector Instance of the API collector t...
extract_resources
python
aws/aws-sam-cli
samcli/lib/providers/cfn_api_provider.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/providers/cfn_api_provider.py
Apache-2.0
def _extract_cloud_formation_authorizer(logical_id: str, resource: dict, collector: ApiCollector) -> None: """ Extract Authorizers from AWS::ApiGateway::Authorizer and add them to the collector. Parameters ---------- logical_id: str The logical ID of the Authorizer ...
Extract Authorizers from AWS::ApiGateway::Authorizer and add them to the collector. Parameters ---------- logical_id: str The logical ID of the Authorizer resource: dict The attributes for the Authorizer collector: ApiCollector ApiCol...
_extract_cloud_formation_authorizer
python
aws/aws-sam-cli
samcli/lib/providers/cfn_api_provider.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/providers/cfn_api_provider.py
Apache-2.0
def _extract_cfn_gateway_v2_authorizer(logical_id: str, resource: dict, collector: ApiCollector) -> None: """ Extract Authorizers from AWS::ApiGatewayV2::Authorizer and add them to the collector. Parameters ---------- logical_id: str The logical ID of the Authorizer ...
Extract Authorizers from AWS::ApiGatewayV2::Authorizer and add them to the collector. Parameters ---------- logical_id: str The logical ID of the Authorizer resource: dict The attributes for the Authorizer collector: ApiCollector ApiC...
_extract_cfn_gateway_v2_authorizer
python
aws/aws-sam-cli
samcli/lib/providers/cfn_api_provider.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/providers/cfn_api_provider.py
Apache-2.0
def _extract_cloud_formation_route( stack_path: str, logical_id: str, api_resource: Dict[str, Any], collector: ApiCollector, cwd: Optional[str] = None, ) -> None: """ Extract APIs from AWS::ApiGateway::RestApi resource by reading and parsing Swagger documents....
Extract APIs from AWS::ApiGateway::RestApi resource by reading and parsing Swagger documents. The result is added to the collector. Parameters ---------- stack_path : str Path of the stack the resource is located logical_id : str Logical ID of t...
_extract_cloud_formation_route
python
aws/aws-sam-cli
samcli/lib/providers/cfn_api_provider.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/providers/cfn_api_provider.py
Apache-2.0
def _extract_cloud_formation_stage( resources: Dict[str, Dict], stage_resource: Dict, collector: ApiCollector ) -> None: """ Extract the stage from AWS::ApiGateway::Stage resource by reading and adds it to the collector. Parameters ---------- resources: dict ...
Extract the stage from AWS::ApiGateway::Stage resource by reading and adds it to the collector. Parameters ---------- resources: dict All Resource definition, including its properties stage_resource : dict Stage Resource definition, including its p...
_extract_cloud_formation_stage
python
aws/aws-sam-cli
samcli/lib/providers/cfn_api_provider.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/providers/cfn_api_provider.py
Apache-2.0
def _extract_cloud_formation_method( self, stack_path: str, resources: Dict[str, Dict], logical_id: str, method_resource: Dict, collector: ApiCollector, disable_authorizer: Optional[bool] = False, ) -> None: """ Extract APIs from AWS::ApiGatewa...
Extract APIs from AWS::ApiGateway::Method and work backwards up the tree to resolve and find the true path. Parameters ---------- stack_path : str Path of the stack the resource is located resources: dict All Resource definition, including its propertie...
_extract_cloud_formation_method
python
aws/aws-sam-cli
samcli/lib/providers/cfn_api_provider.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/providers/cfn_api_provider.py
Apache-2.0
def _extract_cfn_gateway_v2_api( self, stack_path: str, logical_id: str, api_resource: Dict, collector: ApiCollector, cwd: Optional[str] = None, disable_authorizer: Optional[bool] = False, ) -> None: """ Extract APIs from AWS::ApiGatewayV2::Api...
Extract APIs from AWS::ApiGatewayV2::Api resource by reading and parsing Swagger documents. The result is added to the collector. If the Swagger documents is not available, it can add a catch-all route based on the target function. Parameters ---------- stack_path : str...
_extract_cfn_gateway_v2_api
python
aws/aws-sam-cli
samcli/lib/providers/cfn_api_provider.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/providers/cfn_api_provider.py
Apache-2.0
def _extract_cfn_gateway_v2_route( self, stack_path: str, resources: Dict[str, Dict], logical_id: str, route_resource: Dict, collector: ApiCollector, disable_authorizer: Optional[bool] = False, ) -> None: """ Extract APIs from AWS::ApiGatewayV2...
Extract APIs from AWS::ApiGatewayV2::Route, and link it with the integration resource to get the lambda function. Parameters ---------- stack_path : str Path of the stack the resource is located resources: dict All Resource definition, including...
_extract_cfn_gateway_v2_route
python
aws/aws-sam-cli
samcli/lib/providers/cfn_api_provider.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/providers/cfn_api_provider.py
Apache-2.0
def resolve_resource_path( self, resources: Dict[str, Dict], resource: Dict, current_path: str, ) -> str: """ Extract path from the Resource object by going up the tree Parameters ---------- resources: dict Dictionary containing al...
Extract path from the Resource object by going up the tree Parameters ---------- resources: dict Dictionary containing all the resources to resolve resource : dict AWS::ApiGateway::Resource definition and its properties current_path : str ...
resolve_resource_path
python
aws/aws-sam-cli
samcli/lib/providers/cfn_api_provider.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/providers/cfn_api_provider.py
Apache-2.0
def _extract_cfn_gateway_v2_stage( resources: Dict[str, Dict], stage_resource: Dict, collector: ApiCollector, ) -> None: """ Extract the stage from AWS::ApiGatewayV2::Stage resource by reading and adds it to the collector. Parameters ---------- reso...
Extract the stage from AWS::ApiGatewayV2::Stage resource by reading and adds it to the collector. Parameters ---------- resources: dict All Resource definition, including its properties stage_resource : dict Stage Resource definition, including its...
_extract_cfn_gateway_v2_stage
python
aws/aws-sam-cli
samcli/lib/providers/cfn_api_provider.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/providers/cfn_api_provider.py
Apache-2.0
def _get_integration_function_name(integration: Dict) -> Optional[str]: """ Tries to parse the Lambda Function name from the Integration defined in the method configuration. Integration configuration. We care only about Lambda integrations, which are of type aws_proxy, and ignore the rest. ...
Tries to parse the Lambda Function name from the Integration defined in the method configuration. Integration configuration. We care only about Lambda integrations, which are of type aws_proxy, and ignore the rest. Integration URI is complex and hard to parse. Hence we do our best to extract fu...
_get_integration_function_name
python
aws/aws-sam-cli
samcli/lib/providers/cfn_api_provider.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/providers/cfn_api_provider.py
Apache-2.0
def _get_route_function_name( resources: Dict[str, Dict], integration_target: str ) -> Tuple[Optional[str], Optional[str]]: """ Look for the APIGateway integration resource based on the input integration_target, then try to parse the lambda function from the the integration resource ...
Look for the APIGateway integration resource based on the input integration_target, then try to parse the lambda function from the the integration resource properties. It also gets the Payload format version from the API Gateway integration resource. Parameters ---------- ...
_get_route_function_name
python
aws/aws-sam-cli
samcli/lib/providers/cfn_api_provider.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/providers/cfn_api_provider.py
Apache-2.0
def _parse_route_key(route_key: Optional[str]) -> Tuple[str, str]: """ parse the route key, and return the methods && path. route key should be in format "Http_method Path" or to equal "$default" if the route key is $default, return 'X-AMAZON-APIGATEWAY-ANY-METHOD' as a method && $defaul...
parse the route key, and return the methods && path. route key should be in format "Http_method Path" or to equal "$default" if the route key is $default, return 'X-AMAZON-APIGATEWAY-ANY-METHOD' as a method && $default as a path else we will split the route key on space and use the spec...
_parse_route_key
python
aws/aws-sam-cli
samcli/lib/providers/cfn_api_provider.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/providers/cfn_api_provider.py
Apache-2.0
def extract_resources( self, stacks: List[Stack], collector: ApiCollector, cwd: Optional[str] = None, disable_authorizer: Optional[bool] = False, ) -> None: """ Extract the Route Object from a given resource and adds it to the RouteCollector. Paramete...
Extract the Route Object from a given resource and adds it to the RouteCollector. Parameters ---------- stacks: List[Stack] List of stacks apis are extracted from collector: samcli.lib.providers.api_collector.ApiCollector Instance of the API collector th...
extract_resources
python
aws/aws-sam-cli
samcli/lib/providers/cfn_base_api_provider.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/providers/cfn_base_api_provider.py
Apache-2.0
def extract_swagger_route( stack_path: str, logical_id: str, body: Dict, uri: Union[str, Dict], binary_media: Optional[List], collector: ApiCollector, cwd: Optional[str] = None, event_type: str = Route.API, disable_authorizer: Optional[bool] = Fals...
Parse the Swagger documents and adds it to the ApiCollector. Parameters ---------- stack_path : str Path of the stack the resource is located logical_id : str Logical ID of the resource body : dict The body of the RestApi uri ...
extract_swagger_route
python
aws/aws-sam-cli
samcli/lib/providers/cfn_base_api_provider.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/providers/cfn_base_api_provider.py
Apache-2.0
def extract_cors(self, cors_prop: Union[Dict, str]) -> Optional[Cors]: """ Extract Cors property from AWS::Serverless::Api resource by reading and parsing Swagger documents. The result is added to the Api. Parameters ---------- cors_prop : dict Resource prope...
Extract Cors property from AWS::Serverless::Api resource by reading and parsing Swagger documents. The result is added to the Api. Parameters ---------- cors_prop : dict Resource properties for Cors
extract_cors
python
aws/aws-sam-cli
samcli/lib/providers/cfn_base_api_provider.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/providers/cfn_base_api_provider.py
Apache-2.0