MCPcopy Create free account
hub / github.com/s3tools/s3cmd / create

Method create

S3/CloudFront.py:722–753  ·  view source on GitHub ↗
(args)

Source from the content-addressed store, hash-verified

720
721 @staticmethod
722 def create(args):
723 cf = CloudFront(Config())
724 buckets = []
725 for arg in args:
726 uri = S3Uri(arg)
727 if uri.type != "s3":
728 raise ParameterError("Distribution can only be created from a s3:// URI instead of: %s" % arg)
729 if uri.object():
730 raise ParameterError("Use s3:// URI with a bucket name only instead of: %s" % arg)
731 if not uri.is_dns_compatible():
732 raise ParameterError("CloudFront can only handle lowercase-named buckets.")
733 buckets.append(uri)
734 if not buckets:
735 raise ParameterError("No valid bucket names found")
736 for uri in buckets:
737 info("Creating distribution from: %s" % uri)
738 response = cf.CreateDistribution(uri, cnames_add = Cmd.options.cf_cnames_add,
739 comment = Cmd.options.cf_comment,
740 logging = Cmd.options.cf_logging,
741 default_root_object = Cmd.options.cf_default_root_object)
742 d = response['distribution']
743 dc = d.info['DistributionConfig']
744 output("Distribution created:")
745 pretty_output("Origin", S3UriS3.httpurl_to_s3uri(dc.info['S3Origin']['DNSName']))
746 pretty_output("DistId", d.uri())
747 pretty_output("DomainName", d.info['DomainName'])
748 pretty_output("CNAMEs", ", ".join(dc.info['CNAME']))
749 pretty_output("Comment", dc.info['Comment'])
750 pretty_output("Status", d.info['Status'])
751 pretty_output("Enabled", dc.info['Enabled'])
752 pretty_output("DefaultRootObject", dc.info['DefaultRootObject'])
753 pretty_output("Etag", response['headers']['etag'])
754
755 @staticmethod
756 def delete(args):

Callers

nothing calls this directly

Calls 11

CreateDistributionMethod · 0.95
ConfigClass · 0.90
S3UriClass · 0.90
CloudFrontClass · 0.85
ParameterErrorClass · 0.85
outputFunction · 0.85
pretty_outputFunction · 0.85
objectMethod · 0.80
is_dns_compatibleMethod · 0.80
httpurl_to_s3uriMethod · 0.80
uriMethod · 0.45

Tested by

no test coverage detected