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 _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 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 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 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 |
def extract_cors_from_method(self, cors_dict: Dict) -> Optional[Cors]:
"""
Extract the cors parameters from an AWS::ApiGateway::Method.
Parameters
----------
cors_dict : dict
A dict of cors parameters in the format of ResponseParameters
Return
------
... |
Extract the cors parameters from an AWS::ApiGateway::Method.
Parameters
----------
cors_dict : dict
A dict of cors parameters in the format of ResponseParameters
Return
------
A Cors object with the relevant cors headers from the ResponseParameters
... | extract_cors_from_method | 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 _get_cors_prop(cors_dict: Dict, prop_name: str, allow_bool: bool = False) -> Optional[str]:
"""
Extract cors properties from dictionary and remove extra quotes.
Parameters
----------
cors_dict : dict
Resource properties for Cors
prop_name : str
... |
Extract cors properties from dictionary and remove extra quotes.
Parameters
----------
cors_dict : dict
Resource properties for Cors
prop_name : str
Cors property to get the value for
allow_bool : bool
If a boolean value is allowed ... | _get_cors_prop | 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_http(
self,
cors_prop: Union[bool, Dict],
) -> Optional[Cors]:
"""
Extract Cors property from AWS::Serverless::HttpApi resource by reading and parsing Swagger documents.
The result is added to the HttpApi.
Parameters
----------
cors_p... |
Extract Cors property from AWS::Serverless::HttpApi resource by reading and parsing Swagger documents.
The result is added to the HttpApi.
Parameters
----------
cors_prop : dict
Resource properties for CorsConfiguration
| extract_cors_http | 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 _get_cors_prop_http(
cors_dict: Dict,
prop_name: str,
expect_type: Type,
) -> Optional[Any]:
"""
Extract cors properties from dictionary.
Parameters
----------
cors_dict : dict
Resource properties for Cors
prop_name : str
... |
Extract cors properties from dictionary.
Parameters
----------
cors_dict : dict
Resource properties for Cors
prop_name : str
Property name
expect_type : type
Expect property type
Return
------
Value with match... | _get_cors_prop_http | 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 normalize_cors_allow_methods(allow_methods: Union[str, List[str]]) -> str:
"""
Normalize cors AllowMethods and Options to the methods if it's missing.
Parameters
----------
allow_methods : str
The allow_methods string provided in the query
Return
... |
Normalize cors AllowMethods and Options to the methods if it's missing.
Parameters
----------
allow_methods : str
The allow_methods string provided in the query
Return
-------
A string with normalized route
| normalize_cors_allow_methods | 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 __init__(self, template: str, stack_name: str) -> None:
"""Exception when template validation fails
Parameters
----------
template : str
Template location that failed to validate
stack_name : str
Stack name of the template
"""
self._te... | Exception when template validation fails
Parameters
----------
template : str
Template location that failed to validate
stack_name : str
Stack name of the template
| __init__ | python | aws/aws-sam-cli | samcli/lib/providers/exceptions.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/providers/exceptions.py | Apache-2.0 |
def __init__(self, resource_identifier: "ResourceIdentifier", property_name: str) -> None:
"""Exception when a resource does not have local path in it's property
Parameters
----------
resource_identifier : ResourceIdentifier
Resource Identifer
property_name : str
... | Exception when a resource does not have local path in it's property
Parameters
----------
resource_identifier : ResourceIdentifier
Resource Identifer
property_name : str
Property name that's missing
| __init__ | python | aws/aws-sam-cli | samcli/lib/providers/exceptions.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/providers/exceptions.py | Apache-2.0 |
def architecture(self) -> str:
"""
Returns the architecture to use to build and invoke the function
Returns
-------
str
Architecture
Raises
------
InvalidFunctionPropertyType
If the architectures value is invalid
"""
... |
Returns the architecture to use to build and invoke the function
Returns
-------
str
Architecture
Raises
------
InvalidFunctionPropertyType
If the architectures value is invalid
| architecture | python | aws/aws-sam-cli | samcli/lib/providers/provider.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/providers/provider.py | Apache-2.0 |
def __init__(
self,
arn: str,
codeuri: Optional[str],
compatible_runtimes: Optional[List[str]] = None,
metadata: Optional[Dict] = None,
compatible_architectures: Optional[List[str]] = None,
stack_path: str = "",
) -> None:
"""
Parameters
... |
Parameters
----------
stack_path str
The path of the stack relative to the root stack, it is empty for layers in root stack
name str
Name of the layer, this can be the ARN or Logical Id in the template
codeuri str
CodeURI of the layer. This sh... | __init__ | python | aws/aws-sam-cli | samcli/lib/providers/provider.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/providers/provider.py | Apache-2.0 |
def _compute_layer_version(is_defined_within_template: bool, arn: str) -> Optional[int]:
"""
Parses out the Layer version from the arn
Parameters
----------
is_defined_within_template bool
True if the resource is a Ref to a resource otherwise False
arn str
... |
Parses out the Layer version from the arn
Parameters
----------
is_defined_within_template bool
True if the resource is a Ref to a resource otherwise False
arn str
ARN of the Resource
Returns
-------
int
The Version o... | _compute_layer_version | python | aws/aws-sam-cli | samcli/lib/providers/provider.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/providers/provider.py | Apache-2.0 |
def _compute_layer_name(is_defined_within_template: bool, arn: str) -> str:
"""
Computes a unique name based on the LayerVersion Arn
Format:
<Name of the LayerVersion>-<Version of the LayerVersion>-<sha256 of the arn>
Parameters
----------
is_defined_within_temp... |
Computes a unique name based on the LayerVersion Arn
Format:
<Name of the LayerVersion>-<Version of the LayerVersion>-<sha256 of the arn>
Parameters
----------
is_defined_within_template bool
True if the resource is a Ref to a resource otherwise False
... | _compute_layer_name | python | aws/aws-sam-cli | samcli/lib/providers/provider.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/providers/provider.py | Apache-2.0 |
def name(self) -> str:
"""
A unique name from the arn or logical id of the Layer
A LayerVersion Arn example:
arn:aws:lambda:region:account-id:layer:layer-name:version
Returns
-------
str
A name of the Layer that is used on the system to uniquely iden... |
A unique name from the arn or logical id of the Layer
A LayerVersion Arn example:
arn:aws:lambda:region:account-id:layer:layer-name:version
Returns
-------
str
A name of the Layer that is used on the system to uniquely identify the layer
| name | python | aws/aws-sam-cli | samcli/lib/providers/provider.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/providers/provider.py | Apache-2.0 |
def cors_to_headers(
cors: Optional["Cors"], request_origin: Optional[str], event_type: str
) -> Dict[str, Union[int, str]]:
"""
Convert CORS object to headers dictionary
Parameters
----------
cors list(samcli.commands.local.lib.provider.Cors)
CORS configu... |
Convert CORS object to headers dictionary
Parameters
----------
cors list(samcli.commands.local.lib.provider.Cors)
CORS configuration objcet
request_origin str
Origin of the request, e.g. https://example.com:8080
event_type str
The typ... | cors_to_headers | python | aws/aws-sam-cli | samcli/lib/providers/provider.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/providers/provider.py | Apache-2.0 |
def resources(self) -> Dict:
"""
Return the resources dictionary where SAM plugins have been run
and parameter values have been substituted.
"""
if self._resources is not None:
return self._resources
processed_template_dict: Dict[str, Dict] = SamBaseProvider.g... |
Return the resources dictionary where SAM plugins have been run
and parameter values have been substituted.
| resources | python | aws/aws-sam-cli | samcli/lib/providers/provider.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/providers/provider.py | Apache-2.0 |
def raw_resources(self) -> Dict:
"""
Return the resources dictionary without running SAM Transform
"""
if self._raw_resources is not None:
return self._raw_resources
self._raw_resources = cast(Dict, self.template_dict.get("Resources", {}))
return self._raw_res... |
Return the resources dictionary without running SAM Transform
| raw_resources | python | aws/aws-sam-cli | samcli/lib/providers/provider.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/providers/provider.py | Apache-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.