content stringlengths 7 1.05M |
|---|
"""
Exceptions.
"""
class AlreadyAllocated(Exception):
pass
class NotAllocated(Exception):
pass
class BufferAlreadyAllocated(AlreadyAllocated):
pass
class BufferNotAllocated(NotAllocated):
pass
class BusAlreadyAllocated(AlreadyAllocated):
pass
class BusNotAllocated(NotAllocated):
pass
class IncompatibleRate(Exception):
pass
class NodeAlreadyAllocated(AlreadyAllocated):
pass
class NodeNotAllocated(NotAllocated):
pass
class NonrealtimeOutputMissing(Exception):
pass
class NonrealtimeRenderError(Exception):
pass
class RequestTimeout(Exception):
pass
class ServerCannotBoot(Exception):
pass
class ServerOnline(Exception):
pass
class ServerOffline(Exception):
pass
class OwnedServerShutdown(Exception):
pass
class UnownedServerShutdown(Exception):
pass
class TooManyClients(Exception):
pass
|
# The series, 1^1 + 2^2 + 3^3 + ... + 10^10 = 10405071317.
# Find the last ten digits of the series, 1^1 + 2^2 + 3^3 + ... + 1000^1000.
sumSeries = 0
for x in range(1, 1001):
sumSeries += pow(x, x)
print(str(sumSeries)[-10:])
|
class Queue():
def __init__(self):
self.queue = []
def enqueue(self, value):
self.queue.append(value)
def dequeue(self):
if self.size() > 0:
return self.queue.pop(0)
else:
return None
def size(self):
return len(self.queue)
|
#Task 2.1
my_list=[]
i=11
k=1
for i in range(1,i):
my_list.append(k)
k+=3
print("Task 2.1 ",my_list)
#Task 2.2
my_listnew = my_list
my_listnew.extend([1, 5, 13, 20])
print ("Task 2.2 ",my_listnew)
#Task2.3
my_set = set(my_list)
print("Task 2.3 ",my_set)
#Task 2.4
def compare_elements(a:list, b:set):
if len(a) > len(b):
return "List is bigger"
else:
return "Set is bigger"
print("Task 2.4 ",compare_elements(my_listnew, my_set))
#Task 3
def get_value_from_list(data:list, index:int):
try:
return data[index]
except:
return "None"
print("Task 3 ",get_value_from_list([1,2,3], 1))
print("Task 3 ",get_value_from_list([1,2,3], 16))
#Task 4
dict = {"Name": "", "Age": "", "Hobby": ""}
def create_dict(name:str, age:int, hobby:str):
dict["Name"] = name
dict["Age"] = age
dict["Hobby"] = hobby
return dict
print("Task 4",create_dict("Denis", 26, "Books"))
#Task 5
def calculate_fibo(n:int):
fibo = [0]
a, b = 0, 1
for i in range(1,n,1):
fibo.append(b)
a, b = b, a + b
return fibo
print(calculate_fibo(10))
|
# Apresentação
print('Programa para converter temperatura')
print()
# Entradas
celsius = float(input('Informe a temperatura em ºC: '))
# Processamento
fahrenheit = (9 * celsius + 160) / 5
# Saídas
print('A temperatura em ºF é:', fahrenheit)
|
# Кортежи. Повторение *
# Кортеж, который содержит простые числа
A = (1, 2, 3) * 3 # A = (1, 2, 3, 1, 2, 3, 1, 2, 3)
# Кортеж, который содержит вложенные объекты
B = ("ab", ["1", "12"])*2 # A=('ab', ['1','12'], 'ab', ['1','12']) |
class BinaryMaxHeap:
def __init__(self):
self.elements = []
def __str__(self):
return self.elements
def __repr__(self):
return self.elements
def max_heapify(self, unordered_list, i):
left = (2 * i) + 1
right = (2 * i) + 2
# If the element has no left child, then it won't have a right child either,
# because in heaps we insert elements from left to right.
if left >= len(unordered_list):
return unordered_list
# If the element has no right child, check if the max heap property is satisfied with the left child.
if right >= len(unordered_list):
if unordered_list[i] < unordered_list[left]:
unordered_list[i], unordered_list[left] = (
unordered_list[left],
unordered_list[i],
)
return unordered_list
# Check if the max heap property is satisfied if the element has both left and right children.
# If not, replace the root element with the child with the greater priority.
if (
unordered_list[i] < unordered_list[left]
or unordered_list[i] < unordered_list[right]
):
if unordered_list[left] < unordered_list[right]:
unordered_list[i], unordered_list[right] = (
unordered_list[right],
unordered_list[i],
)
# repeat the process of max heapify on the child with whom the element was exchanged.
return self.max_heapify(unordered_list, right)
else:
unordered_list[i], unordered_list[left] = (
unordered_list[left],
unordered_list[i],
)
return self.max_heapify(unordered_list, left)
return unordered_list
def build_max_heap(self, unordered_list):
# To build a max heap from an unordered list,
# start performing the max_heapify routine on elements with index n/2 -> 0,
# as elements with an index greater than n/2 will be leaf nodes.
for i in reversed(range((len(unordered_list) // 2))):
self.max_heapify(unordered_list, i)
self.elements = unordered_list
return unordered_list
def get_max_element(self):
return self.elements[0]
def remove_max_element(self):
# exchange the max element with the last element.
self.elements[0], self.elements[-1] = self.elements[-1], self.elements[0]
element = self.elements.pop(-1)
# perform max heapify on the 0th index to maintain the max heap property.
self.max_heapify(self.elements, 0)
return element
def insert_element(self, element):
# insert the element at the last.
self.elements.append(element)
element_index = len(self.elements) - 1
# keep exchanging the inserted element with its parent if its value is greater.
while element_index > 0:
parent_index = (element_index - 1) // 2
if self.elements[element_index] > self.elements[parent_index]:
self.elements[element_index], self.elements[parent_index] = (
self.elements[parent_index],
self.elements[element_index],
)
element_index = parent_index
else:
break
def main():
h = BinaryMaxHeap()
unordered_list = [16, 4, 10, 14, 7, 9, 3, 2, 8, 1]
print(h.build_max_heap(unordered_list))
print(h.get_max_element())
print(h.remove_max_element())
h.insert_element(40)
print(h.elements)
if __name__ == "__main__":
main()
|
expected_output = {
'vrf':
{'default':
{'address_family':
{'ipv4':
{'default_rpf_table': 'IPv4-Unicast-default',
'isis_mcast_topology': False,
'mo_frr_flow_based': False,
'mo_frr_rib': False,
'multipath': True,
'pim_rpfs_registered': 'Unicast RIB table',
'rib_convergence_time_left': '00:00:00',
'rib_convergence_timeout': '00:30:00',
'rump_mu_rib': False,
'table':
{'IPv4-Unicast-default':
{'pim_rpf_registrations': 1,
'rib_table_converged': True}}}}}}}
|
class AllBrowsersBusy(RuntimeError):
pass
class BrowserStackTunnelClosed(RuntimeError):
pass
class TooManyElements(RuntimeError):
pass
class UnknownSelector(RuntimeError):
pass
class UnsupportedBrowser(RuntimeError):
pass
|
"""Houston client exceptions"""
class HoustonException(Exception):
"""Base Houston client exception"""
pass
class HoustonServerBusy(HoustonException):
"""Raised due to too many requests to process"""
pass
class HoustonClientError(HoustonException):
"""Error raised when the client has made an invalid request"""
pass
class HoustonServerError(HoustonException):
"""Error raised when Houston server has issues"""
pass
|
# robin-0 ( Nabil Ibtehaz)
'''
This code implements the Bellman-Ford Algorithm
to solve the single source shortest path problem.
'''
class Edge:
'''
This is the class to model graph edges
it has 3 attributes startingNode ,
endingNode and weight
'''
# constructor
def __init__(self,startingNode,endingNode,weight):
self.startingNode=startingNode
self.endingNode=endingNode
self.weight=weight
def BellmanFord(source):
'''
This function implements the Bellman Ford algorithm
to find the single source shortest path problem
It takes the source vertex as input and returns a
list containing the lengths of shortest paths to
other vertices
'''
shortestPaths = [ None ] * nVertices
shortestPaths[source]=0 # path from source to source is 0 :p
for i in range(nVertices-1):
for j in edgeList:
if( shortestPaths [ j.startingNode ] !=None ):
if(shortestPaths [j.endingNode] ==None):
shortestPaths [j.endingNode] = shortestPaths [ j.startingNode ] + j.weight
else :
# Relaxation
shortestPaths [j.endingNode] = min( shortestPaths [j.endingNode] , shortestPaths [ j.startingNode ] + j.weight )
# check for negative cycle
for j in edgeList:
if( shortestPaths [ j.startingNode ] !=None and shortestPaths [ j.endingNode ] !=None ):
if ( shortestPaths [j.endingNode] > ( shortestPaths [ j.startingNode ] + j.weight ) ):
print("Not Possible Negative Cycle Exists")
return None
return shortestPaths
if __name__ == "__main__":
'''
This is the main function.
A simple UI is provided
'''
print('Vertices are 0-indexed')
nVertices = int(input('Number of Vertices: '))
edgeList = []
nEdges = int(input('Number of Edges: '))
for i in range(nEdges):
print('Enter Edge ' +str(i+1) )
startingNode = int(input('Starting Node: '))
endingNode = int(input('Ending Node: '))
weight = int(input('Weight: '))
edgeList.append(Edge(startingNode,endingNode,weight))
print("****************************************\n")
print("Please select one of the following\n")
choice = int(input('1. Find Shortest Path From Sources\n2. End\n'))
while(choice==1):
sourceNode=int(input('Source Node(0-indexed) : '))
print(BellmanFord(sourceNode))
print("****************************************\n")
print("Please select one of the following\n")
choice = int(input('1. Find Shortest Path From Sources\n2. End\n'))
|
heif_chroma_undefined = 99
heif_chroma_monochrome = 0
heif_chroma_420 = 1
heif_chroma_422 = 2
heif_chroma_444 = 3
heif_chroma_interleaved_RGB = 10
heif_chroma_interleaved_RGBA = 11
heif_chroma_interleaved_RRGGBB_BE = 12
heif_chroma_interleaved_RRGGBBAA_BE = 13
heif_colorspace_undefined = 99
heif_colorspace_YCbCr = 0
heif_colorspace_RGB = 1
heif_colorspace_monochrome = 2
heif_channel_Y = 0
heif_channel_Cb = 1
heif_channel_Cr = 2
heif_channel_R = 3
heif_channel_G = 4
heif_channel_B = 5
heif_channel_Alpha = 6
heif_channel_interleaved = 10
def encode_fourcc(fourcc):
encoded = (
ord(fourcc[0]) << 24
| ord(fourcc[1]) << 16
| ord(fourcc[2]) << 8
| ord(fourcc[3])
)
return encoded
heif_color_profile_type_not_present = 0
heif_color_profile_type_nclx = encode_fourcc("nclx")
heif_color_profile_type_rICC = encode_fourcc("rICCC")
heif_color_profile_type_prof = encode_fourcc("prof")
heif_filetype_no = 0
heif_filetype_yes_supported = 1
heif_filetype_yes_unsupported = 2
heif_filetype_maybe = 3
|
'''
Problem Statement: Given two sorted arrays, A and B,
determine their intersection. What elements are common to A and B?
'''
A = [2, 3, 3, 5, 7, 11]
B = [3, 3, 7, 15, 31]
# One line solution
#print(set(A).intersection(B))
def intersection_arrays(A, B):
i = 0
j = 0
intersection = list()
while i < len(A) and j < len(B):
if A[i] == B[j]:
if i == 0 or A[i] != A[i-1]:
intersection.append(A[i])
i += 1
j += 1
elif A[i] < B[j]:
i += 1
else:
j += 1
return intersection
print(intersection_arrays(A, B)) |
## Duplicate Encoder
## 6 kyu
## https://www.codewars.com/kata/54b42f9314d9229fd6000d9c
def duplicate_encode(word):
new = ''
for character in word:
if word.lower().count(character.lower()) == 1:
new += ("(")
else:
new += (')')
return new |
print("Welcome to the tip calculator.")
total = float(input("What was the total bill? $"))
percent = int(input("What percentage tip would you like to give? 10%, 12%, or 15%? "))
people = int(input("How many people to split the bill? "))
total += ((percent * total) / 100)
per_person = round(total / people, 2)
print(f"Each person should pay: ${per_person}") |
class Solution:
def networkDelayTime(self, times: List[List[int]], N: int, K: int) -> int:
"""
The original Dijkstra algorithm is to find the shorting distances
between a starting node and each of the rest nodes.
This problem can be considered as a variant of Dijkstra problem.
"""
graph = defaultdict(list)
for entry in times:
source, target, weight = entry
graph[source].append((weight, target))
queue = graph[K]
heapq.heapify(queue)
clocks = 0
visited = [False for i in range(N+1)]
visited[K] = True
visit_cnt = 1
while queue:
timestamp, target = heapq.heappop(queue)
clocks = timestamp
if not visited[target]:
visit_cnt += 1
if visit_cnt == N:
break
visited[target] = True
for next_weight, next_target in graph[target]:
heapq.heappush(queue, (clocks+next_weight, next_target))
return clocks if visit_cnt == N else -1
class SolutionDijkstra:
def networkDelayTime(self, times: List[List[int]], N: int, K: int) -> int:
"""
Dijkstra with heap
"""
graph = defaultdict(list)
for entry in times:
source, target, weight = entry
graph[source].append((weight, target))
queue = graph[K]
heapq.heapify(queue)
min_elapse = {K:0}
while queue:
# one of the cases is that there might be several edges between two nodes.
# the most optimal one would be picked,
# therefore we should ignore the rest of the edges.
clocks, target = heapq.heappop(queue)
if target in min_elapse:
continue
min_elapse[target] = clocks
for next_weight, next_target in graph[target]:
if next_target not in min_elapse:
heapq.heappush(queue, (clocks + next_weight, next_target))
return max(min_elapse.values()) if len(min_elapse) == N else -1
|
class Manager:
place = ""
number = 0
def __init__(self, place, number):
self.place = place
self.number = number
def toString(self):
print("Place: " + self.place + ". Number: " + self.number + ".")
print(" ") |
class Solution:
@staticmethod
def naive(m,n):
dp = [[0 for i in range(n+1)] for j in range(m+1)]
dp[m-1][n-1]=1
for i in range(m-1,-1,-1):
for j in range(n-1,-1,-1):
dp[i][j] = max(dp[i][j],dp[i+1][j]+dp[i][j+1])
return dp[0][0] |
"""
bmh_search.py
This module implements bmh search to find a substring in a string
BMH Search Overview:
--------------------
Uses a bad-character shift of the rightmost character of the window to
compute shifts.
The trick to this algorithm is `bmbc`, a lookup table with a default
value equal to the length of the pattern to be searched, so that
the algorithm can skip `len(pattern)` indices through the string
for efficiency's sake. For example, if we're searching through the
string "cotton milled paper" for the pattern "grumble", we look at
the last letter "r" (BMH goes backwards through a string) and notices
that it is not equal to "e". Thus, we can afford to jump our search
index back a whole seven characters.
However, not all the entries in `bmbc` are equal to `len(pattern)`.
If we searched the string "adventure time" for "grumble", we'd find
the "e" to match but mismatch the "m" and "l" in the string and
pattern, respectively. In this case, we can only jump back six
characters safely, which is why `bmbc` contains values that are not
simply `len(pattern)`.
Pre: a string > substring.
Post: returns a list of indices where the substring was found.
Time: Complexity: O(m + n), where m is the substring to be found.
Space: Complexity: O(m), where m is the substring to be found.
Psuedo Code: https://github.com/FooBarWidget/boyer-moore-horspool
(converted from C++)
bmh_search.search(string, substring) -> list[integers]
bmh_search.search(string, substring) -> list[empty]
"""
def search(text, pattern):
pattern_length = len(pattern)
text_length = len(text)
offsets = []
if pattern_length > text_length:
return offsets
bmbc = [pattern_length] * 256
for index, char in enumerate(pattern[:-1]):
bmbc[ord(char)] = pattern_length - index - 1
bmbc = tuple(bmbc)
search_index = pattern_length - 1
while search_index < text_length:
pattern_index = pattern_length - 1
text_index = search_index
while text_index >= 0 and \
text[text_index] == pattern[pattern_index]:
pattern_index -= 1
text_index -= 1
if pattern_index == -1:
offsets.append(text_index + 1)
search_index += bmbc[ord(text[search_index])]
return offsets |
# The sequence we want to analyze
seq = 'GACAGACUCCAUGCACGUGGGUAUCUGUC'
# Initialize GC counter
n_gc = 0
# Initialize sequence length
len_seq = 0
# Loop through sequence and count G's and C's
for base in seq:
len_seq += 1
if base in 'GCgc':
n_gc += 1
# Divide to get GC content
print(n_gc / len_seq)
# We'll do one through 5
my_integers = [1,2,3,4,5]
# Double each one
for n in my_integers:
n *= 2
# Check out the result
print(my_integers)
# Does not work quite right
# We have to use iterators
# Range function gives an iterable that enables counting.
for i in range(10):
print(i, end=' ')
# Range function gives an iterable that enables counting.
for i in range(2,10):
print(i, end=' ')
# Print a newline
print()
# Print even numbers, 2 through 9
for i in range(2,10,2):
print(i, end=' ')
# Type conversion from range to list
list = list(range(10))
print()
print(list)
print()
# Make the previous function working
my_integers = [1,2,3,4,5]
print(my_integers)
print()
for i in range(len(my_integers)):
my_integers[i] *= 2
print(my_integers)
print()
print(seq)
# Initialize GC counter
n_gc = 0
# Initialized sequence length
len_seq = 0
# Loop through sequence and print index of G's
for base in seq:
if base in 'Gg':
print(len_seq, end=' ')
len_seq += 1
print()
# We can use enumerate ()
# Loop through sequence and print index of G's
for i, base in enumerate(seq):
if base in 'Gg':
print(i, end=' ')
print()
for i, base in enumerate(seq):
print(i,base)
print()
for i in range(len(seq)):
print(i,seq[i])
print()
my_integers = [1,2,3,4,5]
# Double each one
for i, _ in enumerate(my_integers):
my_integers[i] *= 2
# Check out the result
my_integers
# The zip() function
names = ('Lloyd','Holiday','Heath')
positions = ('MF','MF','F')
numbers = (10,12,17)
for num, pos, name in zip(numbers,positions, names):
print(num,name,pos)
# reversed() function
count_up = ('ignition', 1,2,3,4,5,6,7,8,9,10)
for count in reversed(count_up):
print(count)
# 'while' Loop
# Define start codon
start_codon = 'AUG'
# Initialize sequence index
i = 0
# Scan sequence until we hit start codon
while seq[i:i+3] != start_codon:
i += 1
# Show the result
print('The start codon starts at index',i)
print()
# Define codon of interest
codon = 'GCC'
# Initialize sequence index
i = 0
# Scan sequence until we hit the start codon or end of the sequence
while seq[i:i+3] != codon and i < len(seq):
i += 1
# Show the result
if i == len(seq):
print('Codon not found in sequence.')
else:
print('The codon starts at index',i)
# Use 'for' loop with break instead of 'while'
start_codon = 'AUG'
# Scan sequence until we hit the start codon
for i in range(len(seq)):
if seq[i:i+3] == start_codon:
print('The start codon starts at index',i,'as expected')
break
else:
print('Codon not found in sequence.')
|
def search(l, x):
return searchInRange(l, x, 0, len(l)-1)
def searchInRange(l, x, min, max):
if min>max:
return False
else:
middle = min+(max-min)/2
if x > l[middle]:
# Search in right half
return searchInRange(l, x, middle+1, max)
elif x < l[middle]:
# Search in left half
return searchInRange(l, x, min, middle-1)
else:
# Found in the middle
return True
|
"""This file was adapted from Appium sample code found at
https://github.com/appium/appium/tree/master/sample-code
as of November 15, 2021.
For fixtures and imports, see ./conftest.py"""
class TestFirst():
def test_first(self, driver):
"""Simply checks test discovery and setup.
Should be successfully collected and pass."""
print("I am first test! I ran!")
assert True
|
#
# @lc app=leetcode id=1372 lang=python3
#
# [1372] Longest ZigZag Path in a Binary Tree
#
# @lc code=start
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution:
def longestZigZag(self, root: Optional[TreeNode]) -> int:
if not root:
return 0
nodes = [root]
cache = {}
max_len = 0
while nodes:
node = nodes.pop()
if node.left:
nodes.append(node.left)
if node.right:
nodes.append(node.right)
length = max(self._longestZigZag(node,True,cache),self._longestZigZag(node,False,cache))
if length>max_len:
max_len = length
return max_len
def _longestZigZag(self, root,is_left, cache):
if (root,is_left) in cache:
return cache[(root,is_left)]
if is_left:
result = self._longestZigZag(root.left,False,cache)+1 if root.left else 0
cache[(root,is_left)] = result
return result
else:
result = self._longestZigZag(root.right,True,cache)+1 if root.right else 0
cache[(root,is_left)] = result
return result
# @lc code=end
|
CONTACT_FIELDS = {
"preferred_call_time": "STRING",
"quiz_complete_date": "STRING",
"q6": "STRING",
"q5": "STRING",
"q4_other": "STRING",
"q4": "STRING",
"q3": "STRING",
"q2_explained": "STRING",
"q2": "STRING",
"q1_explained": "STRING",
"q1": "STRING",
"preferred_response_time": "STRING",
"response_time_satisfaction": "STRING",
"topic_expectations": "STRING",
"expectation": "STRING",
"close_case": "TIMESTAMP",
"open_case": "TIMESTAMP",
"question_count": "INTEGER",
"main_menu_count": "INTEGER",
"first_choice": "STRING",
"last_call_duration": "STRING",
"uncaught_message": "STRING",
"error_count": "INTEGER",
"love_option": "STRING",
"first_interaction": "TIMESTAMP",
"urnsmerge": "STRING",
"handover_timestamp": "TIMESTAMP",
"gender": "STRING",
"county": "STRING",
"counsellor_request": "STRING",
"urn": "STRING",
"age": "STRING",
"uuid": "STRING",
"name": "STRING",
"modified_on": "TIMESTAMP",
}
GROUP_CONTACT_FIELDS = {"group_uuid": "STRING", "contact_uuid": "STRING"}
GROUP_FIELDS = {"name": "STRING", "uuid": "STRING"}
FLOWS_FIELDS = {"labels": "STRING", "name": "STRING", "uuid": "STRING"}
FLOW_RUNS_FIELDS = {
"modified_on": "TIMESTAMP",
"responded": "BOOLEAN",
"contact_uuid": "STRING",
"flow_uuid": "STRING",
"exit_type": "STRING",
"created_at": "TIMESTAMP",
"exited_on": "TIMESTAMP",
"id": "INTEGER",
}
PAGEVIEW_FIELDS = {
"timestamp": "TIMESTAMP",
"page": "INTEGER",
"revision": "INTEGER",
"id": "INTEGER",
"run_uuid": "STRING",
"contact_uuid": "STRING",
}
FLOW_RUN_VALUES_FIELDS = {
"input": "STRING",
"time": "TIMESTAMP",
"category": "STRING",
"name": "STRING",
"value": "STRING",
"run_id": "INTEGER",
}
|
class Handler:
"""
Cloud provider API handler base class. Defines
common API between inherited handler classes.
"""
def __init__(self, app):
self.app = app
self.compute_client = None
self.storage_client = None
def fetch_available_ip_address(self):
return ""
"""
you'll need more methods, probably one for
each kubernetes object that you need to launch
also -- i subclassed and pushed all this code into
here so that every build() method in the compute_party
class doesnt have like
if my_provider == "AWS":
# some boto3 code
elif my_provider == "GCP":
# some gcloud code
etc.
""" |
"""
Should emit:
B018 - on lines 16-25, 29, 32
"""
def foo1():
"""my docstring"""
def foo2():
"""my docstring"""
a = 2
"str" # Str (no raise)
f"{int}" # JoinedStr (no raise)
1j # Number (complex)
1 # Number (int)
1.0 # Number (float)
b"foo" # Binary
True # NameConstant (True)
False # NameConstant (False)
None # NameConstant (None)
[1, 2] # list
{1, 2} # set
{"foo": "bar"} # dict
def foo3():
123
a = 2
"str"
3
|
# This module contains the shaders used to render snap point coordinates.
# The shaders for snapping to a vertex.
VERT_SHADER_V = """
#version 330
uniform mat4 p3d_ModelMatrix;
in vec4 p3d_Vertex;
void main() {
gl_Position = p3d_ModelMatrix * p3d_Vertex;
}
"""
GEOM_SHADER_V = """
#version 330
layout(triangles) in;
// Three points will be generated: 3 vertices
layout(points, max_vertices=3) out;
uniform mat4 p3d_ViewProjectionMatrix;
uniform mat4 p3d_ViewMatrixInverse;
uniform mat4 p3d_ProjectionMatrix;
uniform bool inverted;
uniform bool two_sided;
out vec3 snap_coords;
void main()
{
vec3 P0 = gl_in[0].gl_Position.xyz;
vec3 P1 = gl_in[1].gl_Position.xyz;
vec3 P2 = gl_in[2].gl_Position.xyz;
vec3 positions[3] = vec3[] (P0, P1, P2);
vec3 V0 = P1 - P0;
vec3 V1 = P2 - P1;
vec3 face_normal = inverted ? cross(V1, V0) : cross(V0, V1);
vec3 vec;
if (p3d_ProjectionMatrix[3].w == 1.)
// orthographic lens;
// use inverted camera direction vector
vec = p3d_ViewMatrixInverse[2].xyz;
else
// perspective lens;
// compute vector pointing from any point of triangle to camera origin
vec = p3d_ViewMatrixInverse[3].xyz - P0;
if (two_sided || dot(vec, face_normal) >= 0.) {
// generate points
for (int i = 0; i < 3; ++i)
{
gl_Position = p3d_ViewProjectionMatrix * vec4(positions[i], 1.0);
snap_coords = positions[i];
EmitVertex();
EndPrimitive();
}
}
}
"""
# The shaders for snapping to an edge midpoint.
VERT_SHADER_E = """
#version 330
uniform mat4 p3d_ModelMatrix;
in vec4 p3d_Vertex;
in int sides;
out Vertex
{
int side_gen;
} vertex;
void main() {
gl_Position = p3d_ModelMatrix * p3d_Vertex;
vertex.side_gen = sides;
}
"""
GEOM_SHADER_E = """
#version 330
layout(triangles) in;
// Three lines will be generated: 6 vertices
layout(line_strip, max_vertices=6) out;
uniform mat4 p3d_ViewProjectionMatrix;
uniform mat4 p3d_ViewMatrixInverse;
uniform mat4 p3d_ProjectionMatrix;
uniform bool inverted;
uniform bool two_sided;
in Vertex
{
int side_gen;
} vertex[];
out vec3 snap_coords;
void main()
{
int side_generation, S0, S1, S2;
int sides[3];
// determine which sides should be generated (1) or not (0)
side_generation = vertex[0].side_gen;
S0 = side_generation >> 2;
S1 = (side_generation ^ (S0 << 2)) >> 1;
S2 = side_generation ^ (S0 << 2) ^ (S1 << 1);
sides = int[] (S0, S1, S2);
vec3 P0 = gl_in[0].gl_Position.xyz;
vec3 P1 = gl_in[1].gl_Position.xyz;
vec3 P2 = gl_in[2].gl_Position.xyz;
vec3 positions[4] = vec3[] (P0, P1, P2, P0);
vec3 V0 = P1 - P0;
vec3 V1 = P2 - P1;
vec3 face_normal = inverted ? cross(V1, V0) : cross(V0, V1);
vec3 vec;
if (p3d_ProjectionMatrix[3].w == 1.)
// orthographic lens;
// use inverted camera direction vector
vec = p3d_ViewMatrixInverse[2].xyz;
else
// perspective lens;
// compute vector pointing from any point of triangle to camera origin
vec = p3d_ViewMatrixInverse[3].xyz - P0;
if (two_sided || dot(vec, face_normal) >= 0.) {
// generate sides
for (int i = 0; i < 3; ++i)
{
for (int j = 0; j < sides[i]; ++j)
{
snap_coords = (positions[i] + positions[i + 1]) * .5;
gl_Position = p3d_ViewProjectionMatrix * vec4(positions[i], 1.0);
EmitVertex();
gl_Position = p3d_ViewProjectionMatrix * vec4(positions[i + 1], 1.0);
EmitVertex();
EndPrimitive();
}
}
}
}
"""
# The shaders for snapping to a polygon center.
VERT_SHADER_P = """
#version 330
uniform mat4 p3d_ModelMatrix;
in vec4 p3d_Vertex;
in vec3 snap_pos;
out Vertex
{
vec3 snap_pos;
} vertex;
void main() {
gl_Position = p3d_ModelMatrix * p3d_Vertex;
vertex.snap_pos = (p3d_ModelMatrix * vec4(snap_pos, 1.)).xyz;
}
"""
GEOM_SHADER_P = """
#version 330
layout(triangles) in;
// One triangles will be generated: 3 vertices
layout(triangle_strip, max_vertices=3) out;
uniform mat4 p3d_ViewProjectionMatrix;
uniform mat4 p3d_ViewMatrixInverse;
uniform mat4 p3d_ProjectionMatrix;
uniform bool inverted;
uniform bool two_sided;
in Vertex
{
vec3 snap_pos;
} vertex[];
out vec3 snap_coords;
void main()
{
vec3 P0, P1, P2;
snap_coords = vertex[0].snap_pos;
if (inverted) {
P0 = gl_in[2].gl_Position.xyz;
P1 = gl_in[1].gl_Position.xyz;
P2 = gl_in[0].gl_Position.xyz;
}
else {
P0 = gl_in[0].gl_Position.xyz;
P1 = gl_in[1].gl_Position.xyz;
P2 = gl_in[2].gl_Position.xyz;
}
vec3 positions[3] = vec3[] (P0, P1, P2);
vec3 V0 = P1 - P0;
vec3 V1 = P2 - P1;
vec3 face_normal = cross(V0, V1);
vec3 vec;
if (p3d_ProjectionMatrix[3].w == 1.)
// orthographic lens;
// use inverted camera direction vector
vec = p3d_ViewMatrixInverse[2].xyz;
else
// perspective lens;
// compute vector pointing from any point of triangle to camera origin
vec = p3d_ViewMatrixInverse[3].xyz - P0;
if (two_sided || dot(vec, face_normal) >= 0.) {
for (int i = 0; i < 3; ++i)
{
gl_Position = p3d_ViewProjectionMatrix * vec4(positions[i], 1.0);
EmitVertex();
}
EndPrimitive();
}
}
"""
FRAG_SHADER = """
#version 330
uniform float snap_type_id;
in vec3 snap_coords;
layout(location = 0) out vec4 out_color;
void main() {
// output the snap point coordinates as a color value
out_color = vec4(snap_coords, snap_type_id);
}
"""
|
# -*- coding: utf-8 -*-
class OutputFormatterStyle(object):
FOREGROUND_COLORS = {
'black': 30,
'red': 31,
'green': 32,
'yellow': 33,
'blue': 34,
'magenta': 35,
'cyan': 36,
'white': 37
}
BACKGROUND_COLORS = {
'black': 40,
'red': 41,
'green': 42,
'yellow': 43,
'blue': 44,
'magenta': 45,
'cyan': 46,
'white': 47
}
OPTIONS = {
'bold': 1,
'underscore': 4,
'blink': 5,
'reverse': 7,
'conceal': 8,
}
def __init__(self, foreground=None, background=None, options=None):
self.foreground = None
self.background = None
if foreground:
self.set_foreground(foreground)
if background:
self.set_background(background)
options = options or []
if not isinstance(options, list):
options = [options]
self.set_options(options)
def set_foreground(self, foreground):
self.foreground = self.__class__.FOREGROUND_COLORS[foreground]
def set_background(self, background):
self.background = self.__class__.BACKGROUND_COLORS[background]
def set_option(self, option):
if option not in self.OPTIONS:
raise Exception('Invalid option specified: "%s". Expected one of (%s)'
% (option, ', '.join(self.OPTIONS.keys())))
if option not in self.options:
self.options.append(self.OPTIONS[option])
def set_options(self, options):
self.options = []
for option in options:
self.set_option(option)
def apply(self, text):
codes = []
if self.foreground:
codes.append(self.foreground)
if self.background:
codes.append(self.background)
if len(self.options):
codes += self.options
if not len(codes):
return text
return '\033[%sm%s\033[0m' % (';'.join(map(str, codes)), text) |
def get_vars(conta) -> list:
vars = list()
for c in conta:
# print(c)
if c.isalpha() or c == '=':
vars.append(c)
# print(c, vars)
# print(vars)
return vars
cores = ['blue',
'green',
'yellow',
'red',
'cyan',
'gray',
'light green',
'white']
def mostrar(n):
for nn in n:
print(nn)
def formatar(line, conta) -> list:
line += 1
line = str(line)
print(conta)
formatado = list()
contador = 0
for i, c in enumerate(conta):
if c.isalpha() and c != '=':
p1 = i
p2 = p1 + 1
p1 = str(p1)
p2 = str(p2)
# print('p1:', type(p1), p1)
nome = c+line+p1
print(nome)
if contador == len(cores):
contador = 0
d = {
'nome': nome,
'p1': line+'.'+p1,
'p2': line +'.'+p2,
'fg': cores[contador]
}
formatado.append(d)
contador += 1
# mostrar
# print()
# mostrar(formatado)
return formatado
if __name__ == '__main__':
formatar(line=0, conta='33xcx8x=safsafsfasfasfsf')
|
def getHammingDistance(a, b):
aLen = len(a)
bLen = len(b)
if aLen == 0 or bLen == 0:
return 0
diff = 0
if aLen != bLen:
diff = abs(aLen - bLen)
if aLen < bLen:
a = a + ' ' * diff
elif bLen < aLen:
b = b + ' ' * diff
result = 0
length = max(aLen, bLen)
for i in range(length):
if a[i] != b[i]:
result += 1
return result
if __name__ == '__main__':
ans = getHammingDistance('12345','abcde')
print(ans) |
printlevel = 0
singlemargin = ' '
marginflag = False
class nextlevel():
def __enter__(self):
global printlevel
printlevel+=1
def __exit__(self, *args, **kwargs):
global printlevel
printlevel-=1
def current_level():
return printlevel
def printmargin(kwargs):
global marginflag
prefix = kwargs.pop('prefix', None)
postfix = kwargs.pop('postfix', None)
prefixopts = kwargs.pop('prefixopts', dict(end=''))
postfixopts = kwargs.pop('postfixopts', dict(end=' '))
if marginflag:
return
if prefix:
print(*prefix, **prefixopts)
print(singlemargin*printlevel, sep='', end='')
if postfix:
print(*postfix, **postfixopts)
marginflag=True
def resetmarginflag(*args, **kwargs):
global marginflag
for arg in args+(kwargs.pop('sep', ''), kwargs.pop('end', '\n')):
if not isinstance(arg, str):
arg = str(arg)
if '\n' in arg:
marginflag=False
return
def printl(*args, **kwargs):
printmargin(kwargs)
print(*args, **kwargs)
resetmarginflag(*args, **kwargs)
|
elementos_eletro = {'F':3.98,"O":3.44,"Cl":3.16,'N':3.04,'Br':2.96,'I':2.66,'S':2.58,'Ac':0.7,"La":0.79,'Sr':0.82,'Ce':0.89,'Th':0.89,'Na':0.93,'Y':0.95,
'Li':0.98,'K':0.82,'Pr':1.1,'Pa':1.1,'Nd':1.12,'Pm':1.13,'Sm':1.14,
'Gd':1.17,"Dy":1.2,'Zr':1.22,'Er':1.22,'Tm':1.23,'Yb':1.24,'Lu':1.25,
'Ta':1.27,'Cm':1.28,'W':1.3,'U':1.3,'Bk':1.3,'Cf':1.3,'Es':1.3,
'Fm':1.3,'Md':1.3,'No':1.3,'Lr':1.3,'Rf':1.3,'Db':1.3,'Mg':1.31,
'Nb':1.31,'Ca':1.36,'Am':1.36,'Pu':1.38,'Re':1.5,'Np':1.5,'Sc':1.54,
'Cr':1.55,'Be':1.57,'Mo':1.6,'Al':1.61,'Bi':1.62,'Ti':1.63,'Cu':1.65,
'V':1.66,'ln':1.69,'Sn':1.78,'Zn':1.81,'Mn':1.83,'Fe':1.88 ,'Si':1.9,
'Ni':1.9,'Ru':1.9,'Ir':1.9,'Co':1.91,'Cd':1.93,'Sb':1.96 ,'Pb':2,
'Rn':2,'Ga':2.01,'At':2.02,'B':2.04,'I':2.05,'Xe':2.1,'Tc':2.16,
'As':2.18,'P':2.19,'H':2.2,'Rh':2.26,'Ag':2.2,'Pt':2.2,'Au':2.2,
'Fr':2.24,'Pd':2.28,'Hg':2.28,'Po':2.33,'Os':2.36,'TI':2.54,'C':2.55,
'Se':2.55,'S':2.58,'Ba':2.6,'Cs':2.66,'Kr':2.96,'Rb':0.8}
|
# [Silent Crusade] Starling's Proposal
BASTILLE = 9073003
sm.setSpeakerID(BASTILLE)
sm.sendNext("I've been expecting you! Come, let's go somewhere where we can speak in private.")
sm.warp(931050500)
sm.completeQuest(parentID) |
def tryInt(inp):
try: return int(inp)
except: return inp
def findNameIndex(name, fileContent):
for i, entry in list(enumerate(fileContent)):
if name == entry and (i%2) == 0:
return i
return False
def getFile():
with open("scores.txt") as f :
return [ tryInt(x) for x in f.read().splitlines() ]
def saveFile(obj):
with open("scores.txt", "w") as f:
for entry in obj: print(entry, file=f)
def addPerson(name, score) :
content = getFile()
content += [ name, int(score) ]
saveFile(content)
def updateScore(name, score):
content = getFile()
ind = findNameIndex( name, content )
content[ ind + 1 ] = int(score)
saveFile( content )
def getScore(name):
content = getFile()
return content[ findNameIndex(name, content) + 1 ]
|
# Target for including SkFlate.
{
'targets': [
{
'target_name': 'skflate',
'type': 'static_library',
'dependencies': [
'skia_lib.gyp:skia_lib',
],
'conditions': [
# When zlib is not availible on a system,
# SK_NO_FLATE will be defined.
[ 'skia_os != "win"',
{
'dependencies': [
'zlib.gyp:zlib',
],
}
],
],
'sources': [
'../src/core/SkFlate.cpp',
],
},
],
}
|
"""
operadores relacionais servem para comparar coisas
todas as vezes que sao usados retorna um valor bolleado true or false
== checar a igualdade
> checar se maior
>= checar se maior ou igual
<
<=
!= se é diferente
"""
#num_1 = 2
#num_2 = 2
#expresao = (num_1 > num_2) #comando compara as partes
#print(expresao)
nome = input('qual seu nome? ')
idade = input('1qual sua idade? ')
idade = int(idade) #converter input (str) para INT
idade_minima = 18
idade_maxima = 45
if idade >= idade_minima and idade <= idade_maxima:
print(f'{nome} pode pegar emprestimo.')
else:
print(f'{nome} BLOQUEADO') |
s = []
dir = [[0,1],[1,0],[1,1],[-1,1]]
for i in range(20):
s.append(list(map(int, input().split())))
print(s)
ans = 0
def f(x, y, dx, dy):
global ans
ret = 1
for i in range(4):
if x >= 20 or y >= 20: return
ret *= s[x][y]
x += dx
y += dy
if ret > ans: ans = ret
for i in range(20):
for j in range(20):
for l in range(len(dir)):
f(i, j, dir[l][0], dir[l][1])
print("ans = ", ans)
|
class Invoice:
"""This class contains basic information about an invoice
:param title: Product name
:type title: str
:param description: Product description
:type description: str
:param start_parameter: Unique bot deep.linking parameter that can be used to generate this invoice
:type start_parameter: str
:param currency: Three letter ISO 4217 currency code
:type currency: str
:param total_amount: Total amount in the smallest units of the currency (int, not float/double)
:type total_amount: int
"""
def __init__(self, *, title, description, start_parameter, currency, total_amount):
self.title = title
self.description = description
self.start_parameter = start_parameter
self.currency = currency
self.total_amount = total_amount
|
def check_exam(arr1,arr2):
def points(corr,stud):
if stud == corr:
return 4
elif stud:
return -1
else:
return 0
return max(0, sum(points(*it) for it in zip(arr1,arr2)))
|
#!/usr/bin/env python3
# https://codeforces.com/problemset/problem/1358/B
t = int(input())
for _ in range(t):
n,m = list(map(int,input().split()))
print((n*m+1)//2)
|
'''9. Faça um programa que pede para o usuário digitar 5 números e, ao final, imprime uma lista com os 5 números digitados pelo usuário (sem converter os números para int ou float).
Exemplo: Se o usuário digitar 1, 5, 2, 3, 6, o programa deve imprimir a lista ['1','5','2','3','6']'''
lists = []
i = 0
print('Adding values in lists')
print('-'*30)
print('')
#Information values of input
while i < 5:
num = input('Enter a number: ')
lists.append(num)
i += 1
#Printing values information
print(lists) |
MAJOR = 0
MINOR = 1
PATCH = ''
SUFFIX = '' # eg.rc0
__version__ = f"{MAJOR}.{MINOR}.{PATCH}{SUFFIX}" |
###############################################################################################
# This module is used to check if a process is already running
# I don't think this is being used anymore. I may delete it, but I suspect it is very useful.
# I may move it to a utility module.
# I'll comment it out later and see what breaks.
# I need to create automated tests first using assert statements.
# Then if I break something, I'll know right away.
def checkIfProcessRunning(processName):
'''
Check if there is any running process that contains the given name processName.
'''
# Iterate over the all the running process
for proc in psutil.process_iter():
try:
# Check if process name contains the given name string.
if processName.lower() in proc.name().lower():
return True
except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess):
pass
return False
###############################################################################################
# End Check if a process is already running |
class Solution:
def shiftingLetters(self, S, shifts):
"""
:type S: str
:type shifts: List[int]
:rtype: str
"""
s = sum(shifts)
lst = list(S)
for i, shift in enumerate(shifts):
ch = ord(lst[i]) - 97
ch = (ch + s) % 26
lst[i] = chr(ch + 97)
s -= shift
return ''.join(lst)
|
lista=[]
soma=0
for cont in range(10):
nota=int(input("Digite a nota: "))
lista.append(nota)
print(lista)
|
"""
This is free and unencumbered software released into the public domain.
For more details, please visit <http://unlicense.org/>.
"""
_v = "1.0.2"
|
class MultiFuture(object):
def __init__(self, futures, merger=None):
self.merger = merger
if hasattr(futures, "__len__"):
self.futures = futures
else:
self.futures = [futures]
def done(self):
for f in self.futures:
if not f.done():
return False
return True
def result(self):
if len(self.futures) == 1:
return self.futures[0].result()
if not self.merger is None:
return self.merger([f.result() for f in self.futures])
return [f.result() for f in self.futures]
|
"""Beaker exception classes"""
class BeakerException(Exception):
pass
class BeakerWarning(RuntimeWarning):
"""Issued at runtime."""
class CreationAbortedError(Exception):
"""Deprecated."""
class InvalidCacheBackendError(BeakerException, ImportError):
pass
class MissingCacheParameter(BeakerException):
pass
class LockError(BeakerException):
pass
class InvalidCryptoBackendError(BeakerException):
pass
|
class AutoTiler:
def __init__(self):
self.autoMap = {'UDLR': 0, 'DLR': 32, 'UDL': 64, 'ULR': 96, 'UDR': 128, 'DL': 160, 'UL': 192, 'UR': 224,
'DR': 256, 'LR': 288, 'UD': 320, 'U': 352, 'R': 384, 'D': 416, 'L': 448, '': 480}
def auto_tile(self, tile_map):
# Do base terrain/void transitions
for i in range(0, tile_map.width):
for j in range(0, tile_map.height):
if not tile_map.get_tile([i, j]) is None and tile_map.get_tile([i, j]).tileable:
tile_string = ''
if not tile_map.valid_tile([i, j + 1]) or tile_map.get_tile([i, j + 1]) is not None:
tile_string += 'U'
if not tile_map.valid_tile([i, j - 1]) or tile_map.get_tile([i, j - 1]) is not None:
tile_string += 'D'
if not tile_map.valid_tile([i - 1, j]) or tile_map.get_tile([i - 1, j]) is not None:
tile_string += 'L'
if not tile_map.valid_tile([i + 1, j]) or tile_map.get_tile([i + 1, j]) is not None:
tile_string += 'R'
image_region = tile_map.tiles[i][j].image_region
image_region[0] = self.autoMap[tile_string]
tile_map.tiles[i][j].set_sprite(tile_map.tiles[i][j].image_name, image_region,
batch=tile_map.tiles[i][j].batch, group=tile_map.tiles[i][j].group)
|
########## Default Octave
C = 261.63 #C
CS = 277.18 #C_Sharp
DF = 277.18 #D_Flat
D = 293.66 #D
DS = 311.13 #D_Sharp
EF = 311.13 #E_Flat
E = 329.63 #E
F = 349.23 #F
FS = 369.99 #F_Sharp
GF = 369.99 #G_Flat
G = 392.00 #G
GS = 415.30 #G_Sharp
AF = 415.30 #A_Flat
A = 440.00 #A
AS = 466.16 #A_Sharp
BF = 466.16 #B_Flat
B = 493.88 #B
########## Octave 0
C0 = 16.35
CS0 = 17.32
DF0 = 17.32
D0 = 18.35
DS0 = 19.45
EF0 = 19.45
E0 = 20.60
F0 = 21.83
FS0 = 23.12
GF0 = 23.12
G0 = 24.50
GS0 = 25.96
AF0 = 25.96
A0 = 27.50
AS0 = 29.14
BF0 = 29.14
B0 = 30.87
########## Octave 1
C1 = 32.70
CS1 = 34.65
DF1 = 34.65
D1 = 36.71
DS1 = 38.89
EF1 = 38.89
E1 = 41.20
F1 = 43.65
FS1 = 46.25
GF1 = 46.25
G1 = 49.00
GS1 = 51.91
AF1 = 51.91
A1 = 55.00
AS1 = 58.27
BF1 = 58.27
B1 = 61.74
########## Octave 2
C2 = 65.41
CS2 = 69.30
DF2 = 69.30
D2 = 73.42
DS2 = 77.78
EF2 = 77.78
E2 = 82.41
F2 = 87.31
FS2 = 92.50
GF2 = 92.50
G2 = 98.00
GS2 = 103.83
AF2 = 103.83
A2 = 110.00
AS2 = 116.54
BF2 = 116.54
B2 = 123.47
########## Octave 3
C3 = 130.81
CS3 = 138.59
DF3 = 138.59
D3 = 146.83
DS3 = 155.56
EF3 = 155.56
E3 = 164.81
F3 = 174.61
FS3 = 185.00
GF3 = 185.00
G3 = 196.00
GS3 = 207.65
AF3 = 207.65
A3 = 220.00
AS3 = 233.08
BF3 = 233.08
B3 = 246.94
########## Octave 4
C4 = 261.63
CS4 = 277.18
DF4 = 277.18
D4 = 293.66
DS4 = 311.13
EF4 = 311.13
E4 = 329.63
F4 = 349.23
FS4 = 369.99
GF4 = 369.99
G4 = 392.00
GS4 = 415.30
AF4 = 415.30
A4 = 440.00
AS4 = 466.16
BF4 = 466.16
B4 = 493.88
########## Octave 5
C5 = 523.25
CS5 = 554.37
DF5 = 554.378
D5 = 587.33
DS5 = 622.25
EF5 = 622.25
E5 = 659.25
F5 = 698.46
FS5 = 739.99
GF5 = 739.99
G5 = 783.99
GS5 = 830.61
AF5 = 830.61
A5 = 880.00
AS5 = 932.33
BF5 = 932.33
B5 = 987.77
########## Octave 6
C6 = 1046.50
CS6 = 1108.73
DF6 = 1108.73
D6 = 1174.66
DS6 = 1244.51
EF6 = 1244.51
E6 = 1318.51
F6 = 1396.91
FS6 = 1479.98
GF6 = 1479.98
G6 = 1567.98
GS6 = 1661.22
AF6 = 1661.22
A6 = 1760.00
AS6 = 1864.66
BF6 = 1864.66
B6 = 1975.53
########## Octave 7
C7 = 2093.00
CS7 = 2217.46
DF7 = 2217.46
D7 = 2349.32
DS7 = 2489.02
EF7 = 2489.02
E7 = 2637.02
F7 = 2793.83
FS7 = 2959.96
GF7 = 2959.96
G7 = 3135.96
GS7 = 3322.44
AF7 = 3322.44
A7 = 3520.00
AS7 = 3729.31
BF7 = 3729.31
B7 = 3951.07
########## Octave 8
C8 = 4186.01
CS8 = 4434.92
DF8 = 4434.92
D8 = 4698.63
DS8 = 4978.03
EF8 = 4978.03
E8 = 5274.04
F8 = 5587.65
FS8 = 5919.91
GF8 = 5919.91
G8 = 6271.93
GS8 = 6644.88
AF8 = 6644.88
A8 = 7040.00
AS8 = 7458.62
BF8 = 7458.62
B8 = 7902.13
|
# THIS FILE IS GENERATED FROM NUMPY SETUP.PY
#
# To compare versions robustly, use `numpy.lib.NumpyVersion`
short_version = '1.13.3'
version = '1.13.3'
full_version = '1.13.3'
git_revision = '31465473c491829d636c9104c390062cba005681'
release = True
if not release:
version = full_version
|
ETHEREUM_TEST_PARAMETERS = ['ethrpc_endpoint,ethereum_manager_connect_at_start', [
# Query etherscan
('', False),
# For real node querying let's use blockscout
('https://mainnet-nethermind.blockscout.com', True),
]]
|
class DataGridViewRowCancelEventArgs(CancelEventArgs):
"""
Provides data for the System.Windows.Forms.DataGridView.UserDeletingRow event of a System.Windows.Forms.DataGridView.
DataGridViewRowCancelEventArgs(dataGridViewRow: DataGridViewRow)
"""
@staticmethod
def __new__(self,dataGridViewRow):
""" __new__(cls: type,dataGridViewRow: DataGridViewRow) """
pass
Row=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""Gets the row that the user is deleting.
Get: Row(self: DataGridViewRowCancelEventArgs) -> DataGridViewRow
"""
|
# Copyright 2016 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Rules for configuring the C++ toolchain (experimental)."""
load("@bazel_tools//tools/cpp:windows_cc_configure.bzl", "configure_windows_toolchain")
load("@bazel_tools//tools/cpp:osx_cc_configure.bzl", "configure_osx_toolchain")
load("@bazel_tools//tools/cpp:unix_cc_configure.bzl", "configure_unix_toolchain")
load("@bazel_tools//tools/cpp:lib_cc_configure.bzl", "get_cpu_value")
def _impl(repository_ctx):
repository_ctx.symlink(
Label("@bazel_tools//tools/cpp:dummy_toolchain.bzl"), "dummy_toolchain.bzl")
# cpu_value = get_cpu_value(repository_ctx)
cpu_value = "arm"
if cpu_value == "freebsd":
# This is defaulting to the static crosstool, we should eventually
# autoconfigure this platform too. Theorically, FreeBSD should be
# straightforward to add but we cannot run it in a docker container so
# skipping until we have proper tests for FreeBSD.
repository_ctx.symlink(Label("@bazel_tools//tools/cpp:CROSSTOOL"), "CROSSTOOL")
repository_ctx.symlink(Label("@bazel_tools//tools/cpp:BUILD.static"), "BUILD")
elif cpu_value == "x64_windows":
configure_windows_toolchain(repository_ctx)
elif cpu_value == "darwin":
configure_osx_toolchain(repository_ctx)
else:
configure_unix_toolchain(repository_ctx, cpu_value)
cc_autoconf = repository_rule(
implementation=_impl,
environ = [
"ABI_LIBC_VERSION",
"ABI_VERSION",
"BAZEL_COMPILER",
"BAZEL_HOST_SYSTEM",
"BAZEL_PYTHON",
"BAZEL_SH",
"BAZEL_TARGET_CPU",
"BAZEL_TARGET_LIBC",
"BAZEL_TARGET_SYSTEM",
"BAZEL_VC",
"BAZEL_VS",
"CC",
"CC_CONFIGURE_DEBUG",
"CC_TOOLCHAIN_NAME",
"CPLUS_INCLUDE_PATH",
"CUDA_COMPUTE_CAPABILITIES",
"CUDA_PATH",
"HOMEBREW_RUBY_PATH",
"NO_WHOLE_ARCHIVE_OPTION",
"USE_DYNAMIC_CRT",
"USE_MSVC_WRAPPER",
"SYSTEMROOT",
"VS90COMNTOOLS",
"VS100COMNTOOLS",
"VS110COMNTOOLS",
"VS120COMNTOOLS",
"VS140COMNTOOLS"])
def cc_configure():
"""A C++ configuration rules that generate the crosstool file."""
cc_autoconf(name="local_config_cc")
native.bind(name="cc_toolchain", actual="@local_config_cc//:toolchain")
|
BASE_URL = 'https://twitter.com'
TIMELINE_SEARCH_URL = 'https://twitter.com/i/search/timeline'
SEARCH_URL = 'https://twitter.com/search/'
LOGIN_URL = 'https://twitter.com/login'
SESSIONS_URL = 'https://twitter.com/sessions'
RETWEET_URL = 'https://api.twitter.com/1.1/statuses/retweet.json'
FOLLOW_URL = 'https://api.twitter.com/1.1/friendships/create.json'
LIKE_URL = 'https://api.twitter.com/1.1/favorites/create.json'
COOKIES_FILE = 'cookies.txt'
BEARER = '''Bearer AAAAAAAAAAAAAAAAAAAAAPYXBAAAAAAACLXUNDekMxqa8h%2F40K4moUkGsoc%3DTYfbDKbT3jJPCEVnMYqilB28NHfOPqkca3qaAxGfsyKCs0wRbw'''
UI_METRICS = '{"rf":{"c6fc1daac14ef08ff96ef7aa26f8642a197bfaad9c65746a6592d55075ef01af":3,"a77e6e7ab2880be27e81075edd6cac9c0b749cc266e1cea17ffc9670a9698252":-1,"ad3dbab6c68043a1127defab5b7d37e45d17f56a6997186b3a08a27544b606e8":252,"ac2624a3b325d64286579b4a61dd242539a755a5a7fa508c44eb1c373257d569":-125},"s":"fTQyo6c8mP7d6L8Og_iS8ulzPObBOzl3Jxa2jRwmtbOBJSk4v8ClmBbF9njbZHRLZx0mTAUPsImZ4OnbZV95f-2gD6-03SZZ8buYdTDkwV-xItDu5lBVCQ_EAiv3F5EuTpVl7F52FTIykWowpNIzowvh_bhCM0_6ReTGj6990294mIKUFM_mPHCyZ xkIUAtC3dVeYPXff92alrVFdrncrO8VnJHOlm9gnSwTLcbHvvpvC0rvtwapSbTja-cGxhxBdekFhcoFo8edCBiMB9pip-VoquZ-ddbQEbpuzE7xBhyk759yQyN4NmRFwdIjjedWYtFyOiy_XtGLp6zKvMjF8QAAAWE468LY"}'
|
arr=list(map(int,input().split()))
left=0
right=len(arr)-1
while(left<=right):
#print(left)
#print(right)
if arr[left]<0 and arr[right]<0:
left+=1
elif arr[left]>0 and arr[right]<0:
arr[left],arr[right]=arr[right],arr[left]
left+=1
right-=1
elif arr[left]>0 and arr[right]>0:
right-=1
else:
left+=1
right-=1
print(arr)
|
class Solution:
def profitableSchemes(self, G: int, P: int, group: List[int], profit: List[int]) -> int:
@lru_cache(maxsize=None)
def schemes(G, P, start):
if G<0:
return 0
if start==len(group):
if P<=0:
return 1
else:
return 0
return schemes(G,P,start+1)+schemes(G-group[start], max(0,P-profit[start]), start+1)
return schemes(G,P,0)%1000000007 |
def theSieve(n):
'''# Finds all primes less than or equal to n using the Sieve of Eratosthenes'''
# Create a boolean array
# "prime[0..n]" and initialize
# all entries it as true.
# A value in prime[i] will
# finally be false if i is
# Not a prime, else true.
prime = [True for i in range(n+1)]
p = 2
results = []
while (p * p <= n):
# If prime[p] is not
# changed, then it is a prime
if (prime[p] == True):
# Update all multiples of p
for i in range(p * p, n+1, p):
prime[i] = False
p += 1
# Add all prime numbers to our list
for p in range(2, n+1):
if prime[p]:
# print(p)
results.append(p)
return results
# Driver code
if __name__ == '__main__':
n = 10000
print("Following are the prime numbers smaller than or equal to", n)
print(str(theSieve(n)))
|
# Crie um programa que mostre quanto dinheiro uma pessoa tem e mostre quantos dolares ela pode comprar.
real = float(input('Digite quantos reais vocês tem: R$ '))
convert = 0.20
dolar = real * convert
print('Você tem {} dolares em reais.'.format(dolar)) |
# Solution A
class Solution:
def groupAnagrams(self, strs: List[str]) -> List[List[str]]:
mp = collections.defaultdict(list)
for st in strs:
key = ''.join(sorted(st))
mp[key].append(st)
return list(mp.values())
# Solution B
class Solution:
def groupAnagrams(self, strs: List[str]) -> List[List[str]]:
mp = collections.defaultdict(list)
for st in strs:
ct = [0] * 26
for ch in st:
ct[ord(ch) - ord('a')] += 1
mp[tuple(ct)].append(st)
return list(mp.values())
|
while True:
friends = hero.findFriends()
for friend in friends:
enemy = friend.findNearestEnemy()
if enemy and friend.distanceTo(enemy) < 30:
hero.command(friend, "attack", enemy)
else:
hero.command(friend, "move", {"x": friend.pos.x + 2, "y": friend.pos.y})
|
"""
Utility scripts for PyTables
============================
:Author: Ivan Vilata i Balaguer
:Contact: ivan@selidor.net
:Created: 2005-12-01
:License: BSD
:Revision: $Id$
This package contains some modules which provide a ``main()`` function
(with no arguments), so that they can be used as scripts.
"""
|
""" 05
Elabore um programa que receba 4 notas de um aluno e calcule a média dele.
Exemplo:
Primeiro Nota = 7
Segundo Nota = 8
Terceiro Nota = 10
Quarto Nota = 6
Média = 7,75
"""
n1 = float(input("Primeira nota: "))
n2 = float(input("Segunda nota: "))
n3 = float(input("Terceira nota: "))
n4 = float(input("Quarta nota: "))
media = (n1+n2+n3+n4)/4
print(f'\nMédia = {media:.2f}') |
n = int(input())
if n & (n-1) > 0:
print("NO")
else:
print("YES") |
#!/usr/bin/env python3
"""
momentum
"""
def update_variables_momentum(alpha, beta1, var, grad, v):
"""
Create momentum
"""
dw = beta1 * v + (1 - beta1) * grad
w = var - alpha * dw
return w, dw
|
number = 9.0 # Float number
division_result = number / 2
division_remainder = number % 2
multiplication_result = division_result * 2
addition_result = multiplication_result + division_remainder
subtraction_result = number - multiplication_result
floor_result = number // 2
power_result = multiplication_result ** 3
print("result = " + str(subtraction_result))
|
class TokenType(tuple):
parent = None
def __contains__(self, item):
return item is not None and (self is item or item[:len(self)] == self)
def __getattr__(self, name):
new = TokenType(self + (name,))
setattr(self, name, new)
new.parent = self
return new
def __repr__(self):
return 'Token' + ('.' if self else '') + '.'.join(self)
token_type = TokenType()
# - Literals
Literal = token_type.Literal
# -- Primitive
String = Literal.String
Number = Literal.Number
Integer = Number.Integer
Float = Number.Float
Boolean = Literal.Boolean
None_ = Literal.None_
# -- Compound
List = Literal.List
# - Operators
Operator = token_type.Operator
# --
Comparison = Operator.Comparison
Logical = Operator.Logical
# - Identifier
Identifier = token_type.Identifier
Path = Identifier.Path
# - Expression
Expression = token_type.Expression
|
"""
1. Clarification
2. Possible solutions
- HashMap
3. Coding
4. Tests
"""
# T=O(n), S=O(min(n, k))
class Solution:
def containsNearbyDuplicate(self, nums: List[int], k: int) -> bool:
d = dict()
for i in range(len(nums)):
if nums[i] in d and i - d[nums[i]] <= k:
return True
d[nums[i]] = i
return False
|
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
def hasCycle(self, head: ListNode) -> bool:
if not head or not head.next:
return False
a, b = head, head.next
while b and b.next and b.next.next:
if a is b:
return True
a = a.next
b = b.next.next
return False
|
class Node():
def __init__(self, val):
self.val = val
self.left = None
self.right = None
def search(root, val):
if root is None or root.val == val:
return root
if root.val < val:
return search(root.left, val)
else:
return search(root.right, val)
def search_iterative(root, val):
while root:
if val > root.val:
root = root.right
elif val < root.val:
root = root.left
else:
return True
return False
|
def show_cmd(task):
return "executing... %s" % task.name
def task_custom_display():
return {'actions':['echo abc efg'],
'title': show_cmd}
|
# This is an input class. Do not edit.
class LinkedList:
def __init__(self, value):
self.value = value
self.next = None
def findLoop(head):
slow = head.next
fast = head.next.next
while slow != fast:
slow = slow.next
fast = fast.next.next
while head != slow:
head = head.next
slow = slow.next
return head
|
# encoding: utf-8
'''
单例模式
单例模式(Singleton Pattern)的核心作用是确保一个类只有一个实例,并且提供一个访问该实例的全局访问点。
单例模式只生成一个实例对象,减少了对系统资源的开销。当一个对象的产生需要比较多的资源,如读取配置文件、产生其他依赖对象时,可以产生一个“单例对象”,
然后永久驻留内存中,从而极大的降低开销。
单例模式有多种实现的方式,我们这里推荐重写__new__()的方法。
'''
class MySingleton:
__obj = None
__init_flag = True
def __new__(cls, *args, **kwargs):
if cls.__obj == None:
cls.__obj = object.__new__(cls)
return cls.__obj
def __init__(self, name):
if MySingleton.__init_flag:
print("init...")
self.name = name
MySingleton.__init_flag == False
instance1 = MySingleton("liuzhen")
print(instance1)
instance2 = MySingleton("hahaha")
print(instance2)
class CarFactory:
__obj = None
__init_flag = True
def create_car(self, brand):
if brand == "奔驰":
return Benz()
elif brand == "宝马":
return BMW()
elif brand == "比亚迪":
return BYD()
else:
return "未知品牌,无法创建"
def __new__(cls, *args, **kwargs):
if cls.__obj == None:
cls.__obj = object.__new__(cls)
return cls.__obj
def __init__(self):
if CarFactory.__init_flag:
print("init CarFactory ...")
CarFactory.__init_flag = False
class Benz:
pass
class BMW:
pass
class BYD:
pass
factory = CarFactory()
c1 = factory.create_car("奔驰")
c2 = factory.create_car("宝马")
print(c1)
print(c2)
factory2 = CarFactory()
print(factory)
print(factory2)
|
class NoMessageException(AssertionError):
pass
class ConnectionClosed(Exception):
pass
|
# Multiplying each element in a list by 2
original_list = [1,2,3,4]
new_list = [2*x for x in original_list]
print(new_list)
# [2,4,6,8]
|
# Created by MechAviv
# Map ID :: 940205100
# Ravaged Base Remnants : Ravaged Eastern Base 1
sm.addPopUpSay(3001500, 1000, "#face8#There are more enemies every moment.", "")
sm.systemMessage("Clear out all of the monsters first.") |
# This is merely a tag type to avoid circular import issues.
# Yes, this is a terrible solution but ultimately it is the only solution.
# This was moved out of the ext.commands namespace so discord.Cog/CogMeta
# could be imported into it for backwards compatibility.
class _BaseCommand:
__slots__ = ()
|
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
def alpaca_deps():
"""Loads dependencies need to compile and test with the alpaca library."""
# googletest is a testing framework developed by Google.
if "com_github_google_gooogletest" not in native.existing_rules():
http_archive(
name = "com_github_google_googletest",
strip_prefix = "googletest-release-1.10.0",
urls = ["https://github.com/google/googletest/archive/release-1.10.0.tar.gz"],
sha256 = "9dc9157a9a1551ec7a7e43daea9a694a0bb5fb8bec81235d8a1e6ef64c716dcb",
)
# gflags is a C++ library that implements commandline flags processing.
if "com_github_gflags_gflags" not in native.existing_rules():
http_archive(
name = "com_github_gflags_gflags",
strip_prefix = "gflags-2.2.2",
urls = ["https://github.com/gflags/gflags/archive/v2.2.2.tar.gz"],
sha256 = "34af2f15cf7367513b352bdcd2493ab14ce43692d2dcd9dfc499492966c64dcf",
)
# glog is a C++ implementation of the Google logging module.
if "com_github_google_glog" not in native.existing_rules():
http_archive(
name = "com_github_google_glog",
strip_prefix = "glog-0.4.0",
urls = ["https://github.com/google/glog/archive/v0.4.0.tar.gz"],
sha256 = "f28359aeba12f30d73d9e4711ef356dc842886968112162bc73002645139c39c",
)
# RapidJSON is a fast JSON parser/generator for C++ with both SAX/DOM style API.
if "com_github_tencent_rapidjson" not in native.existing_rules():
http_archive(
name = "com_github_tencent_rapidjson",
strip_prefix = "rapidjson-1.1.0",
urls = ["https://github.com/Tencent/rapidjson/archive/v1.1.0.tar.gz"],
build_file = "@//bazel/third_party/rapidjson:BUILD",
sha256 = "bf7ced29704a1e696fbccf2a2b4ea068e7774fa37f6d7dd4039d0787f8bed98e",
)
# cpp-httplib is a C++ header-only HTTP/HTTPS server and client library.
if "com_github_yhirose_cpp-httplib" not in native.existing_rules():
http_archive(
name = "com_github_yhirose_cpp_httplib",
strip_prefix = "cpp-httplib-0.5.7",
urls = ["https://github.com/yhirose/cpp-httplib/archive/v0.5.7.tar.gz"],
build_file = "@//bazel/third_party/cpphttplib:BUILD",
sha256 = "27b7f6346bdeb1ead9d17bd7cea89d9ad491f50f0479081053cc6e5742a89e64",
)
# BoringSSL is a fork of OpenSSL that is designed to meet Google's needs.
if "com_github_google_boringssl" not in native.existing_rules():
http_archive(
name = "com_github_google_boringssl",
strip_prefix = "boringssl-master-with-bazel",
urls = ["https://github.com/google/boringssl/archive/master-with-bazel.tar.gz"],
)
# zlib is a general purpose data compression library.
if "com_github_madler_zlib" not in native.existing_rules():
http_archive(
name = "com_github_madler_zlib",
strip_prefix = "zlib-1.2.11",
urls = ["https://github.com/madler/zlib/archive/v1.2.11.tar.gz"],
build_file = "@//bazel/third_party/zlib:BUILD",
sha256 = "629380c90a77b964d896ed37163f5c3a34f6e6d897311f1df2a7016355c45eff",
)
# libuv is a multi-platform support library with a focus on asynchronous I/O.
if "com_github_libuv_libuv" not in native.existing_rules():
http_archive(
name = "com_github_libuv_libuv",
strip_prefix = "libuv-1.23.2",
urls = ["https://github.com/libuv/libuv/archive/v1.23.2.tar.gz"],
build_file = "@//bazel/third_party/libuv:BUILD",
sha256 = "30af979c4f4b8d1b895ae6d115f7400c751542ccb9e656350fc89fda08d4eabd",
)
# uWebsockets is a simple, secure & standards compliant web I/O library.
if "com_github_unetworking_uwebsockets" not in native.existing_rules():
http_archive(
name = "com_github_unetworking_uwebsockets",
strip_prefix = "uWebSockets-0.14.8",
urls = ["https://github.com/uNetworking/uWebSockets/archive/v0.14.8.tar.gz"],
build_file = "@//bazel/third_party/uwebsockets:BUILD",
sha256 = "663a22b521c8258e215e34e01c7fcdbbd500296aab2c31d36857228424bb7675",
) |
# Uses python3
def calc_fib(number):
'''Given an integer n, find the nth Fibonacci number Fn.'''
if number <= 1:
return number
previous = 0
current = 1
for _ in range(number - 1):
previous, current = current, previous + current
return current
if __name__ == '__main__':
num = int(input())
print(calc_fib(num))
|
data = list(map(int, open("05.txt")))
size = len(data)
# Part 1
vm = data.copy()
ip = tick = 0
while (ip >= 0 and ip < size):
jr = vm[ip]
vm[ip] += 1
ip += jr
tick += 1
print(tick)
# Part 2
vm = data
ip = tick = 0
while (ip >= 0 and ip < size):
jr = vm[ip]
vm[ip] += 1 if jr < 3 else -1
ip += jr
tick += 1
print(tick)
|
# coding: utf-8
def dp_make_change(coin_list, change, min_coins, coin_used):
"""
利用动态规划解决'使用最少的硬币找零'问题
@Arguments:
coin_list: 零钱集合,被用于找零
change: 需要找零的钱数
min_coins: 存储[0, change+1)之间每个量找零需要的最少硬币数
coin_used: 记录为min_coins的每一项添加的最后一个硬币
"""
for cents in range(change+1):
coin_count = cents
new_coin = 1
for j in [c for c in coin_list if c <= cents]:
# min_coins[cents-j]表示(cents-j)钱数需要的最少找零数
if min_coins[cents-j] + 1 < coin_count:
coin_count = min_coins[cents-j] + 1
new_coin = j
min_coins[cents] = coin_count
coin_used[cents] = new_coin
return min_coins[change]
def print_coins(coin_used, change):
coin = change
while coin > 0:
this_coin = coin_used[coin]
print(this_coin)
coin = coin - this_coin
def main():
amnt = 63
clist = [1, 5, 10, 21, 25]
coin_used = [0] * (amnt+1)
coin_count = [0] * (amnt+1)
dp_make_change(clist, amnt, coin_count, coin_used)
print_coins(coin_used, amnt)
|
class NetworkService:
def __init__(self, client):
self.client = client
def deleteMember(self, address, id, headers=None, query_params=None, content_type="application/json"):
"""
Delete member from network
It is method for DELETE /network/{id}/member/{address}
"""
uri = self.client.base_url + "/network/"+id+"/member/"+address
return self.client.delete(uri, None, headers, query_params, content_type)
def getMember(self, address, id, headers=None, query_params=None, content_type="application/json"):
"""
Get network member settings
It is method for GET /network/{id}/member/{address}
"""
uri = self.client.base_url + "/network/"+id+"/member/"+address
return self.client.get(uri, None, headers, query_params, content_type)
def updateMember(self, data, address, id, headers=None, query_params=None, content_type="application/json"):
"""
Update member settings
It is method for POST /network/{id}/member/{address}
"""
uri = self.client.base_url + "/network/"+id+"/member/"+address
return self.client.post(uri, data, headers, query_params, content_type)
def listMembers(self, id, headers=None, query_params=None, content_type="application/json"):
"""
Get a list of network members
It is method for GET /network/{id}/member
"""
uri = self.client.base_url + "/network/"+id+"/member"
return self.client.get(uri, None, headers, query_params, content_type)
def deleteNetwork(self, id, headers=None, query_params=None, content_type="application/json"):
"""
Delete network
It is method for DELETE /network/{id}
"""
uri = self.client.base_url + "/network/"+id
return self.client.delete(uri, None, headers, query_params, content_type)
def getNetwork(self, id, headers=None, query_params=None, content_type="application/json"):
"""
Get network configuration and status information
It is method for GET /network/{id}
"""
uri = self.client.base_url + "/network/"+id
return self.client.get(uri, None, headers, query_params, content_type)
def updateNetwork(self, data, id, headers=None, query_params=None, content_type="application/json"):
"""
Update network configuration
It is method for POST /network/{id}
"""
uri = self.client.base_url + "/network/"+id
return self.client.post(uri, data, headers, query_params, content_type)
def listNetworks(self, headers=None, query_params=None, content_type="application/json"):
"""
Get a list of networks this user owns or can view/edit
It is method for GET /network
"""
uri = self.client.base_url + "/network"
return self.client.get(uri, None, headers, query_params, content_type)
def createNetwork(self, data, headers=None, query_params=None, content_type="application/json"):
"""
Create a new network
It is method for POST /network
"""
uri = self.client.base_url + "/network"
return self.client.post(uri, data, headers, query_params, content_type)
|
class Category:
def __init__(self, bot, name: str = '', description: str = '', fp: str = ''):
bot.categories[name] = self
self.bot = bot
self.name = name
self.description = description
self.fp = fp
self.cogs = []
def add_cogs(self, *cogs):
for cog in cogs:
self.add_cog(cog)
def remove_cogs(self):
for cog in self.cogs:
self.bot.remove_cog(cog)
self.cogs.clear()
def remove_cog(self, cog):
self.bot.unload_extension(f"cogs.{self.fp}.{cog.qualified_name.lower()}")
self.cogs.remove(cog)
def add_cog(self, cog):
self.bot.load_extension(f"cogs.{self.fp}.{cog.__name__.lower()}")
c = self.bot.get_cog(cog.__name__)
c.category = self
self.cogs.append(c)
@property
def commands(self):
cmds = []
for n in self.cogs:
cmds.extend(n.commands)
return cmds
|
class Solution:
def isSubsequence(self, s: str, t: str) -> bool:
if not s:
return True
s_index = 0
t_index = 0
while t_index < len(t):
if s[s_index] == t[t_index]:
s_index += 1
if s_index == len(s):
return True
t_index += 1
return False |
'''
In this module we implement counting sort
'''
def counting_sort(arr):
'''
Sort array using counting sort
'''
count = [0] * (max(arr)+1)
sorted_list = [0]*len(arr)
for i in arr:
count[i] += 1
for i in range(1,len(count)):
count[i] += count[i-1]
for i in arr:
sorted_list[count[i] - 1] = i
count[i] -= 1
return sorted_list |
class Menu:
def event_button_up(self):
raise("Not implemented")
def event_button_down(self):
raise("Not implemented")
def event_button_left(self):
raise("Not implemented")
def event_button_right(self):
raise("Not implemented")
def event_button_a(self):
return
def event_button_x(self):
return
def event_button_y(self):
return
def event_button_lb(self):
return
def event_button_rb(self):
return
def event_button_lt(self):
return
def event_button_rt(self):
return
def draw(self, screen):
raise ("Not implemented")
|
for x in (1, 3, 5): #will iterate once with 1, 3, etc
usrRange = 4
for x in range (1, usrRange): #variables can be used as well
print ("I will repeat this the specified number of times")
|
# 2018-11-1 , Model default configurations
# lEFT DOWN RIGHT UP arrow key to operation
options = [0, 1, 2, 3]
#
op = [ 65, 83, 68, 87]
#'A' 'S' 'D' 'W' character to operation.
#operation index
actions = [0,1,2,3]
# ESC
end_game = 27
LR = 1e-3
goal_steps = 2000000
score_requirement = 1024
initial_games = 100
|
C_HEADER = '/*\nThis source was automatically generated by The IMPORTANT Interpreter & Compiler.\n*/'
C_INCLUDE = '#include <stdio.h>\n#include <stdlib.h>\n#include "stack.c"\n'
C_MAIN = 'int main(int argc, char **argv) {\n\t\tchar tape[30000]={0};\n\t\tchar* ptr = tape;\n\t\tstruct Stack* ' \
'stack = createStack(1000);\n'
C_END = '}'
def important_compile(code) -> str:
code_list = [C_HEADER, C_INCLUDE, C_MAIN]
for operation in code:
if operation == '>':
code_list.append('\t\t++ptr;')
elif operation == '<':
code_list.append('\t\t--ptr;')
elif operation == '+':
code_list.append('\t\t++*ptr;')
elif operation == '-':
code_list.append('\t\t--*ptr;')
elif operation == '.':
code_list.append('\t\tputchar(*ptr);')
elif operation == ',':
code_list.append('\t\t*ptr = getchar();')
elif operation == '{':
code_list.append('\twhile(*ptr) {')
elif operation == '}':
code_list.append('\t}')
elif operation == 'ˇ':
code_list.append("\t\tpush(stack, *ptr);")
elif operation == '^':
code_list.append('\t\t*ptr = pop(stack);')
elif operation == ';':
code_list.append('\t\tchar tmp = *ptr;\n\t\t*ptr = pop(stack);\n\t\tpush(stack, tmp);')
else:
raise SyntaxError("Invalid operation: {}".format(operation))
code_list.append(C_END)
return '\n'.join(code_list)
|
# dervied from http://farsitools.sf.net
# Copyright (C) 2003-2011 Parspooyesh Fanavar (http://parspooyesh.com/)
# see LICENSE.txt
g_days_in_month = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
j_days_in_month = [31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29]
class GregorianToJalali:
def __init__(self, gyear, gmonth, gday):
"""
Convert gregorian date to jalali date
gmonth: number of month in range 1-12
"""
self.gyear = gyear
self.gmonth = gmonth
self.gday = gday
self.__gregorianToJalali()
def getJalaliList(self):
return (self.jyear, self.jmonth, self.jday)
def __gregorianToJalali(self):
"""
g_y: gregorian year
g_m: gregorian month
g_d: gregorian day
"""
global g_days_in_month, j_days_in_month
gy = self.gyear - 1600
gm = self.gmonth - 1
gd = self.gday - 1
g_day_no = 365 * gy + (gy + 3) // 4 - (gy + 99) // 100 + (gy + 399) // 400
for i in range(gm):
g_day_no += g_days_in_month[i]
if gm > 1 and ((gy % 4 == 0 and gy % 100 != 0) or (gy % 400 == 0)):
# leap and after Feb
g_day_no += 1
g_day_no += gd
j_day_no = g_day_no - 79
j_np = j_day_no // 12053
j_day_no %= 12053
jy = 979 + 33 * j_np + 4 * int(j_day_no // 1461)
j_day_no %= 1461
if j_day_no >= 366:
jy += (j_day_no - 1) // 365
j_day_no = (j_day_no - 1) % 365
for i in range(11):
if not j_day_no >= j_days_in_month[i]:
i -= 1
break
j_day_no -= j_days_in_month[i]
jm = i + 2
jd = j_day_no + 1
self.jyear = jy
self.jmonth = jm
self.jday = jd
class JalaliToGregorian:
def __init__(self, jyear, jmonth, jday):
"""
Convert db time stamp (in gregorian date) to jalali date
"""
self.jyear = jyear
self.jmonth = jmonth
self.jday = jday
self.__jalaliToGregorian()
def getGregorianList(self):
return (self.gyear, self.gmonth, self.gday)
def __jalaliToGregorian(self):
global g_days_in_month, j_days_in_month
jy = self.jyear - 979
jm = self.jmonth - 1
jd = self.jday - 1
j_day_no = 365 * jy + int(jy // 33) * 8 + (jy % 33 + 3) // 4
for i in range(jm):
j_day_no += j_days_in_month[i]
j_day_no += jd
g_day_no = j_day_no + 79
gy = 1600 + 400 * int(g_day_no // 146097) # 146097 = 365*400 + 400/4 - 400/100 + 400/400
g_day_no = g_day_no % 146097
leap = 1
if g_day_no >= 36525: # 36525 = 365*100 + 100/4
g_day_no -= 1
gy += 100 * int(g_day_no // 36524) # 36524 = 365*100 + 100/4 - 100/100
g_day_no = g_day_no % 36524
if g_day_no >= 365:
g_day_no += 1
else:
leap = 0
gy += 4 * int(g_day_no // 1461) # 1461 = 365*4 + 4/4
g_day_no %= 1461
if g_day_no >= 366:
leap = 0
g_day_no -= 1
gy += g_day_no // 365
g_day_no = g_day_no % 365
i = 0
while g_day_no >= g_days_in_month[i] + (i == 1 and leap):
g_day_no -= g_days_in_month[i] + (i == 1 and leap)
i += 1
self.gmonth = i + 1
self.gday = g_day_no + 1
self.gyear = gy
|
# -*- coding: utf-8 -*-
# Scrapy settings for douban project
#
# For simplicity, this file contains only the most important settings by
# default. All the other settings are documented here:
#
# http://doc.scrapy.org/en/latest/topics/settings.html
#
BOT_NAME = 'douban'
SPIDER_MODULES = ['douban.spiders']
NEWSPIDER_MODULE = 'douban.spiders'
DOWNLOAD_DELAY = 0.1
RANDOMIZE_DOWNLOAD_DELAY = True
USER_AGENT = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.54 Safari/536.5'
COOKIES_ENABLED = True
LOG_LEVEL = 'WARNING'
# pipelines
ITEM_PIPELINES = {
'douban.pipelines.DoubanPipeline': 300
}
# set as BFS
DEPTH_PRIORITY = 1
SCHEDULER_DISK_QUEUE = 'scrapy.squeue.PickleFifoDiskQueue'
SCHEDULER_MEMORY_QUEUE = 'scrapy.squeue.FifoMemoryQueue'
# Crawl responsibly by identifying yourself (and your website) on the user-agent
# USER_AGENT = 'douban (+http://www.yourdomain.com)'
|
12 + 5 + 1
x=12
x
y=20
print("Use print")
print(y) |
# -*- coding: UTF-8 -*-
def add_numbers(x, y):
return x + y
print(type('This is a string')) # <type 'str'>
print(type(None)) # <type 'NoneType'>
print(type(1)) # <type 'int'>
print(type(1.0)) # <type 'float'>
print(type(add_numbers)) # <type 'function'>
print('----------------------------------------')
x = (1, 'a', 2, 'b')
print(type(x)) # <type 'tuple'>
x = [1, 'a', 2, 'b']
print(type(x)) # <type 'list'>
x.append(3.3)
print(x) # [1, 'a', 2, 'b', 3.3]
print('----------------------------------------')
for item in x:
print(item)
i = 0
while i != len(x):
print(x[i])
i += 1
print([1, 2] + [3, 4]) # [1, 2, 3, 4]
print([1] * 3) # [1, 1, 1]
print(1 in [1, 2, 3]) # True
print('----------------------------------------')
x = 'This is a string'
print(x[0]) # first character # T
print(x[0:1]) # first character, but we have explicitly set the end character # T
print(x[0:2]) # first two characters # Th
print(x[-1]) # g
print(x[-4:-2]) # ri
print(x[:3]) # Thi
print(x[3:]) # s is a string
print('----------------------------------------')
firstname = 'Christopher'
lastname = 'Brooks'
print(firstname + ' ' + lastname) # Christopher Brooks
print(firstname * 3) # ChristopherChristopherChristopher
print('Chris' in firstname) # True
firstname = 'Christopher Arthur Hansen Brooks'.split(' ')[0] # [0] selects the first element of the list
lastname = 'Christopher Arthur Hansen Brooks'.split(' ')[-1] # [-1] selects the last element of the list
print(firstname) # Christopher
print(lastname) # Brooks
print('Chris' + str(2)) # Chris2
print('----------------------------------------')
x = {'Christopher Brooks': 'brooksch@umich.edu', 'Bill Gates': 'billg@microsoft.com'}
print(x['Christopher Brooks']) # Retrieve a value by using the indexing operator # brooksch@umich.edu
x['Kevyn Collins-Thompson'] = None
print(x['Kevyn Collins-Thompson']) # None
for name in x:
print(x[name])
for email in x.values():
print(email)
for name, email in x.items():
print(name)
print(email)
print('----------------------------------------')
# x = ('Christopher', 'Brooks', 'brooksch@umich.edu', 'Ann Arbor') # Error is x has 4 elements
x = ('Christopher', 'Brooks', 'brooksch@umich.edu')
fname, lname, email = x
print(fname) # Christopher
print(lname) # Brooks
|
#############################################################
# 2016-09-26: MboxType.py
# Author: Jeremy M. Gibson (State Archives of North Carolina)
#
# Description: Implementation of the mbox-type
##############################################################
class Mbox:
""""""
def __init__(self, rel_path=None, eol=None, hsh=None):
"""Constructor for Mbox"""
self.rel_path = rel_path # type: str
self.eol = eol # type: str
self.hsh = hsh # type: Hash
|
__all__ = (
"SetOptConfError",
"NamingError",
"DataTypeError",
"MissingRequiredError",
"ReadOnlyError",
)
class SetOptConfError(Exception):
pass
class NamingError(SetOptConfError):
pass
class DataTypeError(SetOptConfError):
pass
class MissingRequiredError(SetOptConfError):
pass
class ReadOnlyError(SetOptConfError):
pass
|
'''
The MIT License (MIT)
Copyright (c) 2016 WavyCloud
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
'''
def can_paginate(operation_name=None):
"""
Check if an operation can be paginated.
:type operation_name: string
:param operation_name: The operation name. This is the same name
as the method name on the client. For example, if the
method name is create_foo, and you'd normally invoke the
operation as client.create_foo(**kwargs), if the
create_foo operation can be paginated, you can use the
call client.get_paginator('create_foo').
"""
pass
def create_cloud_front_origin_access_identity(CloudFrontOriginAccessIdentityConfig=None):
"""
Creates a new origin access identity. If you're using Amazon S3 for your origin, you can use an origin access identity to require users to access your content using a CloudFront URL instead of the Amazon S3 URL. For more information about how to use origin access identities, see Serving Private Content through CloudFront in the Amazon CloudFront Developer Guide .
See also: AWS API Documentation
:example: response = client.create_cloud_front_origin_access_identity(
CloudFrontOriginAccessIdentityConfig={
'CallerReference': 'string',
'Comment': 'string'
}
)
:type CloudFrontOriginAccessIdentityConfig: dict
:param CloudFrontOriginAccessIdentityConfig: [REQUIRED]
The current configuration information for the identity.
CallerReference (string) -- [REQUIRED]A unique number that ensures the request can't be replayed.
If the CallerReference is new (no matter the content of the CloudFrontOriginAccessIdentityConfig object), a new origin access identity is created.
If the CallerReference is a value already sent in a previous identity request, and the content of the CloudFrontOriginAccessIdentityConfig is identical to the original request (ignoring white space), the response includes the same information returned to the original request.
If the CallerReference is a value you already sent in a previous request to create an identity, but the content of the CloudFrontOriginAccessIdentityConfig is different from the original request, CloudFront returns a CloudFrontOriginAccessIdentityAlreadyExists error.
Comment (string) -- [REQUIRED]Any comments you want to include about the origin access identity.
:rtype: dict
:return: {
'CloudFrontOriginAccessIdentity': {
'Id': 'string',
'S3CanonicalUserId': 'string',
'CloudFrontOriginAccessIdentityConfig': {
'CallerReference': 'string',
'Comment': 'string'
}
},
'Location': 'string',
'ETag': 'string'
}
"""
pass
def create_distribution(DistributionConfig=None):
"""
Creates a new web distribution. Send a POST request to the /*CloudFront API version* /distribution /distribution ID resource.
See also: AWS API Documentation
:example: response = client.create_distribution(
DistributionConfig={
'CallerReference': 'string',
'Aliases': {
'Quantity': 123,
'Items': [
'string',
]
},
'DefaultRootObject': 'string',
'Origins': {
'Quantity': 123,
'Items': [
{
'Id': 'string',
'DomainName': 'string',
'OriginPath': 'string',
'CustomHeaders': {
'Quantity': 123,
'Items': [
{
'HeaderName': 'string',
'HeaderValue': 'string'
},
]
},
'S3OriginConfig': {
'OriginAccessIdentity': 'string'
},
'CustomOriginConfig': {
'HTTPPort': 123,
'HTTPSPort': 123,
'OriginProtocolPolicy': 'http-only'|'match-viewer'|'https-only',
'OriginSslProtocols': {
'Quantity': 123,
'Items': [
'SSLv3'|'TLSv1'|'TLSv1.1'|'TLSv1.2',
]
},
'OriginReadTimeout': 123,
'OriginKeepaliveTimeout': 123
}
},
]
},
'DefaultCacheBehavior': {
'TargetOriginId': 'string',
'ForwardedValues': {
'QueryString': True|False,
'Cookies': {
'Forward': 'none'|'whitelist'|'all',
'WhitelistedNames': {
'Quantity': 123,
'Items': [
'string',
]
}
},
'Headers': {
'Quantity': 123,
'Items': [
'string',
]
},
'QueryStringCacheKeys': {
'Quantity': 123,
'Items': [
'string',
]
}
},
'TrustedSigners': {
'Enabled': True|False,
'Quantity': 123,
'Items': [
'string',
]
},
'ViewerProtocolPolicy': 'allow-all'|'https-only'|'redirect-to-https',
'MinTTL': 123,
'AllowedMethods': {
'Quantity': 123,
'Items': [
'GET'|'HEAD'|'POST'|'PUT'|'PATCH'|'OPTIONS'|'DELETE',
],
'CachedMethods': {
'Quantity': 123,
'Items': [
'GET'|'HEAD'|'POST'|'PUT'|'PATCH'|'OPTIONS'|'DELETE',
]
}
},
'SmoothStreaming': True|False,
'DefaultTTL': 123,
'MaxTTL': 123,
'Compress': True|False,
'LambdaFunctionAssociations': {
'Quantity': 123,
'Items': [
{
'LambdaFunctionARN': 'string',
'EventType': 'viewer-request'|'viewer-response'|'origin-request'|'origin-response'
},
]
}
},
'CacheBehaviors': {
'Quantity': 123,
'Items': [
{
'PathPattern': 'string',
'TargetOriginId': 'string',
'ForwardedValues': {
'QueryString': True|False,
'Cookies': {
'Forward': 'none'|'whitelist'|'all',
'WhitelistedNames': {
'Quantity': 123,
'Items': [
'string',
]
}
},
'Headers': {
'Quantity': 123,
'Items': [
'string',
]
},
'QueryStringCacheKeys': {
'Quantity': 123,
'Items': [
'string',
]
}
},
'TrustedSigners': {
'Enabled': True|False,
'Quantity': 123,
'Items': [
'string',
]
},
'ViewerProtocolPolicy': 'allow-all'|'https-only'|'redirect-to-https',
'MinTTL': 123,
'AllowedMethods': {
'Quantity': 123,
'Items': [
'GET'|'HEAD'|'POST'|'PUT'|'PATCH'|'OPTIONS'|'DELETE',
],
'CachedMethods': {
'Quantity': 123,
'Items': [
'GET'|'HEAD'|'POST'|'PUT'|'PATCH'|'OPTIONS'|'DELETE',
]
}
},
'SmoothStreaming': True|False,
'DefaultTTL': 123,
'MaxTTL': 123,
'Compress': True|False,
'LambdaFunctionAssociations': {
'Quantity': 123,
'Items': [
{
'LambdaFunctionARN': 'string',
'EventType': 'viewer-request'|'viewer-response'|'origin-request'|'origin-response'
},
]
}
},
]
},
'CustomErrorResponses': {
'Quantity': 123,
'Items': [
{
'ErrorCode': 123,
'ResponsePagePath': 'string',
'ResponseCode': 'string',
'ErrorCachingMinTTL': 123
},
]
},
'Comment': 'string',
'Logging': {
'Enabled': True|False,
'IncludeCookies': True|False,
'Bucket': 'string',
'Prefix': 'string'
},
'PriceClass': 'PriceClass_100'|'PriceClass_200'|'PriceClass_All',
'Enabled': True|False,
'ViewerCertificate': {
'CloudFrontDefaultCertificate': True|False,
'IAMCertificateId': 'string',
'ACMCertificateArn': 'string',
'SSLSupportMethod': 'sni-only'|'vip',
'MinimumProtocolVersion': 'SSLv3'|'TLSv1',
'Certificate': 'string',
'CertificateSource': 'cloudfront'|'iam'|'acm'
},
'Restrictions': {
'GeoRestriction': {
'RestrictionType': 'blacklist'|'whitelist'|'none',
'Quantity': 123,
'Items': [
'string',
]
}
},
'WebACLId': 'string',
'HttpVersion': 'http1.1'|'http2',
'IsIPV6Enabled': True|False
}
)
:type DistributionConfig: dict
:param DistributionConfig: [REQUIRED]
The distribution's configuration information.
CallerReference (string) -- [REQUIRED]A unique value (for example, a date-time stamp) that ensures that the request can't be replayed.
If the value of CallerReference is new (regardless of the content of the DistributionConfig object), CloudFront creates a new distribution.
If CallerReference is a value you already sent in a previous request to create a distribution, and if the content of the DistributionConfig is identical to the original request (ignoring white space), CloudFront returns the same the response that it returned to the original request.
If CallerReference is a value you already sent in a previous request to create a distribution but the content of the DistributionConfig is different from the original request, CloudFront returns a DistributionAlreadyExists error.
Aliases (dict) --A complex type that contains information about CNAMEs (alternate domain names), if any, for this distribution.
Quantity (integer) -- [REQUIRED]The number of CNAME aliases, if any, that you want to associate with this distribution.
Items (list) --A complex type that contains the CNAME aliases, if any, that you want to associate with this distribution.
(string) --
DefaultRootObject (string) --The object that you want CloudFront to request from your origin (for example, index.html ) when a viewer requests the root URL for your distribution (http://www.example.com ) instead of an object in your distribution (http://www.example.com/product-description.html ). Specifying a default root object avoids exposing the contents of your distribution.
Specify only the object name, for example, index.html . Do not add a / before the object name.
If you don't want to specify a default root object when you create a distribution, include an empty DefaultRootObject element.
To delete the default root object from an existing distribution, update the distribution configuration and include an empty DefaultRootObject element.
To replace the default root object, update the distribution configuration and specify the new object.
For more information about the default root object, see Creating a Default Root Object in the Amazon CloudFront Developer Guide .
Origins (dict) -- [REQUIRED]A complex type that contains information about origins for this distribution.
Quantity (integer) -- [REQUIRED]The number of origins for this distribution.
Items (list) --A complex type that contains origins for this distribution.
(dict) --A complex type that describes the Amazon S3 bucket or the HTTP server (for example, a web server) from which CloudFront gets your files. You must create at least one origin.
For the current limit on the number of origins that you can create for a distribution, see Amazon CloudFront Limits in the AWS General Reference .
Id (string) -- [REQUIRED]A unique identifier for the origin. The value of Id must be unique within the distribution.
When you specify the value of TargetOriginId for the default cache behavior or for another cache behavior, you indicate the origin to which you want the cache behavior to route requests by specifying the value of the Id element for that origin. When a request matches the path pattern for that cache behavior, CloudFront routes the request to the specified origin. For more information, see Cache Behavior Settings in the Amazon CloudFront Developer Guide .
DomainName (string) -- [REQUIRED]
Amazon S3 origins : The DNS name of the Amazon S3 bucket from which you want CloudFront to get objects for this origin, for example, myawsbucket.s3.amazonaws.com .
Constraints for Amazon S3 origins:
If you configured Amazon S3 Transfer Acceleration for your bucket, do not specify the s3-accelerate endpoint for DomainName .
The bucket name must be between 3 and 63 characters long (inclusive).
The bucket name must contain only lowercase characters, numbers, periods, underscores, and dashes.
The bucket name must not contain adjacent periods.
Custom Origins : The DNS domain name for the HTTP server from which you want CloudFront to get objects for this origin, for example, www.example.com .
Constraints for custom origins:
DomainName must be a valid DNS name that contains only a-z, A-Z, 0-9, dot (.), hyphen (-), or underscore (_) characters.
The name cannot exceed 128 characters.
OriginPath (string) --An optional element that causes CloudFront to request your content from a directory in your Amazon S3 bucket or your custom origin. When you include the OriginPath element, specify the directory name, beginning with a / . CloudFront appends the directory name to the value of DomainName , for example, example.com/production . Do not include a / at the end of the directory name.
For example, suppose you've specified the following values for your distribution:
DomainName : An Amazon S3 bucket named myawsbucket .
OriginPath : /production
CNAME : example.com
When a user enters example.com/index.html in a browser, CloudFront sends a request to Amazon S3 for myawsbucket/production/index.html .
When a user enters example.com/acme/index.html in a browser, CloudFront sends a request to Amazon S3 for myawsbucket/production/acme/index.html .
CustomHeaders (dict) --A complex type that contains names and values for the custom headers that you want.
Quantity (integer) -- [REQUIRED]The number of custom headers, if any, for this distribution.
Items (list) --
Optional : A list that contains one OriginCustomHeader element for each custom header that you want CloudFront to forward to the origin. If Quantity is 0 , omit Items .
(dict) --A complex type that contains HeaderName and HeaderValue elements, if any, for this distribution.
HeaderName (string) -- [REQUIRED]The name of a header that you want CloudFront to forward to your origin. For more information, see Forwarding Custom Headers to Your Origin (Web Distributions Only) in the Amazon Amazon CloudFront Developer Guide .
HeaderValue (string) -- [REQUIRED]The value for the header that you specified in the HeaderName field.
S3OriginConfig (dict) --A complex type that contains information about the Amazon S3 origin. If the origin is a custom origin, use the CustomOriginConfig element instead.
OriginAccessIdentity (string) -- [REQUIRED]The CloudFront origin access identity to associate with the origin. Use an origin access identity to configure the origin so that viewers can only access objects in an Amazon S3 bucket through CloudFront. The format of the value is:
origin-access-identity/CloudFront/ID-of-origin-access-identity
where `` ID-of-origin-access-identity `` is the value that CloudFront returned in the ID element when you created the origin access identity.
If you want viewers to be able to access objects using either the CloudFront URL or the Amazon S3 URL, specify an empty OriginAccessIdentity element.
To delete the origin access identity from an existing distribution, update the distribution configuration and include an empty OriginAccessIdentity element.
To replace the origin access identity, update the distribution configuration and specify the new origin access identity.
For more information about the origin access identity, see Serving Private Content through CloudFront in the Amazon CloudFront Developer Guide .
CustomOriginConfig (dict) --A complex type that contains information about a custom origin. If the origin is an Amazon S3 bucket, use the S3OriginConfig element instead.
HTTPPort (integer) -- [REQUIRED]The HTTP port the custom origin listens on.
HTTPSPort (integer) -- [REQUIRED]The HTTPS port the custom origin listens on.
OriginProtocolPolicy (string) -- [REQUIRED]The origin protocol policy to apply to your origin.
OriginSslProtocols (dict) --The SSL/TLS protocols that you want CloudFront to use when communicating with your origin over HTTPS.
Quantity (integer) -- [REQUIRED]The number of SSL/TLS protocols that you want to allow CloudFront to use when establishing an HTTPS connection with this origin.
Items (list) -- [REQUIRED]A list that contains allowed SSL/TLS protocols for this distribution.
(string) --
OriginReadTimeout (integer) --You can create a custom origin read timeout. All timeout units are in seconds. The default origin read timeout is 30 seconds, but you can configure custom timeout lengths using the CloudFront API. The minimum timeout length is 4 seconds; the maximum is 60 seconds.
If you need to increase the maximum time limit, contact the AWS Support Center .
OriginKeepaliveTimeout (integer) --You can create a custom keep-alive timeout. All timeout units are in seconds. The default keep-alive timeout is 5 seconds, but you can configure custom timeout lengths using the CloudFront API. The minimum timeout length is 1 second; the maximum is 60 seconds.
If you need to increase the maximum time limit, contact the AWS Support Center .
DefaultCacheBehavior (dict) -- [REQUIRED]A complex type that describes the default cache behavior if you do not specify a CacheBehavior element or if files don't match any of the values of PathPattern in CacheBehavior elements. You must create exactly one default cache behavior.
TargetOriginId (string) -- [REQUIRED]The value of ID for the origin that you want CloudFront to route requests to when a request matches the path pattern either for a cache behavior or for the default cache behavior.
ForwardedValues (dict) -- [REQUIRED]A complex type that specifies how CloudFront handles query strings and cookies.
QueryString (boolean) -- [REQUIRED]Indicates whether you want CloudFront to forward query strings to the origin that is associated with this cache behavior and cache based on the query string parameters. CloudFront behavior depends on the value of QueryString and on the values that you specify for QueryStringCacheKeys , if any:
If you specify true for QueryString and you don't specify any values for QueryStringCacheKeys , CloudFront forwards all query string parameters to the origin and caches based on all query string parameters. Depending on how many query string parameters and values you have, this can adversely affect performance because CloudFront must forward more requests to the origin.
If you specify true for QueryString and you specify one or more values for QueryStringCacheKeys , CloudFront forwards all query string parameters to the origin, but it only caches based on the query string parameters that you specify.
If you specify false for QueryString , CloudFront doesn't forward any query string parameters to the origin, and doesn't cache based on query string parameters.
For more information, see Configuring CloudFront to Cache Based on Query String Parameters in the Amazon CloudFront Developer Guide .
Cookies (dict) -- [REQUIRED]A complex type that specifies whether you want CloudFront to forward cookies to the origin and, if so, which ones. For more information about forwarding cookies to the origin, see How CloudFront Forwards, Caches, and Logs Cookies in the Amazon CloudFront Developer Guide .
Forward (string) -- [REQUIRED]Specifies which cookies to forward to the origin for this cache behavior: all, none, or the list of cookies specified in the WhitelistedNames complex type.
Amazon S3 doesn't process cookies. When the cache behavior is forwarding requests to an Amazon S3 origin, specify none for the Forward element.
WhitelistedNames (dict) --Required if you specify whitelist for the value of Forward: . A complex type that specifies how many different cookies you want CloudFront to forward to the origin for this cache behavior and, if you want to forward selected cookies, the names of those cookies.
If you specify all or none for the value of Forward , omit WhitelistedNames . If you change the value of Forward from whitelist to all or none and you don't delete the WhitelistedNames element and its child elements, CloudFront deletes them automatically.
For the current limit on the number of cookie names that you can whitelist for each cache behavior, see Amazon CloudFront Limits in the AWS General Reference .
Quantity (integer) -- [REQUIRED]The number of different cookies that you want CloudFront to forward to the origin for this cache behavior.
Items (list) --A complex type that contains one Name element for each cookie that you want CloudFront to forward to the origin for this cache behavior.
(string) --
Headers (dict) --A complex type that specifies the Headers , if any, that you want CloudFront to vary upon for this cache behavior.
Quantity (integer) -- [REQUIRED]The number of different headers that you want CloudFront to forward to the origin for this cache behavior. You can configure each cache behavior in a web distribution to do one of the following:
Forward all headers to your origin : Specify 1 for Quantity and * for Name .
Warning
If you configure CloudFront to forward all headers to your origin, CloudFront doesn't cache the objects associated with this cache behavior. Instead, it sends every request to the origin.
Forward a whitelist of headers you specify : Specify the number of headers that you want to forward, and specify the header names in Name elements. CloudFront caches your objects based on the values in all of the specified headers. CloudFront also forwards the headers that it forwards by default, but it caches your objects based only on the headers that you specify.
Forward only the default headers : Specify 0 for Quantity and omit Items . In this configuration, CloudFront doesn't cache based on the values in the request headers.
Items (list) --A complex type that contains one Name element for each header that you want CloudFront to forward to the origin and to vary on for this cache behavior. If Quantity is 0 , omit Items .
(string) --
QueryStringCacheKeys (dict) --A complex type that contains information about the query string parameters that you want CloudFront to use for caching for this cache behavior.
Quantity (integer) -- [REQUIRED]The number of whitelisted query string parameters for this cache behavior.
Items (list) --(Optional) A list that contains the query string parameters that you want CloudFront to use as a basis for caching for this cache behavior. If Quantity is 0, you can omit Items .
(string) --
TrustedSigners (dict) -- [REQUIRED]A complex type that specifies the AWS accounts, if any, that you want to allow to create signed URLs for private content.
If you want to require signed URLs in requests for objects in the target origin that match the PathPattern for this cache behavior, specify true for Enabled , and specify the applicable values for Quantity and Items . For more information, see Serving Private Content through CloudFront in the Amazon Amazon CloudFront Developer Guide .
If you don't want to require signed URLs in requests for objects that match PathPattern , specify false for Enabled and 0 for Quantity . Omit Items .
To add, change, or remove one or more trusted signers, change Enabled to true (if it's currently false ), change Quantity as applicable, and specify all of the trusted signers that you want to include in the updated distribution.
Enabled (boolean) -- [REQUIRED]Specifies whether you want to require viewers to use signed URLs to access the files specified by PathPattern and TargetOriginId .
Quantity (integer) -- [REQUIRED]The number of trusted signers for this cache behavior.
Items (list) --
Optional : A complex type that contains trusted signers for this cache behavior. If Quantity is 0 , you can omit Items .
(string) --
ViewerProtocolPolicy (string) -- [REQUIRED]The protocol that viewers can use to access the files in the origin specified by TargetOriginId when a request matches the path pattern in PathPattern . You can specify the following options:
allow-all : Viewers can use HTTP or HTTPS.
redirect-to-https : If a viewer submits an HTTP request, CloudFront returns an HTTP status code of 301 (Moved Permanently) to the viewer along with the HTTPS URL. The viewer then resubmits the request using the new URL.
https-only : If a viewer sends an HTTP request, CloudFront returns an HTTP status code of 403 (Forbidden).
For more information about requiring the HTTPS protocol, see Using an HTTPS Connection to Access Your Objects in the Amazon CloudFront Developer Guide .
Note
The only way to guarantee that viewers retrieve an object that was fetched from the origin using HTTPS is never to use any other protocol to fetch the object. If you have recently changed from HTTP to HTTPS, we recommend that you clear your objects' cache because cached objects are protocol agnostic. That means that an edge location will return an object from the cache regardless of whether the current request protocol matches the protocol used previously. For more information, see Specifying How Long Objects and Errors Stay in a CloudFront Edge Cache (Expiration) in the Amazon CloudFront Developer Guide .
MinTTL (integer) -- [REQUIRED]The minimum amount of time that you want objects to stay in CloudFront caches before CloudFront forwards another request to your origin to determine whether the object has been updated. For more information, see Specifying How Long Objects and Errors Stay in a CloudFront Edge Cache (Expiration) in the Amazon Amazon CloudFront Developer Guide .
You must specify 0 for MinTTL if you configure CloudFront to forward all headers to your origin (under Headers , if you specify 1 for Quantity and * for Name ).
AllowedMethods (dict) --A complex type that controls which HTTP methods CloudFront processes and forwards to your Amazon S3 bucket or your custom origin. There are three choices:
CloudFront forwards only GET and HEAD requests.
CloudFront forwards only GET , HEAD , and OPTIONS requests.
CloudFront forwards GET, HEAD, OPTIONS, PUT, PATCH, POST , and DELETE requests.
If you pick the third choice, you may need to restrict access to your Amazon S3 bucket or to your custom origin so users can't perform operations that you don't want them to. For example, you might not want users to have permissions to delete objects from your origin.
Quantity (integer) -- [REQUIRED]The number of HTTP methods that you want CloudFront to forward to your origin. Valid values are 2 (for GET and HEAD requests), 3 (for GET , HEAD , and OPTIONS requests) and 7 (for GET, HEAD, OPTIONS, PUT, PATCH, POST , and DELETE requests).
Items (list) -- [REQUIRED]A complex type that contains the HTTP methods that you want CloudFront to process and forward to your origin.
(string) --
CachedMethods (dict) --A complex type that controls whether CloudFront caches the response to requests using the specified HTTP methods. There are two choices:
CloudFront caches responses to GET and HEAD requests.
CloudFront caches responses to GET , HEAD , and OPTIONS requests.
If you pick the second choice for your Amazon S3 Origin, you may need to forward Access-Control-Request-Method, Access-Control-Request-Headers, and Origin headers for the responses to be cached correctly.
Quantity (integer) -- [REQUIRED]The number of HTTP methods for which you want CloudFront to cache responses. Valid values are 2 (for caching responses to GET and HEAD requests) and 3 (for caching responses to GET , HEAD , and OPTIONS requests).
Items (list) -- [REQUIRED]A complex type that contains the HTTP methods that you want CloudFront to cache responses to.
(string) --
SmoothStreaming (boolean) --Indicates whether you want to distribute media files in the Microsoft Smooth Streaming format using the origin that is associated with this cache behavior. If so, specify true ; if not, specify false . If you specify true for SmoothStreaming , you can still distribute other content using this cache behavior if the content matches the value of PathPattern .
DefaultTTL (integer) --The default amount of time that you want objects to stay in CloudFront caches before CloudFront forwards another request to your origin to determine whether the object has been updated. The value that you specify applies only when your origin does not add HTTP headers such as Cache-Control max-age , Cache-Control s-maxage , and Expires to objects. For more information, see Specifying How Long Objects and Errors Stay in a CloudFront Edge Cache (Expiration) in the Amazon CloudFront Developer Guide .
MaxTTL (integer) --
Compress (boolean) --Whether you want CloudFront to automatically compress certain files for this cache behavior. If so, specify true ; if not, specify false . For more information, see Serving Compressed Files in the Amazon CloudFront Developer Guide .
LambdaFunctionAssociations (dict) --A complex type that contains zero or more Lambda function associations for a cache behavior.
Quantity (integer) -- [REQUIRED]The number of Lambda function associations for this cache behavior.
Items (list) --
Optional : A complex type that contains LambdaFunctionAssociation items for this cache behavior. If Quantity is 0 , you can omit Items .
(dict) --A complex type that contains a Lambda function association.
LambdaFunctionARN (string) --The ARN of the Lambda function.
EventType (string) --Specifies the event type that triggers a Lambda function invocation. Valid values are:
viewer-request
origin-request
viewer-response
origin-response
CacheBehaviors (dict) --A complex type that contains zero or more CacheBehavior elements.
Quantity (integer) -- [REQUIRED]The number of cache behaviors for this distribution.
Items (list) --Optional: A complex type that contains cache behaviors for this distribution. If Quantity is 0 , you can omit Items .
(dict) --A complex type that describes how CloudFront processes requests.
You must create at least as many cache behaviors (including the default cache behavior) as you have origins if you want CloudFront to distribute objects from all of the origins. Each cache behavior specifies the one origin from which you want CloudFront to get objects. If you have two origins and only the default cache behavior, the default cache behavior will cause CloudFront to get objects from one of the origins, but the other origin is never used.
For the current limit on the number of cache behaviors that you can add to a distribution, see Amazon CloudFront Limits in the AWS General Reference .
If you don't want to specify any cache behaviors, include only an empty CacheBehaviors element. Don't include an empty CacheBehavior element, or CloudFront returns a MalformedXML error.
To delete all cache behaviors in an existing distribution, update the distribution configuration and include only an empty CacheBehaviors element.
To add, change, or remove one or more cache behaviors, update the distribution configuration and specify all of the cache behaviors that you want to include in the updated distribution.
For more information about cache behaviors, see Cache Behaviors in the Amazon CloudFront Developer Guide .
PathPattern (string) -- [REQUIRED]The pattern (for example, images/*.jpg ) that specifies which requests to apply the behavior to. When CloudFront receives a viewer request, the requested path is compared with path patterns in the order in which cache behaviors are listed in the distribution.
Note
You can optionally include a slash (/ ) at the beginning of the path pattern. For example, /images/*.jpg . CloudFront behavior is the same with or without the leading / .
The path pattern for the default cache behavior is * and cannot be changed. If the request for an object does not match the path pattern for any cache behaviors, CloudFront applies the behavior in the default cache behavior.
For more information, see Path Pattern in the Amazon CloudFront Developer Guide .
TargetOriginId (string) -- [REQUIRED]The value of ID for the origin that you want CloudFront to route requests to when a request matches the path pattern either for a cache behavior or for the default cache behavior.
ForwardedValues (dict) -- [REQUIRED]A complex type that specifies how CloudFront handles query strings and cookies.
QueryString (boolean) -- [REQUIRED]Indicates whether you want CloudFront to forward query strings to the origin that is associated with this cache behavior and cache based on the query string parameters. CloudFront behavior depends on the value of QueryString and on the values that you specify for QueryStringCacheKeys , if any:
If you specify true for QueryString and you don't specify any values for QueryStringCacheKeys , CloudFront forwards all query string parameters to the origin and caches based on all query string parameters. Depending on how many query string parameters and values you have, this can adversely affect performance because CloudFront must forward more requests to the origin.
If you specify true for QueryString and you specify one or more values for QueryStringCacheKeys , CloudFront forwards all query string parameters to the origin, but it only caches based on the query string parameters that you specify.
If you specify false for QueryString , CloudFront doesn't forward any query string parameters to the origin, and doesn't cache based on query string parameters.
For more information, see Configuring CloudFront to Cache Based on Query String Parameters in the Amazon CloudFront Developer Guide .
Cookies (dict) -- [REQUIRED]A complex type that specifies whether you want CloudFront to forward cookies to the origin and, if so, which ones. For more information about forwarding cookies to the origin, see How CloudFront Forwards, Caches, and Logs Cookies in the Amazon CloudFront Developer Guide .
Forward (string) -- [REQUIRED]Specifies which cookies to forward to the origin for this cache behavior: all, none, or the list of cookies specified in the WhitelistedNames complex type.
Amazon S3 doesn't process cookies. When the cache behavior is forwarding requests to an Amazon S3 origin, specify none for the Forward element.
WhitelistedNames (dict) --Required if you specify whitelist for the value of Forward: . A complex type that specifies how many different cookies you want CloudFront to forward to the origin for this cache behavior and, if you want to forward selected cookies, the names of those cookies.
If you specify all or none for the value of Forward , omit WhitelistedNames . If you change the value of Forward from whitelist to all or none and you don't delete the WhitelistedNames element and its child elements, CloudFront deletes them automatically.
For the current limit on the number of cookie names that you can whitelist for each cache behavior, see Amazon CloudFront Limits in the AWS General Reference .
Quantity (integer) -- [REQUIRED]The number of different cookies that you want CloudFront to forward to the origin for this cache behavior.
Items (list) --A complex type that contains one Name element for each cookie that you want CloudFront to forward to the origin for this cache behavior.
(string) --
Headers (dict) --A complex type that specifies the Headers , if any, that you want CloudFront to vary upon for this cache behavior.
Quantity (integer) -- [REQUIRED]The number of different headers that you want CloudFront to forward to the origin for this cache behavior. You can configure each cache behavior in a web distribution to do one of the following:
Forward all headers to your origin : Specify 1 for Quantity and * for Name .
Warning
If you configure CloudFront to forward all headers to your origin, CloudFront doesn't cache the objects associated with this cache behavior. Instead, it sends every request to the origin.
Forward a whitelist of headers you specify : Specify the number of headers that you want to forward, and specify the header names in Name elements. CloudFront caches your objects based on the values in all of the specified headers. CloudFront also forwards the headers that it forwards by default, but it caches your objects based only on the headers that you specify.
Forward only the default headers : Specify 0 for Quantity and omit Items . In this configuration, CloudFront doesn't cache based on the values in the request headers.
Items (list) --A complex type that contains one Name element for each header that you want CloudFront to forward to the origin and to vary on for this cache behavior. If Quantity is 0 , omit Items .
(string) --
QueryStringCacheKeys (dict) --A complex type that contains information about the query string parameters that you want CloudFront to use for caching for this cache behavior.
Quantity (integer) -- [REQUIRED]The number of whitelisted query string parameters for this cache behavior.
Items (list) --(Optional) A list that contains the query string parameters that you want CloudFront to use as a basis for caching for this cache behavior. If Quantity is 0, you can omit Items .
(string) --
TrustedSigners (dict) -- [REQUIRED]A complex type that specifies the AWS accounts, if any, that you want to allow to create signed URLs for private content.
If you want to require signed URLs in requests for objects in the target origin that match the PathPattern for this cache behavior, specify true for Enabled , and specify the applicable values for Quantity and Items . For more information, see Serving Private Content through CloudFront in the Amazon Amazon CloudFront Developer Guide .
If you don't want to require signed URLs in requests for objects that match PathPattern , specify false for Enabled and 0 for Quantity . Omit Items .
To add, change, or remove one or more trusted signers, change Enabled to true (if it's currently false ), change Quantity as applicable, and specify all of the trusted signers that you want to include in the updated distribution.
Enabled (boolean) -- [REQUIRED]Specifies whether you want to require viewers to use signed URLs to access the files specified by PathPattern and TargetOriginId .
Quantity (integer) -- [REQUIRED]The number of trusted signers for this cache behavior.
Items (list) --
Optional : A complex type that contains trusted signers for this cache behavior. If Quantity is 0 , you can omit Items .
(string) --
ViewerProtocolPolicy (string) -- [REQUIRED]The protocol that viewers can use to access the files in the origin specified by TargetOriginId when a request matches the path pattern in PathPattern . You can specify the following options:
allow-all : Viewers can use HTTP or HTTPS.
redirect-to-https : If a viewer submits an HTTP request, CloudFront returns an HTTP status code of 301 (Moved Permanently) to the viewer along with the HTTPS URL. The viewer then resubmits the request using the new URL.
https-only : If a viewer sends an HTTP request, CloudFront returns an HTTP status code of 403 (Forbidden).
For more information about requiring the HTTPS protocol, see Using an HTTPS Connection to Access Your Objects in the Amazon CloudFront Developer Guide .
Note
The only way to guarantee that viewers retrieve an object that was fetched from the origin using HTTPS is never to use any other protocol to fetch the object. If you have recently changed from HTTP to HTTPS, we recommend that you clear your objects' cache because cached objects are protocol agnostic. That means that an edge location will return an object from the cache regardless of whether the current request protocol matches the protocol used previously. For more information, see Specifying How Long Objects and Errors Stay in a CloudFront Edge Cache (Expiration) in the Amazon CloudFront Developer Guide .
MinTTL (integer) -- [REQUIRED]The minimum amount of time that you want objects to stay in CloudFront caches before CloudFront forwards another request to your origin to determine whether the object has been updated. For more information, see Specifying How Long Objects and Errors Stay in a CloudFront Edge Cache (Expiration) in the Amazon Amazon CloudFront Developer Guide .
You must specify 0 for MinTTL if you configure CloudFront to forward all headers to your origin (under Headers , if you specify 1 for Quantity and * for Name ).
AllowedMethods (dict) --A complex type that controls which HTTP methods CloudFront processes and forwards to your Amazon S3 bucket or your custom origin. There are three choices:
CloudFront forwards only GET and HEAD requests.
CloudFront forwards only GET , HEAD , and OPTIONS requests.
CloudFront forwards GET, HEAD, OPTIONS, PUT, PATCH, POST , and DELETE requests.
If you pick the third choice, you may need to restrict access to your Amazon S3 bucket or to your custom origin so users can't perform operations that you don't want them to. For example, you might not want users to have permissions to delete objects from your origin.
Quantity (integer) -- [REQUIRED]The number of HTTP methods that you want CloudFront to forward to your origin. Valid values are 2 (for GET and HEAD requests), 3 (for GET , HEAD , and OPTIONS requests) and 7 (for GET, HEAD, OPTIONS, PUT, PATCH, POST , and DELETE requests).
Items (list) -- [REQUIRED]A complex type that contains the HTTP methods that you want CloudFront to process and forward to your origin.
(string) --
CachedMethods (dict) --A complex type that controls whether CloudFront caches the response to requests using the specified HTTP methods. There are two choices:
CloudFront caches responses to GET and HEAD requests.
CloudFront caches responses to GET , HEAD , and OPTIONS requests.
If you pick the second choice for your Amazon S3 Origin, you may need to forward Access-Control-Request-Method, Access-Control-Request-Headers, and Origin headers for the responses to be cached correctly.
Quantity (integer) -- [REQUIRED]The number of HTTP methods for which you want CloudFront to cache responses. Valid values are 2 (for caching responses to GET and HEAD requests) and 3 (for caching responses to GET , HEAD , and OPTIONS requests).
Items (list) -- [REQUIRED]A complex type that contains the HTTP methods that you want CloudFront to cache responses to.
(string) --
SmoothStreaming (boolean) --Indicates whether you want to distribute media files in the Microsoft Smooth Streaming format using the origin that is associated with this cache behavior. If so, specify true ; if not, specify false . If you specify true for SmoothStreaming , you can still distribute other content using this cache behavior if the content matches the value of PathPattern .
DefaultTTL (integer) --The default amount of time that you want objects to stay in CloudFront caches before CloudFront forwards another request to your origin to determine whether the object has been updated. The value that you specify applies only when your origin does not add HTTP headers such as Cache-Control max-age , Cache-Control s-maxage , and Expires to objects. For more information, see Specifying How Long Objects and Errors Stay in a CloudFront Edge Cache (Expiration) in the Amazon CloudFront Developer Guide .
MaxTTL (integer) --The maximum amount of time that you want objects to stay in CloudFront caches before CloudFront forwards another request to your origin to determine whether the object has been updated. The value that you specify applies only when your origin adds HTTP headers such as Cache-Control max-age , Cache-Control s-maxage , and Expires to objects. For more information, see Specifying How Long Objects and Errors Stay in a CloudFront Edge Cache (Expiration) in the Amazon CloudFront Developer Guide .
Compress (boolean) --Whether you want CloudFront to automatically compress certain files for this cache behavior. If so, specify true; if not, specify false. For more information, see Serving Compressed Files in the Amazon CloudFront Developer Guide .
LambdaFunctionAssociations (dict) --A complex type that contains zero or more Lambda function associations for a cache behavior.
Quantity (integer) -- [REQUIRED]The number of Lambda function associations for this cache behavior.
Items (list) --
Optional : A complex type that contains LambdaFunctionAssociation items for this cache behavior. If Quantity is 0 , you can omit Items .
(dict) --A complex type that contains a Lambda function association.
LambdaFunctionARN (string) --The ARN of the Lambda function.
EventType (string) --Specifies the event type that triggers a Lambda function invocation. Valid values are:
viewer-request
origin-request
viewer-response
origin-response
CustomErrorResponses (dict) --A complex type that controls the following:
Whether CloudFront replaces HTTP status codes in the 4xx and 5xx range with custom error messages before returning the response to the viewer.
How long CloudFront caches HTTP status codes in the 4xx and 5xx range.
For more information about custom error pages, see Customizing Error Responses in the Amazon CloudFront Developer Guide .
Quantity (integer) -- [REQUIRED]The number of HTTP status codes for which you want to specify a custom error page and/or a caching duration. If Quantity is 0 , you can omit Items .
Items (list) --A complex type that contains a CustomErrorResponse element for each HTTP status code for which you want to specify a custom error page and/or a caching duration.
(dict) --A complex type that controls:
Whether CloudFront replaces HTTP status codes in the 4xx and 5xx range with custom error messages before returning the response to the viewer.
How long CloudFront caches HTTP status codes in the 4xx and 5xx range.
For more information about custom error pages, see Customizing Error Responses in the Amazon CloudFront Developer Guide .
ErrorCode (integer) -- [REQUIRED]The HTTP status code for which you want to specify a custom error page and/or a caching duration.
ResponsePagePath (string) --The path to the custom error page that you want CloudFront to return to a viewer when your origin returns the HTTP status code specified by ErrorCode , for example, /4xx-errors/403-forbidden.html . If you want to store your objects and your custom error pages in different locations, your distribution must include a cache behavior for which the following is true:
The value of PathPattern matches the path to your custom error messages. For example, suppose you saved custom error pages for 4xx errors in an Amazon S3 bucket in a directory named /4xx-errors . Your distribution must include a cache behavior for which the path pattern routes requests for your custom error pages to that location, for example, /4xx-errors/* .
The value of TargetOriginId specifies the value of the ID element for the origin that contains your custom error pages.
If you specify a value for ResponsePagePath , you must also specify a value for ResponseCode . If you don't want to specify a value, include an empty element, ResponsePagePath , in the XML document.
We recommend that you store custom error pages in an Amazon S3 bucket. If you store custom error pages on an HTTP server and the server starts to return 5xx errors, CloudFront can't get the files that you want to return to viewers because the origin server is unavailable.
ResponseCode (string) --The HTTP status code that you want CloudFront to return to the viewer along with the custom error page. There are a variety of reasons that you might want CloudFront to return a status code different from the status code that your origin returned to CloudFront, for example:
Some Internet devices (some firewalls and corporate proxies, for example) intercept HTTP 4xx and 5xx and prevent the response from being returned to the viewer. If you substitute 200 , the response typically won't be intercepted.
If you don't care about distinguishing among different client errors or server errors, you can specify 400 or 500 as the ResponseCode for all 4xx or 5xx errors.
You might want to return a 200 status code (OK) and static website so your customers don't know that your website is down.
If you specify a value for ResponseCode , you must also specify a value for ResponsePagePath . If you don't want to specify a value, include an empty element, ResponseCode , in the XML document.
ErrorCachingMinTTL (integer) --The minimum amount of time, in seconds, that you want CloudFront to cache the HTTP status code specified in ErrorCode . When this time period has elapsed, CloudFront queries your origin to see whether the problem that caused the error has been resolved and the requested object is now available.
If you don't want to specify a value, include an empty element, ErrorCachingMinTTL , in the XML document.
For more information, see Customizing Error Responses in the Amazon CloudFront Developer Guide .
Comment (string) -- [REQUIRED]Any comments you want to include about the distribution.
If you don't want to specify a comment, include an empty Comment element.
To delete an existing comment, update the distribution configuration and include an empty Comment element.
To add or change a comment, update the distribution configuration and specify the new comment.
Logging (dict) --A complex type that controls whether access logs are written for the distribution.
For more information about logging, see Access Logs in the Amazon CloudFront Developer Guide .
Enabled (boolean) -- [REQUIRED]Specifies whether you want CloudFront to save access logs to an Amazon S3 bucket. If you do not want to enable logging when you create a distribution or if you want to disable logging for an existing distribution, specify false for Enabled , and specify empty Bucket and Prefix elements. If you specify false for Enabled but you specify values for Bucket , prefix , and IncludeCookies , the values are automatically deleted.
IncludeCookies (boolean) -- [REQUIRED]Specifies whether you want CloudFront to include cookies in access logs, specify true for IncludeCookies . If you choose to include cookies in logs, CloudFront logs all cookies regardless of how you configure the cache behaviors for this distribution. If you do not want to include cookies when you create a distribution or if you want to disable include cookies for an existing distribution, specify false for IncludeCookies .
Bucket (string) -- [REQUIRED]The Amazon S3 bucket to store the access logs in, for example, myawslogbucket.s3.amazonaws.com .
Prefix (string) -- [REQUIRED]An optional string that you want CloudFront to prefix to the access log filenames for this distribution, for example, myprefix/ . If you want to enable logging, but you do not want to specify a prefix, you still must include an empty Prefix element in the Logging element.
PriceClass (string) --The price class that corresponds with the maximum price that you want to pay for CloudFront service. If you specify PriceClass_All , CloudFront responds to requests for your objects from all CloudFront edge locations.
If you specify a price class other than PriceClass_All , CloudFront serves your objects from the CloudFront edge location that has the lowest latency among the edge locations in your price class. Viewers who are in or near regions that are excluded from your specified price class may encounter slower performance.
For more information about price classes, see Choosing the Price Class for a CloudFront Distribution in the Amazon CloudFront Developer Guide . For information about CloudFront pricing, including how price classes map to CloudFront regions, see Amazon CloudFront Pricing .
Enabled (boolean) -- [REQUIRED]From this field, you can enable or disable the selected distribution.
If you specify false for Enabled but you specify values for Bucket and Prefix , the values are automatically deleted.
ViewerCertificate (dict) --A complex type that specifies the following:
Which SSL/TLS certificate to use when viewers request objects using HTTPS
Whether you want CloudFront to use dedicated IP addresses or SNI when you're using alternate domain names in your object names
The minimum protocol version that you want CloudFront to use when communicating with viewers
For more information, see Using an HTTPS Connection to Access Your Objects in the Amazon Amazon CloudFront Developer Guide .
CloudFrontDefaultCertificate (boolean) --
IAMCertificateId (string) --
ACMCertificateArn (string) --
SSLSupportMethod (string) --If you specify a value for ACMCertificateArn or for IAMCertificateId , you must also specify how you want CloudFront to serve HTTPS requests: using a method that works for all clients or one that works for most clients:
vip : CloudFront uses dedicated IP addresses for your content and can respond to HTTPS requests from any viewer. However, you will incur additional monthly charges.
sni-only : CloudFront can respond to HTTPS requests from viewers that support Server Name Indication (SNI). All modern browsers support SNI, but some browsers still in use don't support SNI. If some of your users' browsers don't support SNI, we recommend that you do one of the following:
Use the vip option (dedicated IP addresses) instead of sni-only .
Use the CloudFront SSL/TLS certificate instead of a custom certificate. This requires that you use the CloudFront domain name of your distribution in the URLs for your objects, for example, https://d111111abcdef8.cloudfront.net/logo.png .
If you can control which browser your users use, upgrade the browser to one that supports SNI.
Use HTTP instead of HTTPS.
Do not specify a value for SSLSupportMethod if you specified CloudFrontDefaultCertificatetrueCloudFrontDefaultCertificate .
For more information, see Using Alternate Domain Names and HTTPS in the Amazon CloudFront Developer Guide .
MinimumProtocolVersion (string) --Specify the minimum version of the SSL/TLS protocol that you want CloudFront to use for HTTPS connections between viewers and CloudFront: SSLv3 or TLSv1 . CloudFront serves your objects only to viewers that support SSL/TLS version that you specify and later versions. The TLSv1 protocol is more secure, so we recommend that you specify SSLv3 only if your users are using browsers or devices that don't support TLSv1 . Note the following:
If you specify CloudFrontDefaultCertificatetrueCloudFrontDefaultCertificate, the minimum SSL protocol version is TLSv1 and can't be changed.
If you're using a custom certificate (if you specify a value for ACMCertificateArn or for IAMCertificateId ) and if you're using SNI (if you specify sni-only for SSLSupportMethod ), you must specify TLSv1 for MinimumProtocolVersion .
Certificate (string) --Include one of these values to specify the following:
Whether you want viewers to use HTTP or HTTPS to request your objects.
If you want viewers to use HTTPS, whether you're using an alternate domain name such as example.com or the CloudFront domain name for your distribution, such as d111111abcdef8.cloudfront.net .
If you're using an alternate domain name, whether AWS Certificate Manager (ACM) provided the certificate, or you purchased a certificate from a third-party certificate authority and imported it into ACM or uploaded it to the IAM certificate store.
You must specify one (and only one) of the three values. Do not specify false for CloudFrontDefaultCertificate .
If you want viewers to use HTTP to request your objects : Specify the following value:CloudFrontDefaultCertificatetrueCloudFrontDefaultCertificate
In addition, specify allow-all for ViewerProtocolPolicy for all of your cache behaviors.
If you want viewers to use HTTPS to request your objects : Choose the type of certificate that you want to use based on whether you're using an alternate domain name for your objects or the CloudFront domain name:
If you're using an alternate domain name, such as example.com : Specify one of the following values, depending on whether ACM provided your certificate or you purchased your certificate from third-party certificate authority:
ACMCertificateArnARN for ACM SSL/TLS certificateACMCertificateArn where ARN for ACM SSL/TLS certificate is the ARN for the ACM SSL/TLS certificate that you want to use for this distribution.
IAMCertificateIdIAM certificate IDIAMCertificateId where IAM certificate ID is the ID that IAM returned when you added the certificate to the IAM certificate store.
If you specify ACMCertificateArn or IAMCertificateId , you must also specify a value for SSLSupportMethod .
If you choose to use an ACM certificate or a certificate in the IAM certificate store, we recommend that you use only an alternate domain name in your object URLs (https://example.com/logo.jpg ). If you use the domain name that is associated with your CloudFront distribution (https://d111111abcdef8.cloudfront.net/logo.jpg ) and the viewer supports SNI , then CloudFront behaves normally. However, if the browser does not support SNI, the user's experience depends on the value that you choose for SSLSupportMethod :
vip : The viewer displays a warning because there is a mismatch between the CloudFront domain name and the domain name in your SSL/TLS certificate.
sni-only : CloudFront drops the connection with the browser without returning the object.
**If you're using the CloudFront domain name for your distribution, such as d111111abcdef8.cloudfront.net ** : Specify the following value: `` CloudFrontDefaultCertificatetrueCloudFrontDefaultCertificate`` If you want viewers to use HTTPS, you must also specify one of the following values in your cache behaviors:
ViewerProtocolPolicyhttps-onlyViewerProtocolPolicy
ViewerProtocolPolicyredirect-to-httpsViewerProtocolPolicy
You can also optionally require that CloudFront use HTTPS to communicate with your origin by specifying one of the following values for the applicable origins:
OriginProtocolPolicyhttps-onlyOriginProtocolPolicy
OriginProtocolPolicymatch-viewerOriginProtocolPolicy
For more information, see Using Alternate Domain Names and HTTPS in the Amazon CloudFront Developer Guide .
CertificateSource (string) --
Note
This field is deprecated. You can use one of the following: [ACMCertificateArn , IAMCertificateId , or CloudFrontDefaultCertificate] .
Restrictions (dict) --A complex type that identifies ways in which you want to restrict distribution of your content.
GeoRestriction (dict) -- [REQUIRED]A complex type that controls the countries in which your content is distributed. CloudFront determines the location of your users using MaxMind GeoIP databases.
RestrictionType (string) -- [REQUIRED]The method that you want to use to restrict distribution of your content by country:
none : No geo restriction is enabled, meaning access to content is not restricted by client geo location.
blacklist : The Location elements specify the countries in which you do not want CloudFront to distribute your content.
whitelist : The Location elements specify the countries in which you want CloudFront to distribute your content.
Quantity (integer) -- [REQUIRED]When geo restriction is enabled , this is the number of countries in your whitelist or blacklist . Otherwise, when it is not enabled, Quantity is 0 , and you can omit Items .
Items (list) --A complex type that contains a Location element for each country in which you want CloudFront either to distribute your content (whitelist ) or not distribute your content (blacklist ).
The Location element is a two-letter, uppercase country code for a country that you want to include in your blacklist or whitelist . Include one Location element for each country.
CloudFront and MaxMind both use ISO 3166 country codes. For the current list of countries and the corresponding codes, see ISO 3166-1-alpha-2 code on the International Organization for Standardization website. You can also refer to the country list in the CloudFront console, which includes both country names and codes.
(string) --
WebACLId (string) --A unique identifier that specifies the AWS WAF web ACL, if any, to associate with this distribution.
AWS WAF is a web application firewall that lets you monitor the HTTP and HTTPS requests that are forwarded to CloudFront, and lets you control access to your content. Based on conditions that you specify, such as the IP addresses that requests originate from or the values of query strings, CloudFront responds to requests either with the requested content or with an HTTP 403 status code (Forbidden). You can also configure CloudFront to return a custom error page when a request is blocked. For more information about AWS WAF, see the AWS WAF Developer Guide .
HttpVersion (string) --(Optional) Specify the maximum HTTP version that you want viewers to use to communicate with CloudFront. The default value for new web distributions is http2. Viewers that don't support HTTP/2 automatically use an earlier HTTP version.
For viewers and CloudFront to use HTTP/2, viewers must support TLS 1.2 or later, and must support Server Name Identification (SNI).
In general, configuring CloudFront to communicate with viewers using HTTP/2 reduces latency. You can improve performance by optimizing for HTTP/2. For more information, do an Internet search for 'http/2 optimization.'
IsIPV6Enabled (boolean) --If you want CloudFront to respond to IPv6 DNS requests with an IPv6 address for your distribution, specify true . If you specify false , CloudFront responds to IPv6 DNS requests with the DNS response code NOERROR and with no IP addresses. This allows viewers to submit a second request, for an IPv4 address for your distribution.
In general, you should enable IPv6 if you have users on IPv6 networks who want to access your content. However, if you're using signed URLs or signed cookies to restrict access to your content, and if you're using a custom policy that includes the IpAddress parameter to restrict the IP addresses that can access your content, do not enable IPv6. If you want to restrict access to some content by IP address and not restrict access to other content (or restrict access but not by IP address), you can create two distributions. For more information, see Creating a Signed URL Using a Custom Policy in the Amazon CloudFront Developer Guide .
If you're using an Amazon Route 53 alias resource record set to route traffic to your CloudFront distribution, you need to create a second alias resource record set when both of the following are true:
You enable IPv6 for the distribution
You're using alternate domain names in the URLs for your objects
For more information, see Routing Traffic to an Amazon CloudFront Web Distribution by Using Your Domain Name in the Amazon Route 53 Developer Guide .
If you created a CNAME resource record set, either with Amazon Route 53 or with another DNS service, you don't need to make any changes. A CNAME record will route traffic to your distribution regardless of the IP address format of the viewer request.
:rtype: dict
:return: {
'Distribution': {
'Id': 'string',
'ARN': 'string',
'Status': 'string',
'LastModifiedTime': datetime(2015, 1, 1),
'InProgressInvalidationBatches': 123,
'DomainName': 'string',
'ActiveTrustedSigners': {
'Enabled': True|False,
'Quantity': 123,
'Items': [
{
'AwsAccountNumber': 'string',
'KeyPairIds': {
'Quantity': 123,
'Items': [
'string',
]
}
},
]
},
'DistributionConfig': {
'CallerReference': 'string',
'Aliases': {
'Quantity': 123,
'Items': [
'string',
]
},
'DefaultRootObject': 'string',
'Origins': {
'Quantity': 123,
'Items': [
{
'Id': 'string',
'DomainName': 'string',
'OriginPath': 'string',
'CustomHeaders': {
'Quantity': 123,
'Items': [
{
'HeaderName': 'string',
'HeaderValue': 'string'
},
]
},
'S3OriginConfig': {
'OriginAccessIdentity': 'string'
},
'CustomOriginConfig': {
'HTTPPort': 123,
'HTTPSPort': 123,
'OriginProtocolPolicy': 'http-only'|'match-viewer'|'https-only',
'OriginSslProtocols': {
'Quantity': 123,
'Items': [
'SSLv3'|'TLSv1'|'TLSv1.1'|'TLSv1.2',
]
},
'OriginReadTimeout': 123,
'OriginKeepaliveTimeout': 123
}
},
]
},
'DefaultCacheBehavior': {
'TargetOriginId': 'string',
'ForwardedValues': {
'QueryString': True|False,
'Cookies': {
'Forward': 'none'|'whitelist'|'all',
'WhitelistedNames': {
'Quantity': 123,
'Items': [
'string',
]
}
},
'Headers': {
'Quantity': 123,
'Items': [
'string',
]
},
'QueryStringCacheKeys': {
'Quantity': 123,
'Items': [
'string',
]
}
},
'TrustedSigners': {
'Enabled': True|False,
'Quantity': 123,
'Items': [
'string',
]
},
'ViewerProtocolPolicy': 'allow-all'|'https-only'|'redirect-to-https',
'MinTTL': 123,
'AllowedMethods': {
'Quantity': 123,
'Items': [
'GET'|'HEAD'|'POST'|'PUT'|'PATCH'|'OPTIONS'|'DELETE',
],
'CachedMethods': {
'Quantity': 123,
'Items': [
'GET'|'HEAD'|'POST'|'PUT'|'PATCH'|'OPTIONS'|'DELETE',
]
}
},
'SmoothStreaming': True|False,
'DefaultTTL': 123,
'MaxTTL': 123,
'Compress': True|False,
'LambdaFunctionAssociations': {
'Quantity': 123,
'Items': [
{
'LambdaFunctionARN': 'string',
'EventType': 'viewer-request'|'viewer-response'|'origin-request'|'origin-response'
},
]
}
},
'CacheBehaviors': {
'Quantity': 123,
'Items': [
{
'PathPattern': 'string',
'TargetOriginId': 'string',
'ForwardedValues': {
'QueryString': True|False,
'Cookies': {
'Forward': 'none'|'whitelist'|'all',
'WhitelistedNames': {
'Quantity': 123,
'Items': [
'string',
]
}
},
'Headers': {
'Quantity': 123,
'Items': [
'string',
]
},
'QueryStringCacheKeys': {
'Quantity': 123,
'Items': [
'string',
]
}
},
'TrustedSigners': {
'Enabled': True|False,
'Quantity': 123,
'Items': [
'string',
]
},
'ViewerProtocolPolicy': 'allow-all'|'https-only'|'redirect-to-https',
'MinTTL': 123,
'AllowedMethods': {
'Quantity': 123,
'Items': [
'GET'|'HEAD'|'POST'|'PUT'|'PATCH'|'OPTIONS'|'DELETE',
],
'CachedMethods': {
'Quantity': 123,
'Items': [
'GET'|'HEAD'|'POST'|'PUT'|'PATCH'|'OPTIONS'|'DELETE',
]
}
},
'SmoothStreaming': True|False,
'DefaultTTL': 123,
'MaxTTL': 123,
'Compress': True|False,
'LambdaFunctionAssociations': {
'Quantity': 123,
'Items': [
{
'LambdaFunctionARN': 'string',
'EventType': 'viewer-request'|'viewer-response'|'origin-request'|'origin-response'
},
]
}
},
]
},
'CustomErrorResponses': {
'Quantity': 123,
'Items': [
{
'ErrorCode': 123,
'ResponsePagePath': 'string',
'ResponseCode': 'string',
'ErrorCachingMinTTL': 123
},
]
},
'Comment': 'string',
'Logging': {
'Enabled': True|False,
'IncludeCookies': True|False,
'Bucket': 'string',
'Prefix': 'string'
},
'PriceClass': 'PriceClass_100'|'PriceClass_200'|'PriceClass_All',
'Enabled': True|False,
'ViewerCertificate': {
'CloudFrontDefaultCertificate': True|False,
'IAMCertificateId': 'string',
'ACMCertificateArn': 'string',
'SSLSupportMethod': 'sni-only'|'vip',
'MinimumProtocolVersion': 'SSLv3'|'TLSv1',
'Certificate': 'string',
'CertificateSource': 'cloudfront'|'iam'|'acm'
},
'Restrictions': {
'GeoRestriction': {
'RestrictionType': 'blacklist'|'whitelist'|'none',
'Quantity': 123,
'Items': [
'string',
]
}
},
'WebACLId': 'string',
'HttpVersion': 'http1.1'|'http2',
'IsIPV6Enabled': True|False
}
},
'Location': 'string',
'ETag': 'string'
}
:returns:
If you configured Amazon S3 Transfer Acceleration for your bucket, do not specify the s3-accelerate endpoint for DomainName .
The bucket name must be between 3 and 63 characters long (inclusive).
The bucket name must contain only lowercase characters, numbers, periods, underscores, and dashes.
The bucket name must not contain adjacent periods.
"""
pass
def create_distribution_with_tags(DistributionConfigWithTags=None):
"""
Create a new distribution with tags.
See also: AWS API Documentation
:example: response = client.create_distribution_with_tags(
DistributionConfigWithTags={
'DistributionConfig': {
'CallerReference': 'string',
'Aliases': {
'Quantity': 123,
'Items': [
'string',
]
},
'DefaultRootObject': 'string',
'Origins': {
'Quantity': 123,
'Items': [
{
'Id': 'string',
'DomainName': 'string',
'OriginPath': 'string',
'CustomHeaders': {
'Quantity': 123,
'Items': [
{
'HeaderName': 'string',
'HeaderValue': 'string'
},
]
},
'S3OriginConfig': {
'OriginAccessIdentity': 'string'
},
'CustomOriginConfig': {
'HTTPPort': 123,
'HTTPSPort': 123,
'OriginProtocolPolicy': 'http-only'|'match-viewer'|'https-only',
'OriginSslProtocols': {
'Quantity': 123,
'Items': [
'SSLv3'|'TLSv1'|'TLSv1.1'|'TLSv1.2',
]
},
'OriginReadTimeout': 123,
'OriginKeepaliveTimeout': 123
}
},
]
},
'DefaultCacheBehavior': {
'TargetOriginId': 'string',
'ForwardedValues': {
'QueryString': True|False,
'Cookies': {
'Forward': 'none'|'whitelist'|'all',
'WhitelistedNames': {
'Quantity': 123,
'Items': [
'string',
]
}
},
'Headers': {
'Quantity': 123,
'Items': [
'string',
]
},
'QueryStringCacheKeys': {
'Quantity': 123,
'Items': [
'string',
]
}
},
'TrustedSigners': {
'Enabled': True|False,
'Quantity': 123,
'Items': [
'string',
]
},
'ViewerProtocolPolicy': 'allow-all'|'https-only'|'redirect-to-https',
'MinTTL': 123,
'AllowedMethods': {
'Quantity': 123,
'Items': [
'GET'|'HEAD'|'POST'|'PUT'|'PATCH'|'OPTIONS'|'DELETE',
],
'CachedMethods': {
'Quantity': 123,
'Items': [
'GET'|'HEAD'|'POST'|'PUT'|'PATCH'|'OPTIONS'|'DELETE',
]
}
},
'SmoothStreaming': True|False,
'DefaultTTL': 123,
'MaxTTL': 123,
'Compress': True|False,
'LambdaFunctionAssociations': {
'Quantity': 123,
'Items': [
{
'LambdaFunctionARN': 'string',
'EventType': 'viewer-request'|'viewer-response'|'origin-request'|'origin-response'
},
]
}
},
'CacheBehaviors': {
'Quantity': 123,
'Items': [
{
'PathPattern': 'string',
'TargetOriginId': 'string',
'ForwardedValues': {
'QueryString': True|False,
'Cookies': {
'Forward': 'none'|'whitelist'|'all',
'WhitelistedNames': {
'Quantity': 123,
'Items': [
'string',
]
}
},
'Headers': {
'Quantity': 123,
'Items': [
'string',
]
},
'QueryStringCacheKeys': {
'Quantity': 123,
'Items': [
'string',
]
}
},
'TrustedSigners': {
'Enabled': True|False,
'Quantity': 123,
'Items': [
'string',
]
},
'ViewerProtocolPolicy': 'allow-all'|'https-only'|'redirect-to-https',
'MinTTL': 123,
'AllowedMethods': {
'Quantity': 123,
'Items': [
'GET'|'HEAD'|'POST'|'PUT'|'PATCH'|'OPTIONS'|'DELETE',
],
'CachedMethods': {
'Quantity': 123,
'Items': [
'GET'|'HEAD'|'POST'|'PUT'|'PATCH'|'OPTIONS'|'DELETE',
]
}
},
'SmoothStreaming': True|False,
'DefaultTTL': 123,
'MaxTTL': 123,
'Compress': True|False,
'LambdaFunctionAssociations': {
'Quantity': 123,
'Items': [
{
'LambdaFunctionARN': 'string',
'EventType': 'viewer-request'|'viewer-response'|'origin-request'|'origin-response'
},
]
}
},
]
},
'CustomErrorResponses': {
'Quantity': 123,
'Items': [
{
'ErrorCode': 123,
'ResponsePagePath': 'string',
'ResponseCode': 'string',
'ErrorCachingMinTTL': 123
},
]
},
'Comment': 'string',
'Logging': {
'Enabled': True|False,
'IncludeCookies': True|False,
'Bucket': 'string',
'Prefix': 'string'
},
'PriceClass': 'PriceClass_100'|'PriceClass_200'|'PriceClass_All',
'Enabled': True|False,
'ViewerCertificate': {
'CloudFrontDefaultCertificate': True|False,
'IAMCertificateId': 'string',
'ACMCertificateArn': 'string',
'SSLSupportMethod': 'sni-only'|'vip',
'MinimumProtocolVersion': 'SSLv3'|'TLSv1',
'Certificate': 'string',
'CertificateSource': 'cloudfront'|'iam'|'acm'
},
'Restrictions': {
'GeoRestriction': {
'RestrictionType': 'blacklist'|'whitelist'|'none',
'Quantity': 123,
'Items': [
'string',
]
}
},
'WebACLId': 'string',
'HttpVersion': 'http1.1'|'http2',
'IsIPV6Enabled': True|False
},
'Tags': {
'Items': [
{
'Key': 'string',
'Value': 'string'
},
]
}
}
)
:type DistributionConfigWithTags: dict
:param DistributionConfigWithTags: [REQUIRED]
The distribution's configuration information.
DistributionConfig (dict) -- [REQUIRED]A distribution configuration.
CallerReference (string) -- [REQUIRED]A unique value (for example, a date-time stamp) that ensures that the request can't be replayed.
If the value of CallerReference is new (regardless of the content of the DistributionConfig object), CloudFront creates a new distribution.
If CallerReference is a value you already sent in a previous request to create a distribution, and if the content of the DistributionConfig is identical to the original request (ignoring white space), CloudFront returns the same the response that it returned to the original request.
If CallerReference is a value you already sent in a previous request to create a distribution but the content of the DistributionConfig is different from the original request, CloudFront returns a DistributionAlreadyExists error.
Aliases (dict) --A complex type that contains information about CNAMEs (alternate domain names), if any, for this distribution.
Quantity (integer) -- [REQUIRED]The number of CNAME aliases, if any, that you want to associate with this distribution.
Items (list) --A complex type that contains the CNAME aliases, if any, that you want to associate with this distribution.
(string) --
DefaultRootObject (string) --The object that you want CloudFront to request from your origin (for example, index.html ) when a viewer requests the root URL for your distribution (http://www.example.com ) instead of an object in your distribution (http://www.example.com/product-description.html ). Specifying a default root object avoids exposing the contents of your distribution.
Specify only the object name, for example, index.html . Do not add a / before the object name.
If you don't want to specify a default root object when you create a distribution, include an empty DefaultRootObject element.
To delete the default root object from an existing distribution, update the distribution configuration and include an empty DefaultRootObject element.
To replace the default root object, update the distribution configuration and specify the new object.
For more information about the default root object, see Creating a Default Root Object in the Amazon CloudFront Developer Guide .
Origins (dict) -- [REQUIRED]A complex type that contains information about origins for this distribution.
Quantity (integer) -- [REQUIRED]The number of origins for this distribution.
Items (list) --A complex type that contains origins for this distribution.
(dict) --A complex type that describes the Amazon S3 bucket or the HTTP server (for example, a web server) from which CloudFront gets your files. You must create at least one origin.
For the current limit on the number of origins that you can create for a distribution, see Amazon CloudFront Limits in the AWS General Reference .
Id (string) -- [REQUIRED]A unique identifier for the origin. The value of Id must be unique within the distribution.
When you specify the value of TargetOriginId for the default cache behavior or for another cache behavior, you indicate the origin to which you want the cache behavior to route requests by specifying the value of the Id element for that origin. When a request matches the path pattern for that cache behavior, CloudFront routes the request to the specified origin. For more information, see Cache Behavior Settings in the Amazon CloudFront Developer Guide .
DomainName (string) -- [REQUIRED]
Amazon S3 origins : The DNS name of the Amazon S3 bucket from which you want CloudFront to get objects for this origin, for example, myawsbucket.s3.amazonaws.com .
Constraints for Amazon S3 origins:
If you configured Amazon S3 Transfer Acceleration for your bucket, do not specify the s3-accelerate endpoint for DomainName .
The bucket name must be between 3 and 63 characters long (inclusive).
The bucket name must contain only lowercase characters, numbers, periods, underscores, and dashes.
The bucket name must not contain adjacent periods.
Custom Origins : The DNS domain name for the HTTP server from which you want CloudFront to get objects for this origin, for example, www.example.com .
Constraints for custom origins:
DomainName must be a valid DNS name that contains only a-z, A-Z, 0-9, dot (.), hyphen (-), or underscore (_) characters.
The name cannot exceed 128 characters.
OriginPath (string) --An optional element that causes CloudFront to request your content from a directory in your Amazon S3 bucket or your custom origin. When you include the OriginPath element, specify the directory name, beginning with a / . CloudFront appends the directory name to the value of DomainName , for example, example.com/production . Do not include a / at the end of the directory name.
For example, suppose you've specified the following values for your distribution:
DomainName : An Amazon S3 bucket named myawsbucket .
OriginPath : /production
CNAME : example.com
When a user enters example.com/index.html in a browser, CloudFront sends a request to Amazon S3 for myawsbucket/production/index.html .
When a user enters example.com/acme/index.html in a browser, CloudFront sends a request to Amazon S3 for myawsbucket/production/acme/index.html .
CustomHeaders (dict) --A complex type that contains names and values for the custom headers that you want.
Quantity (integer) -- [REQUIRED]The number of custom headers, if any, for this distribution.
Items (list) --
Optional : A list that contains one OriginCustomHeader element for each custom header that you want CloudFront to forward to the origin. If Quantity is 0 , omit Items .
(dict) --A complex type that contains HeaderName and HeaderValue elements, if any, for this distribution.
HeaderName (string) -- [REQUIRED]The name of a header that you want CloudFront to forward to your origin. For more information, see Forwarding Custom Headers to Your Origin (Web Distributions Only) in the Amazon Amazon CloudFront Developer Guide .
HeaderValue (string) -- [REQUIRED]The value for the header that you specified in the HeaderName field.
S3OriginConfig (dict) --A complex type that contains information about the Amazon S3 origin. If the origin is a custom origin, use the CustomOriginConfig element instead.
OriginAccessIdentity (string) -- [REQUIRED]The CloudFront origin access identity to associate with the origin. Use an origin access identity to configure the origin so that viewers can only access objects in an Amazon S3 bucket through CloudFront. The format of the value is:
origin-access-identity/CloudFront/ID-of-origin-access-identity
where `` ID-of-origin-access-identity `` is the value that CloudFront returned in the ID element when you created the origin access identity.
If you want viewers to be able to access objects using either the CloudFront URL or the Amazon S3 URL, specify an empty OriginAccessIdentity element.
To delete the origin access identity from an existing distribution, update the distribution configuration and include an empty OriginAccessIdentity element.
To replace the origin access identity, update the distribution configuration and specify the new origin access identity.
For more information about the origin access identity, see Serving Private Content through CloudFront in the Amazon CloudFront Developer Guide .
CustomOriginConfig (dict) --A complex type that contains information about a custom origin. If the origin is an Amazon S3 bucket, use the S3OriginConfig element instead.
HTTPPort (integer) -- [REQUIRED]The HTTP port the custom origin listens on.
HTTPSPort (integer) -- [REQUIRED]The HTTPS port the custom origin listens on.
OriginProtocolPolicy (string) -- [REQUIRED]The origin protocol policy to apply to your origin.
OriginSslProtocols (dict) --The SSL/TLS protocols that you want CloudFront to use when communicating with your origin over HTTPS.
Quantity (integer) -- [REQUIRED]The number of SSL/TLS protocols that you want to allow CloudFront to use when establishing an HTTPS connection with this origin.
Items (list) -- [REQUIRED]A list that contains allowed SSL/TLS protocols for this distribution.
(string) --
OriginReadTimeout (integer) --You can create a custom origin read timeout. All timeout units are in seconds. The default origin read timeout is 30 seconds, but you can configure custom timeout lengths using the CloudFront API. The minimum timeout length is 4 seconds; the maximum is 60 seconds.
If you need to increase the maximum time limit, contact the AWS Support Center .
OriginKeepaliveTimeout (integer) --You can create a custom keep-alive timeout. All timeout units are in seconds. The default keep-alive timeout is 5 seconds, but you can configure custom timeout lengths using the CloudFront API. The minimum timeout length is 1 second; the maximum is 60 seconds.
If you need to increase the maximum time limit, contact the AWS Support Center .
DefaultCacheBehavior (dict) -- [REQUIRED]A complex type that describes the default cache behavior if you do not specify a CacheBehavior element or if files don't match any of the values of PathPattern in CacheBehavior elements. You must create exactly one default cache behavior.
TargetOriginId (string) -- [REQUIRED]The value of ID for the origin that you want CloudFront to route requests to when a request matches the path pattern either for a cache behavior or for the default cache behavior.
ForwardedValues (dict) -- [REQUIRED]A complex type that specifies how CloudFront handles query strings and cookies.
QueryString (boolean) -- [REQUIRED]Indicates whether you want CloudFront to forward query strings to the origin that is associated with this cache behavior and cache based on the query string parameters. CloudFront behavior depends on the value of QueryString and on the values that you specify for QueryStringCacheKeys , if any:
If you specify true for QueryString and you don't specify any values for QueryStringCacheKeys , CloudFront forwards all query string parameters to the origin and caches based on all query string parameters. Depending on how many query string parameters and values you have, this can adversely affect performance because CloudFront must forward more requests to the origin.
If you specify true for QueryString and you specify one or more values for QueryStringCacheKeys , CloudFront forwards all query string parameters to the origin, but it only caches based on the query string parameters that you specify.
If you specify false for QueryString , CloudFront doesn't forward any query string parameters to the origin, and doesn't cache based on query string parameters.
For more information, see Configuring CloudFront to Cache Based on Query String Parameters in the Amazon CloudFront Developer Guide .
Cookies (dict) -- [REQUIRED]A complex type that specifies whether you want CloudFront to forward cookies to the origin and, if so, which ones. For more information about forwarding cookies to the origin, see How CloudFront Forwards, Caches, and Logs Cookies in the Amazon CloudFront Developer Guide .
Forward (string) -- [REQUIRED]Specifies which cookies to forward to the origin for this cache behavior: all, none, or the list of cookies specified in the WhitelistedNames complex type.
Amazon S3 doesn't process cookies. When the cache behavior is forwarding requests to an Amazon S3 origin, specify none for the Forward element.
WhitelistedNames (dict) --Required if you specify whitelist for the value of Forward: . A complex type that specifies how many different cookies you want CloudFront to forward to the origin for this cache behavior and, if you want to forward selected cookies, the names of those cookies.
If you specify all or none for the value of Forward , omit WhitelistedNames . If you change the value of Forward from whitelist to all or none and you don't delete the WhitelistedNames element and its child elements, CloudFront deletes them automatically.
For the current limit on the number of cookie names that you can whitelist for each cache behavior, see Amazon CloudFront Limits in the AWS General Reference .
Quantity (integer) -- [REQUIRED]The number of different cookies that you want CloudFront to forward to the origin for this cache behavior.
Items (list) --A complex type that contains one Name element for each cookie that you want CloudFront to forward to the origin for this cache behavior.
(string) --
Headers (dict) --A complex type that specifies the Headers , if any, that you want CloudFront to vary upon for this cache behavior.
Quantity (integer) -- [REQUIRED]The number of different headers that you want CloudFront to forward to the origin for this cache behavior. You can configure each cache behavior in a web distribution to do one of the following:
Forward all headers to your origin : Specify 1 for Quantity and * for Name .
Warning
If you configure CloudFront to forward all headers to your origin, CloudFront doesn't cache the objects associated with this cache behavior. Instead, it sends every request to the origin.
Forward a whitelist of headers you specify : Specify the number of headers that you want to forward, and specify the header names in Name elements. CloudFront caches your objects based on the values in all of the specified headers. CloudFront also forwards the headers that it forwards by default, but it caches your objects based only on the headers that you specify.
Forward only the default headers : Specify 0 for Quantity and omit Items . In this configuration, CloudFront doesn't cache based on the values in the request headers.
Items (list) --A complex type that contains one Name element for each header that you want CloudFront to forward to the origin and to vary on for this cache behavior. If Quantity is 0 , omit Items .
(string) --
QueryStringCacheKeys (dict) --A complex type that contains information about the query string parameters that you want CloudFront to use for caching for this cache behavior.
Quantity (integer) -- [REQUIRED]The number of whitelisted query string parameters for this cache behavior.
Items (list) --(Optional) A list that contains the query string parameters that you want CloudFront to use as a basis for caching for this cache behavior. If Quantity is 0, you can omit Items .
(string) --
TrustedSigners (dict) -- [REQUIRED]A complex type that specifies the AWS accounts, if any, that you want to allow to create signed URLs for private content.
If you want to require signed URLs in requests for objects in the target origin that match the PathPattern for this cache behavior, specify true for Enabled , and specify the applicable values for Quantity and Items . For more information, see Serving Private Content through CloudFront in the Amazon Amazon CloudFront Developer Guide .
If you don't want to require signed URLs in requests for objects that match PathPattern , specify false for Enabled and 0 for Quantity . Omit Items .
To add, change, or remove one or more trusted signers, change Enabled to true (if it's currently false ), change Quantity as applicable, and specify all of the trusted signers that you want to include in the updated distribution.
Enabled (boolean) -- [REQUIRED]Specifies whether you want to require viewers to use signed URLs to access the files specified by PathPattern and TargetOriginId .
Quantity (integer) -- [REQUIRED]The number of trusted signers for this cache behavior.
Items (list) --
Optional : A complex type that contains trusted signers for this cache behavior. If Quantity is 0 , you can omit Items .
(string) --
ViewerProtocolPolicy (string) -- [REQUIRED]The protocol that viewers can use to access the files in the origin specified by TargetOriginId when a request matches the path pattern in PathPattern . You can specify the following options:
allow-all : Viewers can use HTTP or HTTPS.
redirect-to-https : If a viewer submits an HTTP request, CloudFront returns an HTTP status code of 301 (Moved Permanently) to the viewer along with the HTTPS URL. The viewer then resubmits the request using the new URL.
https-only : If a viewer sends an HTTP request, CloudFront returns an HTTP status code of 403 (Forbidden).
For more information about requiring the HTTPS protocol, see Using an HTTPS Connection to Access Your Objects in the Amazon CloudFront Developer Guide .
Note
The only way to guarantee that viewers retrieve an object that was fetched from the origin using HTTPS is never to use any other protocol to fetch the object. If you have recently changed from HTTP to HTTPS, we recommend that you clear your objects' cache because cached objects are protocol agnostic. That means that an edge location will return an object from the cache regardless of whether the current request protocol matches the protocol used previously. For more information, see Specifying How Long Objects and Errors Stay in a CloudFront Edge Cache (Expiration) in the Amazon CloudFront Developer Guide .
MinTTL (integer) -- [REQUIRED]The minimum amount of time that you want objects to stay in CloudFront caches before CloudFront forwards another request to your origin to determine whether the object has been updated. For more information, see Specifying How Long Objects and Errors Stay in a CloudFront Edge Cache (Expiration) in the Amazon Amazon CloudFront Developer Guide .
You must specify 0 for MinTTL if you configure CloudFront to forward all headers to your origin (under Headers , if you specify 1 for Quantity and * for Name ).
AllowedMethods (dict) --A complex type that controls which HTTP methods CloudFront processes and forwards to your Amazon S3 bucket or your custom origin. There are three choices:
CloudFront forwards only GET and HEAD requests.
CloudFront forwards only GET , HEAD , and OPTIONS requests.
CloudFront forwards GET, HEAD, OPTIONS, PUT, PATCH, POST , and DELETE requests.
If you pick the third choice, you may need to restrict access to your Amazon S3 bucket or to your custom origin so users can't perform operations that you don't want them to. For example, you might not want users to have permissions to delete objects from your origin.
Quantity (integer) -- [REQUIRED]The number of HTTP methods that you want CloudFront to forward to your origin. Valid values are 2 (for GET and HEAD requests), 3 (for GET , HEAD , and OPTIONS requests) and 7 (for GET, HEAD, OPTIONS, PUT, PATCH, POST , and DELETE requests).
Items (list) -- [REQUIRED]A complex type that contains the HTTP methods that you want CloudFront to process and forward to your origin.
(string) --
CachedMethods (dict) --A complex type that controls whether CloudFront caches the response to requests using the specified HTTP methods. There are two choices:
CloudFront caches responses to GET and HEAD requests.
CloudFront caches responses to GET , HEAD , and OPTIONS requests.
If you pick the second choice for your Amazon S3 Origin, you may need to forward Access-Control-Request-Method, Access-Control-Request-Headers, and Origin headers for the responses to be cached correctly.
Quantity (integer) -- [REQUIRED]The number of HTTP methods for which you want CloudFront to cache responses. Valid values are 2 (for caching responses to GET and HEAD requests) and 3 (for caching responses to GET , HEAD , and OPTIONS requests).
Items (list) -- [REQUIRED]A complex type that contains the HTTP methods that you want CloudFront to cache responses to.
(string) --
SmoothStreaming (boolean) --Indicates whether you want to distribute media files in the Microsoft Smooth Streaming format using the origin that is associated with this cache behavior. If so, specify true ; if not, specify false . If you specify true for SmoothStreaming , you can still distribute other content using this cache behavior if the content matches the value of PathPattern .
DefaultTTL (integer) --The default amount of time that you want objects to stay in CloudFront caches before CloudFront forwards another request to your origin to determine whether the object has been updated. The value that you specify applies only when your origin does not add HTTP headers such as Cache-Control max-age , Cache-Control s-maxage , and Expires to objects. For more information, see Specifying How Long Objects and Errors Stay in a CloudFront Edge Cache (Expiration) in the Amazon CloudFront Developer Guide .
MaxTTL (integer) --
Compress (boolean) --Whether you want CloudFront to automatically compress certain files for this cache behavior. If so, specify true ; if not, specify false . For more information, see Serving Compressed Files in the Amazon CloudFront Developer Guide .
LambdaFunctionAssociations (dict) --A complex type that contains zero or more Lambda function associations for a cache behavior.
Quantity (integer) -- [REQUIRED]The number of Lambda function associations for this cache behavior.
Items (list) --
Optional : A complex type that contains LambdaFunctionAssociation items for this cache behavior. If Quantity is 0 , you can omit Items .
(dict) --A complex type that contains a Lambda function association.
LambdaFunctionARN (string) --The ARN of the Lambda function.
EventType (string) --Specifies the event type that triggers a Lambda function invocation. Valid values are:
viewer-request
origin-request
viewer-response
origin-response
CacheBehaviors (dict) --A complex type that contains zero or more CacheBehavior elements.
Quantity (integer) -- [REQUIRED]The number of cache behaviors for this distribution.
Items (list) --Optional: A complex type that contains cache behaviors for this distribution. If Quantity is 0 , you can omit Items .
(dict) --A complex type that describes how CloudFront processes requests.
You must create at least as many cache behaviors (including the default cache behavior) as you have origins if you want CloudFront to distribute objects from all of the origins. Each cache behavior specifies the one origin from which you want CloudFront to get objects. If you have two origins and only the default cache behavior, the default cache behavior will cause CloudFront to get objects from one of the origins, but the other origin is never used.
For the current limit on the number of cache behaviors that you can add to a distribution, see Amazon CloudFront Limits in the AWS General Reference .
If you don't want to specify any cache behaviors, include only an empty CacheBehaviors element. Don't include an empty CacheBehavior element, or CloudFront returns a MalformedXML error.
To delete all cache behaviors in an existing distribution, update the distribution configuration and include only an empty CacheBehaviors element.
To add, change, or remove one or more cache behaviors, update the distribution configuration and specify all of the cache behaviors that you want to include in the updated distribution.
For more information about cache behaviors, see Cache Behaviors in the Amazon CloudFront Developer Guide .
PathPattern (string) -- [REQUIRED]The pattern (for example, images/*.jpg ) that specifies which requests to apply the behavior to. When CloudFront receives a viewer request, the requested path is compared with path patterns in the order in which cache behaviors are listed in the distribution.
Note
You can optionally include a slash (/ ) at the beginning of the path pattern. For example, /images/*.jpg . CloudFront behavior is the same with or without the leading / .
The path pattern for the default cache behavior is * and cannot be changed. If the request for an object does not match the path pattern for any cache behaviors, CloudFront applies the behavior in the default cache behavior.
For more information, see Path Pattern in the Amazon CloudFront Developer Guide .
TargetOriginId (string) -- [REQUIRED]The value of ID for the origin that you want CloudFront to route requests to when a request matches the path pattern either for a cache behavior or for the default cache behavior.
ForwardedValues (dict) -- [REQUIRED]A complex type that specifies how CloudFront handles query strings and cookies.
QueryString (boolean) -- [REQUIRED]Indicates whether you want CloudFront to forward query strings to the origin that is associated with this cache behavior and cache based on the query string parameters. CloudFront behavior depends on the value of QueryString and on the values that you specify for QueryStringCacheKeys , if any:
If you specify true for QueryString and you don't specify any values for QueryStringCacheKeys , CloudFront forwards all query string parameters to the origin and caches based on all query string parameters. Depending on how many query string parameters and values you have, this can adversely affect performance because CloudFront must forward more requests to the origin.
If you specify true for QueryString and you specify one or more values for QueryStringCacheKeys , CloudFront forwards all query string parameters to the origin, but it only caches based on the query string parameters that you specify.
If you specify false for QueryString , CloudFront doesn't forward any query string parameters to the origin, and doesn't cache based on query string parameters.
For more information, see Configuring CloudFront to Cache Based on Query String Parameters in the Amazon CloudFront Developer Guide .
Cookies (dict) -- [REQUIRED]A complex type that specifies whether you want CloudFront to forward cookies to the origin and, if so, which ones. For more information about forwarding cookies to the origin, see How CloudFront Forwards, Caches, and Logs Cookies in the Amazon CloudFront Developer Guide .
Forward (string) -- [REQUIRED]Specifies which cookies to forward to the origin for this cache behavior: all, none, or the list of cookies specified in the WhitelistedNames complex type.
Amazon S3 doesn't process cookies. When the cache behavior is forwarding requests to an Amazon S3 origin, specify none for the Forward element.
WhitelistedNames (dict) --Required if you specify whitelist for the value of Forward: . A complex type that specifies how many different cookies you want CloudFront to forward to the origin for this cache behavior and, if you want to forward selected cookies, the names of those cookies.
If you specify all or none for the value of Forward , omit WhitelistedNames . If you change the value of Forward from whitelist to all or none and you don't delete the WhitelistedNames element and its child elements, CloudFront deletes them automatically.
For the current limit on the number of cookie names that you can whitelist for each cache behavior, see Amazon CloudFront Limits in the AWS General Reference .
Quantity (integer) -- [REQUIRED]The number of different cookies that you want CloudFront to forward to the origin for this cache behavior.
Items (list) --A complex type that contains one Name element for each cookie that you want CloudFront to forward to the origin for this cache behavior.
(string) --
Headers (dict) --A complex type that specifies the Headers , if any, that you want CloudFront to vary upon for this cache behavior.
Quantity (integer) -- [REQUIRED]The number of different headers that you want CloudFront to forward to the origin for this cache behavior. You can configure each cache behavior in a web distribution to do one of the following:
Forward all headers to your origin : Specify 1 for Quantity and * for Name .
Warning
If you configure CloudFront to forward all headers to your origin, CloudFront doesn't cache the objects associated with this cache behavior. Instead, it sends every request to the origin.
Forward a whitelist of headers you specify : Specify the number of headers that you want to forward, and specify the header names in Name elements. CloudFront caches your objects based on the values in all of the specified headers. CloudFront also forwards the headers that it forwards by default, but it caches your objects based only on the headers that you specify.
Forward only the default headers : Specify 0 for Quantity and omit Items . In this configuration, CloudFront doesn't cache based on the values in the request headers.
Items (list) --A complex type that contains one Name element for each header that you want CloudFront to forward to the origin and to vary on for this cache behavior. If Quantity is 0 , omit Items .
(string) --
QueryStringCacheKeys (dict) --A complex type that contains information about the query string parameters that you want CloudFront to use for caching for this cache behavior.
Quantity (integer) -- [REQUIRED]The number of whitelisted query string parameters for this cache behavior.
Items (list) --(Optional) A list that contains the query string parameters that you want CloudFront to use as a basis for caching for this cache behavior. If Quantity is 0, you can omit Items .
(string) --
TrustedSigners (dict) -- [REQUIRED]A complex type that specifies the AWS accounts, if any, that you want to allow to create signed URLs for private content.
If you want to require signed URLs in requests for objects in the target origin that match the PathPattern for this cache behavior, specify true for Enabled , and specify the applicable values for Quantity and Items . For more information, see Serving Private Content through CloudFront in the Amazon Amazon CloudFront Developer Guide .
If you don't want to require signed URLs in requests for objects that match PathPattern , specify false for Enabled and 0 for Quantity . Omit Items .
To add, change, or remove one or more trusted signers, change Enabled to true (if it's currently false ), change Quantity as applicable, and specify all of the trusted signers that you want to include in the updated distribution.
Enabled (boolean) -- [REQUIRED]Specifies whether you want to require viewers to use signed URLs to access the files specified by PathPattern and TargetOriginId .
Quantity (integer) -- [REQUIRED]The number of trusted signers for this cache behavior.
Items (list) --
Optional : A complex type that contains trusted signers for this cache behavior. If Quantity is 0 , you can omit Items .
(string) --
ViewerProtocolPolicy (string) -- [REQUIRED]The protocol that viewers can use to access the files in the origin specified by TargetOriginId when a request matches the path pattern in PathPattern . You can specify the following options:
allow-all : Viewers can use HTTP or HTTPS.
redirect-to-https : If a viewer submits an HTTP request, CloudFront returns an HTTP status code of 301 (Moved Permanently) to the viewer along with the HTTPS URL. The viewer then resubmits the request using the new URL.
https-only : If a viewer sends an HTTP request, CloudFront returns an HTTP status code of 403 (Forbidden).
For more information about requiring the HTTPS protocol, see Using an HTTPS Connection to Access Your Objects in the Amazon CloudFront Developer Guide .
Note
The only way to guarantee that viewers retrieve an object that was fetched from the origin using HTTPS is never to use any other protocol to fetch the object. If you have recently changed from HTTP to HTTPS, we recommend that you clear your objects' cache because cached objects are protocol agnostic. That means that an edge location will return an object from the cache regardless of whether the current request protocol matches the protocol used previously. For more information, see Specifying How Long Objects and Errors Stay in a CloudFront Edge Cache (Expiration) in the Amazon CloudFront Developer Guide .
MinTTL (integer) -- [REQUIRED]The minimum amount of time that you want objects to stay in CloudFront caches before CloudFront forwards another request to your origin to determine whether the object has been updated. For more information, see Specifying How Long Objects and Errors Stay in a CloudFront Edge Cache (Expiration) in the Amazon Amazon CloudFront Developer Guide .
You must specify 0 for MinTTL if you configure CloudFront to forward all headers to your origin (under Headers , if you specify 1 for Quantity and * for Name ).
AllowedMethods (dict) --A complex type that controls which HTTP methods CloudFront processes and forwards to your Amazon S3 bucket or your custom origin. There are three choices:
CloudFront forwards only GET and HEAD requests.
CloudFront forwards only GET , HEAD , and OPTIONS requests.
CloudFront forwards GET, HEAD, OPTIONS, PUT, PATCH, POST , and DELETE requests.
If you pick the third choice, you may need to restrict access to your Amazon S3 bucket or to your custom origin so users can't perform operations that you don't want them to. For example, you might not want users to have permissions to delete objects from your origin.
Quantity (integer) -- [REQUIRED]The number of HTTP methods that you want CloudFront to forward to your origin. Valid values are 2 (for GET and HEAD requests), 3 (for GET , HEAD , and OPTIONS requests) and 7 (for GET, HEAD, OPTIONS, PUT, PATCH, POST , and DELETE requests).
Items (list) -- [REQUIRED]A complex type that contains the HTTP methods that you want CloudFront to process and forward to your origin.
(string) --
CachedMethods (dict) --A complex type that controls whether CloudFront caches the response to requests using the specified HTTP methods. There are two choices:
CloudFront caches responses to GET and HEAD requests.
CloudFront caches responses to GET , HEAD , and OPTIONS requests.
If you pick the second choice for your Amazon S3 Origin, you may need to forward Access-Control-Request-Method, Access-Control-Request-Headers, and Origin headers for the responses to be cached correctly.
Quantity (integer) -- [REQUIRED]The number of HTTP methods for which you want CloudFront to cache responses. Valid values are 2 (for caching responses to GET and HEAD requests) and 3 (for caching responses to GET , HEAD , and OPTIONS requests).
Items (list) -- [REQUIRED]A complex type that contains the HTTP methods that you want CloudFront to cache responses to.
(string) --
SmoothStreaming (boolean) --Indicates whether you want to distribute media files in the Microsoft Smooth Streaming format using the origin that is associated with this cache behavior. If so, specify true ; if not, specify false . If you specify true for SmoothStreaming , you can still distribute other content using this cache behavior if the content matches the value of PathPattern .
DefaultTTL (integer) --The default amount of time that you want objects to stay in CloudFront caches before CloudFront forwards another request to your origin to determine whether the object has been updated. The value that you specify applies only when your origin does not add HTTP headers such as Cache-Control max-age , Cache-Control s-maxage , and Expires to objects. For more information, see Specifying How Long Objects and Errors Stay in a CloudFront Edge Cache (Expiration) in the Amazon CloudFront Developer Guide .
MaxTTL (integer) --The maximum amount of time that you want objects to stay in CloudFront caches before CloudFront forwards another request to your origin to determine whether the object has been updated. The value that you specify applies only when your origin adds HTTP headers such as Cache-Control max-age , Cache-Control s-maxage , and Expires to objects. For more information, see Specifying How Long Objects and Errors Stay in a CloudFront Edge Cache (Expiration) in the Amazon CloudFront Developer Guide .
Compress (boolean) --Whether you want CloudFront to automatically compress certain files for this cache behavior. If so, specify true; if not, specify false. For more information, see Serving Compressed Files in the Amazon CloudFront Developer Guide .
LambdaFunctionAssociations (dict) --A complex type that contains zero or more Lambda function associations for a cache behavior.
Quantity (integer) -- [REQUIRED]The number of Lambda function associations for this cache behavior.
Items (list) --
Optional : A complex type that contains LambdaFunctionAssociation items for this cache behavior. If Quantity is 0 , you can omit Items .
(dict) --A complex type that contains a Lambda function association.
LambdaFunctionARN (string) --The ARN of the Lambda function.
EventType (string) --Specifies the event type that triggers a Lambda function invocation. Valid values are:
viewer-request
origin-request
viewer-response
origin-response
CustomErrorResponses (dict) --A complex type that controls the following:
Whether CloudFront replaces HTTP status codes in the 4xx and 5xx range with custom error messages before returning the response to the viewer.
How long CloudFront caches HTTP status codes in the 4xx and 5xx range.
For more information about custom error pages, see Customizing Error Responses in the Amazon CloudFront Developer Guide .
Quantity (integer) -- [REQUIRED]The number of HTTP status codes for which you want to specify a custom error page and/or a caching duration. If Quantity is 0 , you can omit Items .
Items (list) --A complex type that contains a CustomErrorResponse element for each HTTP status code for which you want to specify a custom error page and/or a caching duration.
(dict) --A complex type that controls:
Whether CloudFront replaces HTTP status codes in the 4xx and 5xx range with custom error messages before returning the response to the viewer.
How long CloudFront caches HTTP status codes in the 4xx and 5xx range.
For more information about custom error pages, see Customizing Error Responses in the Amazon CloudFront Developer Guide .
ErrorCode (integer) -- [REQUIRED]The HTTP status code for which you want to specify a custom error page and/or a caching duration.
ResponsePagePath (string) --The path to the custom error page that you want CloudFront to return to a viewer when your origin returns the HTTP status code specified by ErrorCode , for example, /4xx-errors/403-forbidden.html . If you want to store your objects and your custom error pages in different locations, your distribution must include a cache behavior for which the following is true:
The value of PathPattern matches the path to your custom error messages. For example, suppose you saved custom error pages for 4xx errors in an Amazon S3 bucket in a directory named /4xx-errors . Your distribution must include a cache behavior for which the path pattern routes requests for your custom error pages to that location, for example, /4xx-errors/* .
The value of TargetOriginId specifies the value of the ID element for the origin that contains your custom error pages.
If you specify a value for ResponsePagePath , you must also specify a value for ResponseCode . If you don't want to specify a value, include an empty element, ResponsePagePath , in the XML document.
We recommend that you store custom error pages in an Amazon S3 bucket. If you store custom error pages on an HTTP server and the server starts to return 5xx errors, CloudFront can't get the files that you want to return to viewers because the origin server is unavailable.
ResponseCode (string) --The HTTP status code that you want CloudFront to return to the viewer along with the custom error page. There are a variety of reasons that you might want CloudFront to return a status code different from the status code that your origin returned to CloudFront, for example:
Some Internet devices (some firewalls and corporate proxies, for example) intercept HTTP 4xx and 5xx and prevent the response from being returned to the viewer. If you substitute 200 , the response typically won't be intercepted.
If you don't care about distinguishing among different client errors or server errors, you can specify 400 or 500 as the ResponseCode for all 4xx or 5xx errors.
You might want to return a 200 status code (OK) and static website so your customers don't know that your website is down.
If you specify a value for ResponseCode , you must also specify a value for ResponsePagePath . If you don't want to specify a value, include an empty element, ResponseCode , in the XML document.
ErrorCachingMinTTL (integer) --The minimum amount of time, in seconds, that you want CloudFront to cache the HTTP status code specified in ErrorCode . When this time period has elapsed, CloudFront queries your origin to see whether the problem that caused the error has been resolved and the requested object is now available.
If you don't want to specify a value, include an empty element, ErrorCachingMinTTL , in the XML document.
For more information, see Customizing Error Responses in the Amazon CloudFront Developer Guide .
Comment (string) -- [REQUIRED]Any comments you want to include about the distribution.
If you don't want to specify a comment, include an empty Comment element.
To delete an existing comment, update the distribution configuration and include an empty Comment element.
To add or change a comment, update the distribution configuration and specify the new comment.
Logging (dict) --A complex type that controls whether access logs are written for the distribution.
For more information about logging, see Access Logs in the Amazon CloudFront Developer Guide .
Enabled (boolean) -- [REQUIRED]Specifies whether you want CloudFront to save access logs to an Amazon S3 bucket. If you do not want to enable logging when you create a distribution or if you want to disable logging for an existing distribution, specify false for Enabled , and specify empty Bucket and Prefix elements. If you specify false for Enabled but you specify values for Bucket , prefix , and IncludeCookies , the values are automatically deleted.
IncludeCookies (boolean) -- [REQUIRED]Specifies whether you want CloudFront to include cookies in access logs, specify true for IncludeCookies . If you choose to include cookies in logs, CloudFront logs all cookies regardless of how you configure the cache behaviors for this distribution. If you do not want to include cookies when you create a distribution or if you want to disable include cookies for an existing distribution, specify false for IncludeCookies .
Bucket (string) -- [REQUIRED]The Amazon S3 bucket to store the access logs in, for example, myawslogbucket.s3.amazonaws.com .
Prefix (string) -- [REQUIRED]An optional string that you want CloudFront to prefix to the access log filenames for this distribution, for example, myprefix/ . If you want to enable logging, but you do not want to specify a prefix, you still must include an empty Prefix element in the Logging element.
PriceClass (string) --The price class that corresponds with the maximum price that you want to pay for CloudFront service. If you specify PriceClass_All , CloudFront responds to requests for your objects from all CloudFront edge locations.
If you specify a price class other than PriceClass_All , CloudFront serves your objects from the CloudFront edge location that has the lowest latency among the edge locations in your price class. Viewers who are in or near regions that are excluded from your specified price class may encounter slower performance.
For more information about price classes, see Choosing the Price Class for a CloudFront Distribution in the Amazon CloudFront Developer Guide . For information about CloudFront pricing, including how price classes map to CloudFront regions, see Amazon CloudFront Pricing .
Enabled (boolean) -- [REQUIRED]From this field, you can enable or disable the selected distribution.
If you specify false for Enabled but you specify values for Bucket and Prefix , the values are automatically deleted.
ViewerCertificate (dict) --A complex type that specifies the following:
Which SSL/TLS certificate to use when viewers request objects using HTTPS
Whether you want CloudFront to use dedicated IP addresses or SNI when you're using alternate domain names in your object names
The minimum protocol version that you want CloudFront to use when communicating with viewers
For more information, see Using an HTTPS Connection to Access Your Objects in the Amazon Amazon CloudFront Developer Guide .
CloudFrontDefaultCertificate (boolean) --
IAMCertificateId (string) --
ACMCertificateArn (string) --
SSLSupportMethod (string) --If you specify a value for ACMCertificateArn or for IAMCertificateId , you must also specify how you want CloudFront to serve HTTPS requests: using a method that works for all clients or one that works for most clients:
vip : CloudFront uses dedicated IP addresses for your content and can respond to HTTPS requests from any viewer. However, you will incur additional monthly charges.
sni-only : CloudFront can respond to HTTPS requests from viewers that support Server Name Indication (SNI). All modern browsers support SNI, but some browsers still in use don't support SNI. If some of your users' browsers don't support SNI, we recommend that you do one of the following:
Use the vip option (dedicated IP addresses) instead of sni-only .
Use the CloudFront SSL/TLS certificate instead of a custom certificate. This requires that you use the CloudFront domain name of your distribution in the URLs for your objects, for example, https://d111111abcdef8.cloudfront.net/logo.png .
If you can control which browser your users use, upgrade the browser to one that supports SNI.
Use HTTP instead of HTTPS.
Do not specify a value for SSLSupportMethod if you specified CloudFrontDefaultCertificatetrueCloudFrontDefaultCertificate .
For more information, see Using Alternate Domain Names and HTTPS in the Amazon CloudFront Developer Guide .
MinimumProtocolVersion (string) --Specify the minimum version of the SSL/TLS protocol that you want CloudFront to use for HTTPS connections between viewers and CloudFront: SSLv3 or TLSv1 . CloudFront serves your objects only to viewers that support SSL/TLS version that you specify and later versions. The TLSv1 protocol is more secure, so we recommend that you specify SSLv3 only if your users are using browsers or devices that don't support TLSv1 . Note the following:
If you specify CloudFrontDefaultCertificatetrueCloudFrontDefaultCertificate, the minimum SSL protocol version is TLSv1 and can't be changed.
If you're using a custom certificate (if you specify a value for ACMCertificateArn or for IAMCertificateId ) and if you're using SNI (if you specify sni-only for SSLSupportMethod ), you must specify TLSv1 for MinimumProtocolVersion .
Certificate (string) --Include one of these values to specify the following:
Whether you want viewers to use HTTP or HTTPS to request your objects.
If you want viewers to use HTTPS, whether you're using an alternate domain name such as example.com or the CloudFront domain name for your distribution, such as d111111abcdef8.cloudfront.net .
If you're using an alternate domain name, whether AWS Certificate Manager (ACM) provided the certificate, or you purchased a certificate from a third-party certificate authority and imported it into ACM or uploaded it to the IAM certificate store.
You must specify one (and only one) of the three values. Do not specify false for CloudFrontDefaultCertificate .
If you want viewers to use HTTP to request your objects : Specify the following value:CloudFrontDefaultCertificatetrueCloudFrontDefaultCertificate
In addition, specify allow-all for ViewerProtocolPolicy for all of your cache behaviors.
If you want viewers to use HTTPS to request your objects : Choose the type of certificate that you want to use based on whether you're using an alternate domain name for your objects or the CloudFront domain name:
If you're using an alternate domain name, such as example.com : Specify one of the following values, depending on whether ACM provided your certificate or you purchased your certificate from third-party certificate authority:
ACMCertificateArnARN for ACM SSL/TLS certificateACMCertificateArn where ARN for ACM SSL/TLS certificate is the ARN for the ACM SSL/TLS certificate that you want to use for this distribution.
IAMCertificateIdIAM certificate IDIAMCertificateId where IAM certificate ID is the ID that IAM returned when you added the certificate to the IAM certificate store.
If you specify ACMCertificateArn or IAMCertificateId , you must also specify a value for SSLSupportMethod .
If you choose to use an ACM certificate or a certificate in the IAM certificate store, we recommend that you use only an alternate domain name in your object URLs (https://example.com/logo.jpg ). If you use the domain name that is associated with your CloudFront distribution (https://d111111abcdef8.cloudfront.net/logo.jpg ) and the viewer supports SNI , then CloudFront behaves normally. However, if the browser does not support SNI, the user's experience depends on the value that you choose for SSLSupportMethod :
vip : The viewer displays a warning because there is a mismatch between the CloudFront domain name and the domain name in your SSL/TLS certificate.
sni-only : CloudFront drops the connection with the browser without returning the object.
**If you're using the CloudFront domain name for your distribution, such as d111111abcdef8.cloudfront.net ** : Specify the following value: `` CloudFrontDefaultCertificatetrueCloudFrontDefaultCertificate`` If you want viewers to use HTTPS, you must also specify one of the following values in your cache behaviors:
ViewerProtocolPolicyhttps-onlyViewerProtocolPolicy
ViewerProtocolPolicyredirect-to-httpsViewerProtocolPolicy
You can also optionally require that CloudFront use HTTPS to communicate with your origin by specifying one of the following values for the applicable origins:
OriginProtocolPolicyhttps-onlyOriginProtocolPolicy
OriginProtocolPolicymatch-viewerOriginProtocolPolicy
For more information, see Using Alternate Domain Names and HTTPS in the Amazon CloudFront Developer Guide .
CertificateSource (string) --
Note
This field is deprecated. You can use one of the following: [ACMCertificateArn , IAMCertificateId , or CloudFrontDefaultCertificate] .
Restrictions (dict) --A complex type that identifies ways in which you want to restrict distribution of your content.
GeoRestriction (dict) -- [REQUIRED]A complex type that controls the countries in which your content is distributed. CloudFront determines the location of your users using MaxMind GeoIP databases.
RestrictionType (string) -- [REQUIRED]The method that you want to use to restrict distribution of your content by country:
none : No geo restriction is enabled, meaning access to content is not restricted by client geo location.
blacklist : The Location elements specify the countries in which you do not want CloudFront to distribute your content.
whitelist : The Location elements specify the countries in which you want CloudFront to distribute your content.
Quantity (integer) -- [REQUIRED]When geo restriction is enabled , this is the number of countries in your whitelist or blacklist . Otherwise, when it is not enabled, Quantity is 0 , and you can omit Items .
Items (list) --A complex type that contains a Location element for each country in which you want CloudFront either to distribute your content (whitelist ) or not distribute your content (blacklist ).
The Location element is a two-letter, uppercase country code for a country that you want to include in your blacklist or whitelist . Include one Location element for each country.
CloudFront and MaxMind both use ISO 3166 country codes. For the current list of countries and the corresponding codes, see ISO 3166-1-alpha-2 code on the International Organization for Standardization website. You can also refer to the country list in the CloudFront console, which includes both country names and codes.
(string) --
WebACLId (string) --A unique identifier that specifies the AWS WAF web ACL, if any, to associate with this distribution.
AWS WAF is a web application firewall that lets you monitor the HTTP and HTTPS requests that are forwarded to CloudFront, and lets you control access to your content. Based on conditions that you specify, such as the IP addresses that requests originate from or the values of query strings, CloudFront responds to requests either with the requested content or with an HTTP 403 status code (Forbidden). You can also configure CloudFront to return a custom error page when a request is blocked. For more information about AWS WAF, see the AWS WAF Developer Guide .
HttpVersion (string) --(Optional) Specify the maximum HTTP version that you want viewers to use to communicate with CloudFront. The default value for new web distributions is http2. Viewers that don't support HTTP/2 automatically use an earlier HTTP version.
For viewers and CloudFront to use HTTP/2, viewers must support TLS 1.2 or later, and must support Server Name Identification (SNI).
In general, configuring CloudFront to communicate with viewers using HTTP/2 reduces latency. You can improve performance by optimizing for HTTP/2. For more information, do an Internet search for 'http/2 optimization.'
IsIPV6Enabled (boolean) --If you want CloudFront to respond to IPv6 DNS requests with an IPv6 address for your distribution, specify true . If you specify false , CloudFront responds to IPv6 DNS requests with the DNS response code NOERROR and with no IP addresses. This allows viewers to submit a second request, for an IPv4 address for your distribution.
In general, you should enable IPv6 if you have users on IPv6 networks who want to access your content. However, if you're using signed URLs or signed cookies to restrict access to your content, and if you're using a custom policy that includes the IpAddress parameter to restrict the IP addresses that can access your content, do not enable IPv6. If you want to restrict access to some content by IP address and not restrict access to other content (or restrict access but not by IP address), you can create two distributions. For more information, see Creating a Signed URL Using a Custom Policy in the Amazon CloudFront Developer Guide .
If you're using an Amazon Route 53 alias resource record set to route traffic to your CloudFront distribution, you need to create a second alias resource record set when both of the following are true:
You enable IPv6 for the distribution
You're using alternate domain names in the URLs for your objects
For more information, see Routing Traffic to an Amazon CloudFront Web Distribution by Using Your Domain Name in the Amazon Route 53 Developer Guide .
If you created a CNAME resource record set, either with Amazon Route 53 or with another DNS service, you don't need to make any changes. A CNAME record will route traffic to your distribution regardless of the IP address format of the viewer request.
Tags (dict) -- [REQUIRED]A complex type that contains zero or more Tag elements.
Items (list) --A complex type that contains Tag elements.
(dict) --A complex type that contains Tag key and Tag value.
Key (string) -- [REQUIRED]A string that contains Tag key.
The string length should be between 1 and 128 characters. Valid characters include a-z , A-Z , 0-9 , space, and the special characters _ - . : / = + @ .
Value (string) --A string that contains an optional Tag value.
The string length should be between 0 and 256 characters. Valid characters include a-z , A-Z , 0-9 , space, and the special characters _ - . : / = + @ .
:rtype: dict
:return: {
'Distribution': {
'Id': 'string',
'ARN': 'string',
'Status': 'string',
'LastModifiedTime': datetime(2015, 1, 1),
'InProgressInvalidationBatches': 123,
'DomainName': 'string',
'ActiveTrustedSigners': {
'Enabled': True|False,
'Quantity': 123,
'Items': [
{
'AwsAccountNumber': 'string',
'KeyPairIds': {
'Quantity': 123,
'Items': [
'string',
]
}
},
]
},
'DistributionConfig': {
'CallerReference': 'string',
'Aliases': {
'Quantity': 123,
'Items': [
'string',
]
},
'DefaultRootObject': 'string',
'Origins': {
'Quantity': 123,
'Items': [
{
'Id': 'string',
'DomainName': 'string',
'OriginPath': 'string',
'CustomHeaders': {
'Quantity': 123,
'Items': [
{
'HeaderName': 'string',
'HeaderValue': 'string'
},
]
},
'S3OriginConfig': {
'OriginAccessIdentity': 'string'
},
'CustomOriginConfig': {
'HTTPPort': 123,
'HTTPSPort': 123,
'OriginProtocolPolicy': 'http-only'|'match-viewer'|'https-only',
'OriginSslProtocols': {
'Quantity': 123,
'Items': [
'SSLv3'|'TLSv1'|'TLSv1.1'|'TLSv1.2',
]
},
'OriginReadTimeout': 123,
'OriginKeepaliveTimeout': 123
}
},
]
},
'DefaultCacheBehavior': {
'TargetOriginId': 'string',
'ForwardedValues': {
'QueryString': True|False,
'Cookies': {
'Forward': 'none'|'whitelist'|'all',
'WhitelistedNames': {
'Quantity': 123,
'Items': [
'string',
]
}
},
'Headers': {
'Quantity': 123,
'Items': [
'string',
]
},
'QueryStringCacheKeys': {
'Quantity': 123,
'Items': [
'string',
]
}
},
'TrustedSigners': {
'Enabled': True|False,
'Quantity': 123,
'Items': [
'string',
]
},
'ViewerProtocolPolicy': 'allow-all'|'https-only'|'redirect-to-https',
'MinTTL': 123,
'AllowedMethods': {
'Quantity': 123,
'Items': [
'GET'|'HEAD'|'POST'|'PUT'|'PATCH'|'OPTIONS'|'DELETE',
],
'CachedMethods': {
'Quantity': 123,
'Items': [
'GET'|'HEAD'|'POST'|'PUT'|'PATCH'|'OPTIONS'|'DELETE',
]
}
},
'SmoothStreaming': True|False,
'DefaultTTL': 123,
'MaxTTL': 123,
'Compress': True|False,
'LambdaFunctionAssociations': {
'Quantity': 123,
'Items': [
{
'LambdaFunctionARN': 'string',
'EventType': 'viewer-request'|'viewer-response'|'origin-request'|'origin-response'
},
]
}
},
'CacheBehaviors': {
'Quantity': 123,
'Items': [
{
'PathPattern': 'string',
'TargetOriginId': 'string',
'ForwardedValues': {
'QueryString': True|False,
'Cookies': {
'Forward': 'none'|'whitelist'|'all',
'WhitelistedNames': {
'Quantity': 123,
'Items': [
'string',
]
}
},
'Headers': {
'Quantity': 123,
'Items': [
'string',
]
},
'QueryStringCacheKeys': {
'Quantity': 123,
'Items': [
'string',
]
}
},
'TrustedSigners': {
'Enabled': True|False,
'Quantity': 123,
'Items': [
'string',
]
},
'ViewerProtocolPolicy': 'allow-all'|'https-only'|'redirect-to-https',
'MinTTL': 123,
'AllowedMethods': {
'Quantity': 123,
'Items': [
'GET'|'HEAD'|'POST'|'PUT'|'PATCH'|'OPTIONS'|'DELETE',
],
'CachedMethods': {
'Quantity': 123,
'Items': [
'GET'|'HEAD'|'POST'|'PUT'|'PATCH'|'OPTIONS'|'DELETE',
]
}
},
'SmoothStreaming': True|False,
'DefaultTTL': 123,
'MaxTTL': 123,
'Compress': True|False,
'LambdaFunctionAssociations': {
'Quantity': 123,
'Items': [
{
'LambdaFunctionARN': 'string',
'EventType': 'viewer-request'|'viewer-response'|'origin-request'|'origin-response'
},
]
}
},
]
},
'CustomErrorResponses': {
'Quantity': 123,
'Items': [
{
'ErrorCode': 123,
'ResponsePagePath': 'string',
'ResponseCode': 'string',
'ErrorCachingMinTTL': 123
},
]
},
'Comment': 'string',
'Logging': {
'Enabled': True|False,
'IncludeCookies': True|False,
'Bucket': 'string',
'Prefix': 'string'
},
'PriceClass': 'PriceClass_100'|'PriceClass_200'|'PriceClass_All',
'Enabled': True|False,
'ViewerCertificate': {
'CloudFrontDefaultCertificate': True|False,
'IAMCertificateId': 'string',
'ACMCertificateArn': 'string',
'SSLSupportMethod': 'sni-only'|'vip',
'MinimumProtocolVersion': 'SSLv3'|'TLSv1',
'Certificate': 'string',
'CertificateSource': 'cloudfront'|'iam'|'acm'
},
'Restrictions': {
'GeoRestriction': {
'RestrictionType': 'blacklist'|'whitelist'|'none',
'Quantity': 123,
'Items': [
'string',
]
}
},
'WebACLId': 'string',
'HttpVersion': 'http1.1'|'http2',
'IsIPV6Enabled': True|False
}
},
'Location': 'string',
'ETag': 'string'
}
:returns:
If you configured Amazon S3 Transfer Acceleration for your bucket, do not specify the s3-accelerate endpoint for DomainName .
The bucket name must be between 3 and 63 characters long (inclusive).
The bucket name must contain only lowercase characters, numbers, periods, underscores, and dashes.
The bucket name must not contain adjacent periods.
"""
pass
def create_invalidation(DistributionId=None, InvalidationBatch=None):
"""
Create a new invalidation.
See also: AWS API Documentation
:example: response = client.create_invalidation(
DistributionId='string',
InvalidationBatch={
'Paths': {
'Quantity': 123,
'Items': [
'string',
]
},
'CallerReference': 'string'
}
)
:type DistributionId: string
:param DistributionId: [REQUIRED]
The distribution's id.
:type InvalidationBatch: dict
:param InvalidationBatch: [REQUIRED]
The batch information for the invalidation.
Paths (dict) -- [REQUIRED]A complex type that contains information about the objects that you want to invalidate. For more information, see Specifying the Objects to Invalidate in the Amazon CloudFront Developer Guide .
Quantity (integer) -- [REQUIRED]The number of objects that you want to invalidate.
Items (list) --A complex type that contains a list of the paths that you want to invalidate.
(string) --
CallerReference (string) -- [REQUIRED]A value that you specify to uniquely identify an invalidation request. CloudFront uses the value to prevent you from accidentally resubmitting an identical request. Whenever you create a new invalidation request, you must specify a new value for CallerReference and change other values in the request as applicable. One way to ensure that the value of CallerReference is unique is to use a timestamp , for example, 20120301090000 .
If you make a second invalidation request with the same value for CallerReference , and if the rest of the request is the same, CloudFront doesn't create a new invalidation request. Instead, CloudFront returns information about the invalidation request that you previously created with the same CallerReference .
If CallerReference is a value you already sent in a previous invalidation batch request but the content of any Path is different from the original request, CloudFront returns an InvalidationBatchAlreadyExists error.
:rtype: dict
:return: {
'Location': 'string',
'Invalidation': {
'Id': 'string',
'Status': 'string',
'CreateTime': datetime(2015, 1, 1),
'InvalidationBatch': {
'Paths': {
'Quantity': 123,
'Items': [
'string',
]
},
'CallerReference': 'string'
}
}
}
:returns:
(string) --
"""
pass
def create_streaming_distribution(StreamingDistributionConfig=None):
"""
Creates a new RMTP distribution. An RTMP distribution is similar to a web distribution, but an RTMP distribution streams media files using the Adobe Real-Time Messaging Protocol (RTMP) instead of serving files using HTTP.
To create a new web distribution, submit a POST request to the CloudFront API version /distribution resource. The request body must include a document with a StreamingDistributionConfig element. The response echoes the StreamingDistributionConfig element and returns other information about the RTMP distribution.
To get the status of your request, use the GET StreamingDistribution API action. When the value of Enabled is true and the value of Status is Deployed , your distribution is ready. A distribution usually deploys in less than 15 minutes.
For more information about web distributions, see Working with RTMP Distributions in the Amazon CloudFront Developer Guide .
See also: AWS API Documentation
:example: response = client.create_streaming_distribution(
StreamingDistributionConfig={
'CallerReference': 'string',
'S3Origin': {
'DomainName': 'string',
'OriginAccessIdentity': 'string'
},
'Aliases': {
'Quantity': 123,
'Items': [
'string',
]
},
'Comment': 'string',
'Logging': {
'Enabled': True|False,
'Bucket': 'string',
'Prefix': 'string'
},
'TrustedSigners': {
'Enabled': True|False,
'Quantity': 123,
'Items': [
'string',
]
},
'PriceClass': 'PriceClass_100'|'PriceClass_200'|'PriceClass_All',
'Enabled': True|False
}
)
:type StreamingDistributionConfig: dict
:param StreamingDistributionConfig: [REQUIRED]
The streaming distribution's configuration information.
CallerReference (string) -- [REQUIRED]A unique number that ensures that the request can't be replayed. If the CallerReference is new (no matter the content of the StreamingDistributionConfig object), a new streaming distribution is created. If the CallerReference is a value that you already sent in a previous request to create a streaming distribution, and the content of the StreamingDistributionConfig is identical to the original request (ignoring white space), the response includes the same information returned to the original request. If the CallerReference is a value that you already sent in a previous request to create a streaming distribution but the content of the StreamingDistributionConfig is different from the original request, CloudFront returns a DistributionAlreadyExists error.
S3Origin (dict) -- [REQUIRED]A complex type that contains information about the Amazon S3 bucket from which you want CloudFront to get your media files for distribution.
DomainName (string) -- [REQUIRED]The DNS name of the Amazon S3 origin.
OriginAccessIdentity (string) -- [REQUIRED]The CloudFront origin access identity to associate with the RTMP distribution. Use an origin access identity to configure the distribution so that end users can only access objects in an Amazon S3 bucket through CloudFront.
If you want end users to be able to access objects using either the CloudFront URL or the Amazon S3 URL, specify an empty OriginAccessIdentity element.
To delete the origin access identity from an existing distribution, update the distribution configuration and include an empty OriginAccessIdentity element.
To replace the origin access identity, update the distribution configuration and specify the new origin access identity.
For more information, see Using an Origin Access Identity to Restrict Access to Your Amazon S3 Content in the Amazon Amazon CloudFront Developer Guide .
Aliases (dict) --A complex type that contains information about CNAMEs (alternate domain names), if any, for this streaming distribution.
Quantity (integer) -- [REQUIRED]The number of CNAME aliases, if any, that you want to associate with this distribution.
Items (list) --A complex type that contains the CNAME aliases, if any, that you want to associate with this distribution.
(string) --
Comment (string) -- [REQUIRED]Any comments you want to include about the streaming distribution.
Logging (dict) --A complex type that controls whether access logs are written for the streaming distribution.
Enabled (boolean) -- [REQUIRED]Specifies whether you want CloudFront to save access logs to an Amazon S3 bucket. If you do not want to enable logging when you create a streaming distribution or if you want to disable logging for an existing streaming distribution, specify false for Enabled , and specify empty Bucket and Prefix elements. If you specify false for Enabled but you specify values for Bucket and Prefix , the values are automatically deleted.
Bucket (string) -- [REQUIRED]The Amazon S3 bucket to store the access logs in, for example, myawslogbucket.s3.amazonaws.com .
Prefix (string) -- [REQUIRED]An optional string that you want CloudFront to prefix to the access log filenames for this streaming distribution, for example, myprefix/ . If you want to enable logging, but you do not want to specify a prefix, you still must include an empty Prefix element in the Logging element.
TrustedSigners (dict) -- [REQUIRED]A complex type that specifies any AWS accounts that you want to permit to create signed URLs for private content. If you want the distribution to use signed URLs, include this element; if you want the distribution to use public URLs, remove this element. For more information, see Serving Private Content through CloudFront in the Amazon CloudFront Developer Guide .
Enabled (boolean) -- [REQUIRED]Specifies whether you want to require viewers to use signed URLs to access the files specified by PathPattern and TargetOriginId .
Quantity (integer) -- [REQUIRED]The number of trusted signers for this cache behavior.
Items (list) --
Optional : A complex type that contains trusted signers for this cache behavior. If Quantity is 0 , you can omit Items .
(string) --
PriceClass (string) --A complex type that contains information about price class for this streaming distribution.
Enabled (boolean) -- [REQUIRED]Whether the streaming distribution is enabled to accept user requests for content.
:rtype: dict
:return: {
'StreamingDistribution': {
'Id': 'string',
'ARN': 'string',
'Status': 'string',
'LastModifiedTime': datetime(2015, 1, 1),
'DomainName': 'string',
'ActiveTrustedSigners': {
'Enabled': True|False,
'Quantity': 123,
'Items': [
{
'AwsAccountNumber': 'string',
'KeyPairIds': {
'Quantity': 123,
'Items': [
'string',
]
}
},
]
},
'StreamingDistributionConfig': {
'CallerReference': 'string',
'S3Origin': {
'DomainName': 'string',
'OriginAccessIdentity': 'string'
},
'Aliases': {
'Quantity': 123,
'Items': [
'string',
]
},
'Comment': 'string',
'Logging': {
'Enabled': True|False,
'Bucket': 'string',
'Prefix': 'string'
},
'TrustedSigners': {
'Enabled': True|False,
'Quantity': 123,
'Items': [
'string',
]
},
'PriceClass': 'PriceClass_100'|'PriceClass_200'|'PriceClass_All',
'Enabled': True|False
}
},
'Location': 'string',
'ETag': 'string'
}
:returns:
(string) --
"""
pass
def create_streaming_distribution_with_tags(StreamingDistributionConfigWithTags=None):
"""
Create a new streaming distribution with tags.
See also: AWS API Documentation
:example: response = client.create_streaming_distribution_with_tags(
StreamingDistributionConfigWithTags={
'StreamingDistributionConfig': {
'CallerReference': 'string',
'S3Origin': {
'DomainName': 'string',
'OriginAccessIdentity': 'string'
},
'Aliases': {
'Quantity': 123,
'Items': [
'string',
]
},
'Comment': 'string',
'Logging': {
'Enabled': True|False,
'Bucket': 'string',
'Prefix': 'string'
},
'TrustedSigners': {
'Enabled': True|False,
'Quantity': 123,
'Items': [
'string',
]
},
'PriceClass': 'PriceClass_100'|'PriceClass_200'|'PriceClass_All',
'Enabled': True|False
},
'Tags': {
'Items': [
{
'Key': 'string',
'Value': 'string'
},
]
}
}
)
:type StreamingDistributionConfigWithTags: dict
:param StreamingDistributionConfigWithTags: [REQUIRED]
The streaming distribution's configuration information.
StreamingDistributionConfig (dict) -- [REQUIRED]A streaming distribution Configuration.
CallerReference (string) -- [REQUIRED]A unique number that ensures that the request can't be replayed. If the CallerReference is new (no matter the content of the StreamingDistributionConfig object), a new streaming distribution is created. If the CallerReference is a value that you already sent in a previous request to create a streaming distribution, and the content of the StreamingDistributionConfig is identical to the original request (ignoring white space), the response includes the same information returned to the original request. If the CallerReference is a value that you already sent in a previous request to create a streaming distribution but the content of the StreamingDistributionConfig is different from the original request, CloudFront returns a DistributionAlreadyExists error.
S3Origin (dict) -- [REQUIRED]A complex type that contains information about the Amazon S3 bucket from which you want CloudFront to get your media files for distribution.
DomainName (string) -- [REQUIRED]The DNS name of the Amazon S3 origin.
OriginAccessIdentity (string) -- [REQUIRED]The CloudFront origin access identity to associate with the RTMP distribution. Use an origin access identity to configure the distribution so that end users can only access objects in an Amazon S3 bucket through CloudFront.
If you want end users to be able to access objects using either the CloudFront URL or the Amazon S3 URL, specify an empty OriginAccessIdentity element.
To delete the origin access identity from an existing distribution, update the distribution configuration and include an empty OriginAccessIdentity element.
To replace the origin access identity, update the distribution configuration and specify the new origin access identity.
For more information, see Using an Origin Access Identity to Restrict Access to Your Amazon S3 Content in the Amazon Amazon CloudFront Developer Guide .
Aliases (dict) --A complex type that contains information about CNAMEs (alternate domain names), if any, for this streaming distribution.
Quantity (integer) -- [REQUIRED]The number of CNAME aliases, if any, that you want to associate with this distribution.
Items (list) --A complex type that contains the CNAME aliases, if any, that you want to associate with this distribution.
(string) --
Comment (string) -- [REQUIRED]Any comments you want to include about the streaming distribution.
Logging (dict) --A complex type that controls whether access logs are written for the streaming distribution.
Enabled (boolean) -- [REQUIRED]Specifies whether you want CloudFront to save access logs to an Amazon S3 bucket. If you do not want to enable logging when you create a streaming distribution or if you want to disable logging for an existing streaming distribution, specify false for Enabled , and specify empty Bucket and Prefix elements. If you specify false for Enabled but you specify values for Bucket and Prefix , the values are automatically deleted.
Bucket (string) -- [REQUIRED]The Amazon S3 bucket to store the access logs in, for example, myawslogbucket.s3.amazonaws.com .
Prefix (string) -- [REQUIRED]An optional string that you want CloudFront to prefix to the access log filenames for this streaming distribution, for example, myprefix/ . If you want to enable logging, but you do not want to specify a prefix, you still must include an empty Prefix element in the Logging element.
TrustedSigners (dict) -- [REQUIRED]A complex type that specifies any AWS accounts that you want to permit to create signed URLs for private content. If you want the distribution to use signed URLs, include this element; if you want the distribution to use public URLs, remove this element. For more information, see Serving Private Content through CloudFront in the Amazon CloudFront Developer Guide .
Enabled (boolean) -- [REQUIRED]Specifies whether you want to require viewers to use signed URLs to access the files specified by PathPattern and TargetOriginId .
Quantity (integer) -- [REQUIRED]The number of trusted signers for this cache behavior.
Items (list) --
Optional : A complex type that contains trusted signers for this cache behavior. If Quantity is 0 , you can omit Items .
(string) --
PriceClass (string) --A complex type that contains information about price class for this streaming distribution.
Enabled (boolean) -- [REQUIRED]Whether the streaming distribution is enabled to accept user requests for content.
Tags (dict) -- [REQUIRED]A complex type that contains zero or more Tag elements.
Items (list) --A complex type that contains Tag elements.
(dict) --A complex type that contains Tag key and Tag value.
Key (string) -- [REQUIRED]A string that contains Tag key.
The string length should be between 1 and 128 characters. Valid characters include a-z , A-Z , 0-9 , space, and the special characters _ - . : / = + @ .
Value (string) --A string that contains an optional Tag value.
The string length should be between 0 and 256 characters. Valid characters include a-z , A-Z , 0-9 , space, and the special characters _ - . : / = + @ .
:rtype: dict
:return: {
'StreamingDistribution': {
'Id': 'string',
'ARN': 'string',
'Status': 'string',
'LastModifiedTime': datetime(2015, 1, 1),
'DomainName': 'string',
'ActiveTrustedSigners': {
'Enabled': True|False,
'Quantity': 123,
'Items': [
{
'AwsAccountNumber': 'string',
'KeyPairIds': {
'Quantity': 123,
'Items': [
'string',
]
}
},
]
},
'StreamingDistributionConfig': {
'CallerReference': 'string',
'S3Origin': {
'DomainName': 'string',
'OriginAccessIdentity': 'string'
},
'Aliases': {
'Quantity': 123,
'Items': [
'string',
]
},
'Comment': 'string',
'Logging': {
'Enabled': True|False,
'Bucket': 'string',
'Prefix': 'string'
},
'TrustedSigners': {
'Enabled': True|False,
'Quantity': 123,
'Items': [
'string',
]
},
'PriceClass': 'PriceClass_100'|'PriceClass_200'|'PriceClass_All',
'Enabled': True|False
}
},
'Location': 'string',
'ETag': 'string'
}
:returns:
(string) --
"""
pass
def delete_cloud_front_origin_access_identity(Id=None, IfMatch=None):
"""
Delete an origin access identity.
See also: AWS API Documentation
:example: response = client.delete_cloud_front_origin_access_identity(
Id='string',
IfMatch='string'
)
:type Id: string
:param Id: [REQUIRED]
The origin access identity's ID.
:type IfMatch: string
:param IfMatch: The value of the ETag header you received from a previous GET or PUT request. For example: E2QWRUHAPOMQZL .
"""
pass
def delete_distribution(Id=None, IfMatch=None):
"""
Delete a distribution.
See also: AWS API Documentation
:example: response = client.delete_distribution(
Id='string',
IfMatch='string'
)
:type Id: string
:param Id: [REQUIRED]
The distribution ID.
:type IfMatch: string
:param IfMatch: The value of the ETag header that you received when you disabled the distribution. For example: E2QWRUHAPOMQZL .
"""
pass
def delete_streaming_distribution(Id=None, IfMatch=None):
"""
Delete a streaming distribution. To delete an RTMP distribution using the CloudFront API, perform the following steps.
For information about deleting a distribution using the CloudFront console, see Deleting a Distribution in the Amazon CloudFront Developer Guide .
See also: AWS API Documentation
:example: response = client.delete_streaming_distribution(
Id='string',
IfMatch='string'
)
:type Id: string
:param Id: [REQUIRED]
The distribution ID.
:type IfMatch: string
:param IfMatch: The value of the ETag header that you received when you disabled the streaming distribution. For example: E2QWRUHAPOMQZL .
:returns:
Id (string) -- [REQUIRED]
The distribution ID.
IfMatch (string) -- The value of the ETag header that you received when you disabled the streaming distribution. For example: E2QWRUHAPOMQZL .
"""
pass
def generate_presigned_url(ClientMethod=None, Params=None, ExpiresIn=None, HttpMethod=None):
"""
Generate a presigned url given a client, its method, and arguments
:type ClientMethod: string
:param ClientMethod: The client method to presign for
:type Params: dict
:param Params: The parameters normally passed to
ClientMethod.
:type ExpiresIn: int
:param ExpiresIn: The number of seconds the presigned url is valid
for. By default it expires in an hour (3600 seconds)
:type HttpMethod: string
:param HttpMethod: The http method to use on the generated url. By
default, the http method is whatever is used in the method's model.
"""
pass
def get_cloud_front_origin_access_identity(Id=None):
"""
Get the information about an origin access identity.
See also: AWS API Documentation
:example: response = client.get_cloud_front_origin_access_identity(
Id='string'
)
:type Id: string
:param Id: [REQUIRED]
The identity's ID.
:rtype: dict
:return: {
'CloudFrontOriginAccessIdentity': {
'Id': 'string',
'S3CanonicalUserId': 'string',
'CloudFrontOriginAccessIdentityConfig': {
'CallerReference': 'string',
'Comment': 'string'
}
},
'ETag': 'string'
}
"""
pass
def get_cloud_front_origin_access_identity_config(Id=None):
"""
Get the configuration information about an origin access identity.
See also: AWS API Documentation
:example: response = client.get_cloud_front_origin_access_identity_config(
Id='string'
)
:type Id: string
:param Id: [REQUIRED]
The identity's ID.
:rtype: dict
:return: {
'CloudFrontOriginAccessIdentityConfig': {
'CallerReference': 'string',
'Comment': 'string'
},
'ETag': 'string'
}
"""
pass
def get_distribution(Id=None):
"""
Get the information about a distribution.
See also: AWS API Documentation
:example: response = client.get_distribution(
Id='string'
)
:type Id: string
:param Id: [REQUIRED]
The distribution's ID.
:rtype: dict
:return: {
'Distribution': {
'Id': 'string',
'ARN': 'string',
'Status': 'string',
'LastModifiedTime': datetime(2015, 1, 1),
'InProgressInvalidationBatches': 123,
'DomainName': 'string',
'ActiveTrustedSigners': {
'Enabled': True|False,
'Quantity': 123,
'Items': [
{
'AwsAccountNumber': 'string',
'KeyPairIds': {
'Quantity': 123,
'Items': [
'string',
]
}
},
]
},
'DistributionConfig': {
'CallerReference': 'string',
'Aliases': {
'Quantity': 123,
'Items': [
'string',
]
},
'DefaultRootObject': 'string',
'Origins': {
'Quantity': 123,
'Items': [
{
'Id': 'string',
'DomainName': 'string',
'OriginPath': 'string',
'CustomHeaders': {
'Quantity': 123,
'Items': [
{
'HeaderName': 'string',
'HeaderValue': 'string'
},
]
},
'S3OriginConfig': {
'OriginAccessIdentity': 'string'
},
'CustomOriginConfig': {
'HTTPPort': 123,
'HTTPSPort': 123,
'OriginProtocolPolicy': 'http-only'|'match-viewer'|'https-only',
'OriginSslProtocols': {
'Quantity': 123,
'Items': [
'SSLv3'|'TLSv1'|'TLSv1.1'|'TLSv1.2',
]
},
'OriginReadTimeout': 123,
'OriginKeepaliveTimeout': 123
}
},
]
},
'DefaultCacheBehavior': {
'TargetOriginId': 'string',
'ForwardedValues': {
'QueryString': True|False,
'Cookies': {
'Forward': 'none'|'whitelist'|'all',
'WhitelistedNames': {
'Quantity': 123,
'Items': [
'string',
]
}
},
'Headers': {
'Quantity': 123,
'Items': [
'string',
]
},
'QueryStringCacheKeys': {
'Quantity': 123,
'Items': [
'string',
]
}
},
'TrustedSigners': {
'Enabled': True|False,
'Quantity': 123,
'Items': [
'string',
]
},
'ViewerProtocolPolicy': 'allow-all'|'https-only'|'redirect-to-https',
'MinTTL': 123,
'AllowedMethods': {
'Quantity': 123,
'Items': [
'GET'|'HEAD'|'POST'|'PUT'|'PATCH'|'OPTIONS'|'DELETE',
],
'CachedMethods': {
'Quantity': 123,
'Items': [
'GET'|'HEAD'|'POST'|'PUT'|'PATCH'|'OPTIONS'|'DELETE',
]
}
},
'SmoothStreaming': True|False,
'DefaultTTL': 123,
'MaxTTL': 123,
'Compress': True|False,
'LambdaFunctionAssociations': {
'Quantity': 123,
'Items': [
{
'LambdaFunctionARN': 'string',
'EventType': 'viewer-request'|'viewer-response'|'origin-request'|'origin-response'
},
]
}
},
'CacheBehaviors': {
'Quantity': 123,
'Items': [
{
'PathPattern': 'string',
'TargetOriginId': 'string',
'ForwardedValues': {
'QueryString': True|False,
'Cookies': {
'Forward': 'none'|'whitelist'|'all',
'WhitelistedNames': {
'Quantity': 123,
'Items': [
'string',
]
}
},
'Headers': {
'Quantity': 123,
'Items': [
'string',
]
},
'QueryStringCacheKeys': {
'Quantity': 123,
'Items': [
'string',
]
}
},
'TrustedSigners': {
'Enabled': True|False,
'Quantity': 123,
'Items': [
'string',
]
},
'ViewerProtocolPolicy': 'allow-all'|'https-only'|'redirect-to-https',
'MinTTL': 123,
'AllowedMethods': {
'Quantity': 123,
'Items': [
'GET'|'HEAD'|'POST'|'PUT'|'PATCH'|'OPTIONS'|'DELETE',
],
'CachedMethods': {
'Quantity': 123,
'Items': [
'GET'|'HEAD'|'POST'|'PUT'|'PATCH'|'OPTIONS'|'DELETE',
]
}
},
'SmoothStreaming': True|False,
'DefaultTTL': 123,
'MaxTTL': 123,
'Compress': True|False,
'LambdaFunctionAssociations': {
'Quantity': 123,
'Items': [
{
'LambdaFunctionARN': 'string',
'EventType': 'viewer-request'|'viewer-response'|'origin-request'|'origin-response'
},
]
}
},
]
},
'CustomErrorResponses': {
'Quantity': 123,
'Items': [
{
'ErrorCode': 123,
'ResponsePagePath': 'string',
'ResponseCode': 'string',
'ErrorCachingMinTTL': 123
},
]
},
'Comment': 'string',
'Logging': {
'Enabled': True|False,
'IncludeCookies': True|False,
'Bucket': 'string',
'Prefix': 'string'
},
'PriceClass': 'PriceClass_100'|'PriceClass_200'|'PriceClass_All',
'Enabled': True|False,
'ViewerCertificate': {
'CloudFrontDefaultCertificate': True|False,
'IAMCertificateId': 'string',
'ACMCertificateArn': 'string',
'SSLSupportMethod': 'sni-only'|'vip',
'MinimumProtocolVersion': 'SSLv3'|'TLSv1',
'Certificate': 'string',
'CertificateSource': 'cloudfront'|'iam'|'acm'
},
'Restrictions': {
'GeoRestriction': {
'RestrictionType': 'blacklist'|'whitelist'|'none',
'Quantity': 123,
'Items': [
'string',
]
}
},
'WebACLId': 'string',
'HttpVersion': 'http1.1'|'http2',
'IsIPV6Enabled': True|False
}
},
'ETag': 'string'
}
:returns:
(string) --
"""
pass
def get_distribution_config(Id=None):
"""
Get the configuration information about a distribution.
See also: AWS API Documentation
:example: response = client.get_distribution_config(
Id='string'
)
:type Id: string
:param Id: [REQUIRED]
The distribution's ID.
:rtype: dict
:return: {
'DistributionConfig': {
'CallerReference': 'string',
'Aliases': {
'Quantity': 123,
'Items': [
'string',
]
},
'DefaultRootObject': 'string',
'Origins': {
'Quantity': 123,
'Items': [
{
'Id': 'string',
'DomainName': 'string',
'OriginPath': 'string',
'CustomHeaders': {
'Quantity': 123,
'Items': [
{
'HeaderName': 'string',
'HeaderValue': 'string'
},
]
},
'S3OriginConfig': {
'OriginAccessIdentity': 'string'
},
'CustomOriginConfig': {
'HTTPPort': 123,
'HTTPSPort': 123,
'OriginProtocolPolicy': 'http-only'|'match-viewer'|'https-only',
'OriginSslProtocols': {
'Quantity': 123,
'Items': [
'SSLv3'|'TLSv1'|'TLSv1.1'|'TLSv1.2',
]
},
'OriginReadTimeout': 123,
'OriginKeepaliveTimeout': 123
}
},
]
},
'DefaultCacheBehavior': {
'TargetOriginId': 'string',
'ForwardedValues': {
'QueryString': True|False,
'Cookies': {
'Forward': 'none'|'whitelist'|'all',
'WhitelistedNames': {
'Quantity': 123,
'Items': [
'string',
]
}
},
'Headers': {
'Quantity': 123,
'Items': [
'string',
]
},
'QueryStringCacheKeys': {
'Quantity': 123,
'Items': [
'string',
]
}
},
'TrustedSigners': {
'Enabled': True|False,
'Quantity': 123,
'Items': [
'string',
]
},
'ViewerProtocolPolicy': 'allow-all'|'https-only'|'redirect-to-https',
'MinTTL': 123,
'AllowedMethods': {
'Quantity': 123,
'Items': [
'GET'|'HEAD'|'POST'|'PUT'|'PATCH'|'OPTIONS'|'DELETE',
],
'CachedMethods': {
'Quantity': 123,
'Items': [
'GET'|'HEAD'|'POST'|'PUT'|'PATCH'|'OPTIONS'|'DELETE',
]
}
},
'SmoothStreaming': True|False,
'DefaultTTL': 123,
'MaxTTL': 123,
'Compress': True|False,
'LambdaFunctionAssociations': {
'Quantity': 123,
'Items': [
{
'LambdaFunctionARN': 'string',
'EventType': 'viewer-request'|'viewer-response'|'origin-request'|'origin-response'
},
]
}
},
'CacheBehaviors': {
'Quantity': 123,
'Items': [
{
'PathPattern': 'string',
'TargetOriginId': 'string',
'ForwardedValues': {
'QueryString': True|False,
'Cookies': {
'Forward': 'none'|'whitelist'|'all',
'WhitelistedNames': {
'Quantity': 123,
'Items': [
'string',
]
}
},
'Headers': {
'Quantity': 123,
'Items': [
'string',
]
},
'QueryStringCacheKeys': {
'Quantity': 123,
'Items': [
'string',
]
}
},
'TrustedSigners': {
'Enabled': True|False,
'Quantity': 123,
'Items': [
'string',
]
},
'ViewerProtocolPolicy': 'allow-all'|'https-only'|'redirect-to-https',
'MinTTL': 123,
'AllowedMethods': {
'Quantity': 123,
'Items': [
'GET'|'HEAD'|'POST'|'PUT'|'PATCH'|'OPTIONS'|'DELETE',
],
'CachedMethods': {
'Quantity': 123,
'Items': [
'GET'|'HEAD'|'POST'|'PUT'|'PATCH'|'OPTIONS'|'DELETE',
]
}
},
'SmoothStreaming': True|False,
'DefaultTTL': 123,
'MaxTTL': 123,
'Compress': True|False,
'LambdaFunctionAssociations': {
'Quantity': 123,
'Items': [
{
'LambdaFunctionARN': 'string',
'EventType': 'viewer-request'|'viewer-response'|'origin-request'|'origin-response'
},
]
}
},
]
},
'CustomErrorResponses': {
'Quantity': 123,
'Items': [
{
'ErrorCode': 123,
'ResponsePagePath': 'string',
'ResponseCode': 'string',
'ErrorCachingMinTTL': 123
},
]
},
'Comment': 'string',
'Logging': {
'Enabled': True|False,
'IncludeCookies': True|False,
'Bucket': 'string',
'Prefix': 'string'
},
'PriceClass': 'PriceClass_100'|'PriceClass_200'|'PriceClass_All',
'Enabled': True|False,
'ViewerCertificate': {
'CloudFrontDefaultCertificate': True|False,
'IAMCertificateId': 'string',
'ACMCertificateArn': 'string',
'SSLSupportMethod': 'sni-only'|'vip',
'MinimumProtocolVersion': 'SSLv3'|'TLSv1',
'Certificate': 'string',
'CertificateSource': 'cloudfront'|'iam'|'acm'
},
'Restrictions': {
'GeoRestriction': {
'RestrictionType': 'blacklist'|'whitelist'|'none',
'Quantity': 123,
'Items': [
'string',
]
}
},
'WebACLId': 'string',
'HttpVersion': 'http1.1'|'http2',
'IsIPV6Enabled': True|False
},
'ETag': 'string'
}
:returns:
If you configured Amazon S3 Transfer Acceleration for your bucket, do not specify the s3-accelerate endpoint for DomainName .
The bucket name must be between 3 and 63 characters long (inclusive).
The bucket name must contain only lowercase characters, numbers, periods, underscores, and dashes.
The bucket name must not contain adjacent periods.
"""
pass
def get_invalidation(DistributionId=None, Id=None):
"""
Get the information about an invalidation.
See also: AWS API Documentation
:example: response = client.get_invalidation(
DistributionId='string',
Id='string'
)
:type DistributionId: string
:param DistributionId: [REQUIRED]
The distribution's ID.
:type Id: string
:param Id: [REQUIRED]
The identifier for the invalidation request, for example, IDFDVBD632BHDS5 .
:rtype: dict
:return: {
'Invalidation': {
'Id': 'string',
'Status': 'string',
'CreateTime': datetime(2015, 1, 1),
'InvalidationBatch': {
'Paths': {
'Quantity': 123,
'Items': [
'string',
]
},
'CallerReference': 'string'
}
}
}
:returns:
(string) --
"""
pass
def get_paginator(operation_name=None):
"""
Create a paginator for an operation.
:type operation_name: string
:param operation_name: The operation name. This is the same name
as the method name on the client. For example, if the
method name is create_foo, and you'd normally invoke the
operation as client.create_foo(**kwargs), if the
create_foo operation can be paginated, you can use the
call client.get_paginator('create_foo').
:rtype: L{botocore.paginate.Paginator}
"""
pass
def get_streaming_distribution(Id=None):
"""
Gets information about a specified RTMP distribution, including the distribution configuration.
See also: AWS API Documentation
:example: response = client.get_streaming_distribution(
Id='string'
)
:type Id: string
:param Id: [REQUIRED]
The streaming distribution's ID.
:rtype: dict
:return: {
'StreamingDistribution': {
'Id': 'string',
'ARN': 'string',
'Status': 'string',
'LastModifiedTime': datetime(2015, 1, 1),
'DomainName': 'string',
'ActiveTrustedSigners': {
'Enabled': True|False,
'Quantity': 123,
'Items': [
{
'AwsAccountNumber': 'string',
'KeyPairIds': {
'Quantity': 123,
'Items': [
'string',
]
}
},
]
},
'StreamingDistributionConfig': {
'CallerReference': 'string',
'S3Origin': {
'DomainName': 'string',
'OriginAccessIdentity': 'string'
},
'Aliases': {
'Quantity': 123,
'Items': [
'string',
]
},
'Comment': 'string',
'Logging': {
'Enabled': True|False,
'Bucket': 'string',
'Prefix': 'string'
},
'TrustedSigners': {
'Enabled': True|False,
'Quantity': 123,
'Items': [
'string',
]
},
'PriceClass': 'PriceClass_100'|'PriceClass_200'|'PriceClass_All',
'Enabled': True|False
}
},
'ETag': 'string'
}
:returns:
(string) --
"""
pass
def get_streaming_distribution_config(Id=None):
"""
Get the configuration information about a streaming distribution.
See also: AWS API Documentation
:example: response = client.get_streaming_distribution_config(
Id='string'
)
:type Id: string
:param Id: [REQUIRED]
The streaming distribution's ID.
:rtype: dict
:return: {
'StreamingDistributionConfig': {
'CallerReference': 'string',
'S3Origin': {
'DomainName': 'string',
'OriginAccessIdentity': 'string'
},
'Aliases': {
'Quantity': 123,
'Items': [
'string',
]
},
'Comment': 'string',
'Logging': {
'Enabled': True|False,
'Bucket': 'string',
'Prefix': 'string'
},
'TrustedSigners': {
'Enabled': True|False,
'Quantity': 123,
'Items': [
'string',
]
},
'PriceClass': 'PriceClass_100'|'PriceClass_200'|'PriceClass_All',
'Enabled': True|False
},
'ETag': 'string'
}
:returns:
(string) --
"""
pass
def get_waiter():
"""
"""
pass
def list_cloud_front_origin_access_identities(Marker=None, MaxItems=None):
"""
Lists origin access identities.
See also: AWS API Documentation
:example: response = client.list_cloud_front_origin_access_identities(
Marker='string',
MaxItems='string'
)
:type Marker: string
:param Marker: Use this when paginating results to indicate where to begin in your list of origin access identities. The results include identities in the list that occur after the marker. To get the next page of results, set the Marker to the value of the NextMarker from the current page's response (which is also the ID of the last identity on that page).
:type MaxItems: string
:param MaxItems: The maximum number of origin access identities you want in the response body.
:rtype: dict
:return: {
'CloudFrontOriginAccessIdentityList': {
'Marker': 'string',
'NextMarker': 'string',
'MaxItems': 123,
'IsTruncated': True|False,
'Quantity': 123,
'Items': [
{
'Id': 'string',
'S3CanonicalUserId': 'string',
'Comment': 'string'
},
]
}
}
"""
pass
def list_distributions(Marker=None, MaxItems=None):
"""
List distributions.
See also: AWS API Documentation
:example: response = client.list_distributions(
Marker='string',
MaxItems='string'
)
:type Marker: string
:param Marker: Use this when paginating results to indicate where to begin in your list of distributions. The results include distributions in the list that occur after the marker. To get the next page of results, set the Marker to the value of the NextMarker from the current page's response (which is also the ID of the last distribution on that page).
:type MaxItems: string
:param MaxItems: The maximum number of distributions you want in the response body.
:rtype: dict
:return: {
'DistributionList': {
'Marker': 'string',
'NextMarker': 'string',
'MaxItems': 123,
'IsTruncated': True|False,
'Quantity': 123,
'Items': [
{
'Id': 'string',
'ARN': 'string',
'Status': 'string',
'LastModifiedTime': datetime(2015, 1, 1),
'DomainName': 'string',
'Aliases': {
'Quantity': 123,
'Items': [
'string',
]
},
'Origins': {
'Quantity': 123,
'Items': [
{
'Id': 'string',
'DomainName': 'string',
'OriginPath': 'string',
'CustomHeaders': {
'Quantity': 123,
'Items': [
{
'HeaderName': 'string',
'HeaderValue': 'string'
},
]
},
'S3OriginConfig': {
'OriginAccessIdentity': 'string'
},
'CustomOriginConfig': {
'HTTPPort': 123,
'HTTPSPort': 123,
'OriginProtocolPolicy': 'http-only'|'match-viewer'|'https-only',
'OriginSslProtocols': {
'Quantity': 123,
'Items': [
'SSLv3'|'TLSv1'|'TLSv1.1'|'TLSv1.2',
]
},
'OriginReadTimeout': 123,
'OriginKeepaliveTimeout': 123
}
},
]
},
'DefaultCacheBehavior': {
'TargetOriginId': 'string',
'ForwardedValues': {
'QueryString': True|False,
'Cookies': {
'Forward': 'none'|'whitelist'|'all',
'WhitelistedNames': {
'Quantity': 123,
'Items': [
'string',
]
}
},
'Headers': {
'Quantity': 123,
'Items': [
'string',
]
},
'QueryStringCacheKeys': {
'Quantity': 123,
'Items': [
'string',
]
}
},
'TrustedSigners': {
'Enabled': True|False,
'Quantity': 123,
'Items': [
'string',
]
},
'ViewerProtocolPolicy': 'allow-all'|'https-only'|'redirect-to-https',
'MinTTL': 123,
'AllowedMethods': {
'Quantity': 123,
'Items': [
'GET'|'HEAD'|'POST'|'PUT'|'PATCH'|'OPTIONS'|'DELETE',
],
'CachedMethods': {
'Quantity': 123,
'Items': [
'GET'|'HEAD'|'POST'|'PUT'|'PATCH'|'OPTIONS'|'DELETE',
]
}
},
'SmoothStreaming': True|False,
'DefaultTTL': 123,
'MaxTTL': 123,
'Compress': True|False,
'LambdaFunctionAssociations': {
'Quantity': 123,
'Items': [
{
'LambdaFunctionARN': 'string',
'EventType': 'viewer-request'|'viewer-response'|'origin-request'|'origin-response'
},
]
}
},
'CacheBehaviors': {
'Quantity': 123,
'Items': [
{
'PathPattern': 'string',
'TargetOriginId': 'string',
'ForwardedValues': {
'QueryString': True|False,
'Cookies': {
'Forward': 'none'|'whitelist'|'all',
'WhitelistedNames': {
'Quantity': 123,
'Items': [
'string',
]
}
},
'Headers': {
'Quantity': 123,
'Items': [
'string',
]
},
'QueryStringCacheKeys': {
'Quantity': 123,
'Items': [
'string',
]
}
},
'TrustedSigners': {
'Enabled': True|False,
'Quantity': 123,
'Items': [
'string',
]
},
'ViewerProtocolPolicy': 'allow-all'|'https-only'|'redirect-to-https',
'MinTTL': 123,
'AllowedMethods': {
'Quantity': 123,
'Items': [
'GET'|'HEAD'|'POST'|'PUT'|'PATCH'|'OPTIONS'|'DELETE',
],
'CachedMethods': {
'Quantity': 123,
'Items': [
'GET'|'HEAD'|'POST'|'PUT'|'PATCH'|'OPTIONS'|'DELETE',
]
}
},
'SmoothStreaming': True|False,
'DefaultTTL': 123,
'MaxTTL': 123,
'Compress': True|False,
'LambdaFunctionAssociations': {
'Quantity': 123,
'Items': [
{
'LambdaFunctionARN': 'string',
'EventType': 'viewer-request'|'viewer-response'|'origin-request'|'origin-response'
},
]
}
},
]
},
'CustomErrorResponses': {
'Quantity': 123,
'Items': [
{
'ErrorCode': 123,
'ResponsePagePath': 'string',
'ResponseCode': 'string',
'ErrorCachingMinTTL': 123
},
]
},
'Comment': 'string',
'PriceClass': 'PriceClass_100'|'PriceClass_200'|'PriceClass_All',
'Enabled': True|False,
'ViewerCertificate': {
'CloudFrontDefaultCertificate': True|False,
'IAMCertificateId': 'string',
'ACMCertificateArn': 'string',
'SSLSupportMethod': 'sni-only'|'vip',
'MinimumProtocolVersion': 'SSLv3'|'TLSv1',
'Certificate': 'string',
'CertificateSource': 'cloudfront'|'iam'|'acm'
},
'Restrictions': {
'GeoRestriction': {
'RestrictionType': 'blacklist'|'whitelist'|'none',
'Quantity': 123,
'Items': [
'string',
]
}
},
'WebACLId': 'string',
'HttpVersion': 'http1.1'|'http2',
'IsIPV6Enabled': True|False
},
]
}
}
:returns:
(string) --
"""
pass
def list_distributions_by_web_acl_id(Marker=None, MaxItems=None, WebACLId=None):
"""
List the distributions that are associated with a specified AWS WAF web ACL.
See also: AWS API Documentation
:example: response = client.list_distributions_by_web_acl_id(
Marker='string',
MaxItems='string',
WebACLId='string'
)
:type Marker: string
:param Marker: Use Marker and MaxItems to control pagination of results. If you have more than MaxItems distributions that satisfy the request, the response includes a NextMarker element. To get the next page of results, submit another request. For the value of Marker , specify the value of NextMarker from the last response. (For the first request, omit Marker .)
:type MaxItems: string
:param MaxItems: The maximum number of distributions that you want CloudFront to return in the response body. The maximum and default values are both 100.
:type WebACLId: string
:param WebACLId: [REQUIRED]
The ID of the AWS WAF web ACL that you want to list the associated distributions. If you specify 'null' for the ID, the request returns a list of the distributions that aren't associated with a web ACL.
:rtype: dict
:return: {
'DistributionList': {
'Marker': 'string',
'NextMarker': 'string',
'MaxItems': 123,
'IsTruncated': True|False,
'Quantity': 123,
'Items': [
{
'Id': 'string',
'ARN': 'string',
'Status': 'string',
'LastModifiedTime': datetime(2015, 1, 1),
'DomainName': 'string',
'Aliases': {
'Quantity': 123,
'Items': [
'string',
]
},
'Origins': {
'Quantity': 123,
'Items': [
{
'Id': 'string',
'DomainName': 'string',
'OriginPath': 'string',
'CustomHeaders': {
'Quantity': 123,
'Items': [
{
'HeaderName': 'string',
'HeaderValue': 'string'
},
]
},
'S3OriginConfig': {
'OriginAccessIdentity': 'string'
},
'CustomOriginConfig': {
'HTTPPort': 123,
'HTTPSPort': 123,
'OriginProtocolPolicy': 'http-only'|'match-viewer'|'https-only',
'OriginSslProtocols': {
'Quantity': 123,
'Items': [
'SSLv3'|'TLSv1'|'TLSv1.1'|'TLSv1.2',
]
},
'OriginReadTimeout': 123,
'OriginKeepaliveTimeout': 123
}
},
]
},
'DefaultCacheBehavior': {
'TargetOriginId': 'string',
'ForwardedValues': {
'QueryString': True|False,
'Cookies': {
'Forward': 'none'|'whitelist'|'all',
'WhitelistedNames': {
'Quantity': 123,
'Items': [
'string',
]
}
},
'Headers': {
'Quantity': 123,
'Items': [
'string',
]
},
'QueryStringCacheKeys': {
'Quantity': 123,
'Items': [
'string',
]
}
},
'TrustedSigners': {
'Enabled': True|False,
'Quantity': 123,
'Items': [
'string',
]
},
'ViewerProtocolPolicy': 'allow-all'|'https-only'|'redirect-to-https',
'MinTTL': 123,
'AllowedMethods': {
'Quantity': 123,
'Items': [
'GET'|'HEAD'|'POST'|'PUT'|'PATCH'|'OPTIONS'|'DELETE',
],
'CachedMethods': {
'Quantity': 123,
'Items': [
'GET'|'HEAD'|'POST'|'PUT'|'PATCH'|'OPTIONS'|'DELETE',
]
}
},
'SmoothStreaming': True|False,
'DefaultTTL': 123,
'MaxTTL': 123,
'Compress': True|False,
'LambdaFunctionAssociations': {
'Quantity': 123,
'Items': [
{
'LambdaFunctionARN': 'string',
'EventType': 'viewer-request'|'viewer-response'|'origin-request'|'origin-response'
},
]
}
},
'CacheBehaviors': {
'Quantity': 123,
'Items': [
{
'PathPattern': 'string',
'TargetOriginId': 'string',
'ForwardedValues': {
'QueryString': True|False,
'Cookies': {
'Forward': 'none'|'whitelist'|'all',
'WhitelistedNames': {
'Quantity': 123,
'Items': [
'string',
]
}
},
'Headers': {
'Quantity': 123,
'Items': [
'string',
]
},
'QueryStringCacheKeys': {
'Quantity': 123,
'Items': [
'string',
]
}
},
'TrustedSigners': {
'Enabled': True|False,
'Quantity': 123,
'Items': [
'string',
]
},
'ViewerProtocolPolicy': 'allow-all'|'https-only'|'redirect-to-https',
'MinTTL': 123,
'AllowedMethods': {
'Quantity': 123,
'Items': [
'GET'|'HEAD'|'POST'|'PUT'|'PATCH'|'OPTIONS'|'DELETE',
],
'CachedMethods': {
'Quantity': 123,
'Items': [
'GET'|'HEAD'|'POST'|'PUT'|'PATCH'|'OPTIONS'|'DELETE',
]
}
},
'SmoothStreaming': True|False,
'DefaultTTL': 123,
'MaxTTL': 123,
'Compress': True|False,
'LambdaFunctionAssociations': {
'Quantity': 123,
'Items': [
{
'LambdaFunctionARN': 'string',
'EventType': 'viewer-request'|'viewer-response'|'origin-request'|'origin-response'
},
]
}
},
]
},
'CustomErrorResponses': {
'Quantity': 123,
'Items': [
{
'ErrorCode': 123,
'ResponsePagePath': 'string',
'ResponseCode': 'string',
'ErrorCachingMinTTL': 123
},
]
},
'Comment': 'string',
'PriceClass': 'PriceClass_100'|'PriceClass_200'|'PriceClass_All',
'Enabled': True|False,
'ViewerCertificate': {
'CloudFrontDefaultCertificate': True|False,
'IAMCertificateId': 'string',
'ACMCertificateArn': 'string',
'SSLSupportMethod': 'sni-only'|'vip',
'MinimumProtocolVersion': 'SSLv3'|'TLSv1',
'Certificate': 'string',
'CertificateSource': 'cloudfront'|'iam'|'acm'
},
'Restrictions': {
'GeoRestriction': {
'RestrictionType': 'blacklist'|'whitelist'|'none',
'Quantity': 123,
'Items': [
'string',
]
}
},
'WebACLId': 'string',
'HttpVersion': 'http1.1'|'http2',
'IsIPV6Enabled': True|False
},
]
}
}
:returns:
(string) --
"""
pass
def list_invalidations(DistributionId=None, Marker=None, MaxItems=None):
"""
Lists invalidation batches.
See also: AWS API Documentation
:example: response = client.list_invalidations(
DistributionId='string',
Marker='string',
MaxItems='string'
)
:type DistributionId: string
:param DistributionId: [REQUIRED]
The distribution's ID.
:type Marker: string
:param Marker: Use this parameter when paginating results to indicate where to begin in your list of invalidation batches. Because the results are returned in decreasing order from most recent to oldest, the most recent results are on the first page, the second page will contain earlier results, and so on. To get the next page of results, set Marker to the value of the NextMarker from the current page's response. This value is the same as the ID of the last invalidation batch on that page.
:type MaxItems: string
:param MaxItems: The maximum number of invalidation batches that you want in the response body.
:rtype: dict
:return: {
'InvalidationList': {
'Marker': 'string',
'NextMarker': 'string',
'MaxItems': 123,
'IsTruncated': True|False,
'Quantity': 123,
'Items': [
{
'Id': 'string',
'CreateTime': datetime(2015, 1, 1),
'Status': 'string'
},
]
}
}
"""
pass
def list_streaming_distributions(Marker=None, MaxItems=None):
"""
List streaming distributions.
See also: AWS API Documentation
:example: response = client.list_streaming_distributions(
Marker='string',
MaxItems='string'
)
:type Marker: string
:param Marker: The value that you provided for the Marker request parameter.
:type MaxItems: string
:param MaxItems: The value that you provided for the MaxItems request parameter.
:rtype: dict
:return: {
'StreamingDistributionList': {
'Marker': 'string',
'NextMarker': 'string',
'MaxItems': 123,
'IsTruncated': True|False,
'Quantity': 123,
'Items': [
{
'Id': 'string',
'ARN': 'string',
'Status': 'string',
'LastModifiedTime': datetime(2015, 1, 1),
'DomainName': 'string',
'S3Origin': {
'DomainName': 'string',
'OriginAccessIdentity': 'string'
},
'Aliases': {
'Quantity': 123,
'Items': [
'string',
]
},
'TrustedSigners': {
'Enabled': True|False,
'Quantity': 123,
'Items': [
'string',
]
},
'Comment': 'string',
'PriceClass': 'PriceClass_100'|'PriceClass_200'|'PriceClass_All',
'Enabled': True|False
},
]
}
}
:returns:
(string) --
"""
pass
def list_tags_for_resource(Resource=None):
"""
List tags for a CloudFront resource.
See also: AWS API Documentation
:example: response = client.list_tags_for_resource(
Resource='string'
)
:type Resource: string
:param Resource: [REQUIRED]
An ARN of a CloudFront resource.
:rtype: dict
:return: {
'Tags': {
'Items': [
{
'Key': 'string',
'Value': 'string'
},
]
}
}
"""
pass
def tag_resource(Resource=None, Tags=None):
"""
Add tags to a CloudFront resource.
See also: AWS API Documentation
:example: response = client.tag_resource(
Resource='string',
Tags={
'Items': [
{
'Key': 'string',
'Value': 'string'
},
]
}
)
:type Resource: string
:param Resource: [REQUIRED]
An ARN of a CloudFront resource.
:type Tags: dict
:param Tags: [REQUIRED]
A complex type that contains zero or more Tag elements.
Items (list) --A complex type that contains Tag elements.
(dict) --A complex type that contains Tag key and Tag value.
Key (string) -- [REQUIRED]A string that contains Tag key.
The string length should be between 1 and 128 characters. Valid characters include a-z , A-Z , 0-9 , space, and the special characters _ - . : / = + @ .
Value (string) --A string that contains an optional Tag value.
The string length should be between 0 and 256 characters. Valid characters include a-z , A-Z , 0-9 , space, and the special characters _ - . : / = + @ .
"""
pass
def untag_resource(Resource=None, TagKeys=None):
"""
Remove tags from a CloudFront resource.
See also: AWS API Documentation
:example: response = client.untag_resource(
Resource='string',
TagKeys={
'Items': [
'string',
]
}
)
:type Resource: string
:param Resource: [REQUIRED]
An ARN of a CloudFront resource.
:type TagKeys: dict
:param TagKeys: [REQUIRED]
A complex type that contains zero or more Tag key elements.
Items (list) --A complex type that contains Tag key elements.
(string) --A string that contains Tag key.
The string length should be between 1 and 128 characters. Valid characters include a-z , A-Z , 0-9 , space, and the special characters _ - . : / = + @ .
"""
pass
def update_cloud_front_origin_access_identity(CloudFrontOriginAccessIdentityConfig=None, Id=None, IfMatch=None):
"""
Update an origin access identity.
See also: AWS API Documentation
:example: response = client.update_cloud_front_origin_access_identity(
CloudFrontOriginAccessIdentityConfig={
'CallerReference': 'string',
'Comment': 'string'
},
Id='string',
IfMatch='string'
)
:type CloudFrontOriginAccessIdentityConfig: dict
:param CloudFrontOriginAccessIdentityConfig: [REQUIRED]
The identity's configuration information.
CallerReference (string) -- [REQUIRED]A unique number that ensures the request can't be replayed.
If the CallerReference is new (no matter the content of the CloudFrontOriginAccessIdentityConfig object), a new origin access identity is created.
If the CallerReference is a value already sent in a previous identity request, and the content of the CloudFrontOriginAccessIdentityConfig is identical to the original request (ignoring white space), the response includes the same information returned to the original request.
If the CallerReference is a value you already sent in a previous request to create an identity, but the content of the CloudFrontOriginAccessIdentityConfig is different from the original request, CloudFront returns a CloudFrontOriginAccessIdentityAlreadyExists error.
Comment (string) -- [REQUIRED]Any comments you want to include about the origin access identity.
:type Id: string
:param Id: [REQUIRED]
The identity's id.
:type IfMatch: string
:param IfMatch: The value of the ETag header that you received when retrieving the identity's configuration. For example: E2QWRUHAPOMQZL .
:rtype: dict
:return: {
'CloudFrontOriginAccessIdentity': {
'Id': 'string',
'S3CanonicalUserId': 'string',
'CloudFrontOriginAccessIdentityConfig': {
'CallerReference': 'string',
'Comment': 'string'
}
},
'ETag': 'string'
}
"""
pass
def update_distribution(DistributionConfig=None, Id=None, IfMatch=None):
"""
Update a distribution.
See also: AWS API Documentation
:example: response = client.update_distribution(
DistributionConfig={
'CallerReference': 'string',
'Aliases': {
'Quantity': 123,
'Items': [
'string',
]
},
'DefaultRootObject': 'string',
'Origins': {
'Quantity': 123,
'Items': [
{
'Id': 'string',
'DomainName': 'string',
'OriginPath': 'string',
'CustomHeaders': {
'Quantity': 123,
'Items': [
{
'HeaderName': 'string',
'HeaderValue': 'string'
},
]
},
'S3OriginConfig': {
'OriginAccessIdentity': 'string'
},
'CustomOriginConfig': {
'HTTPPort': 123,
'HTTPSPort': 123,
'OriginProtocolPolicy': 'http-only'|'match-viewer'|'https-only',
'OriginSslProtocols': {
'Quantity': 123,
'Items': [
'SSLv3'|'TLSv1'|'TLSv1.1'|'TLSv1.2',
]
},
'OriginReadTimeout': 123,
'OriginKeepaliveTimeout': 123
}
},
]
},
'DefaultCacheBehavior': {
'TargetOriginId': 'string',
'ForwardedValues': {
'QueryString': True|False,
'Cookies': {
'Forward': 'none'|'whitelist'|'all',
'WhitelistedNames': {
'Quantity': 123,
'Items': [
'string',
]
}
},
'Headers': {
'Quantity': 123,
'Items': [
'string',
]
},
'QueryStringCacheKeys': {
'Quantity': 123,
'Items': [
'string',
]
}
},
'TrustedSigners': {
'Enabled': True|False,
'Quantity': 123,
'Items': [
'string',
]
},
'ViewerProtocolPolicy': 'allow-all'|'https-only'|'redirect-to-https',
'MinTTL': 123,
'AllowedMethods': {
'Quantity': 123,
'Items': [
'GET'|'HEAD'|'POST'|'PUT'|'PATCH'|'OPTIONS'|'DELETE',
],
'CachedMethods': {
'Quantity': 123,
'Items': [
'GET'|'HEAD'|'POST'|'PUT'|'PATCH'|'OPTIONS'|'DELETE',
]
}
},
'SmoothStreaming': True|False,
'DefaultTTL': 123,
'MaxTTL': 123,
'Compress': True|False,
'LambdaFunctionAssociations': {
'Quantity': 123,
'Items': [
{
'LambdaFunctionARN': 'string',
'EventType': 'viewer-request'|'viewer-response'|'origin-request'|'origin-response'
},
]
}
},
'CacheBehaviors': {
'Quantity': 123,
'Items': [
{
'PathPattern': 'string',
'TargetOriginId': 'string',
'ForwardedValues': {
'QueryString': True|False,
'Cookies': {
'Forward': 'none'|'whitelist'|'all',
'WhitelistedNames': {
'Quantity': 123,
'Items': [
'string',
]
}
},
'Headers': {
'Quantity': 123,
'Items': [
'string',
]
},
'QueryStringCacheKeys': {
'Quantity': 123,
'Items': [
'string',
]
}
},
'TrustedSigners': {
'Enabled': True|False,
'Quantity': 123,
'Items': [
'string',
]
},
'ViewerProtocolPolicy': 'allow-all'|'https-only'|'redirect-to-https',
'MinTTL': 123,
'AllowedMethods': {
'Quantity': 123,
'Items': [
'GET'|'HEAD'|'POST'|'PUT'|'PATCH'|'OPTIONS'|'DELETE',
],
'CachedMethods': {
'Quantity': 123,
'Items': [
'GET'|'HEAD'|'POST'|'PUT'|'PATCH'|'OPTIONS'|'DELETE',
]
}
},
'SmoothStreaming': True|False,
'DefaultTTL': 123,
'MaxTTL': 123,
'Compress': True|False,
'LambdaFunctionAssociations': {
'Quantity': 123,
'Items': [
{
'LambdaFunctionARN': 'string',
'EventType': 'viewer-request'|'viewer-response'|'origin-request'|'origin-response'
},
]
}
},
]
},
'CustomErrorResponses': {
'Quantity': 123,
'Items': [
{
'ErrorCode': 123,
'ResponsePagePath': 'string',
'ResponseCode': 'string',
'ErrorCachingMinTTL': 123
},
]
},
'Comment': 'string',
'Logging': {
'Enabled': True|False,
'IncludeCookies': True|False,
'Bucket': 'string',
'Prefix': 'string'
},
'PriceClass': 'PriceClass_100'|'PriceClass_200'|'PriceClass_All',
'Enabled': True|False,
'ViewerCertificate': {
'CloudFrontDefaultCertificate': True|False,
'IAMCertificateId': 'string',
'ACMCertificateArn': 'string',
'SSLSupportMethod': 'sni-only'|'vip',
'MinimumProtocolVersion': 'SSLv3'|'TLSv1',
'Certificate': 'string',
'CertificateSource': 'cloudfront'|'iam'|'acm'
},
'Restrictions': {
'GeoRestriction': {
'RestrictionType': 'blacklist'|'whitelist'|'none',
'Quantity': 123,
'Items': [
'string',
]
}
},
'WebACLId': 'string',
'HttpVersion': 'http1.1'|'http2',
'IsIPV6Enabled': True|False
},
Id='string',
IfMatch='string'
)
:type DistributionConfig: dict
:param DistributionConfig: [REQUIRED]
The distribution's configuration information.
CallerReference (string) -- [REQUIRED]A unique value (for example, a date-time stamp) that ensures that the request can't be replayed.
If the value of CallerReference is new (regardless of the content of the DistributionConfig object), CloudFront creates a new distribution.
If CallerReference is a value you already sent in a previous request to create a distribution, and if the content of the DistributionConfig is identical to the original request (ignoring white space), CloudFront returns the same the response that it returned to the original request.
If CallerReference is a value you already sent in a previous request to create a distribution but the content of the DistributionConfig is different from the original request, CloudFront returns a DistributionAlreadyExists error.
Aliases (dict) --A complex type that contains information about CNAMEs (alternate domain names), if any, for this distribution.
Quantity (integer) -- [REQUIRED]The number of CNAME aliases, if any, that you want to associate with this distribution.
Items (list) --A complex type that contains the CNAME aliases, if any, that you want to associate with this distribution.
(string) --
DefaultRootObject (string) --The object that you want CloudFront to request from your origin (for example, index.html ) when a viewer requests the root URL for your distribution (http://www.example.com ) instead of an object in your distribution (http://www.example.com/product-description.html ). Specifying a default root object avoids exposing the contents of your distribution.
Specify only the object name, for example, index.html . Do not add a / before the object name.
If you don't want to specify a default root object when you create a distribution, include an empty DefaultRootObject element.
To delete the default root object from an existing distribution, update the distribution configuration and include an empty DefaultRootObject element.
To replace the default root object, update the distribution configuration and specify the new object.
For more information about the default root object, see Creating a Default Root Object in the Amazon CloudFront Developer Guide .
Origins (dict) -- [REQUIRED]A complex type that contains information about origins for this distribution.
Quantity (integer) -- [REQUIRED]The number of origins for this distribution.
Items (list) --A complex type that contains origins for this distribution.
(dict) --A complex type that describes the Amazon S3 bucket or the HTTP server (for example, a web server) from which CloudFront gets your files. You must create at least one origin.
For the current limit on the number of origins that you can create for a distribution, see Amazon CloudFront Limits in the AWS General Reference .
Id (string) -- [REQUIRED]A unique identifier for the origin. The value of Id must be unique within the distribution.
When you specify the value of TargetOriginId for the default cache behavior or for another cache behavior, you indicate the origin to which you want the cache behavior to route requests by specifying the value of the Id element for that origin. When a request matches the path pattern for that cache behavior, CloudFront routes the request to the specified origin. For more information, see Cache Behavior Settings in the Amazon CloudFront Developer Guide .
DomainName (string) -- [REQUIRED]
Amazon S3 origins : The DNS name of the Amazon S3 bucket from which you want CloudFront to get objects for this origin, for example, myawsbucket.s3.amazonaws.com .
Constraints for Amazon S3 origins:
If you configured Amazon S3 Transfer Acceleration for your bucket, do not specify the s3-accelerate endpoint for DomainName .
The bucket name must be between 3 and 63 characters long (inclusive).
The bucket name must contain only lowercase characters, numbers, periods, underscores, and dashes.
The bucket name must not contain adjacent periods.
Custom Origins : The DNS domain name for the HTTP server from which you want CloudFront to get objects for this origin, for example, www.example.com .
Constraints for custom origins:
DomainName must be a valid DNS name that contains only a-z, A-Z, 0-9, dot (.), hyphen (-), or underscore (_) characters.
The name cannot exceed 128 characters.
OriginPath (string) --An optional element that causes CloudFront to request your content from a directory in your Amazon S3 bucket or your custom origin. When you include the OriginPath element, specify the directory name, beginning with a / . CloudFront appends the directory name to the value of DomainName , for example, example.com/production . Do not include a / at the end of the directory name.
For example, suppose you've specified the following values for your distribution:
DomainName : An Amazon S3 bucket named myawsbucket .
OriginPath : /production
CNAME : example.com
When a user enters example.com/index.html in a browser, CloudFront sends a request to Amazon S3 for myawsbucket/production/index.html .
When a user enters example.com/acme/index.html in a browser, CloudFront sends a request to Amazon S3 for myawsbucket/production/acme/index.html .
CustomHeaders (dict) --A complex type that contains names and values for the custom headers that you want.
Quantity (integer) -- [REQUIRED]The number of custom headers, if any, for this distribution.
Items (list) --
Optional : A list that contains one OriginCustomHeader element for each custom header that you want CloudFront to forward to the origin. If Quantity is 0 , omit Items .
(dict) --A complex type that contains HeaderName and HeaderValue elements, if any, for this distribution.
HeaderName (string) -- [REQUIRED]The name of a header that you want CloudFront to forward to your origin. For more information, see Forwarding Custom Headers to Your Origin (Web Distributions Only) in the Amazon Amazon CloudFront Developer Guide .
HeaderValue (string) -- [REQUIRED]The value for the header that you specified in the HeaderName field.
S3OriginConfig (dict) --A complex type that contains information about the Amazon S3 origin. If the origin is a custom origin, use the CustomOriginConfig element instead.
OriginAccessIdentity (string) -- [REQUIRED]The CloudFront origin access identity to associate with the origin. Use an origin access identity to configure the origin so that viewers can only access objects in an Amazon S3 bucket through CloudFront. The format of the value is:
origin-access-identity/CloudFront/ID-of-origin-access-identity
where `` ID-of-origin-access-identity `` is the value that CloudFront returned in the ID element when you created the origin access identity.
If you want viewers to be able to access objects using either the CloudFront URL or the Amazon S3 URL, specify an empty OriginAccessIdentity element.
To delete the origin access identity from an existing distribution, update the distribution configuration and include an empty OriginAccessIdentity element.
To replace the origin access identity, update the distribution configuration and specify the new origin access identity.
For more information about the origin access identity, see Serving Private Content through CloudFront in the Amazon CloudFront Developer Guide .
CustomOriginConfig (dict) --A complex type that contains information about a custom origin. If the origin is an Amazon S3 bucket, use the S3OriginConfig element instead.
HTTPPort (integer) -- [REQUIRED]The HTTP port the custom origin listens on.
HTTPSPort (integer) -- [REQUIRED]The HTTPS port the custom origin listens on.
OriginProtocolPolicy (string) -- [REQUIRED]The origin protocol policy to apply to your origin.
OriginSslProtocols (dict) --The SSL/TLS protocols that you want CloudFront to use when communicating with your origin over HTTPS.
Quantity (integer) -- [REQUIRED]The number of SSL/TLS protocols that you want to allow CloudFront to use when establishing an HTTPS connection with this origin.
Items (list) -- [REQUIRED]A list that contains allowed SSL/TLS protocols for this distribution.
(string) --
OriginReadTimeout (integer) --You can create a custom origin read timeout. All timeout units are in seconds. The default origin read timeout is 30 seconds, but you can configure custom timeout lengths using the CloudFront API. The minimum timeout length is 4 seconds; the maximum is 60 seconds.
If you need to increase the maximum time limit, contact the AWS Support Center .
OriginKeepaliveTimeout (integer) --You can create a custom keep-alive timeout. All timeout units are in seconds. The default keep-alive timeout is 5 seconds, but you can configure custom timeout lengths using the CloudFront API. The minimum timeout length is 1 second; the maximum is 60 seconds.
If you need to increase the maximum time limit, contact the AWS Support Center .
DefaultCacheBehavior (dict) -- [REQUIRED]A complex type that describes the default cache behavior if you do not specify a CacheBehavior element or if files don't match any of the values of PathPattern in CacheBehavior elements. You must create exactly one default cache behavior.
TargetOriginId (string) -- [REQUIRED]The value of ID for the origin that you want CloudFront to route requests to when a request matches the path pattern either for a cache behavior or for the default cache behavior.
ForwardedValues (dict) -- [REQUIRED]A complex type that specifies how CloudFront handles query strings and cookies.
QueryString (boolean) -- [REQUIRED]Indicates whether you want CloudFront to forward query strings to the origin that is associated with this cache behavior and cache based on the query string parameters. CloudFront behavior depends on the value of QueryString and on the values that you specify for QueryStringCacheKeys , if any:
If you specify true for QueryString and you don't specify any values for QueryStringCacheKeys , CloudFront forwards all query string parameters to the origin and caches based on all query string parameters. Depending on how many query string parameters and values you have, this can adversely affect performance because CloudFront must forward more requests to the origin.
If you specify true for QueryString and you specify one or more values for QueryStringCacheKeys , CloudFront forwards all query string parameters to the origin, but it only caches based on the query string parameters that you specify.
If you specify false for QueryString , CloudFront doesn't forward any query string parameters to the origin, and doesn't cache based on query string parameters.
For more information, see Configuring CloudFront to Cache Based on Query String Parameters in the Amazon CloudFront Developer Guide .
Cookies (dict) -- [REQUIRED]A complex type that specifies whether you want CloudFront to forward cookies to the origin and, if so, which ones. For more information about forwarding cookies to the origin, see How CloudFront Forwards, Caches, and Logs Cookies in the Amazon CloudFront Developer Guide .
Forward (string) -- [REQUIRED]Specifies which cookies to forward to the origin for this cache behavior: all, none, or the list of cookies specified in the WhitelistedNames complex type.
Amazon S3 doesn't process cookies. When the cache behavior is forwarding requests to an Amazon S3 origin, specify none for the Forward element.
WhitelistedNames (dict) --Required if you specify whitelist for the value of Forward: . A complex type that specifies how many different cookies you want CloudFront to forward to the origin for this cache behavior and, if you want to forward selected cookies, the names of those cookies.
If you specify all or none for the value of Forward , omit WhitelistedNames . If you change the value of Forward from whitelist to all or none and you don't delete the WhitelistedNames element and its child elements, CloudFront deletes them automatically.
For the current limit on the number of cookie names that you can whitelist for each cache behavior, see Amazon CloudFront Limits in the AWS General Reference .
Quantity (integer) -- [REQUIRED]The number of different cookies that you want CloudFront to forward to the origin for this cache behavior.
Items (list) --A complex type that contains one Name element for each cookie that you want CloudFront to forward to the origin for this cache behavior.
(string) --
Headers (dict) --A complex type that specifies the Headers , if any, that you want CloudFront to vary upon for this cache behavior.
Quantity (integer) -- [REQUIRED]The number of different headers that you want CloudFront to forward to the origin for this cache behavior. You can configure each cache behavior in a web distribution to do one of the following:
Forward all headers to your origin : Specify 1 for Quantity and * for Name .
Warning
If you configure CloudFront to forward all headers to your origin, CloudFront doesn't cache the objects associated with this cache behavior. Instead, it sends every request to the origin.
Forward a whitelist of headers you specify : Specify the number of headers that you want to forward, and specify the header names in Name elements. CloudFront caches your objects based on the values in all of the specified headers. CloudFront also forwards the headers that it forwards by default, but it caches your objects based only on the headers that you specify.
Forward only the default headers : Specify 0 for Quantity and omit Items . In this configuration, CloudFront doesn't cache based on the values in the request headers.
Items (list) --A complex type that contains one Name element for each header that you want CloudFront to forward to the origin and to vary on for this cache behavior. If Quantity is 0 , omit Items .
(string) --
QueryStringCacheKeys (dict) --A complex type that contains information about the query string parameters that you want CloudFront to use for caching for this cache behavior.
Quantity (integer) -- [REQUIRED]The number of whitelisted query string parameters for this cache behavior.
Items (list) --(Optional) A list that contains the query string parameters that you want CloudFront to use as a basis for caching for this cache behavior. If Quantity is 0, you can omit Items .
(string) --
TrustedSigners (dict) -- [REQUIRED]A complex type that specifies the AWS accounts, if any, that you want to allow to create signed URLs for private content.
If you want to require signed URLs in requests for objects in the target origin that match the PathPattern for this cache behavior, specify true for Enabled , and specify the applicable values for Quantity and Items . For more information, see Serving Private Content through CloudFront in the Amazon Amazon CloudFront Developer Guide .
If you don't want to require signed URLs in requests for objects that match PathPattern , specify false for Enabled and 0 for Quantity . Omit Items .
To add, change, or remove one or more trusted signers, change Enabled to true (if it's currently false ), change Quantity as applicable, and specify all of the trusted signers that you want to include in the updated distribution.
Enabled (boolean) -- [REQUIRED]Specifies whether you want to require viewers to use signed URLs to access the files specified by PathPattern and TargetOriginId .
Quantity (integer) -- [REQUIRED]The number of trusted signers for this cache behavior.
Items (list) --
Optional : A complex type that contains trusted signers for this cache behavior. If Quantity is 0 , you can omit Items .
(string) --
ViewerProtocolPolicy (string) -- [REQUIRED]The protocol that viewers can use to access the files in the origin specified by TargetOriginId when a request matches the path pattern in PathPattern . You can specify the following options:
allow-all : Viewers can use HTTP or HTTPS.
redirect-to-https : If a viewer submits an HTTP request, CloudFront returns an HTTP status code of 301 (Moved Permanently) to the viewer along with the HTTPS URL. The viewer then resubmits the request using the new URL.
https-only : If a viewer sends an HTTP request, CloudFront returns an HTTP status code of 403 (Forbidden).
For more information about requiring the HTTPS protocol, see Using an HTTPS Connection to Access Your Objects in the Amazon CloudFront Developer Guide .
Note
The only way to guarantee that viewers retrieve an object that was fetched from the origin using HTTPS is never to use any other protocol to fetch the object. If you have recently changed from HTTP to HTTPS, we recommend that you clear your objects' cache because cached objects are protocol agnostic. That means that an edge location will return an object from the cache regardless of whether the current request protocol matches the protocol used previously. For more information, see Specifying How Long Objects and Errors Stay in a CloudFront Edge Cache (Expiration) in the Amazon CloudFront Developer Guide .
MinTTL (integer) -- [REQUIRED]The minimum amount of time that you want objects to stay in CloudFront caches before CloudFront forwards another request to your origin to determine whether the object has been updated. For more information, see Specifying How Long Objects and Errors Stay in a CloudFront Edge Cache (Expiration) in the Amazon Amazon CloudFront Developer Guide .
You must specify 0 for MinTTL if you configure CloudFront to forward all headers to your origin (under Headers , if you specify 1 for Quantity and * for Name ).
AllowedMethods (dict) --A complex type that controls which HTTP methods CloudFront processes and forwards to your Amazon S3 bucket or your custom origin. There are three choices:
CloudFront forwards only GET and HEAD requests.
CloudFront forwards only GET , HEAD , and OPTIONS requests.
CloudFront forwards GET, HEAD, OPTIONS, PUT, PATCH, POST , and DELETE requests.
If you pick the third choice, you may need to restrict access to your Amazon S3 bucket or to your custom origin so users can't perform operations that you don't want them to. For example, you might not want users to have permissions to delete objects from your origin.
Quantity (integer) -- [REQUIRED]The number of HTTP methods that you want CloudFront to forward to your origin. Valid values are 2 (for GET and HEAD requests), 3 (for GET , HEAD , and OPTIONS requests) and 7 (for GET, HEAD, OPTIONS, PUT, PATCH, POST , and DELETE requests).
Items (list) -- [REQUIRED]A complex type that contains the HTTP methods that you want CloudFront to process and forward to your origin.
(string) --
CachedMethods (dict) --A complex type that controls whether CloudFront caches the response to requests using the specified HTTP methods. There are two choices:
CloudFront caches responses to GET and HEAD requests.
CloudFront caches responses to GET , HEAD , and OPTIONS requests.
If you pick the second choice for your Amazon S3 Origin, you may need to forward Access-Control-Request-Method, Access-Control-Request-Headers, and Origin headers for the responses to be cached correctly.
Quantity (integer) -- [REQUIRED]The number of HTTP methods for which you want CloudFront to cache responses. Valid values are 2 (for caching responses to GET and HEAD requests) and 3 (for caching responses to GET , HEAD , and OPTIONS requests).
Items (list) -- [REQUIRED]A complex type that contains the HTTP methods that you want CloudFront to cache responses to.
(string) --
SmoothStreaming (boolean) --Indicates whether you want to distribute media files in the Microsoft Smooth Streaming format using the origin that is associated with this cache behavior. If so, specify true ; if not, specify false . If you specify true for SmoothStreaming , you can still distribute other content using this cache behavior if the content matches the value of PathPattern .
DefaultTTL (integer) --The default amount of time that you want objects to stay in CloudFront caches before CloudFront forwards another request to your origin to determine whether the object has been updated. The value that you specify applies only when your origin does not add HTTP headers such as Cache-Control max-age , Cache-Control s-maxage , and Expires to objects. For more information, see Specifying How Long Objects and Errors Stay in a CloudFront Edge Cache (Expiration) in the Amazon CloudFront Developer Guide .
MaxTTL (integer) --
Compress (boolean) --Whether you want CloudFront to automatically compress certain files for this cache behavior. If so, specify true ; if not, specify false . For more information, see Serving Compressed Files in the Amazon CloudFront Developer Guide .
LambdaFunctionAssociations (dict) --A complex type that contains zero or more Lambda function associations for a cache behavior.
Quantity (integer) -- [REQUIRED]The number of Lambda function associations for this cache behavior.
Items (list) --
Optional : A complex type that contains LambdaFunctionAssociation items for this cache behavior. If Quantity is 0 , you can omit Items .
(dict) --A complex type that contains a Lambda function association.
LambdaFunctionARN (string) --The ARN of the Lambda function.
EventType (string) --Specifies the event type that triggers a Lambda function invocation. Valid values are:
viewer-request
origin-request
viewer-response
origin-response
CacheBehaviors (dict) --A complex type that contains zero or more CacheBehavior elements.
Quantity (integer) -- [REQUIRED]The number of cache behaviors for this distribution.
Items (list) --Optional: A complex type that contains cache behaviors for this distribution. If Quantity is 0 , you can omit Items .
(dict) --A complex type that describes how CloudFront processes requests.
You must create at least as many cache behaviors (including the default cache behavior) as you have origins if you want CloudFront to distribute objects from all of the origins. Each cache behavior specifies the one origin from which you want CloudFront to get objects. If you have two origins and only the default cache behavior, the default cache behavior will cause CloudFront to get objects from one of the origins, but the other origin is never used.
For the current limit on the number of cache behaviors that you can add to a distribution, see Amazon CloudFront Limits in the AWS General Reference .
If you don't want to specify any cache behaviors, include only an empty CacheBehaviors element. Don't include an empty CacheBehavior element, or CloudFront returns a MalformedXML error.
To delete all cache behaviors in an existing distribution, update the distribution configuration and include only an empty CacheBehaviors element.
To add, change, or remove one or more cache behaviors, update the distribution configuration and specify all of the cache behaviors that you want to include in the updated distribution.
For more information about cache behaviors, see Cache Behaviors in the Amazon CloudFront Developer Guide .
PathPattern (string) -- [REQUIRED]The pattern (for example, images/*.jpg ) that specifies which requests to apply the behavior to. When CloudFront receives a viewer request, the requested path is compared with path patterns in the order in which cache behaviors are listed in the distribution.
Note
You can optionally include a slash (/ ) at the beginning of the path pattern. For example, /images/*.jpg . CloudFront behavior is the same with or without the leading / .
The path pattern for the default cache behavior is * and cannot be changed. If the request for an object does not match the path pattern for any cache behaviors, CloudFront applies the behavior in the default cache behavior.
For more information, see Path Pattern in the Amazon CloudFront Developer Guide .
TargetOriginId (string) -- [REQUIRED]The value of ID for the origin that you want CloudFront to route requests to when a request matches the path pattern either for a cache behavior or for the default cache behavior.
ForwardedValues (dict) -- [REQUIRED]A complex type that specifies how CloudFront handles query strings and cookies.
QueryString (boolean) -- [REQUIRED]Indicates whether you want CloudFront to forward query strings to the origin that is associated with this cache behavior and cache based on the query string parameters. CloudFront behavior depends on the value of QueryString and on the values that you specify for QueryStringCacheKeys , if any:
If you specify true for QueryString and you don't specify any values for QueryStringCacheKeys , CloudFront forwards all query string parameters to the origin and caches based on all query string parameters. Depending on how many query string parameters and values you have, this can adversely affect performance because CloudFront must forward more requests to the origin.
If you specify true for QueryString and you specify one or more values for QueryStringCacheKeys , CloudFront forwards all query string parameters to the origin, but it only caches based on the query string parameters that you specify.
If you specify false for QueryString , CloudFront doesn't forward any query string parameters to the origin, and doesn't cache based on query string parameters.
For more information, see Configuring CloudFront to Cache Based on Query String Parameters in the Amazon CloudFront Developer Guide .
Cookies (dict) -- [REQUIRED]A complex type that specifies whether you want CloudFront to forward cookies to the origin and, if so, which ones. For more information about forwarding cookies to the origin, see How CloudFront Forwards, Caches, and Logs Cookies in the Amazon CloudFront Developer Guide .
Forward (string) -- [REQUIRED]Specifies which cookies to forward to the origin for this cache behavior: all, none, or the list of cookies specified in the WhitelistedNames complex type.
Amazon S3 doesn't process cookies. When the cache behavior is forwarding requests to an Amazon S3 origin, specify none for the Forward element.
WhitelistedNames (dict) --Required if you specify whitelist for the value of Forward: . A complex type that specifies how many different cookies you want CloudFront to forward to the origin for this cache behavior and, if you want to forward selected cookies, the names of those cookies.
If you specify all or none for the value of Forward , omit WhitelistedNames . If you change the value of Forward from whitelist to all or none and you don't delete the WhitelistedNames element and its child elements, CloudFront deletes them automatically.
For the current limit on the number of cookie names that you can whitelist for each cache behavior, see Amazon CloudFront Limits in the AWS General Reference .
Quantity (integer) -- [REQUIRED]The number of different cookies that you want CloudFront to forward to the origin for this cache behavior.
Items (list) --A complex type that contains one Name element for each cookie that you want CloudFront to forward to the origin for this cache behavior.
(string) --
Headers (dict) --A complex type that specifies the Headers , if any, that you want CloudFront to vary upon for this cache behavior.
Quantity (integer) -- [REQUIRED]The number of different headers that you want CloudFront to forward to the origin for this cache behavior. You can configure each cache behavior in a web distribution to do one of the following:
Forward all headers to your origin : Specify 1 for Quantity and * for Name .
Warning
If you configure CloudFront to forward all headers to your origin, CloudFront doesn't cache the objects associated with this cache behavior. Instead, it sends every request to the origin.
Forward a whitelist of headers you specify : Specify the number of headers that you want to forward, and specify the header names in Name elements. CloudFront caches your objects based on the values in all of the specified headers. CloudFront also forwards the headers that it forwards by default, but it caches your objects based only on the headers that you specify.
Forward only the default headers : Specify 0 for Quantity and omit Items . In this configuration, CloudFront doesn't cache based on the values in the request headers.
Items (list) --A complex type that contains one Name element for each header that you want CloudFront to forward to the origin and to vary on for this cache behavior. If Quantity is 0 , omit Items .
(string) --
QueryStringCacheKeys (dict) --A complex type that contains information about the query string parameters that you want CloudFront to use for caching for this cache behavior.
Quantity (integer) -- [REQUIRED]The number of whitelisted query string parameters for this cache behavior.
Items (list) --(Optional) A list that contains the query string parameters that you want CloudFront to use as a basis for caching for this cache behavior. If Quantity is 0, you can omit Items .
(string) --
TrustedSigners (dict) -- [REQUIRED]A complex type that specifies the AWS accounts, if any, that you want to allow to create signed URLs for private content.
If you want to require signed URLs in requests for objects in the target origin that match the PathPattern for this cache behavior, specify true for Enabled , and specify the applicable values for Quantity and Items . For more information, see Serving Private Content through CloudFront in the Amazon Amazon CloudFront Developer Guide .
If you don't want to require signed URLs in requests for objects that match PathPattern , specify false for Enabled and 0 for Quantity . Omit Items .
To add, change, or remove one or more trusted signers, change Enabled to true (if it's currently false ), change Quantity as applicable, and specify all of the trusted signers that you want to include in the updated distribution.
Enabled (boolean) -- [REQUIRED]Specifies whether you want to require viewers to use signed URLs to access the files specified by PathPattern and TargetOriginId .
Quantity (integer) -- [REQUIRED]The number of trusted signers for this cache behavior.
Items (list) --
Optional : A complex type that contains trusted signers for this cache behavior. If Quantity is 0 , you can omit Items .
(string) --
ViewerProtocolPolicy (string) -- [REQUIRED]The protocol that viewers can use to access the files in the origin specified by TargetOriginId when a request matches the path pattern in PathPattern . You can specify the following options:
allow-all : Viewers can use HTTP or HTTPS.
redirect-to-https : If a viewer submits an HTTP request, CloudFront returns an HTTP status code of 301 (Moved Permanently) to the viewer along with the HTTPS URL. The viewer then resubmits the request using the new URL.
https-only : If a viewer sends an HTTP request, CloudFront returns an HTTP status code of 403 (Forbidden).
For more information about requiring the HTTPS protocol, see Using an HTTPS Connection to Access Your Objects in the Amazon CloudFront Developer Guide .
Note
The only way to guarantee that viewers retrieve an object that was fetched from the origin using HTTPS is never to use any other protocol to fetch the object. If you have recently changed from HTTP to HTTPS, we recommend that you clear your objects' cache because cached objects are protocol agnostic. That means that an edge location will return an object from the cache regardless of whether the current request protocol matches the protocol used previously. For more information, see Specifying How Long Objects and Errors Stay in a CloudFront Edge Cache (Expiration) in the Amazon CloudFront Developer Guide .
MinTTL (integer) -- [REQUIRED]The minimum amount of time that you want objects to stay in CloudFront caches before CloudFront forwards another request to your origin to determine whether the object has been updated. For more information, see Specifying How Long Objects and Errors Stay in a CloudFront Edge Cache (Expiration) in the Amazon Amazon CloudFront Developer Guide .
You must specify 0 for MinTTL if you configure CloudFront to forward all headers to your origin (under Headers , if you specify 1 for Quantity and * for Name ).
AllowedMethods (dict) --A complex type that controls which HTTP methods CloudFront processes and forwards to your Amazon S3 bucket or your custom origin. There are three choices:
CloudFront forwards only GET and HEAD requests.
CloudFront forwards only GET , HEAD , and OPTIONS requests.
CloudFront forwards GET, HEAD, OPTIONS, PUT, PATCH, POST , and DELETE requests.
If you pick the third choice, you may need to restrict access to your Amazon S3 bucket or to your custom origin so users can't perform operations that you don't want them to. For example, you might not want users to have permissions to delete objects from your origin.
Quantity (integer) -- [REQUIRED]The number of HTTP methods that you want CloudFront to forward to your origin. Valid values are 2 (for GET and HEAD requests), 3 (for GET , HEAD , and OPTIONS requests) and 7 (for GET, HEAD, OPTIONS, PUT, PATCH, POST , and DELETE requests).
Items (list) -- [REQUIRED]A complex type that contains the HTTP methods that you want CloudFront to process and forward to your origin.
(string) --
CachedMethods (dict) --A complex type that controls whether CloudFront caches the response to requests using the specified HTTP methods. There are two choices:
CloudFront caches responses to GET and HEAD requests.
CloudFront caches responses to GET , HEAD , and OPTIONS requests.
If you pick the second choice for your Amazon S3 Origin, you may need to forward Access-Control-Request-Method, Access-Control-Request-Headers, and Origin headers for the responses to be cached correctly.
Quantity (integer) -- [REQUIRED]The number of HTTP methods for which you want CloudFront to cache responses. Valid values are 2 (for caching responses to GET and HEAD requests) and 3 (for caching responses to GET , HEAD , and OPTIONS requests).
Items (list) -- [REQUIRED]A complex type that contains the HTTP methods that you want CloudFront to cache responses to.
(string) --
SmoothStreaming (boolean) --Indicates whether you want to distribute media files in the Microsoft Smooth Streaming format using the origin that is associated with this cache behavior. If so, specify true ; if not, specify false . If you specify true for SmoothStreaming , you can still distribute other content using this cache behavior if the content matches the value of PathPattern .
DefaultTTL (integer) --The default amount of time that you want objects to stay in CloudFront caches before CloudFront forwards another request to your origin to determine whether the object has been updated. The value that you specify applies only when your origin does not add HTTP headers such as Cache-Control max-age , Cache-Control s-maxage , and Expires to objects. For more information, see Specifying How Long Objects and Errors Stay in a CloudFront Edge Cache (Expiration) in the Amazon CloudFront Developer Guide .
MaxTTL (integer) --The maximum amount of time that you want objects to stay in CloudFront caches before CloudFront forwards another request to your origin to determine whether the object has been updated. The value that you specify applies only when your origin adds HTTP headers such as Cache-Control max-age , Cache-Control s-maxage , and Expires to objects. For more information, see Specifying How Long Objects and Errors Stay in a CloudFront Edge Cache (Expiration) in the Amazon CloudFront Developer Guide .
Compress (boolean) --Whether you want CloudFront to automatically compress certain files for this cache behavior. If so, specify true; if not, specify false. For more information, see Serving Compressed Files in the Amazon CloudFront Developer Guide .
LambdaFunctionAssociations (dict) --A complex type that contains zero or more Lambda function associations for a cache behavior.
Quantity (integer) -- [REQUIRED]The number of Lambda function associations for this cache behavior.
Items (list) --
Optional : A complex type that contains LambdaFunctionAssociation items for this cache behavior. If Quantity is 0 , you can omit Items .
(dict) --A complex type that contains a Lambda function association.
LambdaFunctionARN (string) --The ARN of the Lambda function.
EventType (string) --Specifies the event type that triggers a Lambda function invocation. Valid values are:
viewer-request
origin-request
viewer-response
origin-response
CustomErrorResponses (dict) --A complex type that controls the following:
Whether CloudFront replaces HTTP status codes in the 4xx and 5xx range with custom error messages before returning the response to the viewer.
How long CloudFront caches HTTP status codes in the 4xx and 5xx range.
For more information about custom error pages, see Customizing Error Responses in the Amazon CloudFront Developer Guide .
Quantity (integer) -- [REQUIRED]The number of HTTP status codes for which you want to specify a custom error page and/or a caching duration. If Quantity is 0 , you can omit Items .
Items (list) --A complex type that contains a CustomErrorResponse element for each HTTP status code for which you want to specify a custom error page and/or a caching duration.
(dict) --A complex type that controls:
Whether CloudFront replaces HTTP status codes in the 4xx and 5xx range with custom error messages before returning the response to the viewer.
How long CloudFront caches HTTP status codes in the 4xx and 5xx range.
For more information about custom error pages, see Customizing Error Responses in the Amazon CloudFront Developer Guide .
ErrorCode (integer) -- [REQUIRED]The HTTP status code for which you want to specify a custom error page and/or a caching duration.
ResponsePagePath (string) --The path to the custom error page that you want CloudFront to return to a viewer when your origin returns the HTTP status code specified by ErrorCode , for example, /4xx-errors/403-forbidden.html . If you want to store your objects and your custom error pages in different locations, your distribution must include a cache behavior for which the following is true:
The value of PathPattern matches the path to your custom error messages. For example, suppose you saved custom error pages for 4xx errors in an Amazon S3 bucket in a directory named /4xx-errors . Your distribution must include a cache behavior for which the path pattern routes requests for your custom error pages to that location, for example, /4xx-errors/* .
The value of TargetOriginId specifies the value of the ID element for the origin that contains your custom error pages.
If you specify a value for ResponsePagePath , you must also specify a value for ResponseCode . If you don't want to specify a value, include an empty element, ResponsePagePath , in the XML document.
We recommend that you store custom error pages in an Amazon S3 bucket. If you store custom error pages on an HTTP server and the server starts to return 5xx errors, CloudFront can't get the files that you want to return to viewers because the origin server is unavailable.
ResponseCode (string) --The HTTP status code that you want CloudFront to return to the viewer along with the custom error page. There are a variety of reasons that you might want CloudFront to return a status code different from the status code that your origin returned to CloudFront, for example:
Some Internet devices (some firewalls and corporate proxies, for example) intercept HTTP 4xx and 5xx and prevent the response from being returned to the viewer. If you substitute 200 , the response typically won't be intercepted.
If you don't care about distinguishing among different client errors or server errors, you can specify 400 or 500 as the ResponseCode for all 4xx or 5xx errors.
You might want to return a 200 status code (OK) and static website so your customers don't know that your website is down.
If you specify a value for ResponseCode , you must also specify a value for ResponsePagePath . If you don't want to specify a value, include an empty element, ResponseCode , in the XML document.
ErrorCachingMinTTL (integer) --The minimum amount of time, in seconds, that you want CloudFront to cache the HTTP status code specified in ErrorCode . When this time period has elapsed, CloudFront queries your origin to see whether the problem that caused the error has been resolved and the requested object is now available.
If you don't want to specify a value, include an empty element, ErrorCachingMinTTL , in the XML document.
For more information, see Customizing Error Responses in the Amazon CloudFront Developer Guide .
Comment (string) -- [REQUIRED]Any comments you want to include about the distribution.
If you don't want to specify a comment, include an empty Comment element.
To delete an existing comment, update the distribution configuration and include an empty Comment element.
To add or change a comment, update the distribution configuration and specify the new comment.
Logging (dict) --A complex type that controls whether access logs are written for the distribution.
For more information about logging, see Access Logs in the Amazon CloudFront Developer Guide .
Enabled (boolean) -- [REQUIRED]Specifies whether you want CloudFront to save access logs to an Amazon S3 bucket. If you do not want to enable logging when you create a distribution or if you want to disable logging for an existing distribution, specify false for Enabled , and specify empty Bucket and Prefix elements. If you specify false for Enabled but you specify values for Bucket , prefix , and IncludeCookies , the values are automatically deleted.
IncludeCookies (boolean) -- [REQUIRED]Specifies whether you want CloudFront to include cookies in access logs, specify true for IncludeCookies . If you choose to include cookies in logs, CloudFront logs all cookies regardless of how you configure the cache behaviors for this distribution. If you do not want to include cookies when you create a distribution or if you want to disable include cookies for an existing distribution, specify false for IncludeCookies .
Bucket (string) -- [REQUIRED]The Amazon S3 bucket to store the access logs in, for example, myawslogbucket.s3.amazonaws.com .
Prefix (string) -- [REQUIRED]An optional string that you want CloudFront to prefix to the access log filenames for this distribution, for example, myprefix/ . If you want to enable logging, but you do not want to specify a prefix, you still must include an empty Prefix element in the Logging element.
PriceClass (string) --The price class that corresponds with the maximum price that you want to pay for CloudFront service. If you specify PriceClass_All , CloudFront responds to requests for your objects from all CloudFront edge locations.
If you specify a price class other than PriceClass_All , CloudFront serves your objects from the CloudFront edge location that has the lowest latency among the edge locations in your price class. Viewers who are in or near regions that are excluded from your specified price class may encounter slower performance.
For more information about price classes, see Choosing the Price Class for a CloudFront Distribution in the Amazon CloudFront Developer Guide . For information about CloudFront pricing, including how price classes map to CloudFront regions, see Amazon CloudFront Pricing .
Enabled (boolean) -- [REQUIRED]From this field, you can enable or disable the selected distribution.
If you specify false for Enabled but you specify values for Bucket and Prefix , the values are automatically deleted.
ViewerCertificate (dict) --A complex type that specifies the following:
Which SSL/TLS certificate to use when viewers request objects using HTTPS
Whether you want CloudFront to use dedicated IP addresses or SNI when you're using alternate domain names in your object names
The minimum protocol version that you want CloudFront to use when communicating with viewers
For more information, see Using an HTTPS Connection to Access Your Objects in the Amazon Amazon CloudFront Developer Guide .
CloudFrontDefaultCertificate (boolean) --
IAMCertificateId (string) --
ACMCertificateArn (string) --
SSLSupportMethod (string) --If you specify a value for ACMCertificateArn or for IAMCertificateId , you must also specify how you want CloudFront to serve HTTPS requests: using a method that works for all clients or one that works for most clients:
vip : CloudFront uses dedicated IP addresses for your content and can respond to HTTPS requests from any viewer. However, you will incur additional monthly charges.
sni-only : CloudFront can respond to HTTPS requests from viewers that support Server Name Indication (SNI). All modern browsers support SNI, but some browsers still in use don't support SNI. If some of your users' browsers don't support SNI, we recommend that you do one of the following:
Use the vip option (dedicated IP addresses) instead of sni-only .
Use the CloudFront SSL/TLS certificate instead of a custom certificate. This requires that you use the CloudFront domain name of your distribution in the URLs for your objects, for example, https://d111111abcdef8.cloudfront.net/logo.png .
If you can control which browser your users use, upgrade the browser to one that supports SNI.
Use HTTP instead of HTTPS.
Do not specify a value for SSLSupportMethod if you specified CloudFrontDefaultCertificatetrueCloudFrontDefaultCertificate .
For more information, see Using Alternate Domain Names and HTTPS in the Amazon CloudFront Developer Guide .
MinimumProtocolVersion (string) --Specify the minimum version of the SSL/TLS protocol that you want CloudFront to use for HTTPS connections between viewers and CloudFront: SSLv3 or TLSv1 . CloudFront serves your objects only to viewers that support SSL/TLS version that you specify and later versions. The TLSv1 protocol is more secure, so we recommend that you specify SSLv3 only if your users are using browsers or devices that don't support TLSv1 . Note the following:
If you specify CloudFrontDefaultCertificatetrueCloudFrontDefaultCertificate, the minimum SSL protocol version is TLSv1 and can't be changed.
If you're using a custom certificate (if you specify a value for ACMCertificateArn or for IAMCertificateId ) and if you're using SNI (if you specify sni-only for SSLSupportMethod ), you must specify TLSv1 for MinimumProtocolVersion .
Certificate (string) --Include one of these values to specify the following:
Whether you want viewers to use HTTP or HTTPS to request your objects.
If you want viewers to use HTTPS, whether you're using an alternate domain name such as example.com or the CloudFront domain name for your distribution, such as d111111abcdef8.cloudfront.net .
If you're using an alternate domain name, whether AWS Certificate Manager (ACM) provided the certificate, or you purchased a certificate from a third-party certificate authority and imported it into ACM or uploaded it to the IAM certificate store.
You must specify one (and only one) of the three values. Do not specify false for CloudFrontDefaultCertificate .
If you want viewers to use HTTP to request your objects : Specify the following value:CloudFrontDefaultCertificatetrueCloudFrontDefaultCertificate
In addition, specify allow-all for ViewerProtocolPolicy for all of your cache behaviors.
If you want viewers to use HTTPS to request your objects : Choose the type of certificate that you want to use based on whether you're using an alternate domain name for your objects or the CloudFront domain name:
If you're using an alternate domain name, such as example.com : Specify one of the following values, depending on whether ACM provided your certificate or you purchased your certificate from third-party certificate authority:
ACMCertificateArnARN for ACM SSL/TLS certificateACMCertificateArn where ARN for ACM SSL/TLS certificate is the ARN for the ACM SSL/TLS certificate that you want to use for this distribution.
IAMCertificateIdIAM certificate IDIAMCertificateId where IAM certificate ID is the ID that IAM returned when you added the certificate to the IAM certificate store.
If you specify ACMCertificateArn or IAMCertificateId , you must also specify a value for SSLSupportMethod .
If you choose to use an ACM certificate or a certificate in the IAM certificate store, we recommend that you use only an alternate domain name in your object URLs (https://example.com/logo.jpg ). If you use the domain name that is associated with your CloudFront distribution (https://d111111abcdef8.cloudfront.net/logo.jpg ) and the viewer supports SNI , then CloudFront behaves normally. However, if the browser does not support SNI, the user's experience depends on the value that you choose for SSLSupportMethod :
vip : The viewer displays a warning because there is a mismatch between the CloudFront domain name and the domain name in your SSL/TLS certificate.
sni-only : CloudFront drops the connection with the browser without returning the object.
**If you're using the CloudFront domain name for your distribution, such as d111111abcdef8.cloudfront.net ** : Specify the following value: `` CloudFrontDefaultCertificatetrueCloudFrontDefaultCertificate`` If you want viewers to use HTTPS, you must also specify one of the following values in your cache behaviors:
ViewerProtocolPolicyhttps-onlyViewerProtocolPolicy
ViewerProtocolPolicyredirect-to-httpsViewerProtocolPolicy
You can also optionally require that CloudFront use HTTPS to communicate with your origin by specifying one of the following values for the applicable origins:
OriginProtocolPolicyhttps-onlyOriginProtocolPolicy
OriginProtocolPolicymatch-viewerOriginProtocolPolicy
For more information, see Using Alternate Domain Names and HTTPS in the Amazon CloudFront Developer Guide .
CertificateSource (string) --
Note
This field is deprecated. You can use one of the following: [ACMCertificateArn , IAMCertificateId , or CloudFrontDefaultCertificate] .
Restrictions (dict) --A complex type that identifies ways in which you want to restrict distribution of your content.
GeoRestriction (dict) -- [REQUIRED]A complex type that controls the countries in which your content is distributed. CloudFront determines the location of your users using MaxMind GeoIP databases.
RestrictionType (string) -- [REQUIRED]The method that you want to use to restrict distribution of your content by country:
none : No geo restriction is enabled, meaning access to content is not restricted by client geo location.
blacklist : The Location elements specify the countries in which you do not want CloudFront to distribute your content.
whitelist : The Location elements specify the countries in which you want CloudFront to distribute your content.
Quantity (integer) -- [REQUIRED]When geo restriction is enabled , this is the number of countries in your whitelist or blacklist . Otherwise, when it is not enabled, Quantity is 0 , and you can omit Items .
Items (list) --A complex type that contains a Location element for each country in which you want CloudFront either to distribute your content (whitelist ) or not distribute your content (blacklist ).
The Location element is a two-letter, uppercase country code for a country that you want to include in your blacklist or whitelist . Include one Location element for each country.
CloudFront and MaxMind both use ISO 3166 country codes. For the current list of countries and the corresponding codes, see ISO 3166-1-alpha-2 code on the International Organization for Standardization website. You can also refer to the country list in the CloudFront console, which includes both country names and codes.
(string) --
WebACLId (string) --A unique identifier that specifies the AWS WAF web ACL, if any, to associate with this distribution.
AWS WAF is a web application firewall that lets you monitor the HTTP and HTTPS requests that are forwarded to CloudFront, and lets you control access to your content. Based on conditions that you specify, such as the IP addresses that requests originate from or the values of query strings, CloudFront responds to requests either with the requested content or with an HTTP 403 status code (Forbidden). You can also configure CloudFront to return a custom error page when a request is blocked. For more information about AWS WAF, see the AWS WAF Developer Guide .
HttpVersion (string) --(Optional) Specify the maximum HTTP version that you want viewers to use to communicate with CloudFront. The default value for new web distributions is http2. Viewers that don't support HTTP/2 automatically use an earlier HTTP version.
For viewers and CloudFront to use HTTP/2, viewers must support TLS 1.2 or later, and must support Server Name Identification (SNI).
In general, configuring CloudFront to communicate with viewers using HTTP/2 reduces latency. You can improve performance by optimizing for HTTP/2. For more information, do an Internet search for 'http/2 optimization.'
IsIPV6Enabled (boolean) --If you want CloudFront to respond to IPv6 DNS requests with an IPv6 address for your distribution, specify true . If you specify false , CloudFront responds to IPv6 DNS requests with the DNS response code NOERROR and with no IP addresses. This allows viewers to submit a second request, for an IPv4 address for your distribution.
In general, you should enable IPv6 if you have users on IPv6 networks who want to access your content. However, if you're using signed URLs or signed cookies to restrict access to your content, and if you're using a custom policy that includes the IpAddress parameter to restrict the IP addresses that can access your content, do not enable IPv6. If you want to restrict access to some content by IP address and not restrict access to other content (or restrict access but not by IP address), you can create two distributions. For more information, see Creating a Signed URL Using a Custom Policy in the Amazon CloudFront Developer Guide .
If you're using an Amazon Route 53 alias resource record set to route traffic to your CloudFront distribution, you need to create a second alias resource record set when both of the following are true:
You enable IPv6 for the distribution
You're using alternate domain names in the URLs for your objects
For more information, see Routing Traffic to an Amazon CloudFront Web Distribution by Using Your Domain Name in the Amazon Route 53 Developer Guide .
If you created a CNAME resource record set, either with Amazon Route 53 or with another DNS service, you don't need to make any changes. A CNAME record will route traffic to your distribution regardless of the IP address format of the viewer request.
:type Id: string
:param Id: [REQUIRED]
The distribution's id.
:type IfMatch: string
:param IfMatch: The value of the ETag header that you received when retrieving the distribution's configuration. For example: E2QWRUHAPOMQZL .
:rtype: dict
:return: {
'Distribution': {
'Id': 'string',
'ARN': 'string',
'Status': 'string',
'LastModifiedTime': datetime(2015, 1, 1),
'InProgressInvalidationBatches': 123,
'DomainName': 'string',
'ActiveTrustedSigners': {
'Enabled': True|False,
'Quantity': 123,
'Items': [
{
'AwsAccountNumber': 'string',
'KeyPairIds': {
'Quantity': 123,
'Items': [
'string',
]
}
},
]
},
'DistributionConfig': {
'CallerReference': 'string',
'Aliases': {
'Quantity': 123,
'Items': [
'string',
]
},
'DefaultRootObject': 'string',
'Origins': {
'Quantity': 123,
'Items': [
{
'Id': 'string',
'DomainName': 'string',
'OriginPath': 'string',
'CustomHeaders': {
'Quantity': 123,
'Items': [
{
'HeaderName': 'string',
'HeaderValue': 'string'
},
]
},
'S3OriginConfig': {
'OriginAccessIdentity': 'string'
},
'CustomOriginConfig': {
'HTTPPort': 123,
'HTTPSPort': 123,
'OriginProtocolPolicy': 'http-only'|'match-viewer'|'https-only',
'OriginSslProtocols': {
'Quantity': 123,
'Items': [
'SSLv3'|'TLSv1'|'TLSv1.1'|'TLSv1.2',
]
},
'OriginReadTimeout': 123,
'OriginKeepaliveTimeout': 123
}
},
]
},
'DefaultCacheBehavior': {
'TargetOriginId': 'string',
'ForwardedValues': {
'QueryString': True|False,
'Cookies': {
'Forward': 'none'|'whitelist'|'all',
'WhitelistedNames': {
'Quantity': 123,
'Items': [
'string',
]
}
},
'Headers': {
'Quantity': 123,
'Items': [
'string',
]
},
'QueryStringCacheKeys': {
'Quantity': 123,
'Items': [
'string',
]
}
},
'TrustedSigners': {
'Enabled': True|False,
'Quantity': 123,
'Items': [
'string',
]
},
'ViewerProtocolPolicy': 'allow-all'|'https-only'|'redirect-to-https',
'MinTTL': 123,
'AllowedMethods': {
'Quantity': 123,
'Items': [
'GET'|'HEAD'|'POST'|'PUT'|'PATCH'|'OPTIONS'|'DELETE',
],
'CachedMethods': {
'Quantity': 123,
'Items': [
'GET'|'HEAD'|'POST'|'PUT'|'PATCH'|'OPTIONS'|'DELETE',
]
}
},
'SmoothStreaming': True|False,
'DefaultTTL': 123,
'MaxTTL': 123,
'Compress': True|False,
'LambdaFunctionAssociations': {
'Quantity': 123,
'Items': [
{
'LambdaFunctionARN': 'string',
'EventType': 'viewer-request'|'viewer-response'|'origin-request'|'origin-response'
},
]
}
},
'CacheBehaviors': {
'Quantity': 123,
'Items': [
{
'PathPattern': 'string',
'TargetOriginId': 'string',
'ForwardedValues': {
'QueryString': True|False,
'Cookies': {
'Forward': 'none'|'whitelist'|'all',
'WhitelistedNames': {
'Quantity': 123,
'Items': [
'string',
]
}
},
'Headers': {
'Quantity': 123,
'Items': [
'string',
]
},
'QueryStringCacheKeys': {
'Quantity': 123,
'Items': [
'string',
]
}
},
'TrustedSigners': {
'Enabled': True|False,
'Quantity': 123,
'Items': [
'string',
]
},
'ViewerProtocolPolicy': 'allow-all'|'https-only'|'redirect-to-https',
'MinTTL': 123,
'AllowedMethods': {
'Quantity': 123,
'Items': [
'GET'|'HEAD'|'POST'|'PUT'|'PATCH'|'OPTIONS'|'DELETE',
],
'CachedMethods': {
'Quantity': 123,
'Items': [
'GET'|'HEAD'|'POST'|'PUT'|'PATCH'|'OPTIONS'|'DELETE',
]
}
},
'SmoothStreaming': True|False,
'DefaultTTL': 123,
'MaxTTL': 123,
'Compress': True|False,
'LambdaFunctionAssociations': {
'Quantity': 123,
'Items': [
{
'LambdaFunctionARN': 'string',
'EventType': 'viewer-request'|'viewer-response'|'origin-request'|'origin-response'
},
]
}
},
]
},
'CustomErrorResponses': {
'Quantity': 123,
'Items': [
{
'ErrorCode': 123,
'ResponsePagePath': 'string',
'ResponseCode': 'string',
'ErrorCachingMinTTL': 123
},
]
},
'Comment': 'string',
'Logging': {
'Enabled': True|False,
'IncludeCookies': True|False,
'Bucket': 'string',
'Prefix': 'string'
},
'PriceClass': 'PriceClass_100'|'PriceClass_200'|'PriceClass_All',
'Enabled': True|False,
'ViewerCertificate': {
'CloudFrontDefaultCertificate': True|False,
'IAMCertificateId': 'string',
'ACMCertificateArn': 'string',
'SSLSupportMethod': 'sni-only'|'vip',
'MinimumProtocolVersion': 'SSLv3'|'TLSv1',
'Certificate': 'string',
'CertificateSource': 'cloudfront'|'iam'|'acm'
},
'Restrictions': {
'GeoRestriction': {
'RestrictionType': 'blacklist'|'whitelist'|'none',
'Quantity': 123,
'Items': [
'string',
]
}
},
'WebACLId': 'string',
'HttpVersion': 'http1.1'|'http2',
'IsIPV6Enabled': True|False
}
},
'ETag': 'string'
}
:returns:
self , which is the AWS account used to create the distribution.
An AWS account number.
"""
pass
def update_streaming_distribution(StreamingDistributionConfig=None, Id=None, IfMatch=None):
"""
Update a streaming distribution.
See also: AWS API Documentation
:example: response = client.update_streaming_distribution(
StreamingDistributionConfig={
'CallerReference': 'string',
'S3Origin': {
'DomainName': 'string',
'OriginAccessIdentity': 'string'
},
'Aliases': {
'Quantity': 123,
'Items': [
'string',
]
},
'Comment': 'string',
'Logging': {
'Enabled': True|False,
'Bucket': 'string',
'Prefix': 'string'
},
'TrustedSigners': {
'Enabled': True|False,
'Quantity': 123,
'Items': [
'string',
]
},
'PriceClass': 'PriceClass_100'|'PriceClass_200'|'PriceClass_All',
'Enabled': True|False
},
Id='string',
IfMatch='string'
)
:type StreamingDistributionConfig: dict
:param StreamingDistributionConfig: [REQUIRED]
The streaming distribution's configuration information.
CallerReference (string) -- [REQUIRED]A unique number that ensures that the request can't be replayed. If the CallerReference is new (no matter the content of the StreamingDistributionConfig object), a new streaming distribution is created. If the CallerReference is a value that you already sent in a previous request to create a streaming distribution, and the content of the StreamingDistributionConfig is identical to the original request (ignoring white space), the response includes the same information returned to the original request. If the CallerReference is a value that you already sent in a previous request to create a streaming distribution but the content of the StreamingDistributionConfig is different from the original request, CloudFront returns a DistributionAlreadyExists error.
S3Origin (dict) -- [REQUIRED]A complex type that contains information about the Amazon S3 bucket from which you want CloudFront to get your media files for distribution.
DomainName (string) -- [REQUIRED]The DNS name of the Amazon S3 origin.
OriginAccessIdentity (string) -- [REQUIRED]The CloudFront origin access identity to associate with the RTMP distribution. Use an origin access identity to configure the distribution so that end users can only access objects in an Amazon S3 bucket through CloudFront.
If you want end users to be able to access objects using either the CloudFront URL or the Amazon S3 URL, specify an empty OriginAccessIdentity element.
To delete the origin access identity from an existing distribution, update the distribution configuration and include an empty OriginAccessIdentity element.
To replace the origin access identity, update the distribution configuration and specify the new origin access identity.
For more information, see Using an Origin Access Identity to Restrict Access to Your Amazon S3 Content in the Amazon Amazon CloudFront Developer Guide .
Aliases (dict) --A complex type that contains information about CNAMEs (alternate domain names), if any, for this streaming distribution.
Quantity (integer) -- [REQUIRED]The number of CNAME aliases, if any, that you want to associate with this distribution.
Items (list) --A complex type that contains the CNAME aliases, if any, that you want to associate with this distribution.
(string) --
Comment (string) -- [REQUIRED]Any comments you want to include about the streaming distribution.
Logging (dict) --A complex type that controls whether access logs are written for the streaming distribution.
Enabled (boolean) -- [REQUIRED]Specifies whether you want CloudFront to save access logs to an Amazon S3 bucket. If you do not want to enable logging when you create a streaming distribution or if you want to disable logging for an existing streaming distribution, specify false for Enabled , and specify empty Bucket and Prefix elements. If you specify false for Enabled but you specify values for Bucket and Prefix , the values are automatically deleted.
Bucket (string) -- [REQUIRED]The Amazon S3 bucket to store the access logs in, for example, myawslogbucket.s3.amazonaws.com .
Prefix (string) -- [REQUIRED]An optional string that you want CloudFront to prefix to the access log filenames for this streaming distribution, for example, myprefix/ . If you want to enable logging, but you do not want to specify a prefix, you still must include an empty Prefix element in the Logging element.
TrustedSigners (dict) -- [REQUIRED]A complex type that specifies any AWS accounts that you want to permit to create signed URLs for private content. If you want the distribution to use signed URLs, include this element; if you want the distribution to use public URLs, remove this element. For more information, see Serving Private Content through CloudFront in the Amazon CloudFront Developer Guide .
Enabled (boolean) -- [REQUIRED]Specifies whether you want to require viewers to use signed URLs to access the files specified by PathPattern and TargetOriginId .
Quantity (integer) -- [REQUIRED]The number of trusted signers for this cache behavior.
Items (list) --
Optional : A complex type that contains trusted signers for this cache behavior. If Quantity is 0 , you can omit Items .
(string) --
PriceClass (string) --A complex type that contains information about price class for this streaming distribution.
Enabled (boolean) -- [REQUIRED]Whether the streaming distribution is enabled to accept user requests for content.
:type Id: string
:param Id: [REQUIRED]
The streaming distribution's id.
:type IfMatch: string
:param IfMatch: The value of the ETag header that you received when retrieving the streaming distribution's configuration. For example: E2QWRUHAPOMQZL .
:rtype: dict
:return: {
'StreamingDistribution': {
'Id': 'string',
'ARN': 'string',
'Status': 'string',
'LastModifiedTime': datetime(2015, 1, 1),
'DomainName': 'string',
'ActiveTrustedSigners': {
'Enabled': True|False,
'Quantity': 123,
'Items': [
{
'AwsAccountNumber': 'string',
'KeyPairIds': {
'Quantity': 123,
'Items': [
'string',
]
}
},
]
},
'StreamingDistributionConfig': {
'CallerReference': 'string',
'S3Origin': {
'DomainName': 'string',
'OriginAccessIdentity': 'string'
},
'Aliases': {
'Quantity': 123,
'Items': [
'string',
]
},
'Comment': 'string',
'Logging': {
'Enabled': True|False,
'Bucket': 'string',
'Prefix': 'string'
},
'TrustedSigners': {
'Enabled': True|False,
'Quantity': 123,
'Items': [
'string',
]
},
'PriceClass': 'PriceClass_100'|'PriceClass_200'|'PriceClass_All',
'Enabled': True|False
}
},
'ETag': 'string'
}
:returns:
self , which is the AWS account used to create the distribution.
An AWS account number.
"""
pass
|
# https://codeforces.com/problemset/problem/467/A
n = int(input())
rooms = [list(map(int, input().split())) for _ in range(n)]
ans = 0
for room in rooms:
if room[1] - room[0] >= 2:
ans += 1
print(ans) |
#
# PySNMP MIB module A3COM-HUAWEI-VRRP-EXT-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/A3COM-HUAWEI-VRRP-EXT-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 16:53:06 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019, 09:23:15)
#
h3cCommon, = mibBuilder.importSymbols("A3COM-HUAWEI-OID-MIB", "h3cCommon")
ObjectIdentifier, OctetString, Integer = mibBuilder.importSymbols("ASN1", "ObjectIdentifier", "OctetString", "Integer")
NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues")
SingleValueConstraint, ConstraintsIntersection, ValueRangeConstraint, ValueSizeConstraint, ConstraintsUnion = mibBuilder.importSymbols("ASN1-REFINEMENT", "SingleValueConstraint", "ConstraintsIntersection", "ValueRangeConstraint", "ValueSizeConstraint", "ConstraintsUnion")
ifIndex, = mibBuilder.importSymbols("IF-MIB", "ifIndex")
NotificationGroup, ModuleCompliance = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance")
NotificationType, ModuleIdentity, Counter32, TimeTicks, Unsigned32, ObjectIdentity, Bits, IpAddress, Counter64, MibIdentifier, MibScalar, MibTable, MibTableRow, MibTableColumn, iso, Gauge32, Integer32 = mibBuilder.importSymbols("SNMPv2-SMI", "NotificationType", "ModuleIdentity", "Counter32", "TimeTicks", "Unsigned32", "ObjectIdentity", "Bits", "IpAddress", "Counter64", "MibIdentifier", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "iso", "Gauge32", "Integer32")
DisplayString, RowStatus, TextualConvention = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "RowStatus", "TextualConvention")
vrrpOperVrId, = mibBuilder.importSymbols("VRRP-MIB", "vrrpOperVrId")
h3cVrrpExt = ModuleIdentity((1, 3, 6, 1, 4, 1, 43, 45, 1, 10, 2, 24))
if mibBuilder.loadTexts: h3cVrrpExt.setLastUpdated('200412090000Z')
if mibBuilder.loadTexts: h3cVrrpExt.setOrganization('Huawei-3Com Technologies Co.,Ltd.')
h3cVrrpExtMibObject = MibIdentifier((1, 3, 6, 1, 4, 1, 43, 45, 1, 10, 2, 24, 1))
h3cVrrpExtTable = MibTable((1, 3, 6, 1, 4, 1, 43, 45, 1, 10, 2, 24, 1, 1), )
if mibBuilder.loadTexts: h3cVrrpExtTable.setStatus('current')
h3cVrrpExtEntry = MibTableRow((1, 3, 6, 1, 4, 1, 43, 45, 1, 10, 2, 24, 1, 1, 1), ).setIndexNames((0, "IF-MIB", "ifIndex"), (0, "VRRP-MIB", "vrrpOperVrId"), (0, "A3COM-HUAWEI-VRRP-EXT-MIB", "h3cVrrpExtTrackInterface"))
if mibBuilder.loadTexts: h3cVrrpExtEntry.setStatus('current')
h3cVrrpExtTrackInterface = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 45, 1, 10, 2, 24, 1, 1, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 2147483647)))
if mibBuilder.loadTexts: h3cVrrpExtTrackInterface.setStatus('current')
h3cVrrpExtPriorityReduce = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 45, 1, 10, 2, 24, 1, 1, 1, 2), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 255)).clone(10)).setMaxAccess("readcreate")
if mibBuilder.loadTexts: h3cVrrpExtPriorityReduce.setStatus('current')
h3cVrrpExtRowStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 45, 1, 10, 2, 24, 1, 1, 1, 3), RowStatus()).setMaxAccess("readcreate")
if mibBuilder.loadTexts: h3cVrrpExtRowStatus.setStatus('current')
mibBuilder.exportSymbols("A3COM-HUAWEI-VRRP-EXT-MIB", h3cVrrpExtMibObject=h3cVrrpExtMibObject, h3cVrrpExtPriorityReduce=h3cVrrpExtPriorityReduce, PYSNMP_MODULE_ID=h3cVrrpExt, h3cVrrpExtTrackInterface=h3cVrrpExtTrackInterface, h3cVrrpExtRowStatus=h3cVrrpExtRowStatus, h3cVrrpExtEntry=h3cVrrpExtEntry, h3cVrrpExtTable=h3cVrrpExtTable, h3cVrrpExt=h3cVrrpExt)
|
age = float(input())
gender = input()
if gender == 'm':
if 0 < age < 16:
print('Master')
elif age >= 16:
print ('Mr.')
elif gender == 'f':
if 0 < age < 16:
print('Miss')
elif age >= 16:
print ('Ms.') |
# encoding: utf-8
"""
error.py
We declare here a class hierarchy for all exceptions produced by IPython, in
cases where we don't just raise one from the standard library.
"""
__docformat__ = "restructuredtext en"
#-------------------------------------------------------------------------------
# Copyright (C) 2008 The IPython Development Team
#
# Distributed under the terms of the BSD License. The full license is in
# the file COPYING, distributed as part of this software.
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
# Imports
#-------------------------------------------------------------------------------
class IPythonError(Exception):
"""Base exception that all of our exceptions inherit from.
This can be raised by code that doesn't have any more specific
information."""
pass
# Exceptions associated with the controller objects
class ControllerError(IPythonError): pass
class ControllerCreationError(ControllerError): pass
# Exceptions associated with the Engines
class EngineError(IPythonError): pass
class EngineCreationError(EngineError): pass
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.