content
stringlengths 7
1.05M
|
---|
"""Contains the methods for reading and writing of files.
All modules and classes involved in the reading or writing of files are
included within this module. Default methods used for writing files (such as
images) do not need to have further definition here, but it is recommended to
obtain the path used for writing through a method in this module.
""" |
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
#
# Copyright 2014 Telefónica Investigación y Desarrollo, S.A.U
#
# This file is part of FI-WARE project.
#
# 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.
#
# For those usages not covered by the Apache version 2.0 License please
# contact with [email protected]
#
# Skuld settings.
__author__ = 'fla'
LOGGING_PATH = u'/var/log/fiware-skuld'
KEYSTONE_ENDPOINT = "http://{KEYSTONE_ENDPOINT}/"
HORIZON_ENDPOINT = "https://{HORIZON_ENDPOINT}/"
TRUSTEE = "idm"
TRUSTEE_PASSWORD = ""
TRIAL_MAX_NUMBER_OF_DAYS = 14 # days
COMMUNITY_MAX_NUMBER_OF_DAYS = 100 # days
NOTIFY_BEFORE_TRIAL_EXPIRED = 7 # days
NOTIFY_BEFORE_COMMUNITY_EXPIRED = 30 # days
STOP_BEFORE_DELETE = 0 # days
TRUSTID_VALIDITY = 36000 # seconds
TRIAL_ROLE_ID = "trial_id"
COMMUNITY_ROLE_ID = "community_id"
BASIC_ROLE_ID = "basic_id"
ADMIN_ROLE_ID = "admin_id"
DONT_DELETE_DOMAINS = ([
'create-net.org', 'telefonica.com', 'man.poznan.pl', 'wigner.mta.hu', 'gatv.ssr.upm.es', 'thalesgroup.com',
'atos.net', 'uth.gr', 'bth.se', 'iminds.be', 'intec.ugent.be', 'neuropublic.gr', 'zhaw.ch', 'tid.es',
'it-innovation.soton.ac.uk', 'cesnet.cz', 'rt.cesnet.cz', 'rt3.cesnet.cz', 'fokus.fraunhofer.de'])
|
ans = []
while True:
a, b = list(map(int, input().split()))
if a == 0 and b == 0:
break
ans.append(a + b)
for a in ans:
print(a)
|
# -*- coding: utf-8 -*-
major = 0
minor = 0
patch = 1
semantic = '{}.{}.{}'.format(major, minor, patch)
|
#Ermittle alle denkbaren Sequenzen mit den vier Basenpaaren AT, TA, CG, GC
paare="AT","TA","CG","GC"
for a in paare:
for b in paare:
for c in paare:
for d in paare:
print(a+b+c+d,end=" ")
|
# listas compostas
test = []
test.append('Igor')
test.append(20)
galera = []
galera.append(test[:])
test[0] = 'maria'
test[1] = 25
galera.append(test)
totmai = totmen = 0
print(galera)
print('-' * 30)
galera = [['joão', 19], ['Ana', 33], ['Joaquim', 15], ['Maria', 45]]
print(galera[3][0][0])
for p in galera:
print(f'{p[0]} > {p[1]}')
print('-' * 30)
galera = []
dado = list()
for p in range(0, 3):
dado.append(str(input('Nome: ')))
dado.append(int(input('Idade: ')))
galera.append(dado[:])
dado.clear()
print(galera)
for pe in galera:
if pe[1] >= 21:
print(f'{pe[0]} é maior de idade')
totmai += 1
else:
print(f'{pe[0]} é menor de idade')
totmen += 1
print(f'Temos {totmai} maiores de idade e {totmen} menores de idade')
|
class QuotaExceptionExceeded(Exception):
pass
class QuotaMaxSimultaneousExceeded(QuotaExceptionExceeded):
pass
class QuotaCpuExceeded(QuotaExceptionExceeded):
pass
class QuotaMemoryExceeded(QuotaExceptionExceeded):
pass
class QuotaHddExceeded(QuotaExceptionExceeded):
pass
class ResourceAlreadyLaunched(Exception):
pass
class DockerExceptionNotFound(Exception):
pass
|
largura = int(input('Indique a largura da parede em metros: '))
altura = int(input('Informe a altura dela: '))
area = (largura * altura)
tinta = area / 2
print(f'A quantidade de tinta necessária para pintar {area}m2,')
print(f'É igual a {tinta} litros de tinta.')
|
class QueryReader:
def __init__(self, delim="\t"):
self.delim = delim
def __call__(self, query_path, include_relevancy=False):
with open(query_path, "r") as fp:
for line in fp:
if include_relevancy == True:
line = line.strip()
query_id, query, relevancy = line.split(sep=self.delim)
relevant, irrelevant = self._get_relevant(relevancy)
yield (query_id, query, relevant, irrelevant)
else:
query_id, query = line.split(sep=self.delim)
yield (query_id, query)
def _get_relevant(self, relevancy):
relevancy = relevancy.split(sep="-")
if len(relevancy) == 2:
relevant, irrelevant = relevancy
irrelevant = set(irrelevant.split(sep=','))
else:
relevant = relevancy[0]
irrelevant = set()
if relevant == '':
relevant = set()
else:
relevant = set(relevant.split(sep=','))
return relevant, irrelevant
class TRECReader:
def __call__(self, judgement_path):
mapping = {}
with open(judgement_path, "r") as fp:
for line in fp:
query, _, doc_id, relevance = line.strip().split()
if int(relevance) == 0:
continue
if query not in mapping:
mapping[query] = set()
mapping[query].add(doc_id)
return mapping
|
# Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Codec:
def __init__(self):
self.array = []
def serialize(self, root):
"""Encodes a tree to a single string.
:type root: TreeNode
:rtype: str
"""
def helper(node):
if not node:
self.array.append("#")
else:
self.array.append(str(node.val))
helper(node.left)
helper(node.right)
helper(root)
return ",".join(self.array)
def deserialize(self, data):
"""Decodes your encoded data to tree.
:type data: str
:rtype: TreeNode
"""
data = data.split(",")
# print(data)
def helper(encoded):
# print(encoded)
value = encoded.pop(0)
if value == "#":
return None
node = TreeNode(int(value))
node.left = helper(encoded)
node.right = helper(encoded)
return node
return helper(data)
# Your Codec object will be instantiated and called as such:
# codec = Codec()
# codec.deserialize(codec.serialize(root))
|
"""
Crie um programa que leia nome e duas notas de varios alunos e
guarde tudo em uma lista composta. No final, mostre um boletim
contendo a media de cada um e permita que o usuario possa mostrar
as notas de cada aluno individualmente.
"""
nomes = []
notas = []
temp = []
while True:
nomes.append(str(input('Nome: ')).strip().title())
for c in range(1, 3):
nota = float(input(f'Nota {c}:'))
while nota > 10 or nota < 0:
nota = float(input(f'\033[31mValor inválido.\033[m\nNota {c}:'))
temp.append(nota)
notas.append(temp[:])
temp.clear()
continuar = str(input('Quer continuar? [S/N]: ')).strip().lower()[0]
while continuar not in 'sn':
continuar = str(input('\033[31mOpção inválida.\033[m\nQuer continuar? [S/N]: ')).strip().lower()[0]
if continuar == 'n':
break
print('-' * 25)
print(f'No. NOME MÉDIA')
print('-' * 25)
for num, name in enumerate(nomes):
media = (notas[num][0] + notas[num][1]) / 2
print(f'{num} {name: <10}{media: >7.2f}')
print('-' * 25)
while True:
aluno = int(input('Digite o No. do aluno cujas notas deseja ver (999 encerra): '))
while aluno < 0 or aluno > len(nomes) - 1 and aluno != 999:
aluno = int(
input('\033[31mNúmero inválido.\033[m\nDigite o No. do aluno cujas notas deseja ver (999 encerra): '))
if aluno == 999:
break
print(f'Notas de {nomes[aluno]} são {notas[aluno]}')
print('FINALIZANDO...\n <<< VOLTE SEMPRE >>>')
# do Guanabara:
# ficha = list()
# while True:
# nome = str(input('Nome: ')).strip().title()
# nota1 = float(input('Nota 1: '))
# nota2 = float(input('Nota 2: '))
# media = (nota1 + nota2) / 2
# ficha.append([nome, [nota1, nota2], media])
# resp = str(input('Quer continuar? [S/N]: ')).strip()[0]
# if resp in 'Nn':
# break
# print('-='*30)
# print(f'{"No.":<4}{"NOME":<10}{"MÉDIA":>8}')
# print('-'*26)
# for i, a in enumerate(ficha):
# print(f'{i:<4}{a[0]:<10}{a[0]:>8.1f}')
# while True:
# print('-'*35)
# opc = int(input('Mostrar notas de qual aluno? (999 interrompe): '))
# if opc == 999:
# print('FINALIZANDO...')
# break
# if opc <= len(ficha) - 1:
# print(f'Notas de {ficha[opc][0]} são {ficha[opc][1]}') |
def gangs(divisors,k):
res=set()
for i in range(1, k+1):
res.add(helper(divisors, i))
return len(res)
def helper(divisors, n):
res=tuple()
for i in divisors:
if n%i==0:
res+=(i, )
return res |
"""Rules for importing a Go toolchain from Nixpkgs.
**NOTE: The following rules must be loaded from
`@io_tweag_rules_nixpkgs//nixpkgs:toolchains/go.bzl` to avoid unnecessary
dependencies on rules_go for those who don't need go toolchain.
`io_bazel_rules_go` must be available for loading before loading of
`@io_tweag_rules_nixpkgs//nixpkgs:toolchains/go.bzl`.**
"""
load(
"@io_bazel_rules_go//go:deps.bzl",
"go_wrap_sdk",
)
load(
"//nixpkgs:nixpkgs.bzl",
"nixpkgs_package",
)
def nixpkgs_go_configure(
sdk_name = "go_sdk",
repository = None,
repositories = {},
nix_file = None,
nix_file_deps = None,
nix_file_content = None,
nixopts = []):
"""Use go toolchain from Nixpkgs. Will fail if not a nix-based platform.
By default rules_go configures the go toolchain to be downloaded as binaries (which doesn't work on NixOS),
there is a way to tell rules_go to look into environment and find local go binary which is not hermetic.
This command allows to setup hermetic go sdk from Nixpkgs, which should be considerate as best practice.
Note that the nix package must provide a full go sdk at the root of the package instead of in `$out/share/go`,
and also provide an empty normal file named `PACKAGE_ROOT` at the root of package.
#### Example
```bzl
nixpkgs_go_configure(repository = "@nixpkgs//:default.nix")
```
Example (optional nix support when go is a transitive dependency):
```bzl
# .bazel-lib/nixos-support.bzl
def _has_nix(ctx):
return ctx.which("nix-build") != None
def _gen_imports_impl(ctx):
ctx.file("BUILD", "")
imports_for_nix = \"""
load("@io_tweag_rules_nixpkgs//nixpkgs:toolchains/go.bzl", "nixpkgs_go_toolchain")
def fix_go():
nixpkgs_go_toolchain(repository = "@nixpkgs")
\"""
imports_for_non_nix = \"""
def fix_go():
# if go isn't transitive you'll need to add call to go_register_toolchains here
pass
\"""
if _has_nix(ctx):
ctx.file("imports.bzl", imports_for_nix)
else:
ctx.file("imports.bzl", imports_for_non_nix)
_gen_imports = repository_rule(
implementation = _gen_imports_impl,
attrs = dict(),
)
def gen_imports():
_gen_imports(
name = "nixos_support",
)
# WORKSPACE
// ...
http_archive(name = "io_tweag_rules_nixpkgs", ...)
// ...
local_repository(
name = "bazel_lib",
path = ".bazel-lib",
)
load("@bazel_lib//:nixos-support.bzl", "gen_imports")
gen_imports()
load("@nixos_support//:imports.bzl", "fix_go")
fix_go()
```
Args:
sdk_name: Go sdk name to pass to rules_go
nix_file: An expression for a Nix environment derivation. The environment should expose the whole go SDK (`bin`, `src`, ...) at the root of package. It also must contain a `PACKAGE_ROOT` file in the root of pacakge.
nix_file_deps: Dependencies of `nix_file` if any.
nix_file_content: An expression for a Nix environment derivation.
repository: A repository label identifying which Nixpkgs to use. Equivalent to `repositories = { "nixpkgs": ...}`.
repositories: A dictionary mapping `NIX_PATH` entries to repository labels.
Setting it to
```
repositories = { "myrepo" : "//:myrepo" }
```
for example would replace all instances of `<myrepo>` in the called nix code by the path to the target `"//:myrepo"`. See the [relevant section in the nix manual](https://nixos.org/nix/manual/#env-NIX_PATH) in the nix manual for more information.
Specify one of `path` or `repositories`.
"""
if not nix_file and not nix_file_content:
nix_file_content = """
with import <nixpkgs> { config = {}; overlays = []; }; buildEnv {
name = "bazel-go-toolchain";
paths = [
go
];
postBuild = ''
touch $out/PACKAGE_ROOT
ln -s $out/share/go/{api,doc,lib,misc,pkg,src} $out/
'';
}
"""
nixpkgs_package(
name = "nixpkgs_go_toolchain",
repository = repository,
repositories = repositories,
nix_file = nix_file,
nix_file_deps = nix_file_deps,
nix_file_content = nix_file_content,
build_file_content = """exports_files(glob(["**/*"]))""",
nixopts = nixopts,
)
go_wrap_sdk(name = sdk_name, root_file = "@nixpkgs_go_toolchain//:PACKAGE_ROOT")
|
def word_break2(s, word_dict):
"""
:type s: str
:type goal: str
:rtype: bool
"""
dp = []
for i in range(0, len(s)):
# print(i, s[:i+1] , dp)
if s[:i+1] in word_dict:
dp.append(i+1)
else:
for j in dp:
if s[j:i+1] in word_dict:
dp.append(i+1)
if len(s) in dp:
return True
return False
#12:30 a working solution by 12:45
#Tests
def word_break2_test():
input_s1 = "leetcode"
input_s2 = "applepenapple"
input_s3 = "catsandog"
input_word_dict1 = ["leet","code"]
input_word_dict2 = ["apple","pen"]
input_word_dict3 = ["cats","dog","sand","and","cat"]
expected_output1 = True
expected_output2 = True
expected_output3 = False
actual_output1 = word_break2(input_s1, input_word_dict1)
actual_output2 = word_break2(input_s2, input_word_dict2)
actual_output3 = word_break2(input_s3, input_word_dict3)
return ( expected_output1 == actual_output1, expected_output2 == actual_output2, expected_output3 == actual_output3 )
print(word_break2_test())
|
#!/usr/bin/env python3
# *****************************************
# PiFire Display Prototype Interface Library
# *****************************************
#
# Description: This library simulates a display.
#
# *****************************************
# *****************************************
# Imported Libraries
# *****************************************
class Display:
def __init__(self):
self.DisplaySplash()
def DisplayStatus(self, in_data, status_data):
print('====[Display]=====')
print('* Grill Temp: ' + str(in_data['GrillTemp'])[:5] + 'F')
print('* Grill SetPoint: ' + str(in_data['GrillSetPoint']) + 'F')
print('* Probe1 Temp: ' + str(in_data['Probe1Temp'])[:5] + 'F')
print('* Probe1 SetPoint: ' + str(in_data['Probe1SetPoint']) + 'F')
print('* Probe2 Temp: ' + str(in_data['Probe2Temp'])[:5] + 'F')
print('* Probe2 SetPoint: ' + str(in_data['Probe2SetPoint']) + 'F')
print('* Mode: ' + str(status_data['mode']))
notification = False
for item in status_data['notify_req']:
if status_data['notify_req'][item] == True:
notification = True
if notification == True:
print('* Notifications: True')
for item in status_data['outpins']:
if status_data['outpins'][item] == 0:
print('* ' + str(item) + ' ON')
print('==================')
def DisplaySplash(self):
print(' ( (')
print(' )\ ) )\ )')
print(' (()/( ( (()/( ( ( (')
print(' /(_)))\ /(_)) )\ )( ))\ ')
print(' (_)) ((_)(_))_|((_)(()\ /((_) ')
print(' | _ \ (_)| |_ (_) ((_)(_)) ')
print(' | _/ | || __| | || \'_|/ -_) ')
print(' |_| |_||_| |_||_| \___| ')
def ClearDisplay(self):
print('[Display] Clear Display Command Sent')
def DisplayText(self, text):
print('====[Display]=====')
print('* Text: ' + str(text))
print('==================')
def EventDetect(self):
return() |
#! /usr/bin/env python
# coding: utf
str_var = "Calculator"
print("Hello, ", str_var)
a = b = 2
print("a: ", a)
print("b: ", b)
print("a + b = ", a + b)
# Функция input() с аргументом-приглашением
a = int(input("Enter a: "))
print("a: ", a)
b = int(input("Enter b: "))
print("b: ", b)
print(1 <= a < 10 and 1 <= b < 20)
print(a < b and b < 10 or b >= 1)
print("a / b = ", a / b)
|
# 4-6. Odd Numbers
odd_numbers = list(range(1,21,2))
print(odd_numbers)
|
lista = []
cont = 0
while True:
n = int(input('Digite um valor: '))
lista.append(n)
res = str(input('Quer continuar? [S/N] ')).upper().strip()
cont += 1
if res == 'N':
break
lista.sort(reverse=True)
print('-=' * 50)
print(f'Você digitou {cont} elementos.')
print(f'Os valores em ordem decrescente são {lista}')
if 5 in lista:
print(f'O valor 5 faz parte da lista!')
else:
print(f'O valor 5 não foi encontrado na lista!') |
def proCategorization(pros, preferences):
pref_dict = {}
for i in range(len(pros)):
name = pros[i]
prefs = preferences[i]
for j in range(len(prefs)):
p = prefs[j]
if p not in pref_dict:
pref_dict[p] = [name]
else:
pref_dict[p] += [name]
out_list = []
for k in sorted(pref_dict):
tmp = [[k], pref_dict[k]]
out_list += [tmp]
return out_list
|
def app(): # pragma: no cover
return None
def returns_app(): # pragma: no cover
return app
|
def test_success():
assert True
def add_and_del(startnum, addnum, delnum):
return startnum + addnum - delnum
|
# dp + recursion (top to down)
# Runtime: 688 ms, faster than 26.38% of Python3 online submissions for Burst Balloons.
# Memory Usage: 13.6 MB, less than 55.82% of Python3 online submissions for Burst Balloons.
class Solution:
def maxCoins(self, nums: List[int]) -> int:
nums = [1] + nums + [1]
n = len(nums)
dp = [[0 for _ in range(n)] for _ in range(n)]
def calculate(nums, dp, left, right):
if dp[left][right] or right == left + 1: return dp[left][right]
coins = 0
for mid in range(left + 1, right):
coins = max(coins, nums[left] * nums[mid] * nums[right] + calculate(nums, dp, left, mid) + calculate(nums, dp, mid, right))
dp[left][right] = coins
return coins
return calculate(nums, dp, 0, n - 1)
# dp + three for (down to top)
# Runtime: 424 ms, faster than 76.29% of Python3 online submissions for Burst Balloons.
# Memory Usage: 13.5 MB, less than 65.96% of Python3 online submissions for Burst Balloons.
class Solution:
def maxCoins(self, nums: List[int]) -> int:
nums = [1] + nums + [1]
n = len(nums)
dp = [[0 for _ in range(n)] for _ in range(n)]
for gap in range(2, n):
for left in range(n - gap):
right = left + gap
for mid in range(left + 1, right):
dp[left][right] = max(dp[left][right], nums[left] * nums[mid] * nums[right] + dp[left][mid] + dp[mid][right])
return dp[0][-1]
# dp: row is left, column is right
|
"""Constants for Skoda Connect library."""
BASE_SESSION = 'https://msg.volkswagen.de'
BASE_AUTH = 'https://identity.vwgroup.io'
BRAND = 'skoda'
COUNTRY = 'CZ'
# Headers used in communication
CLIENT_ID = '7f045eee-7003-4379-9968-9355ed2adb06%40apps_vw-dilab_com'
XCLIENT_ID = '28cd30c6-dee7-4529-a0e6-b1e07ff90b79'
XAPPVERSION = '3.2.6'
XAPPNAME = 'cz.skodaauto.connect'
USER_AGENT = 'okhttp/3.14.7'
APP_URI = 'skodaconnect://oidc.login/'
# Used when fetching data
HEADERS_SESSION = {
'Connection': 'keep-alive',
'Content-Type': 'application/json',
'Accept-charset': 'UTF-8',
'Accept': 'application/json',
'X-Client-Id': XCLIENT_ID,
'X-App-Version': XAPPVERSION,
'X-App-Name': XAPPNAME,
'User-Agent': USER_AGENT
}
# Used for authentication
HEADERS_AUTH = {
'Connection': 'keep-alive',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
'Accept-Encoding': 'gzip, deflate',
'Content-Type': 'application/x-www-form-urlencoded',
'x-requested-with': XAPPNAME,
'User-Agent': USER_AGENT,
'X-App-Name': XAPPNAME
}
# Different parameters used in authentication
SCOPE = 'openid mbb profile address cars email birthdate badge phone driversLicense dealers'
TOKEN_TYPES = 'code id_token token'
|
class Solution(object):
def repeatedSubstringPattern(self, s):
for l in range(1, len(s)//2+1):
if len(s)%l == 0:
str_sub = s[:l]
n = len(s)//l
if str_sub * n == s:
return True
return False
print(Solution().repeatedSubstringPattern("aba")) |
# AutoRead Configuration File default
"""
AUTOREAD CONFIG File
Author: James Cooper
Contact: [email protected]
Description: Shared code for many parts of AutoRead.
This project was made for the Guildhall School of Music and Drama.
Developed with the Milton Court TAIT eChameleon Automation installation in mind.
"""
"""Leave these first sections alone :)"""
class LightType:
def __init__(self, type_name, total_pan, total_tilt, yoke_offset):
self.type_name = type_name
self.total_pan = total_pan
self.total_tilt = total_tilt
self.yoke_offset = yoke_offset
def print_me(self):
print("type_name:\t\t", self.type_name)
print("total_pan:\t\t", self.total_pan)
print("total_tilt:\t\t", self.total_tilt)
print("yoke_offset\t\t", self.yoke_offset)
def GenerateNewLightList():
"""You should use this function to generate a new light configuration.
Note, adaptations will need to be made if you want to add more LightTypes."""
Lights = []
NumberToMake = int(input("How many lights would you like to have in the system?"))
for UnitID in range(NumberToMake):
ThisLightType = str(input("What type of light is this? (\"TW1\" or \"ETC_REV\")"))
CentreOffset = int(input("What is it's X value, based on your origin?\n\t-\tNote: Anything Stage Right of 0 should be negative."))
ThisItemAxis = int(input("What axis is the light on? Enter a number only."))
Lights.append([ThisLightType,(CentreOffset, None, None), ThisItemAxis, UnitID+1])
print("Lights = [{0}]".format(",\n".join([str(x) for x in Lights])))
return Lights
"""AUTO READ CONFIG FILE - READ FROM HERE DOWN"""
"""
_ _ _______ ____ _____ ______ _____
/\ | | | |__ __/ __ \| __ \| ____| /\ | __ \
/ \ | | | | | | | | | | |__) | |__ / \ | | | |
/ /\ \| | | | | | | | | | _ /| __| / /\ \ | | | |
/ ____ \ |__| | | | | |__| | | \ \| |____ / ____ \| |__| |
/_/ \_\____/ |_| \____/|_| \_\______/_/ \_\_____/
"""
"""If this system is installed, with an automation network, set this to False"""
_offline_test_ = True
#_offline_test_ = False
"""AutoRead Track functions"""
"""Set Up GPIO LED Pins"""
LED_def = {"led1":16,"led2":18}
""" AutoRead (Read) Settings """
# The broadcast IP for your Simotion Automation input
UDP_IP = "172.16.1.255"
# Port being used for Simotion output
UDP_PORT = 30501
LENGTH_HEADER = 24 # How many bytes long is the head1..head4 section of the simotion packet.
ATTR_PER_AXIS = 5 # How many data points are being sent per axis? Important because of how we interpret the packet.
# Map your eCham Axis to the Node/Channel format.
# Format: Node,Channel,Axis
axisNodeChannels = [
[1, 1, 20],[1, 2, 22],[1, 3, 24],[1, 4, 26],
[1, 5, 28],[1, 6, 30],[1, 7, 32],[1, 8, 35],
[1, 9, 41],[1, 10, 42],[1, 11, 43],[1, 12, 44],
[1, 13, 45],[1, 14, 46],[1, 15, 91],[1, 16, 92],
[1, 17, 93],[2, 1, 1],[2, 2, 2],[2, 3, 5],
[2, 4, 7],[2, 5, 9],[2, 6, 11],[2, 7, 13],
[2, 8, 15],[2, 9, 17],[2, 10, 19],[2, 11, 21],
[2, 12, 23],[2, 13, 25],[2, 14, 27],[2, 15, 29],
[2, 16, 31],[2, 17, 33],[2, 18, 34],[2, 19, 3],
[2, 20, 4],[2, 21, 6],[2, 22, 8],[2, 23, 10],
[2, 24, 12],[2, 25, 14],[2, 26, 16],[2, 27, 18],
[3, 1, 81],[3, 2, 82]]
# This saves on computing time - if the starting axis in eCham is nowhere near 1
FirstEChamAxis = 1 #Default should be 1 though.
# Copy and paste this to make sure you have the right number of nodes in the system.
Node1 = {
"Name": "1A0",
"IP": "172.16.1.51",
"recv": False,
}
Node2 = {
"Name": "2A0",
"IP": "172.16.1.52",
"recv": False,
}
Nodes = [Node1,Node2]
NumberOfNodes = len(Nodes)
"""AutoRead (Track) Settings"""
# Define AxisYValues based on CAD plan
AxisYValues = [200,500,800,1200,1400,1600,1800,2000,2200,2400,2600,2800,3000,
3200,3400,3600,3800,4000,4200,4400,4600,4800,5000,5200,5400,5600,5800,6000,6200,
6400,6600,6800,7000]
# Update Axis status and Z value here - this is because we're not connected to Auto Network.
axisDict = {
1: (3871,0,0),
2: (10709,0,0),
3: (2550,0,0),
4: (5811,0,0),
5: (4108,0,0),
6: (3701,0,0),
7: (1549,0,0),
8: (6750,0,0),
9: (4127,0,0),
10: (6479,0,0),
11: (6214,0,0),
12: (7136,0,0),
13: (12364,0,0),
14: (3541,0,0),
15: (12606,0,0),
16: (3872,0,0),
17: (4360,0,0),
18: (12200,0,0),
19: (12768,0,0),
20: (2815,0,0),
21: (9137,0,0),
22: (10100,0,0),
23: (9172,0,0),
24: (7573,0,0),
25: (5697,0,0),
26: (13667,0,0),
27: (6386,0,0),
28: (5740,0,0),
29: (7080,0,0),
30: (13992,0,0),
31: (6000,0,0),
32: (3248,0,0),
33: (3869,0,0),
}
LightTypeObjects = [LightType("TW1", 540, 242, 454), # YOKE OFFSET OF 454 does not account for clamps
LightType("ETC_REV", 540, 270, 713)] # 713 accounts to pipe - but measure it
## Format: [ [LightType Name, (X coordinate, None, None), AxisNumber, unitID], ]
Lights = [['ETC_REV', (0, None, None), 8, 1],
['TW1', (-3628, None, None), 8, 2],
['TW1', (-4342, None, None), 22, 3],
['TW1', (-3000, None, None), 31, 4],
['TW1', (145, None, None), 22, 5],
['TW1', (3000, None, None), 31, 6],
['TW1', (3288, None, None), 22, 7],
['TW1', (4328, None, None), 8, 8],
#['TW1', (-4320, 6000, 10000), None, 9],
]
#Lights = [['TW1', (3000, None, None), 10, 1],
#['TW1', (-3000, None, None), 24, 2],]
#Format:
# [ [ UnitID, Univ, AddrPanCoarse, AddrPanFine,AddrTiltCoarse,AddrTiltFine] ]
LightsUniverseAddr=[
[1, 1, 2,3,4,5],
[2, 1, 45,46,47,48],
[3, 1, 65,66,67,68],
[4, 1, 85,86,87,88],
[5, 1, 105,106,107,108],
[6, 1, 125,126,127,128],
[7, 1, 145,146,147,148],
[8, 1, 165,166,167,168],]
# Format per point:
# [ ((X,Y,Z), "Name", ID - should be unique), ... ]
TrackingPoints = [((0,0,0),"Tracking Point 1", 1),
((-2500,1500,0), "Mid Stage Centre Track", 2),
((300,6742,100), "Upstage Left Tracking Point", 3),
((0,4000,3000), "Above CS", 4),
((1521,1400,2000), "Man DSR", 5),
((3000,3000,3000), "3m Square", 6),
((-1569,3313,1000), "Table", 7),
]
# Format: [[Light.unitID, TrackingPoint.ID],...]
LightsTracking = [[1,1],[2,1],[3,7],[4,5],[5,5],[6,7],[7,5],[8,5], [9,5]]
#LightsTracking = [[1,6],[2,6]]
"""AutoRead (Control) Settings"""
sACNPriority = 150
"""
# Axis Definitions
- Describe Node per Axis definitions here, retrofit into AR_read file
"""
def main():
print("""
COM_CONFIG.py - AUTOREAD CONFIG FILE
Sorry chief. This file is just common constant variables.
You'll want to edit this file though:\nuse a text editor, or \"nano\" on the command line
JRC 27APR2020
Support at [email protected] if you're stuck.
Uncomment the last line in this file to help you generate a new "Lights" list,
which you can use to replace the one in this file.
""")
if __name__ == "__main__":
main()
GenerateNewLightList()
|
# n = A.length
# time = O(n)
# space = O(n)
# done time = 30m
class Solution:
def prefixesDivBy5(self, A: List[int]) -> List[bool]:
num = 0
ret = []
for a in A:
num = (num << 1) + a
ret.append(num % 5 == 0)
return ret
|
# -*- coding: utf-8 -*-
"""
Wanini's Python Sample Project
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
wPyProj is a template of Python project.
:copyright: (c) 2021 by Ting-Hsu Chang.
:license: MIT, see LICENSE for more details.
"""
|
n1 = int(input('Digite um Valor:'))
n2 = int(input('Digite outro valor:'))
s = n1 + n2
print('A some entre {} e {} é {}'.format(n1, n2, s))
|
"""
We are given an array containing n distinct numbers taken from the range 0 to n.
Since the array has only n numbers out of the total n+1 numbers, find the missing number."""
def find_missing_number(nums):
i = 0
while i < len(nums):
j = nums[i]
if j < len(nums) and i != nums[i]:
nums[i], nums[j] = nums[j], nums[i]
else:
i+=1
missing = -1
for i, val in enumerate(nums):
if i != val:
missing = i
return missing
print('2: ', find_missing_number([4, 0, 3, 1]))
print('7: ', find_missing_number([8, 3, 5, 2, 4, 6, 0, 1]))
|
author_activate = '''
mutation {
upsertAuthor(name: "Paulinna", author: { active: true }) {
successful
messages {
field
message
}
result {
name
active
}
}
}
'''
author_set_active = '''
mutation SetActive($active: Boolean!){
upsertAuthor(name: "Paulinna", author: { active: $active }) {
successful
messages {
field
message
}
result {
name
active
}
}
}
'''
update_any_author_active = '''
mutation SetActive(
$name: String!
$active: Boolean!
){
updateAuthor(
findBy: { name: $name }
author: { active: $active }
) {
successful
messages {
field
message
}
result {
id
name
lastName
active
dateOfBirth
updatedAt
}
}
}
'''
create_author = '''
mutation CreateAuthor(
$name: String!
$lastName: String!
$active: Boolean
){
createAuthor(
name: $name
lastName: $lastName
active: $active
){
successful
messages{
field
message
}
result{
id
name
lastName
active
}
}
}
'''
bad_author_create = 'mutation {createAuthor(name:"Baruc"){succ}}'
|
class Solution:
def minDistance(self, word1: str, word2: str) -> int:
m, n = len(word1), len(word2)
if m * n == 0:
return max(m, n)
dp = [[0] * (n + 1) for _ in range(m + 1)]
for i in range(1, m + 1):
dp[i][0] = i
for i in range(1, n + 1):
dp[0][i] = i
for i in range(1, m + 1):
for j in range(1, n + 1):
left = dp[i][j - 1] + 1
down = dp[i - 1][j] + 1
left_down = dp[i - 1][j - 1]
if word1[i - 1] != word2[j - 1]:
left_down += 1
dp[i][j] = min(left, down, left_down)
return dp[m][n]
slu = Solution()
print(slu.minDistance("horse", "ros"))
|
"""Factories for the redirect_plus app."""
# import factory
# from ..models import YourModel
|
'''
SNMP Device Defines
'''
BMCSTATUS = {
1: 'ok',
2: 'minor',
3: 'major',
4: 'critical',
5: 'absence',
6: 'unknown',
}
BMCPRESENCE = {
1: 'absence',
2: 'presence',
3: 'unknown',
}
BMCPCESTATUS = {
1: 'disable',
2: 'enable',
}
BMCPCFA = {
1: 'eventlog(1)',
2: 'eventlogAndPowerOff(2)',
}
BMCBOOTSTR = {
1: 'No override',
2: 'PXE',
3: 'Hard Drive',
4: 'DVD ROM',
5: 'FDD Removable Device',
6: 'Unspecified',
7: 'Bios Setup',
}
BMCBOOTSEQUENCE = {
1: 'noOverride(1)',
2: 'pxe(2)',
3: 'hdd(3)',
4: 'cdDvd(4)',
5: 'floppyPrimaryRemovableMedia(5)',
6: 'unspecified(6)',
7: 'biossetup(7)',
}
BMCFPCSTR = {
1: 'Power Off',
2: 'Power On',
3: 'Forced System Reset',
4: 'Forced Power Cycle',
5: 'Forced Power Off',
}
BMCFRUPOWERCONTROL = {
1: 'normalPowerOff(1)',
2: 'powerOn(2)',
3: 'forcedSystemReset(3)',
4: 'forcedPowerCycle(4)',
}
HMMPRESENCE = {
0: 'not present',
1: 'present',
2: 'indeterminate',
}
HMMPCE = {
0: 'disable',
1: 'enable',
}
HMMHEALTH = {
0: 'ok',
1: 'minor',
2: 'major',
3: 'majorandminor',
4: 'critical',
5: 'criticalandminor',
6: 'criticalandmajor',
7: 'criticalandmajorandminor',
}
HMMCPUHEALTH = {
1: 'normal',
2: 'minor',
3: 'major',
4: 'critical',
5: 'unknown',
}
HMMPOWERMODE = {
'0': 'AC',
'1': 'DC',
'2': 'AC and DC',
'3': 'HVDC',
'4': 'unknown',
}
HMMBIOSBOOTOPTION = {
0: 'No override',
1: 'Force PXE',
2: 'Force boot from default Hard-drive[2]',
3: 'Force boot from default Hard-drive, request Safe Mode[2]',
4: 'Force boot from default Diagnostic Partition[2]',
5: 'Force boot from default CD/DVD[2]',
6: 'Force boot into BIOS Setup',
15: 'Force boot from Floppy/primary removable media',
}
HMMFRUCONTROL = {
'0': 'Force System Reset',
'1': 'power off',
'2': 'Force Power Cycle',
'3': 'NMI',
'4': 'power on',
}
HMMLOCATION = {
1: 'PSU1',
2: 'PSU2',
3: 'PSU3',
4: 'PSU4',
5: 'PSU5',
6: 'PSU6',
}
HMMSTATUS = {
1: 'normal',
2: 'minor',
3: 'major',
4: 'critical',
}
HMMNEWSTATUS = {
0: 'reset',
2: 'power off then on',
3: 'interrupt control',
}
|
"""
@file
@brief Shortcut to *algorithms*.
"""
|
def getData():
dataset = pd.read_csv('FUTURES MINUTE.txt', header = None)
dataset.columns = ['Date','time',"1. open","2. high",'3. low','4. close','5. volume']
dataset['date'] = dataset['Date'] +" "+ dataset['time']
dataset.drop('Date', axis=1, inplace=True)
dataset.drop('time', axis=1, inplace=True)
dataset['date'] = dataset['date'].apply(lambda x: pd.to_datetime(x, errors='ignore'))
dataset['date'] = dataset['date'].apply(lambda x: datetime.datetime.strftime(x, '%Y-%m-%d %H:%M:%S'))
dataset.set_index(dataset.index.map(lambda x: pd.to_datetime(x, errors='ignore')))
dataset.set_index('date',inplace=True)
return dataset
|
class DataOwnerPrediction:
def __init__(self, model_id, model_public_key, public_key, encrypted_prediction):
self.id = encrypted_prediction.id
self.model_id = model_id
self.model_public_key = model_public_key
self.public_key = public_key
self.encrypted_prediction = encrypted_prediction
self.confirmed = False
self.is_valid = False
def update(self, valid_status):
self.is_valid = valid_status
self.confirmed = True
def get_data(self):
return {'model_id': self.model_id,
'prediction_id': self.id,
'encrypted_prediction': self.encrypted_prediction.get_values(),
'public_key': self.public_key}
class PredictionService:
def __init__(self, encryption_service):
self.predictions = dict()
self.encryption_service = encryption_service
def add(self, prediction_data):
prediction = self._make_prediction(prediction_data)
self.predictions[prediction.id] = prediction
def get(self, prediction_id=None):
return self.predictions.get(prediction_id) if prediction_id else self.predictions.values()
def _make_prediction(self, prediction_data):
return DataOwnerPrediction(model_id=prediction_data["model"]["model_id"],
model_public_key=prediction_data["model"]["public_key"],
public_key=self.encryption_service.get_public_key(),
encrypted_prediction=prediction_data["encrypted_prediction"])
def check_consistency(self, prediction_id, prediction_data):
"""
:param prediction_id:
:param prediction_data:
:return:
"""
prediction = self.get(prediction_id)
# 1) Decrypt -> (7)
decrypted_prediction = self.encryption_service.decrypt_collection(prediction_data)
# 2) Encrypt with PK MB (8)
encrypted_prediction = self.encryption_service.encrypt_collection(decrypted_prediction,
prediction.model_public_key)
# 3) Compare 2) with (1)
comparision = encrypted_prediction == prediction.encrypted_prediction
prediction.update(prediction_data, comparision)
return comparision
|
#!/usr/bin/env python3
# -*- coding:utf-8 -*-
"""
Loki module for body_part
Input:
inputSTR str,
utterance str,
args str[],
resultDICT dict
Output:
resultDICT dict
"""
DEBUG_body_part = True
userDefinedDICT = {}
ChildLIST =["小孩","兒子","女兒"]
# 將符合句型的參數列表印出。這是 debug 或是開發用的。
def debugInfo(inputSTR, utterance):
if DEBUG_body_part:
print("[body_part] {} ===> {}".format(inputSTR, utterance))
def getResult(inputSTR, utterance, args, resultDICT):
debugInfo(inputSTR, utterance)
if utterance == "上[顎]腫一塊":
# write your code here
resultDICT["bodypart"]=args[0]
pass
if utterance == "[先前]有[耳朵][內部]疼痛":
# write your code here
resultDICT["bodypart"]=args[1]
pass
if utterance == "[口腔][上][顎]有[血][絲]":
# write your code here
resultDICT["bodypart"]=args[2]
pass
if utterance == "[喉嚨]卡卡":
# write your code here
resultDICT["bodypart"]=args[0]
pass
if utterance == "[喉部][兩側]還是會不[舒服]":
# write your code here
resultDICT["bodypart"]=args[0]
pass
if utterance == "[嘴][上][長黑斑]":
# write your code here
if "風池穴" in inputSTR:
resultDICT["bodypart"]="家醫"
else:
resultDICT["bodypart"]=args[0]
pass
if utterance == "[我][下][腹]痛[很久]":
# write your code here
resultDICT["bodypart"]=args[2]
pass
if utterance == "[我][喉嚨]痛到[耳朵]":
# write your code here
resultDICT["bodypart"]=args[1]
pass
if utterance == "[我][外][陰部]長肉":
# write your code here
resultDICT["bodypart"]=args[2]
pass
if utterance == "[我]左側[風池穴]附近[經絡處]摸到[硬塊]":
# write your code here
resultDICT["bodypart"]=args[1]
pass
if utterance == "[我][心臟]亂跳":
# write your code here
resultDICT["bodypart"]=args[1]
pass
if utterance == "[我]昨天晚上[突然]發現[臉頰]下[方]靠近[脖子]的那個[地方]摸到一顆[腫塊]":
# write your code here
resultDICT["bodypart"]=args[2]
pass
if utterance == "[我]最近這一年[多][容易][小腿痠]":
# write your code here
resultDICT["bodypart"]=args[3]
pass
if utterance == "[我][有時][頭]會[突然]暈一下":
# write your code here
resultDICT["bodypart"]=args[2]
pass
if utterance == "[我][瓣膜]鬆掉":
# write your code here
resultDICT["bodypart"]=args[1]
pass
if utterance == "[我][胸口]和[喉嚨][依舊]疼痛":
# write your code here
resultDICT["bodypart"]=args[1]
pass
if utterance == "[我][舌頭][側邊]已經破洞兩個[多]禮拜了":
# write your code here
resultDICT["bodypart"]=args[2]
pass
if utterance == "[我]覺得[頭]稍微暈暈的":
# write your code here
resultDICT["bodypart"]=args[1]
pass
if utterance == "[我][雙腿][無力]":
# write your code here
resultDICT["bodypart"]=args[1]
if "壓力" in inputSTR and ("大" in inputSTR):
resultDICT["symptom"] = "身心"
if "手" in inputSTR and ("打斷" in inputSTR):
resultDICT["bodypart"] = "骨"
pass
if utterance == "[我]感覺[小拇指][快]脫落":
# write your code here
resultDICT["bodypart"]=args[1]
pass
if utterance == "[我]扁[條線]化膿":
# write your code here
resultDICT["bodypart"]=args[1]
pass
if utterance == "[我]擦[屁股]有[血]":
# write your code here
resultDICT["bodypart"]=args[1]
pass
if utterance == "[我]有[點][胸][悶]":
# write your code here
resultDICT["bodypart"]=args[2]
pass
if utterance == "[我]稍微[頸椎][僵直]":
# write your code here
resultDICT["bodypart"]=args[1]
pass
if utterance == "[我]開始[心跳]跳[很快]":
# write your code here
resultDICT["bodypart"]=args[1]
pass
if utterance == "[早上]擤[鼻涕][也]是[綠色]":
# write your code here
resultDICT["bodypart"]=args[1]
pass
if utterance == "[眉間]下[方]還沒到[眼睛]的[地方]會痛":
# write your code here
resultDICT["bodypart"]=args[2]
pass
if utterance == "[眼睛][經常]不[舒服]":
# write your code here
resultDICT["bodypart"]=args[0]
pass
if utterance == "[耳朵]有[聲音]":
# write your code here
resultDICT["bodypart"]=args[0]
pass
if utterance == "[脖子]一顆[硬硬][小小]的":
# write your code here
resultDICT["bodypart"]=args[0]
pass
if utterance == "[頭]很痛":
# write your code here
resultDICT["bodypart"]=args[0]
pass
if utterance == "[頸部]有腫塊":
# write your code here
resultDICT["bodypart"]=args[0]
pass
if utterance == "[頸部]長了[腫塊]":
# write your code here
resultDICT["bodypart"]=args[0]
pass
if utterance == "[鼻子][裡面]感覺[很緊繃]":
# write your code here
resultDICT["bodypart"]=args[0]
pass
if utterance == "[鼻子]開始會[長期]鼻塞":
# write your code here
resultDICT["bodypart"]=args[0]
pass
if utterance == "[鼻樑][兩側]會痛":
# write your code here
resultDICT["bodypart"]=args[0]
pass
if utterance == "[鼻腔內]有東西":
# write your code here
resultDICT["bodypart"]=args[0]
pass
if utterance == "吞嚥[不適]":
# write your code here
if "吞嚥" in inputSTR:
resultDICT["symptom"]="耳鼻喉"
pass
if utterance == "從[兩三年][前]就會頭暈還伴隨耳鳴,[胃]痛和失眠":
# write your code here
resultDICT["bodypart"]=args[2]
pass
if utterance == "轉動[脖子]會不[舒服]":
# write your code here
resultDICT["bodypart"]=args[0]
pass
if utterance == "我[兒子][肚子]不[舒服]":
# args [兒子, 肚子, 舒服]
resultDICT["child"]=args[0]
resultDICT["bodypart"]=args[1]
pass
if utterance == "[肚子]不[舒服]":
# write your code here
resultDICT["bodypart"]=args[0]
pass
if utterance == "[脖子][一顆]硬硬的":
# args [脖子, 一顆]
resultDICT["bodypart"]=args[0]
pass
if utterance == "我[有時][頭]會稍微暈一下":
# args [有時, 頭]
resultDICT["bodypart"]=args[1]
if utterance == "我[最近][一年]多容易[小腿]酸":
# args [最近, 一年, 小腿]
resultDICT["bodypart"]=args[2]
if utterance == "我[心臟]痛痛的":
# args [心臟]
resultDICT["bodypart"]=args[0]
if utterance == "[背]很酸":
# args [背]
resultDICT["bodypart"]=args[0]
if utterance == "[眼][前]有小黑影":
# args [眼, 前]
resultDICT["bodypart"]=args[0]
if utterance == "我[上][臂]痠痛":
# args [上, 臂]
resultDICT["bodypart"]=args[1]
if utterance == "[我][牙齒]痛":
resultDICT["bodypart"]=args[1]
# args [我, 牙齒]
if utterance == "我[骨頭]裂了":
# args [骨頭]
resultDICT["bodypart"]=args[0]
return resultDICT |
class SegmentEndsPath(list):
"""
a list containing {gfapy.SegmentEnd} elements, which defines a path
in the graph
"""
def reverse(self):
"""
Reverses the direction of the path in place
"""
self[:] = list(reversed(self))
def __reversed__(self):
"""
Iterator over the reverse-direction path
"""
for elem in SegmentEndsPath(reversed([segment_end.inverted()
for segment_end in self])):
yield elem
|
n = input()
s = set(map(int, input().split()))
q=int(input())
for x in range(q):
t=input().split()
try:
if(t[0]=="pop"):
s.pop()
elif(t[0]=="remove"):
s.remove(int(t[1]))
else:
s.discard(int(t[1]))
except:
continue
print(sum(s))
|
def isIncreasingDigitsSequence(n):
s = str(n)
for i in range(len(s)-1):
if s[i] >= s[i+1]:
return False
return True
"""
Call an integer an increasing digits sequence if its digits considered from left to right form a strictly increasing sequence.
Given an integer, check if it is an increasing digits sequence.
Example
For n = 12345, the output should be
isIncreasingDigitsSequence(n) = true;
For n = 2446, the output should be
isIncreasingDigitsSequence(n) = false;
For n = 543, the output should be
isIncreasingDigitsSequence(n) = false.
"""
|
year = int(input())
if (year % 400 == 0):
print("Високосный")
elif (year % 4 == 0) and (year % 100 != 0):
print("Високосный")
else:
print("Обычный") |
load("//scala:scala.bzl", "scala_test")
def analyzer_tests_scala_2():
common_jvm_flags = [
"-Dplugin.jar.location=$(execpath //third_party/dependency_analyzer/src/main:dependency_analyzer)",
"-Dscala.library.location=$(rootpath @io_bazel_rules_scala_scala_library)",
"-Dscala.reflect.location=$(rootpath @io_bazel_rules_scala_scala_reflect)",
]
scala_test(
name = "ast_used_jar_finder_test",
size = "small",
srcs = [
"io/bazel/rulesscala/dependencyanalyzer/AstUsedJarFinderTest.scala",
],
jvm_flags = common_jvm_flags,
deps = [
"//src/java/io/bazel/rulesscala/io_utils",
"//third_party/dependency_analyzer/src/main:dependency_analyzer",
"//third_party/dependency_analyzer/src/main:scala_version",
"//third_party/utils/src/test:test_util",
"@io_bazel_rules_scala_scala_compiler",
"@io_bazel_rules_scala_scala_library",
"@io_bazel_rules_scala_scala_reflect",
],
)
scala_test(
name = "scala_version_test",
size = "small",
srcs = [
"io/bazel/rulesscala/dependencyanalyzer/ScalaVersionTest.scala",
],
deps = [
"//third_party/dependency_analyzer/src/main:scala_version",
"@io_bazel_rules_scala_scala_library",
"@io_bazel_rules_scala_scala_reflect",
],
)
scala_test(
name = "scalac_dependency_test",
size = "small",
srcs = [
"io/bazel/rulesscala/dependencyanalyzer/ScalacDependencyTest.scala",
],
jvm_flags = common_jvm_flags,
unused_dependency_checker_mode = "off",
deps = [
"//src/java/io/bazel/rulesscala/io_utils",
"//third_party/dependency_analyzer/src/main:dependency_analyzer",
"//third_party/utils/src/test:test_util",
"@io_bazel_rules_scala_scala_compiler",
"@io_bazel_rules_scala_scala_library",
"@io_bazel_rules_scala_scala_reflect",
],
)
scala_test(
name = "strict_deps_test",
size = "small",
srcs = [
"io/bazel/rulesscala/dependencyanalyzer/StrictDepsTest.scala",
],
jvm_flags = common_jvm_flags + [
"-Dguava.jar.location=$(rootpath @com_google_guava_guava_21_0_with_file//jar)",
"-Dapache.commons.jar.location=$(location @org_apache_commons_commons_lang_3_5_without_file//:linkable_org_apache_commons_commons_lang_3_5_without_file)",
],
unused_dependency_checker_mode = "off",
deps = [
"//third_party/dependency_analyzer/src/main:dependency_analyzer",
"//third_party/utils/src/test:test_util",
"@com_google_guava_guava_21_0_with_file//jar",
"@io_bazel_rules_scala_scala_compiler",
"@io_bazel_rules_scala_scala_library",
"@io_bazel_rules_scala_scala_reflect",
"@org_apache_commons_commons_lang_3_5_without_file//:linkable_org_apache_commons_commons_lang_3_5_without_file",
],
)
scala_test(
name = "unused_dependency_checker_test",
size = "small",
srcs = [
"io/bazel/rulesscala/dependencyanalyzer/UnusedDependencyCheckerTest.scala",
],
jvm_flags = common_jvm_flags + [
"-Dapache.commons.jar.location=$(location @org_apache_commons_commons_lang_3_5_without_file//:linkable_org_apache_commons_commons_lang_3_5_without_file)",
],
unused_dependency_checker_mode = "off",
deps = [
"//third_party/dependency_analyzer/src/main:dependency_analyzer",
"//third_party/utils/src/test:test_util",
"@io_bazel_rules_scala_scala_compiler",
"@io_bazel_rules_scala_scala_library",
"@io_bazel_rules_scala_scala_reflect",
"@org_apache_commons_commons_lang_3_5_without_file//:linkable_org_apache_commons_commons_lang_3_5_without_file",
],
)
|
NER_LABEL_TO_ID = {
"O": 0,
"B-ORG": 1,
"I-ORG": 2,
"B-PER": 3,
"I-PER": 4,
"B-LOC": 5,
"I-LOC": 6,
}
ID_TO_NER_LABEL = {value: key for key, value in NER_LABEL_TO_ID.items()}
def clean_label(ner_label: str) -> str:
"""
Clean the ner label from whitespaces
:param ner_label: takes a ner label
:type ner_label: str
:return: a cleaned label is returned
:rtype: str
"""
if "B-ORG" in ner_label:
return "B-ORG"
elif "I-ORG" in ner_label:
return "I-ORG"
elif "B-PER" in ner_label:
return "B-PER"
elif "I-PER" in ner_label:
return "I-PER"
elif "B-LOC" in ner_label:
return "B-LOC"
elif "I-LOC" in ner_label:
return "I-LOC"
elif "O" in ner_label:
return "O"
def ner_label_to_id(ner_label: str) -> int:
"""
return the id of the ner label
:param ner_label: ner label
:type ner_label: str
:return: id of the ner label
:rtype: int
"""
return NER_LABEL_TO_ID[ner_label]
def id_to_ner_label(id: int) -> str:
"""
return the ner label of the id
:param id: id of the ner label
:type id: int
:return: ner label
:rtype: str
"""
return ID_TO_NER_LABEL[id]
|
# This __about__.py file for storing project metadata is inspired by
# - github.com/delph-in/pydelphin/blob/master/delphin/__about__.py
# referencing (apud)
# - github.com/pypa/warehouse/blob/master/warehouse/__about__.py
__name__ = "Delphin RDF"
__summary__ = "DELPH-IN formats in RDF"
__version__ = "1.0.4"
__author__ = "foo"
__email__ = "foo"
__url__ = "foo"
__license__ = "MIT" |
#### USEFUL FUNCTIONS FOR CLAUSES AND LITERALS ####
# Return true if the clause is unit, false otherwise.
def is_unit_clause(clause):
return len(clause) == 1
# Return true if the clause is empty, false otherwise.
def is_empty_clause(clause):
return len(clause) == 0
# Return true if the literal is positive, false otherwise
def is_positive_literal(lit):
return lit > 0
# Return the variable associated to a given literal
def lit_to_var(lit):
return abs(lit)
#### MAIN ####
if __name__ == "__main__":
# Read the DIMACS header
unused1, unused2, V, C = input().split()
V = int(V) # Number of variables
C = int(C) # Number of clauses
# Declaration of the structures
lit_to_cls = { i : [] for i in range(-V, V + 1) } # Index of clauses containing a literal
clauses = [None] * C # The formula represented by a list of clauses
model = [None] * (V + 1) # The current assignement
units = [] # All literals that should be propagated
sat = True # Is the formula satisfiable?
# Read the clauses
for id_cls in range(C):
# Read the clause and do not forget to remove the '0'
clause = [int(lit) for lit in input().split()[:-1]]
# Update the structures
clauses[id_cls] = clause
# Update reference from lit to clause index
for lit in clause:
lit_to_cls[lit] += [id_cls]
if is_unit_clause(clause): # The clause is unit and is added for propafgation
units += [clause[0]]
elif is_empty_clause(clause): # The formula contains an empty clause
sat = False # it is then unsatisfiable
# Until there is propagation to do and the formula is not unsatisfiable
while len(units) and sat:
lit = units.pop()
var = lit_to_var(lit)
value = is_positive_literal(lit)
if model[var] == None: # The variable as not a value yet
model[var] = value
elif model[var] != value: # There is a conflict => unsatisfaible
sat = False
break
else: # Already been assigned to this value
continue
# Manage clauses containing the literal
for id_cls in lit_to_cls[lit]:
clauses[id_cls] = None # The clause is satisfied and can be forgotten
# Manage clauses containing the inverted literal
for id_cls in lit_to_cls[-lit]:
clause = clauses[id_cls]
if clause == None: # The clause has already been satisfied
continue
clause.remove(-lit) # The literal is false, it is deleted from the clause
if is_unit_clause(clause): # The clause has became unit
units += [clause[0]]
elif is_empty_clause(clause): # The clause has became empty
sat = False # The formula is then unsatisfiable
break
# Print the coresponding answer in DIMACS format
if sat: # SAT
print("s SATISFIABLE")
for var in range(1, V + 1):
if model[var] == None:
model[var] = False
out_model = ["v"]
for var in range(1, V + 1):
if not model[var]:
var = -var
out_model += [var]
out_model += [0]
print(*out_model)
else: # UNSAT
print("s UNSATISFIABLE")
|
if __name__ == "__main__":
s = input()
new_s = ""
for i in range(len(s)-1, -1, -1):
new_s += s[i]
print(new_s)
if s == new_s: print("haha got ya !")
else: print("NOpe")
|
n = int(input())
total = []
for i in range(n):
a = [int(item) for item in input().split()]
temp = 0
for j in range(a[0]):
temp +=a[j + 1]
temp -= (a[0] - 1)
total.append(temp)
a = []
for i in total:
print(i)
|
class main:
def __init__(self):
pass
def draw(self):
print("Welcome to Friend_Tracker_2.0")
print("-----------------------------")
print("Type in read if you want to read a profile,\nand write if you want to add something to the profile,\nor type in help if you need help. Type in exit if you want ot exit.\n\nNOTE: The profile files are in the Data folder.")
self.A = input(">>> ")
if "ead" in self.A:
self.readF()
elif "rite" in self.A:
self.writeF()
elif "el" in self.A:
self.help()
elif "exit" in self.A:
exit()
else:
print("Not correspondingly...")
self.draw()
def readF(self):
self.name = input("Name: ")
self.f = "Data/" + self.name + ".txt"
with open(self.f, "r") as f:
print(f.read())
f.close()
self.A = input("Go back? y: ")
if "y" in self.A:
self.draw()
def writeF(self):
global f
self.name = input("Name: ")
self.f = "Data/" + self.name + ".txt"
self.item = input("Item: ")
self.deff = input("Definition: ")
with open(self.f, "a") as f:
f.write(self.item + " : " + self.deff + "\n")
f.close()
self.A = input("Do you want to write more? y/n: ")
if "y" in self.A:
self.writeFM("yes")
else:
self.draw()
def writeFM(self, y):
while y:
self.item = input("Item: ")
self.deff = input("Definition: ")
with open(self.f, "a") as f:
f.write(self.item + " : " + self.deff + "\n")
f.close()
self.A = input("Do you want to write more? y/n: ")
if "y" in self.A:
self.writeFM(y)
else:
self.draw()
def help(self):
print("If you type in read it will ask you to type in the profile or persons name (Name of the file) like this: if i typed in write and i put in Fred to make a new profile, then i will type in Fred when i deside to read the file. If you wrote write it will ask you the persons name, after you have type in the name, type into the Item and write like there name or age or something like that but dont write the other part like this name is Fred, dont do that just type in name or something and then press enter, after you press enter it will ask you for definition and that is where you will type in the persons name like Fred or the age like 15, lastly it will ask do you want to write more. NOTE: If you type in the name wrong it will make another profile for that name! Make sure you type in the name correctly before you press enter.")
self.A = input("Go back? y: ")
if "y" in self.A:
self.draw()
if __name__ == "__main__":
app = main()
app.draw()
|
# !/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Common helper functions.
This will represent the bread and butter of the application.
"""
def add_two_numbers(x_val: int, y_val: int) -> int:
"""Just adds two numbers together."""
return x_val + y_val
def return_string() -> str:
"""Return the string doggo."""
return "string"
|
'''
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 associate_web_acl(WebACLId=None, ResourceArn=None):
"""
Associates a web ACL with a resource, either an application load balancer or Amazon API Gateway stage.
See also: AWS API Documentation
Exceptions
:example: response = client.associate_web_acl(
WebACLId='string',
ResourceArn='string'
)
:type WebACLId: string
:param WebACLId: [REQUIRED]\nA unique identifier (ID) for the web ACL.\n
:type ResourceArn: string
:param ResourceArn: [REQUIRED]\nThe ARN (Amazon Resource Name) of the resource to be protected, either an application load balancer or Amazon API Gateway stage.\nThe ARN should be in one of the following formats:\n\nFor an Application Load Balancer: ``arn:aws:elasticloadbalancing:region :account-id :loadbalancer/app/load-balancer-name /load-balancer-id ``\nFor an Amazon API Gateway stage: ``arn:aws:apigateway:region ::/restapis/api-id /stages/stage-name ``\n\n
:rtype: dict
ReturnsResponse Syntax
{}
Response Structure
(dict) --
Exceptions
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidAccountException
WAFRegional.Client.exceptions.WAFInvalidParameterException
WAFRegional.Client.exceptions.WAFNonexistentItemException
WAFRegional.Client.exceptions.WAFUnavailableEntityException
:return: {}
:returns:
(dict) --
"""
pass
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\nas the method name on the client. For example, if the\nmethod name is create_foo, and you\'d normally invoke the\noperation as client.create_foo(**kwargs), if the\ncreate_foo operation can be paginated, you can use the\ncall client.get_paginator('create_foo').
"""
pass
def create_byte_match_set(Name=None, ChangeToken=None):
"""
Creates a ByteMatchSet . You then use UpdateByteMatchSet to identify the part of a web request that you want AWS WAF to inspect, such as the values of the User-Agent header or the query string. For example, you can create a ByteMatchSet that matches any requests with User-Agent headers that contain the string BadBot . You can then configure AWS WAF to reject those requests.
To create and configure a ByteMatchSet , perform the following steps:
For more information about how to use the AWS WAF API to allow or block HTTP requests, see the AWS WAF Developer Guide .
See also: AWS API Documentation
Exceptions
:example: response = client.create_byte_match_set(
Name='string',
ChangeToken='string'
)
:type Name: string
:param Name: [REQUIRED]\nA friendly name or description of the ByteMatchSet . You can\'t change Name after you create a ByteMatchSet .\n
:type ChangeToken: string
:param ChangeToken: [REQUIRED]\nThe value returned by the most recent call to GetChangeToken .\n
:rtype: dict
ReturnsResponse Syntax
{
'ByteMatchSet': {
'ByteMatchSetId': 'string',
'Name': 'string',
'ByteMatchTuples': [
{
'FieldToMatch': {
'Type': 'URI'|'QUERY_STRING'|'HEADER'|'METHOD'|'BODY'|'SINGLE_QUERY_ARG'|'ALL_QUERY_ARGS',
'Data': 'string'
},
'TargetString': b'bytes',
'TextTransformation': 'NONE'|'COMPRESS_WHITE_SPACE'|'HTML_ENTITY_DECODE'|'LOWERCASE'|'CMD_LINE'|'URL_DECODE',
'PositionalConstraint': 'EXACTLY'|'STARTS_WITH'|'ENDS_WITH'|'CONTAINS'|'CONTAINS_WORD'
},
]
},
'ChangeToken': 'string'
}
Response Structure
(dict) --
ByteMatchSet (dict) --
A ByteMatchSet that contains no ByteMatchTuple objects.
ByteMatchSetId (string) --
The ByteMatchSetId for a ByteMatchSet . You use ByteMatchSetId to get information about a ByteMatchSet (see GetByteMatchSet ), update a ByteMatchSet (see UpdateByteMatchSet ), insert a ByteMatchSet into a Rule or delete one from a Rule (see UpdateRule ), and delete a ByteMatchSet from AWS WAF (see DeleteByteMatchSet ).
ByteMatchSetId is returned by CreateByteMatchSet and by ListByteMatchSets .
Name (string) --
A friendly name or description of the ByteMatchSet . You can\'t change Name after you create a ByteMatchSet .
ByteMatchTuples (list) --
Specifies the bytes (typically a string that corresponds with ASCII characters) that you want AWS WAF to search for in web requests, the location in requests that you want AWS WAF to search, and other settings.
(dict) --
Note
This is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.
For the latest version of AWS WAF , use the AWS WAFV2 API and see the AWS WAF Developer Guide . With the latest version, AWS WAF has a single set of endpoints for regional and global use.
The bytes (typically a string that corresponds with ASCII characters) that you want AWS WAF to search for in web requests, the location in requests that you want AWS WAF to search, and other settings.
FieldToMatch (dict) --
The part of a web request that you want AWS WAF to search, such as a specified header or a query string. For more information, see FieldToMatch .
Type (string) --
The part of the web request that you want AWS WAF to search for a specified string. Parts of a request that you can search include the following:
HEADER : A specified request header, for example, the value of the User-Agent or Referer header. If you choose HEADER for the type, specify the name of the header in Data .
METHOD : The HTTP method, which indicated the type of operation that the request is asking the origin to perform. Amazon CloudFront supports the following methods: DELETE , GET , HEAD , OPTIONS , PATCH , POST , and PUT .
QUERY_STRING : A query string, which is the part of a URL that appears after a ? character, if any.
URI : The part of a web request that identifies a resource, for example, /images/daily-ad.jpg .
BODY : The part of a request that contains any additional data that you want to send to your web server as the HTTP request body, such as data from a form. The request body immediately follows the request headers. Note that only the first 8192 bytes of the request body are forwarded to AWS WAF for inspection. To allow or block requests based on the length of the body, you can create a size constraint set. For more information, see CreateSizeConstraintSet .
SINGLE_QUERY_ARG : The parameter in the query string that you will inspect, such as UserName or SalesRegion . The maximum length for SINGLE_QUERY_ARG is 30 characters.
ALL_QUERY_ARGS : Similar to SINGLE_QUERY_ARG , but rather than inspecting a single parameter, AWS WAF will inspect all parameters within the query for the value or regex pattern that you specify in TargetString .
Data (string) --
When the value of Type is HEADER , enter the name of the header that you want AWS WAF to search, for example, User-Agent or Referer . The name of the header is not case sensitive.
When the value of Type is SINGLE_QUERY_ARG , enter the name of the parameter that you want AWS WAF to search, for example, UserName or SalesRegion . The parameter name is not case sensitive.
If the value of Type is any other value, omit Data .
TargetString (bytes) --
The value that you want AWS WAF to search for. AWS WAF searches for the specified string in the part of web requests that you specified in FieldToMatch . The maximum length of the value is 50 bytes.
Valid values depend on the values that you specified for FieldToMatch :
HEADER : The value that you want AWS WAF to search for in the request header that you specified in FieldToMatch , for example, the value of the User-Agent or Referer header.
METHOD : The HTTP method, which indicates the type of operation specified in the request. CloudFront supports the following methods: DELETE , GET , HEAD , OPTIONS , PATCH , POST , and PUT .
QUERY_STRING : The value that you want AWS WAF to search for in the query string, which is the part of a URL that appears after a ? character.
URI : The value that you want AWS WAF to search for in the part of a URL that identifies a resource, for example, /images/daily-ad.jpg .
BODY : The part of a request that contains any additional data that you want to send to your web server as the HTTP request body, such as data from a form. The request body immediately follows the request headers. Note that only the first 8192 bytes of the request body are forwarded to AWS WAF for inspection. To allow or block requests based on the length of the body, you can create a size constraint set. For more information, see CreateSizeConstraintSet .
SINGLE_QUERY_ARG : The parameter in the query string that you will inspect, such as UserName or SalesRegion . The maximum length for SINGLE_QUERY_ARG is 30 characters.
ALL_QUERY_ARGS : Similar to SINGLE_QUERY_ARG , but instead of inspecting a single parameter, AWS WAF inspects all parameters within the query string for the value or regex pattern that you specify in TargetString .
If TargetString includes alphabetic characters A-Z and a-z, note that the value is case sensitive.
If you\'re using the AWS WAF API
Specify a base64-encoded version of the value. The maximum length of the value before you base64-encode it is 50 bytes.
For example, suppose the value of Type is HEADER and the value of Data is User-Agent . If you want to search the User-Agent header for the value BadBot , you base64-encode BadBot using MIME base64-encoding and include the resulting value, QmFkQm90 , in the value of TargetString .
If you\'re using the AWS CLI or one of the AWS SDKs
The value that you want AWS WAF to search for. The SDK automatically base64 encodes the value.
TextTransformation (string) --
Text transformations eliminate some of the unusual formatting that attackers use in web requests in an effort to bypass AWS WAF. If you specify a transformation, AWS WAF performs the transformation on FieldToMatch before inspecting it for a match.
You can only specify a single type of TextTransformation.
CMD_LINE
When you\'re concerned that attackers are injecting an operating system command line command and using unusual formatting to disguise some or all of the command, use this option to perform the following transformations:
Delete the following characters: " \' ^
Delete spaces before the following characters: / (
Replace the following characters with a space: , ;
Replace multiple spaces with one space
Convert uppercase letters (A-Z) to lowercase (a-z)
COMPRESS_WHITE_SPACE
Use this option to replace the following characters with a space character (decimal 32):
f, formfeed, decimal 12
t, tab, decimal 9
n, newline, decimal 10
r, carriage return, decimal 13
v, vertical tab, decimal 11
non-breaking space, decimal 160
COMPRESS_WHITE_SPACE also replaces multiple spaces with one space.
HTML_ENTITY_DECODE
Use this option to replace HTML-encoded characters with unencoded characters. HTML_ENTITY_DECODE performs the following operations:
Replaces (ampersand)quot; with "
Replaces (ampersand)nbsp; with a non-breaking space, decimal 160
Replaces (ampersand)lt; with a "less than" symbol
Replaces (ampersand)gt; with >
Replaces characters that are represented in hexadecimal format, (ampersand)#xhhhh; , with the corresponding characters
Replaces characters that are represented in decimal format, (ampersand)#nnnn; , with the corresponding characters
LOWERCASE
Use this option to convert uppercase letters (A-Z) to lowercase (a-z).
URL_DECODE
Use this option to decode a URL-encoded value.
NONE
Specify NONE if you don\'t want to perform any text transformations.
PositionalConstraint (string) --
Within the portion of a web request that you want to search (for example, in the query string, if any), specify where you want AWS WAF to search. Valid values include the following:
CONTAINS
The specified part of the web request must include the value of TargetString , but the location doesn\'t matter.
CONTAINS_WORD
The specified part of the web request must include the value of TargetString , and TargetString must contain only alphanumeric characters or underscore (A-Z, a-z, 0-9, or _). In addition, TargetString must be a word, which means one of the following:
TargetString exactly matches the value of the specified part of the web request, such as the value of a header.
TargetString is at the beginning of the specified part of the web request and is followed by a character other than an alphanumeric character or underscore (_), for example, BadBot; .
TargetString is at the end of the specified part of the web request and is preceded by a character other than an alphanumeric character or underscore (_), for example, ;BadBot .
TargetString is in the middle of the specified part of the web request and is preceded and followed by characters other than alphanumeric characters or underscore (_), for example, -BadBot; .
EXACTLY
The value of the specified part of the web request must exactly match the value of TargetString .
STARTS_WITH
The value of TargetString must appear at the beginning of the specified part of the web request.
ENDS_WITH
The value of TargetString must appear at the end of the specified part of the web request.
ChangeToken (string) --
The ChangeToken that you used to submit the CreateByteMatchSet request. You can also use this value to query the status of the request. For more information, see GetChangeTokenStatus .
Exceptions
WAFRegional.Client.exceptions.WAFDisallowedNameException
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidAccountException
WAFRegional.Client.exceptions.WAFInvalidParameterException
WAFRegional.Client.exceptions.WAFStaleDataException
WAFRegional.Client.exceptions.WAFLimitsExceededException
:return: {
'ByteMatchSet': {
'ByteMatchSetId': 'string',
'Name': 'string',
'ByteMatchTuples': [
{
'FieldToMatch': {
'Type': 'URI'|'QUERY_STRING'|'HEADER'|'METHOD'|'BODY'|'SINGLE_QUERY_ARG'|'ALL_QUERY_ARGS',
'Data': 'string'
},
'TargetString': b'bytes',
'TextTransformation': 'NONE'|'COMPRESS_WHITE_SPACE'|'HTML_ENTITY_DECODE'|'LOWERCASE'|'CMD_LINE'|'URL_DECODE',
'PositionalConstraint': 'EXACTLY'|'STARTS_WITH'|'ENDS_WITH'|'CONTAINS'|'CONTAINS_WORD'
},
]
},
'ChangeToken': 'string'
}
:returns:
Name (string) -- [REQUIRED]
A friendly name or description of the ByteMatchSet . You can\'t change Name after you create a ByteMatchSet .
ChangeToken (string) -- [REQUIRED]
The value returned by the most recent call to GetChangeToken .
"""
pass
def create_geo_match_set(Name=None, ChangeToken=None):
"""
Creates an GeoMatchSet , which you use to specify which web requests you want to allow or block based on the country that the requests originate from. For example, if you\'re receiving a lot of requests from one or more countries and you want to block the requests, you can create an GeoMatchSet that contains those countries and then configure AWS WAF to block the requests.
To create and configure a GeoMatchSet , perform the following steps:
For more information about how to use the AWS WAF API to allow or block HTTP requests, see the AWS WAF Developer Guide .
See also: AWS API Documentation
Exceptions
:example: response = client.create_geo_match_set(
Name='string',
ChangeToken='string'
)
:type Name: string
:param Name: [REQUIRED]\nA friendly name or description of the GeoMatchSet . You can\'t change Name after you create the GeoMatchSet .\n
:type ChangeToken: string
:param ChangeToken: [REQUIRED]\nThe value returned by the most recent call to GetChangeToken .\n
:rtype: dict
ReturnsResponse Syntax
{
'GeoMatchSet': {
'GeoMatchSetId': 'string',
'Name': 'string',
'GeoMatchConstraints': [
{
'Type': 'Country',
'Value': 'AF'|'AX'|'AL'|'DZ'|'AS'|'AD'|'AO'|'AI'|'AQ'|'AG'|'AR'|'AM'|'AW'|'AU'|'AT'|'AZ'|'BS'|'BH'|'BD'|'BB'|'BY'|'BE'|'BZ'|'BJ'|'BM'|'BT'|'BO'|'BQ'|'BA'|'BW'|'BV'|'BR'|'IO'|'BN'|'BG'|'BF'|'BI'|'KH'|'CM'|'CA'|'CV'|'KY'|'CF'|'TD'|'CL'|'CN'|'CX'|'CC'|'CO'|'KM'|'CG'|'CD'|'CK'|'CR'|'CI'|'HR'|'CU'|'CW'|'CY'|'CZ'|'DK'|'DJ'|'DM'|'DO'|'EC'|'EG'|'SV'|'GQ'|'ER'|'EE'|'ET'|'FK'|'FO'|'FJ'|'FI'|'FR'|'GF'|'PF'|'TF'|'GA'|'GM'|'GE'|'DE'|'GH'|'GI'|'GR'|'GL'|'GD'|'GP'|'GU'|'GT'|'GG'|'GN'|'GW'|'GY'|'HT'|'HM'|'VA'|'HN'|'HK'|'HU'|'IS'|'IN'|'ID'|'IR'|'IQ'|'IE'|'IM'|'IL'|'IT'|'JM'|'JP'|'JE'|'JO'|'KZ'|'KE'|'KI'|'KP'|'KR'|'KW'|'KG'|'LA'|'LV'|'LB'|'LS'|'LR'|'LY'|'LI'|'LT'|'LU'|'MO'|'MK'|'MG'|'MW'|'MY'|'MV'|'ML'|'MT'|'MH'|'MQ'|'MR'|'MU'|'YT'|'MX'|'FM'|'MD'|'MC'|'MN'|'ME'|'MS'|'MA'|'MZ'|'MM'|'NA'|'NR'|'NP'|'NL'|'NC'|'NZ'|'NI'|'NE'|'NG'|'NU'|'NF'|'MP'|'NO'|'OM'|'PK'|'PW'|'PS'|'PA'|'PG'|'PY'|'PE'|'PH'|'PN'|'PL'|'PT'|'PR'|'QA'|'RE'|'RO'|'RU'|'RW'|'BL'|'SH'|'KN'|'LC'|'MF'|'PM'|'VC'|'WS'|'SM'|'ST'|'SA'|'SN'|'RS'|'SC'|'SL'|'SG'|'SX'|'SK'|'SI'|'SB'|'SO'|'ZA'|'GS'|'SS'|'ES'|'LK'|'SD'|'SR'|'SJ'|'SZ'|'SE'|'CH'|'SY'|'TW'|'TJ'|'TZ'|'TH'|'TL'|'TG'|'TK'|'TO'|'TT'|'TN'|'TR'|'TM'|'TC'|'TV'|'UG'|'UA'|'AE'|'GB'|'US'|'UM'|'UY'|'UZ'|'VU'|'VE'|'VN'|'VG'|'VI'|'WF'|'EH'|'YE'|'ZM'|'ZW'
},
]
},
'ChangeToken': 'string'
}
Response Structure
(dict) --
GeoMatchSet (dict) --
The GeoMatchSet returned in the CreateGeoMatchSet response. The GeoMatchSet contains no GeoMatchConstraints .
GeoMatchSetId (string) --
The GeoMatchSetId for an GeoMatchSet . You use GeoMatchSetId to get information about a GeoMatchSet (see GeoMatchSet ), update a GeoMatchSet (see UpdateGeoMatchSet ), insert a GeoMatchSet into a Rule or delete one from a Rule (see UpdateRule ), and delete a GeoMatchSet from AWS WAF (see DeleteGeoMatchSet ).
GeoMatchSetId is returned by CreateGeoMatchSet and by ListGeoMatchSets .
Name (string) --
A friendly name or description of the GeoMatchSet . You can\'t change the name of an GeoMatchSet after you create it.
GeoMatchConstraints (list) --
An array of GeoMatchConstraint objects, which contain the country that you want AWS WAF to search for.
(dict) --
Note
This is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.
For the latest version of AWS WAF , use the AWS WAFV2 API and see the AWS WAF Developer Guide . With the latest version, AWS WAF has a single set of endpoints for regional and global use.
The country from which web requests originate that you want AWS WAF to search for.
Type (string) --
The type of geographical area you want AWS WAF to search for. Currently Country is the only valid value.
Value (string) --
The country that you want AWS WAF to search for.
ChangeToken (string) --
The ChangeToken that you used to submit the CreateGeoMatchSet request. You can also use this value to query the status of the request. For more information, see GetChangeTokenStatus .
Exceptions
WAFRegional.Client.exceptions.WAFStaleDataException
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidAccountException
WAFRegional.Client.exceptions.WAFDisallowedNameException
WAFRegional.Client.exceptions.WAFInvalidParameterException
WAFRegional.Client.exceptions.WAFLimitsExceededException
:return: {
'GeoMatchSet': {
'GeoMatchSetId': 'string',
'Name': 'string',
'GeoMatchConstraints': [
{
'Type': 'Country',
'Value': 'AF'|'AX'|'AL'|'DZ'|'AS'|'AD'|'AO'|'AI'|'AQ'|'AG'|'AR'|'AM'|'AW'|'AU'|'AT'|'AZ'|'BS'|'BH'|'BD'|'BB'|'BY'|'BE'|'BZ'|'BJ'|'BM'|'BT'|'BO'|'BQ'|'BA'|'BW'|'BV'|'BR'|'IO'|'BN'|'BG'|'BF'|'BI'|'KH'|'CM'|'CA'|'CV'|'KY'|'CF'|'TD'|'CL'|'CN'|'CX'|'CC'|'CO'|'KM'|'CG'|'CD'|'CK'|'CR'|'CI'|'HR'|'CU'|'CW'|'CY'|'CZ'|'DK'|'DJ'|'DM'|'DO'|'EC'|'EG'|'SV'|'GQ'|'ER'|'EE'|'ET'|'FK'|'FO'|'FJ'|'FI'|'FR'|'GF'|'PF'|'TF'|'GA'|'GM'|'GE'|'DE'|'GH'|'GI'|'GR'|'GL'|'GD'|'GP'|'GU'|'GT'|'GG'|'GN'|'GW'|'GY'|'HT'|'HM'|'VA'|'HN'|'HK'|'HU'|'IS'|'IN'|'ID'|'IR'|'IQ'|'IE'|'IM'|'IL'|'IT'|'JM'|'JP'|'JE'|'JO'|'KZ'|'KE'|'KI'|'KP'|'KR'|'KW'|'KG'|'LA'|'LV'|'LB'|'LS'|'LR'|'LY'|'LI'|'LT'|'LU'|'MO'|'MK'|'MG'|'MW'|'MY'|'MV'|'ML'|'MT'|'MH'|'MQ'|'MR'|'MU'|'YT'|'MX'|'FM'|'MD'|'MC'|'MN'|'ME'|'MS'|'MA'|'MZ'|'MM'|'NA'|'NR'|'NP'|'NL'|'NC'|'NZ'|'NI'|'NE'|'NG'|'NU'|'NF'|'MP'|'NO'|'OM'|'PK'|'PW'|'PS'|'PA'|'PG'|'PY'|'PE'|'PH'|'PN'|'PL'|'PT'|'PR'|'QA'|'RE'|'RO'|'RU'|'RW'|'BL'|'SH'|'KN'|'LC'|'MF'|'PM'|'VC'|'WS'|'SM'|'ST'|'SA'|'SN'|'RS'|'SC'|'SL'|'SG'|'SX'|'SK'|'SI'|'SB'|'SO'|'ZA'|'GS'|'SS'|'ES'|'LK'|'SD'|'SR'|'SJ'|'SZ'|'SE'|'CH'|'SY'|'TW'|'TJ'|'TZ'|'TH'|'TL'|'TG'|'TK'|'TO'|'TT'|'TN'|'TR'|'TM'|'TC'|'TV'|'UG'|'UA'|'AE'|'GB'|'US'|'UM'|'UY'|'UZ'|'VU'|'VE'|'VN'|'VG'|'VI'|'WF'|'EH'|'YE'|'ZM'|'ZW'
},
]
},
'ChangeToken': 'string'
}
:returns:
Name (string) -- [REQUIRED]
A friendly name or description of the GeoMatchSet . You can\'t change Name after you create the GeoMatchSet .
ChangeToken (string) -- [REQUIRED]
The value returned by the most recent call to GetChangeToken .
"""
pass
def create_ip_set(Name=None, ChangeToken=None):
"""
Creates an IPSet , which you use to specify which web requests that you want to allow or block based on the IP addresses that the requests originate from. For example, if you\'re receiving a lot of requests from one or more individual IP addresses or one or more ranges of IP addresses and you want to block the requests, you can create an IPSet that contains those IP addresses and then configure AWS WAF to block the requests.
To create and configure an IPSet , perform the following steps:
For more information about how to use the AWS WAF API to allow or block HTTP requests, see the AWS WAF Developer Guide .
See also: AWS API Documentation
Exceptions
Examples
The following example creates an IP match set named MyIPSetFriendlyName.
Expected Output:
:example: response = client.create_ip_set(
Name='string',
ChangeToken='string'
)
:type Name: string
:param Name: [REQUIRED]\nA friendly name or description of the IPSet . You can\'t change Name after you create the IPSet .\n
:type ChangeToken: string
:param ChangeToken: [REQUIRED]\nThe value returned by the most recent call to GetChangeToken .\n
:rtype: dict
ReturnsResponse Syntax
{
'IPSet': {
'IPSetId': 'string',
'Name': 'string',
'IPSetDescriptors': [
{
'Type': 'IPV4'|'IPV6',
'Value': 'string'
},
]
},
'ChangeToken': 'string'
}
Response Structure
(dict) --
IPSet (dict) --
The IPSet returned in the CreateIPSet response.
IPSetId (string) --
The IPSetId for an IPSet . You use IPSetId to get information about an IPSet (see GetIPSet ), update an IPSet (see UpdateIPSet ), insert an IPSet into a Rule or delete one from a Rule (see UpdateRule ), and delete an IPSet from AWS WAF (see DeleteIPSet ).
IPSetId is returned by CreateIPSet and by ListIPSets .
Name (string) --
A friendly name or description of the IPSet . You can\'t change the name of an IPSet after you create it.
IPSetDescriptors (list) --
The IP address type (IPV4 or IPV6 ) and the IP address range (in CIDR notation) that web requests originate from. If the WebACL is associated with a CloudFront distribution and the viewer did not use an HTTP proxy or a load balancer to send the request, this is the value of the c-ip field in the CloudFront access logs.
(dict) --
Note
This is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.
For the latest version of AWS WAF , use the AWS WAFV2 API and see the AWS WAF Developer Guide . With the latest version, AWS WAF has a single set of endpoints for regional and global use.
Specifies the IP address type (IPV4 or IPV6 ) and the IP address range (in CIDR format) that web requests originate from.
Type (string) --
Specify IPV4 or IPV6 .
Value (string) --
Specify an IPv4 address by using CIDR notation. For example:
To configure AWS WAF to allow, block, or count requests that originated from the IP address 192.0.2.44, specify 192.0.2.44/32 .
To configure AWS WAF to allow, block, or count requests that originated from IP addresses from 192.0.2.0 to 192.0.2.255, specify 192.0.2.0/24 .
For more information about CIDR notation, see the Wikipedia entry Classless Inter-Domain Routing .
Specify an IPv6 address by using CIDR notation. For example:
To configure AWS WAF to allow, block, or count requests that originated from the IP address 1111:0000:0000:0000:0000:0000:0000:0111, specify 1111:0000:0000:0000:0000:0000:0000:0111/128 .
To configure AWS WAF to allow, block, or count requests that originated from IP addresses 1111:0000:0000:0000:0000:0000:0000:0000 to 1111:0000:0000:0000:ffff:ffff:ffff:ffff, specify 1111:0000:0000:0000:0000:0000:0000:0000/64 .
ChangeToken (string) --
The ChangeToken that you used to submit the CreateIPSet request. You can also use this value to query the status of the request. For more information, see GetChangeTokenStatus .
Exceptions
WAFRegional.Client.exceptions.WAFStaleDataException
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidAccountException
WAFRegional.Client.exceptions.WAFDisallowedNameException
WAFRegional.Client.exceptions.WAFInvalidParameterException
WAFRegional.Client.exceptions.WAFLimitsExceededException
Examples
The following example creates an IP match set named MyIPSetFriendlyName.
response = client.create_ip_set(
ChangeToken='abcd12f2-46da-4fdb-b8d5-fbd4c466928f',
Name='MyIPSetFriendlyName',
)
print(response)
Expected Output:
{
'ChangeToken': 'abcd12f2-46da-4fdb-b8d5-fbd4c466928f',
'IPSet': {
'IPSetDescriptors': [
{
'Type': 'IPV4',
'Value': '192.0.2.44/32',
},
],
'IPSetId': 'example1ds3t-46da-4fdb-b8d5-abc321j569j5',
'Name': 'MyIPSetFriendlyName',
},
'ResponseMetadata': {
'...': '...',
},
}
:return: {
'IPSet': {
'IPSetId': 'string',
'Name': 'string',
'IPSetDescriptors': [
{
'Type': 'IPV4'|'IPV6',
'Value': 'string'
},
]
},
'ChangeToken': 'string'
}
:returns:
Name (string) -- [REQUIRED]
A friendly name or description of the IPSet . You can\'t change Name after you create the IPSet .
ChangeToken (string) -- [REQUIRED]
The value returned by the most recent call to GetChangeToken .
"""
pass
def create_rate_based_rule(Name=None, MetricName=None, RateKey=None, RateLimit=None, ChangeToken=None, Tags=None):
"""
Creates a RateBasedRule . The RateBasedRule contains a RateLimit , which specifies the maximum number of requests that AWS WAF allows from a specified IP address in a five-minute period. The RateBasedRule also contains the IPSet objects, ByteMatchSet objects, and other predicates that identify the requests that you want to count or block if these requests exceed the RateLimit .
If you add more than one predicate to a RateBasedRule , a request not only must exceed the RateLimit , but it also must match all the conditions to be counted or blocked. For example, suppose you add the following to a RateBasedRule :
Further, you specify a RateLimit of 1,000.
You then add the RateBasedRule to a WebACL and specify that you want to block requests that meet the conditions in the rule. For a request to be blocked, it must come from the IP address 192.0.2.44 and the User-Agent header in the request must contain the value BadBot . Further, requests that match these two conditions must be received at a rate of more than 1,000 requests every five minutes. If both conditions are met and the rate is exceeded, AWS WAF blocks the requests. If the rate drops below 1,000 for a five-minute period, AWS WAF no longer blocks the requests.
As a second example, suppose you want to limit requests to a particular page on your site. To do this, you could add the following to a RateBasedRule :
Further, you specify a RateLimit of 1,000.
By adding this RateBasedRule to a WebACL , you could limit requests to your login page without affecting the rest of your site.
To create and configure a RateBasedRule , perform the following steps:
For more information about how to use the AWS WAF API to allow or block HTTP requests, see the AWS WAF Developer Guide .
See also: AWS API Documentation
Exceptions
:example: response = client.create_rate_based_rule(
Name='string',
MetricName='string',
RateKey='IP',
RateLimit=123,
ChangeToken='string',
Tags=[
{
'Key': 'string',
'Value': 'string'
},
]
)
:type Name: string
:param Name: [REQUIRED]\nA friendly name or description of the RateBasedRule . You can\'t change the name of a RateBasedRule after you create it.\n
:type MetricName: string
:param MetricName: [REQUIRED]\nA friendly name or description for the metrics for this RateBasedRule . The name can contain only alphanumeric characters (A-Z, a-z, 0-9), with maximum length 128 and minimum length one. It can\'t contain whitespace or metric names reserved for AWS WAF, including 'All' and 'Default_Action.' You can\'t change the name of the metric after you create the RateBasedRule .\n
:type RateKey: string
:param RateKey: [REQUIRED]\nThe field that AWS WAF uses to determine if requests are likely arriving from a single source and thus subject to rate monitoring. The only valid value for RateKey is IP . IP indicates that requests that arrive from the same IP address are subject to the RateLimit that is specified in the RateBasedRule .\n
:type RateLimit: integer
:param RateLimit: [REQUIRED]\nThe maximum number of requests, which have an identical value in the field that is specified by RateKey , allowed in a five-minute period. If the number of requests exceeds the RateLimit and the other predicates specified in the rule are also met, AWS WAF triggers the action that is specified for this rule.\n
:type ChangeToken: string
:param ChangeToken: [REQUIRED]\nThe ChangeToken that you used to submit the CreateRateBasedRule request. You can also use this value to query the status of the request. For more information, see GetChangeTokenStatus .\n
:type Tags: list
:param Tags: \n(dict) --\nNote\nThis is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.\n\nFor the latest version of AWS WAF , use the AWS WAFV2 API and see the AWS WAF Developer Guide . With the latest version, AWS WAF has a single set of endpoints for regional and global use.\n\nA tag associated with an AWS resource. Tags are key:value pairs that you can use to categorize and manage your resources, for purposes like billing. For example, you might set the tag key to 'customer' and the value to the customer name or ID. You can specify one or more tags to add to each AWS resource, up to 50 tags for a resource.\nTagging is only available through the API, SDKs, and CLI. You can\'t manage or view tags through the AWS WAF Classic console. You can tag the AWS resources that you manage through AWS WAF Classic: web ACLs, rule groups, and rules.\n\nKey (string) -- [REQUIRED]\nValue (string) -- [REQUIRED]\n\n\n\n
:rtype: dict
ReturnsResponse Syntax
{
'Rule': {
'RuleId': 'string',
'Name': 'string',
'MetricName': 'string',
'MatchPredicates': [
{
'Negated': True|False,
'Type': 'IPMatch'|'ByteMatch'|'SqlInjectionMatch'|'GeoMatch'|'SizeConstraint'|'XssMatch'|'RegexMatch',
'DataId': 'string'
},
],
'RateKey': 'IP',
'RateLimit': 123
},
'ChangeToken': 'string'
}
Response Structure
(dict) --
Rule (dict) --
The RateBasedRule that is returned in the CreateRateBasedRule response.
RuleId (string) --
A unique identifier for a RateBasedRule . You use RuleId to get more information about a RateBasedRule (see GetRateBasedRule ), update a RateBasedRule (see UpdateRateBasedRule ), insert a RateBasedRule into a WebACL or delete one from a WebACL (see UpdateWebACL ), or delete a RateBasedRule from AWS WAF (see DeleteRateBasedRule ).
Name (string) --
A friendly name or description for a RateBasedRule . You can\'t change the name of a RateBasedRule after you create it.
MetricName (string) --
A friendly name or description for the metrics for a RateBasedRule . The name can contain only alphanumeric characters (A-Z, a-z, 0-9), with maximum length 128 and minimum length one. It can\'t contain whitespace or metric names reserved for AWS WAF, including "All" and "Default_Action." You can\'t change the name of the metric after you create the RateBasedRule .
MatchPredicates (list) --
The Predicates object contains one Predicate element for each ByteMatchSet , IPSet , or SqlInjectionMatchSet object that you want to include in a RateBasedRule .
(dict) --
Note
This is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.
For the latest version of AWS WAF , use the AWS WAFV2 API and see the AWS WAF Developer Guide . With the latest version, AWS WAF has a single set of endpoints for regional and global use.
Specifies the ByteMatchSet , IPSet , SqlInjectionMatchSet , XssMatchSet , RegexMatchSet , GeoMatchSet , and SizeConstraintSet objects that you want to add to a Rule and, for each object, indicates whether you want to negate the settings, for example, requests that do NOT originate from the IP address 192.0.2.44.
Negated (boolean) --
Set Negated to False if you want AWS WAF to allow, block, or count requests based on the settings in the specified ByteMatchSet , IPSet , SqlInjectionMatchSet , XssMatchSet , RegexMatchSet , GeoMatchSet , or SizeConstraintSet . For example, if an IPSet includes the IP address 192.0.2.44 , AWS WAF will allow or block requests based on that IP address.
Set Negated to True if you want AWS WAF to allow or block a request based on the negation of the settings in the ByteMatchSet , IPSet , SqlInjectionMatchSet , XssMatchSet , RegexMatchSet , GeoMatchSet , or SizeConstraintSet . For example, if an IPSet includes the IP address 192.0.2.44 , AWS WAF will allow, block, or count requests based on all IP addresses except 192.0.2.44 .
Type (string) --
The type of predicate in a Rule , such as ByteMatch or IPSet .
DataId (string) --
A unique identifier for a predicate in a Rule , such as ByteMatchSetId or IPSetId . The ID is returned by the corresponding Create or List command.
RateKey (string) --
The field that AWS WAF uses to determine if requests are likely arriving from single source and thus subject to rate monitoring. The only valid value for RateKey is IP . IP indicates that requests arriving from the same IP address are subject to the RateLimit that is specified in the RateBasedRule .
RateLimit (integer) --
The maximum number of requests, which have an identical value in the field specified by the RateKey , allowed in a five-minute period. If the number of requests exceeds the RateLimit and the other predicates specified in the rule are also met, AWS WAF triggers the action that is specified for this rule.
ChangeToken (string) --
The ChangeToken that you used to submit the CreateRateBasedRule request. You can also use this value to query the status of the request. For more information, see GetChangeTokenStatus .
Exceptions
WAFRegional.Client.exceptions.WAFStaleDataException
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFDisallowedNameException
WAFRegional.Client.exceptions.WAFInvalidParameterException
WAFRegional.Client.exceptions.WAFLimitsExceededException
WAFRegional.Client.exceptions.WAFTagOperationException
WAFRegional.Client.exceptions.WAFTagOperationInternalErrorException
WAFRegional.Client.exceptions.WAFBadRequestException
:return: {
'Rule': {
'RuleId': 'string',
'Name': 'string',
'MetricName': 'string',
'MatchPredicates': [
{
'Negated': True|False,
'Type': 'IPMatch'|'ByteMatch'|'SqlInjectionMatch'|'GeoMatch'|'SizeConstraint'|'XssMatch'|'RegexMatch',
'DataId': 'string'
},
],
'RateKey': 'IP',
'RateLimit': 123
},
'ChangeToken': 'string'
}
:returns:
A ByteMatchSet with FieldToMatch of URI
A PositionalConstraint of STARTS_WITH
A TargetString of login
"""
pass
def create_regex_match_set(Name=None, ChangeToken=None):
"""
Creates a RegexMatchSet . You then use UpdateRegexMatchSet to identify the part of a web request that you want AWS WAF to inspect, such as the values of the User-Agent header or the query string. For example, you can create a RegexMatchSet that contains a RegexMatchTuple that looks for any requests with User-Agent headers that match a RegexPatternSet with pattern B[a@]dB[o0]t . You can then configure AWS WAF to reject those requests.
To create and configure a RegexMatchSet , perform the following steps:
For more information about how to use the AWS WAF API to allow or block HTTP requests, see the AWS WAF Developer Guide .
See also: AWS API Documentation
Exceptions
:example: response = client.create_regex_match_set(
Name='string',
ChangeToken='string'
)
:type Name: string
:param Name: [REQUIRED]\nA friendly name or description of the RegexMatchSet . You can\'t change Name after you create a RegexMatchSet .\n
:type ChangeToken: string
:param ChangeToken: [REQUIRED]\nThe value returned by the most recent call to GetChangeToken .\n
:rtype: dict
ReturnsResponse Syntax
{
'RegexMatchSet': {
'RegexMatchSetId': 'string',
'Name': 'string',
'RegexMatchTuples': [
{
'FieldToMatch': {
'Type': 'URI'|'QUERY_STRING'|'HEADER'|'METHOD'|'BODY'|'SINGLE_QUERY_ARG'|'ALL_QUERY_ARGS',
'Data': 'string'
},
'TextTransformation': 'NONE'|'COMPRESS_WHITE_SPACE'|'HTML_ENTITY_DECODE'|'LOWERCASE'|'CMD_LINE'|'URL_DECODE',
'RegexPatternSetId': 'string'
},
]
},
'ChangeToken': 'string'
}
Response Structure
(dict) --
RegexMatchSet (dict) --
A RegexMatchSet that contains no RegexMatchTuple objects.
RegexMatchSetId (string) --
The RegexMatchSetId for a RegexMatchSet . You use RegexMatchSetId to get information about a RegexMatchSet (see GetRegexMatchSet ), update a RegexMatchSet (see UpdateRegexMatchSet ), insert a RegexMatchSet into a Rule or delete one from a Rule (see UpdateRule ), and delete a RegexMatchSet from AWS WAF (see DeleteRegexMatchSet ).
RegexMatchSetId is returned by CreateRegexMatchSet and by ListRegexMatchSets .
Name (string) --
A friendly name or description of the RegexMatchSet . You can\'t change Name after you create a RegexMatchSet .
RegexMatchTuples (list) --
Contains an array of RegexMatchTuple objects. Each RegexMatchTuple object contains:
The part of a web request that you want AWS WAF to inspect, such as a query string or the value of the User-Agent header.
The identifier of the pattern (a regular expression) that you want AWS WAF to look for. For more information, see RegexPatternSet .
Whether to perform any conversions on the request, such as converting it to lowercase, before inspecting it for the specified string.
(dict) --
Note
This is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.
For the latest version of AWS WAF , use the AWS WAFV2 API and see the AWS WAF Developer Guide . With the latest version, AWS WAF has a single set of endpoints for regional and global use.
The regular expression pattern that you want AWS WAF to search for in web requests, the location in requests that you want AWS WAF to search, and other settings. Each RegexMatchTuple object contains:
The part of a web request that you want AWS WAF to inspect, such as a query string or the value of the User-Agent header.
The identifier of the pattern (a regular expression) that you want AWS WAF to look for. For more information, see RegexPatternSet .
Whether to perform any conversions on the request, such as converting it to lowercase, before inspecting it for the specified string.
FieldToMatch (dict) --
Specifies where in a web request to look for the RegexPatternSet .
Type (string) --
The part of the web request that you want AWS WAF to search for a specified string. Parts of a request that you can search include the following:
HEADER : A specified request header, for example, the value of the User-Agent or Referer header. If you choose HEADER for the type, specify the name of the header in Data .
METHOD : The HTTP method, which indicated the type of operation that the request is asking the origin to perform. Amazon CloudFront supports the following methods: DELETE , GET , HEAD , OPTIONS , PATCH , POST , and PUT .
QUERY_STRING : A query string, which is the part of a URL that appears after a ? character, if any.
URI : The part of a web request that identifies a resource, for example, /images/daily-ad.jpg .
BODY : The part of a request that contains any additional data that you want to send to your web server as the HTTP request body, such as data from a form. The request body immediately follows the request headers. Note that only the first 8192 bytes of the request body are forwarded to AWS WAF for inspection. To allow or block requests based on the length of the body, you can create a size constraint set. For more information, see CreateSizeConstraintSet .
SINGLE_QUERY_ARG : The parameter in the query string that you will inspect, such as UserName or SalesRegion . The maximum length for SINGLE_QUERY_ARG is 30 characters.
ALL_QUERY_ARGS : Similar to SINGLE_QUERY_ARG , but rather than inspecting a single parameter, AWS WAF will inspect all parameters within the query for the value or regex pattern that you specify in TargetString .
Data (string) --
When the value of Type is HEADER , enter the name of the header that you want AWS WAF to search, for example, User-Agent or Referer . The name of the header is not case sensitive.
When the value of Type is SINGLE_QUERY_ARG , enter the name of the parameter that you want AWS WAF to search, for example, UserName or SalesRegion . The parameter name is not case sensitive.
If the value of Type is any other value, omit Data .
TextTransformation (string) --
Text transformations eliminate some of the unusual formatting that attackers use in web requests in an effort to bypass AWS WAF. If you specify a transformation, AWS WAF performs the transformation on RegexPatternSet before inspecting a request for a match.
You can only specify a single type of TextTransformation.
CMD_LINE
When you\'re concerned that attackers are injecting an operating system commandline command and using unusual formatting to disguise some or all of the command, use this option to perform the following transformations:
Delete the following characters: " \' ^
Delete spaces before the following characters: / (
Replace the following characters with a space: , ;
Replace multiple spaces with one space
Convert uppercase letters (A-Z) to lowercase (a-z)
COMPRESS_WHITE_SPACE
Use this option to replace the following characters with a space character (decimal 32):
f, formfeed, decimal 12
t, tab, decimal 9
n, newline, decimal 10
r, carriage return, decimal 13
v, vertical tab, decimal 11
non-breaking space, decimal 160
COMPRESS_WHITE_SPACE also replaces multiple spaces with one space.
HTML_ENTITY_DECODE
Use this option to replace HTML-encoded characters with unencoded characters. HTML_ENTITY_DECODE performs the following operations:
Replaces (ampersand)quot; with "
Replaces (ampersand)nbsp; with a non-breaking space, decimal 160
Replaces (ampersand)lt; with a "less than" symbol
Replaces (ampersand)gt; with >
Replaces characters that are represented in hexadecimal format, (ampersand)#xhhhh; , with the corresponding characters
Replaces characters that are represented in decimal format, (ampersand)#nnnn; , with the corresponding characters
LOWERCASE
Use this option to convert uppercase letters (A-Z) to lowercase (a-z).
URL_DECODE
Use this option to decode a URL-encoded value.
NONE
Specify NONE if you don\'t want to perform any text transformations.
RegexPatternSetId (string) --
The RegexPatternSetId for a RegexPatternSet . You use RegexPatternSetId to get information about a RegexPatternSet (see GetRegexPatternSet ), update a RegexPatternSet (see UpdateRegexPatternSet ), insert a RegexPatternSet into a RegexMatchSet or delete one from a RegexMatchSet (see UpdateRegexMatchSet ), and delete an RegexPatternSet from AWS WAF (see DeleteRegexPatternSet ).
RegexPatternSetId is returned by CreateRegexPatternSet and by ListRegexPatternSets .
ChangeToken (string) --
The ChangeToken that you used to submit the CreateRegexMatchSet request. You can also use this value to query the status of the request. For more information, see GetChangeTokenStatus .
Exceptions
WAFRegional.Client.exceptions.WAFStaleDataException
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFDisallowedNameException
WAFRegional.Client.exceptions.WAFLimitsExceededException
:return: {
'RegexMatchSet': {
'RegexMatchSetId': 'string',
'Name': 'string',
'RegexMatchTuples': [
{
'FieldToMatch': {
'Type': 'URI'|'QUERY_STRING'|'HEADER'|'METHOD'|'BODY'|'SINGLE_QUERY_ARG'|'ALL_QUERY_ARGS',
'Data': 'string'
},
'TextTransformation': 'NONE'|'COMPRESS_WHITE_SPACE'|'HTML_ENTITY_DECODE'|'LOWERCASE'|'CMD_LINE'|'URL_DECODE',
'RegexPatternSetId': 'string'
},
]
},
'ChangeToken': 'string'
}
:returns:
Name (string) -- [REQUIRED]
A friendly name or description of the RegexMatchSet . You can\'t change Name after you create a RegexMatchSet .
ChangeToken (string) -- [REQUIRED]
The value returned by the most recent call to GetChangeToken .
"""
pass
def create_regex_pattern_set(Name=None, ChangeToken=None):
"""
Creates a RegexPatternSet . You then use UpdateRegexPatternSet to specify the regular expression (regex) pattern that you want AWS WAF to search for, such as B[a@]dB[o0]t . You can then configure AWS WAF to reject those requests.
To create and configure a RegexPatternSet , perform the following steps:
For more information about how to use the AWS WAF API to allow or block HTTP requests, see the AWS WAF Developer Guide .
See also: AWS API Documentation
Exceptions
:example: response = client.create_regex_pattern_set(
Name='string',
ChangeToken='string'
)
:type Name: string
:param Name: [REQUIRED]\nA friendly name or description of the RegexPatternSet . You can\'t change Name after you create a RegexPatternSet .\n
:type ChangeToken: string
:param ChangeToken: [REQUIRED]\nThe value returned by the most recent call to GetChangeToken .\n
:rtype: dict
ReturnsResponse Syntax
{
'RegexPatternSet': {
'RegexPatternSetId': 'string',
'Name': 'string',
'RegexPatternStrings': [
'string',
]
},
'ChangeToken': 'string'
}
Response Structure
(dict) --
RegexPatternSet (dict) --
A RegexPatternSet that contains no objects.
RegexPatternSetId (string) --
The identifier for the RegexPatternSet . You use RegexPatternSetId to get information about a RegexPatternSet , update a RegexPatternSet , remove a RegexPatternSet from a RegexMatchSet , and delete a RegexPatternSet from AWS WAF.
RegexMatchSetId is returned by CreateRegexPatternSet and by ListRegexPatternSets .
Name (string) --
A friendly name or description of the RegexPatternSet . You can\'t change Name after you create a RegexPatternSet .
RegexPatternStrings (list) --
Specifies the regular expression (regex) patterns that you want AWS WAF to search for, such as B[a@]dB[o0]t .
(string) --
ChangeToken (string) --
The ChangeToken that you used to submit the CreateRegexPatternSet request. You can also use this value to query the status of the request. For more information, see GetChangeTokenStatus .
Exceptions
WAFRegional.Client.exceptions.WAFStaleDataException
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFDisallowedNameException
WAFRegional.Client.exceptions.WAFLimitsExceededException
:return: {
'RegexPatternSet': {
'RegexPatternSetId': 'string',
'Name': 'string',
'RegexPatternStrings': [
'string',
]
},
'ChangeToken': 'string'
}
:returns:
Name (string) -- [REQUIRED]
A friendly name or description of the RegexPatternSet . You can\'t change Name after you create a RegexPatternSet .
ChangeToken (string) -- [REQUIRED]
The value returned by the most recent call to GetChangeToken .
"""
pass
def create_rule(Name=None, MetricName=None, ChangeToken=None, Tags=None):
"""
Creates a Rule , which contains the IPSet objects, ByteMatchSet objects, and other predicates that identify the requests that you want to block. If you add more than one predicate to a Rule , a request must match all of the specifications to be allowed or blocked. For example, suppose that you add the following to a Rule :
You then add the Rule to a WebACL and specify that you want to blocks requests that satisfy the Rule . For a request to be blocked, it must come from the IP address 192.0.2.44 and the User-Agent header in the request must contain the value BadBot .
To create and configure a Rule , perform the following steps:
For more information about how to use the AWS WAF API to allow or block HTTP requests, see the AWS WAF Developer Guide .
See also: AWS API Documentation
Exceptions
Examples
The following example creates a rule named WAFByteHeaderRule.
Expected Output:
:example: response = client.create_rule(
Name='string',
MetricName='string',
ChangeToken='string',
Tags=[
{
'Key': 'string',
'Value': 'string'
},
]
)
:type Name: string
:param Name: [REQUIRED]\nA friendly name or description of the Rule . You can\'t change the name of a Rule after you create it.\n
:type MetricName: string
:param MetricName: [REQUIRED]\nA friendly name or description for the metrics for this Rule . The name can contain only alphanumeric characters (A-Z, a-z, 0-9), with maximum length 128 and minimum length one. It can\'t contain whitespace or metric names reserved for AWS WAF, including 'All' and 'Default_Action.' You can\'t change the name of the metric after you create the Rule .\n
:type ChangeToken: string
:param ChangeToken: [REQUIRED]\nThe value returned by the most recent call to GetChangeToken .\n
:type Tags: list
:param Tags: \n(dict) --\nNote\nThis is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.\n\nFor the latest version of AWS WAF , use the AWS WAFV2 API and see the AWS WAF Developer Guide . With the latest version, AWS WAF has a single set of endpoints for regional and global use.\n\nA tag associated with an AWS resource. Tags are key:value pairs that you can use to categorize and manage your resources, for purposes like billing. For example, you might set the tag key to 'customer' and the value to the customer name or ID. You can specify one or more tags to add to each AWS resource, up to 50 tags for a resource.\nTagging is only available through the API, SDKs, and CLI. You can\'t manage or view tags through the AWS WAF Classic console. You can tag the AWS resources that you manage through AWS WAF Classic: web ACLs, rule groups, and rules.\n\nKey (string) -- [REQUIRED]\nValue (string) -- [REQUIRED]\n\n\n\n
:rtype: dict
ReturnsResponse Syntax
{
'Rule': {
'RuleId': 'string',
'Name': 'string',
'MetricName': 'string',
'Predicates': [
{
'Negated': True|False,
'Type': 'IPMatch'|'ByteMatch'|'SqlInjectionMatch'|'GeoMatch'|'SizeConstraint'|'XssMatch'|'RegexMatch',
'DataId': 'string'
},
]
},
'ChangeToken': 'string'
}
Response Structure
(dict) --
Rule (dict) --
The Rule returned in the CreateRule response.
RuleId (string) --
A unique identifier for a Rule . You use RuleId to get more information about a Rule (see GetRule ), update a Rule (see UpdateRule ), insert a Rule into a WebACL or delete a one from a WebACL (see UpdateWebACL ), or delete a Rule from AWS WAF (see DeleteRule ).
RuleId is returned by CreateRule and by ListRules .
Name (string) --
The friendly name or description for the Rule . You can\'t change the name of a Rule after you create it.
MetricName (string) --
A friendly name or description for the metrics for this Rule . The name can contain only alphanumeric characters (A-Z, a-z, 0-9), with maximum length 128 and minimum length one. It can\'t contain whitespace or metric names reserved for AWS WAF, including "All" and "Default_Action." You can\'t change MetricName after you create the Rule .
Predicates (list) --
The Predicates object contains one Predicate element for each ByteMatchSet , IPSet , or SqlInjectionMatchSet object that you want to include in a Rule .
(dict) --
Note
This is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.
For the latest version of AWS WAF , use the AWS WAFV2 API and see the AWS WAF Developer Guide . With the latest version, AWS WAF has a single set of endpoints for regional and global use.
Specifies the ByteMatchSet , IPSet , SqlInjectionMatchSet , XssMatchSet , RegexMatchSet , GeoMatchSet , and SizeConstraintSet objects that you want to add to a Rule and, for each object, indicates whether you want to negate the settings, for example, requests that do NOT originate from the IP address 192.0.2.44.
Negated (boolean) --
Set Negated to False if you want AWS WAF to allow, block, or count requests based on the settings in the specified ByteMatchSet , IPSet , SqlInjectionMatchSet , XssMatchSet , RegexMatchSet , GeoMatchSet , or SizeConstraintSet . For example, if an IPSet includes the IP address 192.0.2.44 , AWS WAF will allow or block requests based on that IP address.
Set Negated to True if you want AWS WAF to allow or block a request based on the negation of the settings in the ByteMatchSet , IPSet , SqlInjectionMatchSet , XssMatchSet , RegexMatchSet , GeoMatchSet , or SizeConstraintSet . For example, if an IPSet includes the IP address 192.0.2.44 , AWS WAF will allow, block, or count requests based on all IP addresses except 192.0.2.44 .
Type (string) --
The type of predicate in a Rule , such as ByteMatch or IPSet .
DataId (string) --
A unique identifier for a predicate in a Rule , such as ByteMatchSetId or IPSetId . The ID is returned by the corresponding Create or List command.
ChangeToken (string) --
The ChangeToken that you used to submit the CreateRule request. You can also use this value to query the status of the request. For more information, see GetChangeTokenStatus .
Exceptions
WAFRegional.Client.exceptions.WAFStaleDataException
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFDisallowedNameException
WAFRegional.Client.exceptions.WAFInvalidParameterException
WAFRegional.Client.exceptions.WAFLimitsExceededException
WAFRegional.Client.exceptions.WAFTagOperationException
WAFRegional.Client.exceptions.WAFTagOperationInternalErrorException
WAFRegional.Client.exceptions.WAFBadRequestException
Examples
The following example creates a rule named WAFByteHeaderRule.
response = client.create_rule(
ChangeToken='abcd12f2-46da-4fdb-b8d5-fbd4c466928f',
MetricName='WAFByteHeaderRule',
Name='WAFByteHeaderRule',
)
print(response)
Expected Output:
{
'ChangeToken': 'abcd12f2-46da-4fdb-b8d5-fbd4c466928f',
'Rule': {
'MetricName': 'WAFByteHeaderRule',
'Name': 'WAFByteHeaderRule',
'Predicates': [
{
'DataId': 'MyByteMatchSetID',
'Negated': False,
'Type': 'ByteMatch',
},
],
'RuleId': 'WAFRule-1-Example',
},
'ResponseMetadata': {
'...': '...',
},
}
:return: {
'Rule': {
'RuleId': 'string',
'Name': 'string',
'MetricName': 'string',
'Predicates': [
{
'Negated': True|False,
'Type': 'IPMatch'|'ByteMatch'|'SqlInjectionMatch'|'GeoMatch'|'SizeConstraint'|'XssMatch'|'RegexMatch',
'DataId': 'string'
},
]
},
'ChangeToken': 'string'
}
:returns:
Create and update the predicates that you want to include in the Rule . For more information, see CreateByteMatchSet , CreateIPSet , and CreateSqlInjectionMatchSet .
Use GetChangeToken to get the change token that you provide in the ChangeToken parameter of a CreateRule request.
Submit a CreateRule request.
Use GetChangeToken to get the change token that you provide in the ChangeToken parameter of an UpdateRule request.
Submit an UpdateRule request to specify the predicates that you want to include in the Rule .
Create and update a WebACL that contains the Rule . For more information, see CreateWebACL .
"""
pass
def create_rule_group(Name=None, MetricName=None, ChangeToken=None, Tags=None):
"""
Creates a RuleGroup . A rule group is a collection of predefined rules that you add to a web ACL. You use UpdateRuleGroup to add rules to the rule group.
Rule groups are subject to the following limits:
For more information about how to use the AWS WAF API to allow or block HTTP requests, see the AWS WAF Developer Guide .
See also: AWS API Documentation
Exceptions
:example: response = client.create_rule_group(
Name='string',
MetricName='string',
ChangeToken='string',
Tags=[
{
'Key': 'string',
'Value': 'string'
},
]
)
:type Name: string
:param Name: [REQUIRED]\nA friendly name or description of the RuleGroup . You can\'t change Name after you create a RuleGroup .\n
:type MetricName: string
:param MetricName: [REQUIRED]\nA friendly name or description for the metrics for this RuleGroup . The name can contain only alphanumeric characters (A-Z, a-z, 0-9), with maximum length 128 and minimum length one. It can\'t contain whitespace or metric names reserved for AWS WAF, including 'All' and 'Default_Action.' You can\'t change the name of the metric after you create the RuleGroup .\n
:type ChangeToken: string
:param ChangeToken: [REQUIRED]\nThe value returned by the most recent call to GetChangeToken .\n
:type Tags: list
:param Tags: \n(dict) --\nNote\nThis is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.\n\nFor the latest version of AWS WAF , use the AWS WAFV2 API and see the AWS WAF Developer Guide . With the latest version, AWS WAF has a single set of endpoints for regional and global use.\n\nA tag associated with an AWS resource. Tags are key:value pairs that you can use to categorize and manage your resources, for purposes like billing. For example, you might set the tag key to 'customer' and the value to the customer name or ID. You can specify one or more tags to add to each AWS resource, up to 50 tags for a resource.\nTagging is only available through the API, SDKs, and CLI. You can\'t manage or view tags through the AWS WAF Classic console. You can tag the AWS resources that you manage through AWS WAF Classic: web ACLs, rule groups, and rules.\n\nKey (string) -- [REQUIRED]\nValue (string) -- [REQUIRED]\n\n\n\n
:rtype: dict
ReturnsResponse Syntax
{
'RuleGroup': {
'RuleGroupId': 'string',
'Name': 'string',
'MetricName': 'string'
},
'ChangeToken': 'string'
}
Response Structure
(dict) --
RuleGroup (dict) --
An empty RuleGroup .
RuleGroupId (string) --
A unique identifier for a RuleGroup . You use RuleGroupId to get more information about a RuleGroup (see GetRuleGroup ), update a RuleGroup (see UpdateRuleGroup ), insert a RuleGroup into a WebACL or delete a one from a WebACL (see UpdateWebACL ), or delete a RuleGroup from AWS WAF (see DeleteRuleGroup ).
RuleGroupId is returned by CreateRuleGroup and by ListRuleGroups .
Name (string) --
The friendly name or description for the RuleGroup . You can\'t change the name of a RuleGroup after you create it.
MetricName (string) --
A friendly name or description for the metrics for this RuleGroup . The name can contain only alphanumeric characters (A-Z, a-z, 0-9), with maximum length 128 and minimum length one. It can\'t contain whitespace or metric names reserved for AWS WAF, including "All" and "Default_Action." You can\'t change the name of the metric after you create the RuleGroup .
ChangeToken (string) --
The ChangeToken that you used to submit the CreateRuleGroup request. You can also use this value to query the status of the request. For more information, see GetChangeTokenStatus .
Exceptions
WAFRegional.Client.exceptions.WAFStaleDataException
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFDisallowedNameException
WAFRegional.Client.exceptions.WAFLimitsExceededException
WAFRegional.Client.exceptions.WAFTagOperationException
WAFRegional.Client.exceptions.WAFTagOperationInternalErrorException
WAFRegional.Client.exceptions.WAFBadRequestException
:return: {
'RuleGroup': {
'RuleGroupId': 'string',
'Name': 'string',
'MetricName': 'string'
},
'ChangeToken': 'string'
}
:returns:
Name (string) -- [REQUIRED]
A friendly name or description of the RuleGroup . You can\'t change Name after you create a RuleGroup .
MetricName (string) -- [REQUIRED]
A friendly name or description for the metrics for this RuleGroup . The name can contain only alphanumeric characters (A-Z, a-z, 0-9), with maximum length 128 and minimum length one. It can\'t contain whitespace or metric names reserved for AWS WAF, including "All" and "Default_Action." You can\'t change the name of the metric after you create the RuleGroup .
ChangeToken (string) -- [REQUIRED]
The value returned by the most recent call to GetChangeToken .
Tags (list) --
(dict) --
Note
This is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.
For the latest version of AWS WAF , use the AWS WAFV2 API and see the AWS WAF Developer Guide . With the latest version, AWS WAF has a single set of endpoints for regional and global use.
A tag associated with an AWS resource. Tags are key:value pairs that you can use to categorize and manage your resources, for purposes like billing. For example, you might set the tag key to "customer" and the value to the customer name or ID. You can specify one or more tags to add to each AWS resource, up to 50 tags for a resource.
Tagging is only available through the API, SDKs, and CLI. You can\'t manage or view tags through the AWS WAF Classic console. You can tag the AWS resources that you manage through AWS WAF Classic: web ACLs, rule groups, and rules.
Key (string) -- [REQUIRED]
Value (string) -- [REQUIRED]
"""
pass
def create_size_constraint_set(Name=None, ChangeToken=None):
"""
Creates a SizeConstraintSet . You then use UpdateSizeConstraintSet to identify the part of a web request that you want AWS WAF to check for length, such as the length of the User-Agent header or the length of the query string. For example, you can create a SizeConstraintSet that matches any requests that have a query string that is longer than 100 bytes. You can then configure AWS WAF to reject those requests.
To create and configure a SizeConstraintSet , perform the following steps:
For more information about how to use the AWS WAF API to allow or block HTTP requests, see the AWS WAF Developer Guide .
See also: AWS API Documentation
Exceptions
Examples
The following example creates size constraint set named MySampleSizeConstraintSet.
Expected Output:
:example: response = client.create_size_constraint_set(
Name='string',
ChangeToken='string'
)
:type Name: string
:param Name: [REQUIRED]\nA friendly name or description of the SizeConstraintSet . You can\'t change Name after you create a SizeConstraintSet .\n
:type ChangeToken: string
:param ChangeToken: [REQUIRED]\nThe value returned by the most recent call to GetChangeToken .\n
:rtype: dict
ReturnsResponse Syntax
{
'SizeConstraintSet': {
'SizeConstraintSetId': 'string',
'Name': 'string',
'SizeConstraints': [
{
'FieldToMatch': {
'Type': 'URI'|'QUERY_STRING'|'HEADER'|'METHOD'|'BODY'|'SINGLE_QUERY_ARG'|'ALL_QUERY_ARGS',
'Data': 'string'
},
'TextTransformation': 'NONE'|'COMPRESS_WHITE_SPACE'|'HTML_ENTITY_DECODE'|'LOWERCASE'|'CMD_LINE'|'URL_DECODE',
'ComparisonOperator': 'EQ'|'NE'|'LE'|'LT'|'GE'|'GT',
'Size': 123
},
]
},
'ChangeToken': 'string'
}
Response Structure
(dict) --
SizeConstraintSet (dict) --
A SizeConstraintSet that contains no SizeConstraint objects.
SizeConstraintSetId (string) --
A unique identifier for a SizeConstraintSet . You use SizeConstraintSetId to get information about a SizeConstraintSet (see GetSizeConstraintSet ), update a SizeConstraintSet (see UpdateSizeConstraintSet ), insert a SizeConstraintSet into a Rule or delete one from a Rule (see UpdateRule ), and delete a SizeConstraintSet from AWS WAF (see DeleteSizeConstraintSet ).
SizeConstraintSetId is returned by CreateSizeConstraintSet and by ListSizeConstraintSets .
Name (string) --
The name, if any, of the SizeConstraintSet .
SizeConstraints (list) --
Specifies the parts of web requests that you want to inspect the size of.
(dict) --
Note
This is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.
For the latest version of AWS WAF , use the AWS WAFV2 API and see the AWS WAF Developer Guide . With the latest version, AWS WAF has a single set of endpoints for regional and global use.
Specifies a constraint on the size of a part of the web request. AWS WAF uses the Size , ComparisonOperator , and FieldToMatch to build an expression in the form of "Size ComparisonOperator size in bytes of FieldToMatch ". If that expression is true, the SizeConstraint is considered to match.
FieldToMatch (dict) --
Specifies where in a web request to look for the size constraint.
Type (string) --
The part of the web request that you want AWS WAF to search for a specified string. Parts of a request that you can search include the following:
HEADER : A specified request header, for example, the value of the User-Agent or Referer header. If you choose HEADER for the type, specify the name of the header in Data .
METHOD : The HTTP method, which indicated the type of operation that the request is asking the origin to perform. Amazon CloudFront supports the following methods: DELETE , GET , HEAD , OPTIONS , PATCH , POST , and PUT .
QUERY_STRING : A query string, which is the part of a URL that appears after a ? character, if any.
URI : The part of a web request that identifies a resource, for example, /images/daily-ad.jpg .
BODY : The part of a request that contains any additional data that you want to send to your web server as the HTTP request body, such as data from a form. The request body immediately follows the request headers. Note that only the first 8192 bytes of the request body are forwarded to AWS WAF for inspection. To allow or block requests based on the length of the body, you can create a size constraint set. For more information, see CreateSizeConstraintSet .
SINGLE_QUERY_ARG : The parameter in the query string that you will inspect, such as UserName or SalesRegion . The maximum length for SINGLE_QUERY_ARG is 30 characters.
ALL_QUERY_ARGS : Similar to SINGLE_QUERY_ARG , but rather than inspecting a single parameter, AWS WAF will inspect all parameters within the query for the value or regex pattern that you specify in TargetString .
Data (string) --
When the value of Type is HEADER , enter the name of the header that you want AWS WAF to search, for example, User-Agent or Referer . The name of the header is not case sensitive.
When the value of Type is SINGLE_QUERY_ARG , enter the name of the parameter that you want AWS WAF to search, for example, UserName or SalesRegion . The parameter name is not case sensitive.
If the value of Type is any other value, omit Data .
TextTransformation (string) --
Text transformations eliminate some of the unusual formatting that attackers use in web requests in an effort to bypass AWS WAF. If you specify a transformation, AWS WAF performs the transformation on FieldToMatch before inspecting it for a match.
You can only specify a single type of TextTransformation.
Note that if you choose BODY for the value of Type , you must choose NONE for TextTransformation because CloudFront forwards only the first 8192 bytes for inspection.
NONE
Specify NONE if you don\'t want to perform any text transformations.
CMD_LINE
When you\'re concerned that attackers are injecting an operating system command line command and using unusual formatting to disguise some or all of the command, use this option to perform the following transformations:
Delete the following characters: " \' ^
Delete spaces before the following characters: / (
Replace the following characters with a space: , ;
Replace multiple spaces with one space
Convert uppercase letters (A-Z) to lowercase (a-z)
COMPRESS_WHITE_SPACE
Use this option to replace the following characters with a space character (decimal 32):
f, formfeed, decimal 12
t, tab, decimal 9
n, newline, decimal 10
r, carriage return, decimal 13
v, vertical tab, decimal 11
non-breaking space, decimal 160
COMPRESS_WHITE_SPACE also replaces multiple spaces with one space.
HTML_ENTITY_DECODE
Use this option to replace HTML-encoded characters with unencoded characters. HTML_ENTITY_DECODE performs the following operations:
Replaces (ampersand)quot; with "
Replaces (ampersand)nbsp; with a non-breaking space, decimal 160
Replaces (ampersand)lt; with a "less than" symbol
Replaces (ampersand)gt; with >
Replaces characters that are represented in hexadecimal format, (ampersand)#xhhhh; , with the corresponding characters
Replaces characters that are represented in decimal format, (ampersand)#nnnn; , with the corresponding characters
LOWERCASE
Use this option to convert uppercase letters (A-Z) to lowercase (a-z).
URL_DECODE
Use this option to decode a URL-encoded value.
ComparisonOperator (string) --
The type of comparison you want AWS WAF to perform. AWS WAF uses this in combination with the provided Size and FieldToMatch to build an expression in the form of "Size ComparisonOperator size in bytes of FieldToMatch ". If that expression is true, the SizeConstraint is considered to match.
EQ : Used to test if the Size is equal to the size of the FieldToMatch
NE : Used to test if the Size is not equal to the size of the FieldToMatch
LE : Used to test if the Size is less than or equal to the size of the FieldToMatch
LT : Used to test if the Size is strictly less than the size of the FieldToMatch
GE : Used to test if the Size is greater than or equal to the size of the FieldToMatch
GT : Used to test if the Size is strictly greater than the size of the FieldToMatch
Size (integer) --
The size in bytes that you want AWS WAF to compare against the size of the specified FieldToMatch . AWS WAF uses this in combination with ComparisonOperator and FieldToMatch to build an expression in the form of "Size ComparisonOperator size in bytes of FieldToMatch ". If that expression is true, the SizeConstraint is considered to match.
Valid values for size are 0 - 21474836480 bytes (0 - 20 GB).
If you specify URI for the value of Type , the / in the URI counts as one character. For example, the URI /logo.jpg is nine characters long.
ChangeToken (string) --
The ChangeToken that you used to submit the CreateSizeConstraintSet request. You can also use this value to query the status of the request. For more information, see GetChangeTokenStatus .
Exceptions
WAFRegional.Client.exceptions.WAFStaleDataException
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidAccountException
WAFRegional.Client.exceptions.WAFDisallowedNameException
WAFRegional.Client.exceptions.WAFInvalidParameterException
WAFRegional.Client.exceptions.WAFLimitsExceededException
Examples
The following example creates size constraint set named MySampleSizeConstraintSet.
response = client.create_size_constraint_set(
ChangeToken='abcd12f2-46da-4fdb-b8d5-fbd4c466928f',
Name='MySampleSizeConstraintSet',
)
print(response)
Expected Output:
{
'ChangeToken': 'abcd12f2-46da-4fdb-b8d5-fbd4c466928f',
'SizeConstraintSet': {
'Name': 'MySampleSizeConstraintSet',
'SizeConstraintSetId': 'example1ds3t-46da-4fdb-b8d5-abc321j569j5',
'SizeConstraints': [
{
'ComparisonOperator': 'GT',
'FieldToMatch': {
'Type': 'QUERY_STRING',
},
'Size': 0,
'TextTransformation': 'NONE',
},
],
},
'ResponseMetadata': {
'...': '...',
},
}
:return: {
'SizeConstraintSet': {
'SizeConstraintSetId': 'string',
'Name': 'string',
'SizeConstraints': [
{
'FieldToMatch': {
'Type': 'URI'|'QUERY_STRING'|'HEADER'|'METHOD'|'BODY'|'SINGLE_QUERY_ARG'|'ALL_QUERY_ARGS',
'Data': 'string'
},
'TextTransformation': 'NONE'|'COMPRESS_WHITE_SPACE'|'HTML_ENTITY_DECODE'|'LOWERCASE'|'CMD_LINE'|'URL_DECODE',
'ComparisonOperator': 'EQ'|'NE'|'LE'|'LT'|'GE'|'GT',
'Size': 123
},
]
},
'ChangeToken': 'string'
}
:returns:
Name (string) -- [REQUIRED]
A friendly name or description of the SizeConstraintSet . You can\'t change Name after you create a SizeConstraintSet .
ChangeToken (string) -- [REQUIRED]
The value returned by the most recent call to GetChangeToken .
"""
pass
def create_sql_injection_match_set(Name=None, ChangeToken=None):
"""
Creates a SqlInjectionMatchSet , which you use to allow, block, or count requests that contain snippets of SQL code in a specified part of web requests. AWS WAF searches for character sequences that are likely to be malicious strings.
To create and configure a SqlInjectionMatchSet , perform the following steps:
For more information about how to use the AWS WAF API to allow or block HTTP requests, see the AWS WAF Developer Guide .
See also: AWS API Documentation
Exceptions
Examples
The following example creates a SQL injection match set named MySQLInjectionMatchSet.
Expected Output:
:example: response = client.create_sql_injection_match_set(
Name='string',
ChangeToken='string'
)
:type Name: string
:param Name: [REQUIRED]\nA friendly name or description for the SqlInjectionMatchSet that you\'re creating. You can\'t change Name after you create the SqlInjectionMatchSet .\n
:type ChangeToken: string
:param ChangeToken: [REQUIRED]\nThe value returned by the most recent call to GetChangeToken .\n
:rtype: dict
ReturnsResponse Syntax
{
'SqlInjectionMatchSet': {
'SqlInjectionMatchSetId': 'string',
'Name': 'string',
'SqlInjectionMatchTuples': [
{
'FieldToMatch': {
'Type': 'URI'|'QUERY_STRING'|'HEADER'|'METHOD'|'BODY'|'SINGLE_QUERY_ARG'|'ALL_QUERY_ARGS',
'Data': 'string'
},
'TextTransformation': 'NONE'|'COMPRESS_WHITE_SPACE'|'HTML_ENTITY_DECODE'|'LOWERCASE'|'CMD_LINE'|'URL_DECODE'
},
]
},
'ChangeToken': 'string'
}
Response Structure
(dict) --
The response to a CreateSqlInjectionMatchSet request.
SqlInjectionMatchSet (dict) --
A SqlInjectionMatchSet .
SqlInjectionMatchSetId (string) --
A unique identifier for a SqlInjectionMatchSet . You use SqlInjectionMatchSetId to get information about a SqlInjectionMatchSet (see GetSqlInjectionMatchSet ), update a SqlInjectionMatchSet (see UpdateSqlInjectionMatchSet ), insert a SqlInjectionMatchSet into a Rule or delete one from a Rule (see UpdateRule ), and delete a SqlInjectionMatchSet from AWS WAF (see DeleteSqlInjectionMatchSet ).
SqlInjectionMatchSetId is returned by CreateSqlInjectionMatchSet and by ListSqlInjectionMatchSets .
Name (string) --
The name, if any, of the SqlInjectionMatchSet .
SqlInjectionMatchTuples (list) --
Specifies the parts of web requests that you want to inspect for snippets of malicious SQL code.
(dict) --
Note
This is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.
For the latest version of AWS WAF , use the AWS WAFV2 API and see the AWS WAF Developer Guide . With the latest version, AWS WAF has a single set of endpoints for regional and global use.
Specifies the part of a web request that you want AWS WAF to inspect for snippets of malicious SQL code and, if you want AWS WAF to inspect a header, the name of the header.
FieldToMatch (dict) --
Specifies where in a web request to look for snippets of malicious SQL code.
Type (string) --
The part of the web request that you want AWS WAF to search for a specified string. Parts of a request that you can search include the following:
HEADER : A specified request header, for example, the value of the User-Agent or Referer header. If you choose HEADER for the type, specify the name of the header in Data .
METHOD : The HTTP method, which indicated the type of operation that the request is asking the origin to perform. Amazon CloudFront supports the following methods: DELETE , GET , HEAD , OPTIONS , PATCH , POST , and PUT .
QUERY_STRING : A query string, which is the part of a URL that appears after a ? character, if any.
URI : The part of a web request that identifies a resource, for example, /images/daily-ad.jpg .
BODY : The part of a request that contains any additional data that you want to send to your web server as the HTTP request body, such as data from a form. The request body immediately follows the request headers. Note that only the first 8192 bytes of the request body are forwarded to AWS WAF for inspection. To allow or block requests based on the length of the body, you can create a size constraint set. For more information, see CreateSizeConstraintSet .
SINGLE_QUERY_ARG : The parameter in the query string that you will inspect, such as UserName or SalesRegion . The maximum length for SINGLE_QUERY_ARG is 30 characters.
ALL_QUERY_ARGS : Similar to SINGLE_QUERY_ARG , but rather than inspecting a single parameter, AWS WAF will inspect all parameters within the query for the value or regex pattern that you specify in TargetString .
Data (string) --
When the value of Type is HEADER , enter the name of the header that you want AWS WAF to search, for example, User-Agent or Referer . The name of the header is not case sensitive.
When the value of Type is SINGLE_QUERY_ARG , enter the name of the parameter that you want AWS WAF to search, for example, UserName or SalesRegion . The parameter name is not case sensitive.
If the value of Type is any other value, omit Data .
TextTransformation (string) --
Text transformations eliminate some of the unusual formatting that attackers use in web requests in an effort to bypass AWS WAF. If you specify a transformation, AWS WAF performs the transformation on FieldToMatch before inspecting it for a match.
You can only specify a single type of TextTransformation.
CMD_LINE
When you\'re concerned that attackers are injecting an operating system command line command and using unusual formatting to disguise some or all of the command, use this option to perform the following transformations:
Delete the following characters: " \' ^
Delete spaces before the following characters: / (
Replace the following characters with a space: , ;
Replace multiple spaces with one space
Convert uppercase letters (A-Z) to lowercase (a-z)
COMPRESS_WHITE_SPACE
Use this option to replace the following characters with a space character (decimal 32):
f, formfeed, decimal 12
t, tab, decimal 9
n, newline, decimal 10
r, carriage return, decimal 13
v, vertical tab, decimal 11
non-breaking space, decimal 160
COMPRESS_WHITE_SPACE also replaces multiple spaces with one space.
HTML_ENTITY_DECODE
Use this option to replace HTML-encoded characters with unencoded characters. HTML_ENTITY_DECODE performs the following operations:
Replaces (ampersand)quot; with "
Replaces (ampersand)nbsp; with a non-breaking space, decimal 160
Replaces (ampersand)lt; with a "less than" symbol
Replaces (ampersand)gt; with >
Replaces characters that are represented in hexadecimal format, (ampersand)#xhhhh; , with the corresponding characters
Replaces characters that are represented in decimal format, (ampersand)#nnnn; , with the corresponding characters
LOWERCASE
Use this option to convert uppercase letters (A-Z) to lowercase (a-z).
URL_DECODE
Use this option to decode a URL-encoded value.
NONE
Specify NONE if you don\'t want to perform any text transformations.
ChangeToken (string) --
The ChangeToken that you used to submit the CreateSqlInjectionMatchSet request. You can also use this value to query the status of the request. For more information, see GetChangeTokenStatus .
Exceptions
WAFRegional.Client.exceptions.WAFDisallowedNameException
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidAccountException
WAFRegional.Client.exceptions.WAFInvalidParameterException
WAFRegional.Client.exceptions.WAFStaleDataException
WAFRegional.Client.exceptions.WAFLimitsExceededException
Examples
The following example creates a SQL injection match set named MySQLInjectionMatchSet.
response = client.create_sql_injection_match_set(
ChangeToken='abcd12f2-46da-4fdb-b8d5-fbd4c466928f',
Name='MySQLInjectionMatchSet',
)
print(response)
Expected Output:
{
'ChangeToken': 'abcd12f2-46da-4fdb-b8d5-fbd4c466928f',
'SqlInjectionMatchSet': {
'Name': 'MySQLInjectionMatchSet',
'SqlInjectionMatchSetId': 'example1ds3t-46da-4fdb-b8d5-abc321j569j5',
'SqlInjectionMatchTuples': [
{
'FieldToMatch': {
'Type': 'QUERY_STRING',
},
'TextTransformation': 'URL_DECODE',
},
],
},
'ResponseMetadata': {
'...': '...',
},
}
:return: {
'SqlInjectionMatchSet': {
'SqlInjectionMatchSetId': 'string',
'Name': 'string',
'SqlInjectionMatchTuples': [
{
'FieldToMatch': {
'Type': 'URI'|'QUERY_STRING'|'HEADER'|'METHOD'|'BODY'|'SINGLE_QUERY_ARG'|'ALL_QUERY_ARGS',
'Data': 'string'
},
'TextTransformation': 'NONE'|'COMPRESS_WHITE_SPACE'|'HTML_ENTITY_DECODE'|'LOWERCASE'|'CMD_LINE'|'URL_DECODE'
},
]
},
'ChangeToken': 'string'
}
:returns:
Name (string) -- [REQUIRED]
A friendly name or description for the SqlInjectionMatchSet that you\'re creating. You can\'t change Name after you create the SqlInjectionMatchSet .
ChangeToken (string) -- [REQUIRED]
The value returned by the most recent call to GetChangeToken .
"""
pass
def create_web_acl(Name=None, MetricName=None, DefaultAction=None, ChangeToken=None, Tags=None):
"""
Creates a WebACL , which contains the Rules that identify the CloudFront web requests that you want to allow, block, or count. AWS WAF evaluates Rules in order based on the value of Priority for each Rule .
You also specify a default action, either ALLOW or BLOCK . If a web request doesn\'t match any of the Rules in a WebACL , AWS WAF responds to the request with the default action.
To create and configure a WebACL , perform the following steps:
For more information about how to use the AWS WAF API, see the AWS WAF Developer Guide .
See also: AWS API Documentation
Exceptions
Examples
The following example creates a web ACL named CreateExample.
Expected Output:
:example: response = client.create_web_acl(
Name='string',
MetricName='string',
DefaultAction={
'Type': 'BLOCK'|'ALLOW'|'COUNT'
},
ChangeToken='string',
Tags=[
{
'Key': 'string',
'Value': 'string'
},
]
)
:type Name: string
:param Name: [REQUIRED]\nA friendly name or description of the WebACL . You can\'t change Name after you create the WebACL .\n
:type MetricName: string
:param MetricName: [REQUIRED]\nA friendly name or description for the metrics for this WebACL .The name can contain only alphanumeric characters (A-Z, a-z, 0-9), with maximum length 128 and minimum length one. It can\'t contain whitespace or metric names reserved for AWS WAF, including 'All' and 'Default_Action.' You can\'t change MetricName after you create the WebACL .\n
:type DefaultAction: dict
:param DefaultAction: [REQUIRED]\nThe action that you want AWS WAF to take when a request doesn\'t match the criteria specified in any of the Rule objects that are associated with the WebACL .\n\nType (string) -- [REQUIRED]Specifies how you want AWS WAF to respond to requests that match the settings in a Rule . Valid settings include the following:\n\nALLOW : AWS WAF allows requests\nBLOCK : AWS WAF blocks requests\nCOUNT : AWS WAF increments a counter of the requests that match all of the conditions in the rule. AWS WAF then continues to inspect the web request based on the remaining rules in the web ACL. You can\'t specify COUNT for the default action for a WebACL .\n\n\n\n
:type ChangeToken: string
:param ChangeToken: [REQUIRED]\nThe value returned by the most recent call to GetChangeToken .\n
:type Tags: list
:param Tags: \n(dict) --\nNote\nThis is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.\n\nFor the latest version of AWS WAF , use the AWS WAFV2 API and see the AWS WAF Developer Guide . With the latest version, AWS WAF has a single set of endpoints for regional and global use.\n\nA tag associated with an AWS resource. Tags are key:value pairs that you can use to categorize and manage your resources, for purposes like billing. For example, you might set the tag key to 'customer' and the value to the customer name or ID. You can specify one or more tags to add to each AWS resource, up to 50 tags for a resource.\nTagging is only available through the API, SDKs, and CLI. You can\'t manage or view tags through the AWS WAF Classic console. You can tag the AWS resources that you manage through AWS WAF Classic: web ACLs, rule groups, and rules.\n\nKey (string) -- [REQUIRED]\nValue (string) -- [REQUIRED]\n\n\n\n
:rtype: dict
ReturnsResponse Syntax
{
'WebACL': {
'WebACLId': 'string',
'Name': 'string',
'MetricName': 'string',
'DefaultAction': {
'Type': 'BLOCK'|'ALLOW'|'COUNT'
},
'Rules': [
{
'Priority': 123,
'RuleId': 'string',
'Action': {
'Type': 'BLOCK'|'ALLOW'|'COUNT'
},
'OverrideAction': {
'Type': 'NONE'|'COUNT'
},
'Type': 'REGULAR'|'RATE_BASED'|'GROUP',
'ExcludedRules': [
{
'RuleId': 'string'
},
]
},
],
'WebACLArn': 'string'
},
'ChangeToken': 'string'
}
Response Structure
(dict) --
WebACL (dict) --
The WebACL returned in the CreateWebACL response.
WebACLId (string) --
A unique identifier for a WebACL . You use WebACLId to get information about a WebACL (see GetWebACL ), update a WebACL (see UpdateWebACL ), and delete a WebACL from AWS WAF (see DeleteWebACL ).
WebACLId is returned by CreateWebACL and by ListWebACLs .
Name (string) --
A friendly name or description of the WebACL . You can\'t change the name of a WebACL after you create it.
MetricName (string) --
A friendly name or description for the metrics for this WebACL . The name can contain only alphanumeric characters (A-Z, a-z, 0-9), with maximum length 128 and minimum length one. It can\'t contain whitespace or metric names reserved for AWS WAF, including "All" and "Default_Action." You can\'t change MetricName after you create the WebACL .
DefaultAction (dict) --
The action to perform if none of the Rules contained in the WebACL match. The action is specified by the WafAction object.
Type (string) --
Specifies how you want AWS WAF to respond to requests that match the settings in a Rule . Valid settings include the following:
ALLOW : AWS WAF allows requests
BLOCK : AWS WAF blocks requests
COUNT : AWS WAF increments a counter of the requests that match all of the conditions in the rule. AWS WAF then continues to inspect the web request based on the remaining rules in the web ACL. You can\'t specify COUNT for the default action for a WebACL .
Rules (list) --
An array that contains the action for each Rule in a WebACL , the priority of the Rule , and the ID of the Rule .
(dict) --
Note
This is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.
For the latest version of AWS WAF , use the AWS WAFV2 API and see the AWS WAF Developer Guide . With the latest version, AWS WAF has a single set of endpoints for regional and global use.
The ActivatedRule object in an UpdateWebACL request specifies a Rule that you want to insert or delete, the priority of the Rule in the WebACL , and the action that you want AWS WAF to take when a web request matches the Rule (ALLOW , BLOCK , or COUNT ).
To specify whether to insert or delete a Rule , use the Action parameter in the WebACLUpdate data type.
Priority (integer) --
Specifies the order in which the Rules in a WebACL are evaluated. Rules with a lower value for Priority are evaluated before Rules with a higher value. The value must be a unique integer. If you add multiple Rules to a WebACL , the values don\'t need to be consecutive.
RuleId (string) --
The RuleId for a Rule . You use RuleId to get more information about a Rule (see GetRule ), update a Rule (see UpdateRule ), insert a Rule into a WebACL or delete a one from a WebACL (see UpdateWebACL ), or delete a Rule from AWS WAF (see DeleteRule ).
RuleId is returned by CreateRule and by ListRules .
Action (dict) --
Specifies the action that CloudFront or AWS WAF takes when a web request matches the conditions in the Rule . Valid values for Action include the following:
ALLOW : CloudFront responds with the requested object.
BLOCK : CloudFront responds with an HTTP 403 (Forbidden) status code.
COUNT : AWS WAF increments a counter of requests that match the conditions in the rule and then continues to inspect the web request based on the remaining rules in the web ACL.
ActivatedRule|OverrideAction applies only when updating or adding a RuleGroup to a WebACL . In this case, you do not use ActivatedRule|Action . For all other update requests, ActivatedRule|Action is used instead of ActivatedRule|OverrideAction .
Type (string) --
Specifies how you want AWS WAF to respond to requests that match the settings in a Rule . Valid settings include the following:
ALLOW : AWS WAF allows requests
BLOCK : AWS WAF blocks requests
COUNT : AWS WAF increments a counter of the requests that match all of the conditions in the rule. AWS WAF then continues to inspect the web request based on the remaining rules in the web ACL. You can\'t specify COUNT for the default action for a WebACL .
OverrideAction (dict) --
Use the OverrideAction to test your RuleGroup .
Any rule in a RuleGroup can potentially block a request. If you set the OverrideAction to None , the RuleGroup will block a request if any individual rule in the RuleGroup matches the request and is configured to block that request. However if you first want to test the RuleGroup , set the OverrideAction to Count . The RuleGroup will then override any block action specified by individual rules contained within the group. Instead of blocking matching requests, those requests will be counted. You can view a record of counted requests using GetSampledRequests .
ActivatedRule|OverrideAction applies only when updating or adding a RuleGroup to a WebACL . In this case you do not use ActivatedRule|Action . For all other update requests, ActivatedRule|Action is used instead of ActivatedRule|OverrideAction .
Type (string) --
COUNT overrides the action specified by the individual rule within a RuleGroup . If set to NONE , the rule\'s action will take place.
Type (string) --
The rule type, either REGULAR , as defined by Rule , RATE_BASED , as defined by RateBasedRule , or GROUP , as defined by RuleGroup . The default is REGULAR. Although this field is optional, be aware that if you try to add a RATE_BASED rule to a web ACL without setting the type, the UpdateWebACL request will fail because the request tries to add a REGULAR rule with the specified ID, which does not exist.
ExcludedRules (list) --
An array of rules to exclude from a rule group. This is applicable only when the ActivatedRule refers to a RuleGroup .
Sometimes it is necessary to troubleshoot rule groups that are blocking traffic unexpectedly (false positives). One troubleshooting technique is to identify the specific rule within the rule group that is blocking the legitimate traffic and then disable (exclude) that particular rule. You can exclude rules from both your own rule groups and AWS Marketplace rule groups that have been associated with a web ACL.
Specifying ExcludedRules does not remove those rules from the rule group. Rather, it changes the action for the rules to COUNT . Therefore, requests that match an ExcludedRule are counted but not blocked. The RuleGroup owner will receive COUNT metrics for each ExcludedRule .
If you want to exclude rules from a rule group that is already associated with a web ACL, perform the following steps:
Use the AWS WAF logs to identify the IDs of the rules that you want to exclude. For more information about the logs, see Logging Web ACL Traffic Information .
Submit an UpdateWebACL request that has two actions:
The first action deletes the existing rule group from the web ACL. That is, in the UpdateWebACL request, the first Updates:Action should be DELETE and Updates:ActivatedRule:RuleId should be the rule group that contains the rules that you want to exclude.
The second action inserts the same rule group back in, but specifying the rules to exclude. That is, the second Updates:Action should be INSERT , Updates:ActivatedRule:RuleId should be the rule group that you just removed, and ExcludedRules should contain the rules that you want to exclude.
(dict) --
Note
This is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.
For the latest version of AWS WAF , use the AWS WAFV2 API and see the AWS WAF Developer Guide . With the latest version, AWS WAF has a single set of endpoints for regional and global use.
The rule to exclude from a rule group. This is applicable only when the ActivatedRule refers to a RuleGroup . The rule must belong to the RuleGroup that is specified by the ActivatedRule .
RuleId (string) --
The unique identifier for the rule to exclude from the rule group.
WebACLArn (string) --
Tha Amazon Resource Name (ARN) of the web ACL.
ChangeToken (string) --
The ChangeToken that you used to submit the CreateWebACL request. You can also use this value to query the status of the request. For more information, see GetChangeTokenStatus .
Exceptions
WAFRegional.Client.exceptions.WAFStaleDataException
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidAccountException
WAFRegional.Client.exceptions.WAFDisallowedNameException
WAFRegional.Client.exceptions.WAFInvalidParameterException
WAFRegional.Client.exceptions.WAFLimitsExceededException
WAFRegional.Client.exceptions.WAFTagOperationException
WAFRegional.Client.exceptions.WAFTagOperationInternalErrorException
WAFRegional.Client.exceptions.WAFBadRequestException
Examples
The following example creates a web ACL named CreateExample.
response = client.create_web_acl(
ChangeToken='abcd12f2-46da-4fdb-b8d5-fbd4c466928f',
DefaultAction={
'Type': 'ALLOW',
},
MetricName='CreateExample',
Name='CreateExample',
)
print(response)
Expected Output:
{
'ChangeToken': 'abcd12f2-46da-4fdb-b8d5-fbd4c466928f',
'WebACL': {
'DefaultAction': {
'Type': 'ALLOW',
},
'MetricName': 'CreateExample',
'Name': 'CreateExample',
'Rules': [
{
'Action': {
'Type': 'ALLOW',
},
'Priority': 1,
'RuleId': 'WAFRule-1-Example',
},
],
'WebACLId': 'example-46da-4444-5555-example',
},
'ResponseMetadata': {
'...': '...',
},
}
:return: {
'WebACL': {
'WebACLId': 'string',
'Name': 'string',
'MetricName': 'string',
'DefaultAction': {
'Type': 'BLOCK'|'ALLOW'|'COUNT'
},
'Rules': [
{
'Priority': 123,
'RuleId': 'string',
'Action': {
'Type': 'BLOCK'|'ALLOW'|'COUNT'
},
'OverrideAction': {
'Type': 'NONE'|'COUNT'
},
'Type': 'REGULAR'|'RATE_BASED'|'GROUP',
'ExcludedRules': [
{
'RuleId': 'string'
},
]
},
],
'WebACLArn': 'string'
},
'ChangeToken': 'string'
}
:returns:
Name (string) -- [REQUIRED]
A friendly name or description of the WebACL . You can\'t change Name after you create the WebACL .
MetricName (string) -- [REQUIRED]
A friendly name or description for the metrics for this WebACL .The name can contain only alphanumeric characters (A-Z, a-z, 0-9), with maximum length 128 and minimum length one. It can\'t contain whitespace or metric names reserved for AWS WAF, including "All" and "Default_Action." You can\'t change MetricName after you create the WebACL .
DefaultAction (dict) -- [REQUIRED]
The action that you want AWS WAF to take when a request doesn\'t match the criteria specified in any of the Rule objects that are associated with the WebACL .
Type (string) -- [REQUIRED]Specifies how you want AWS WAF to respond to requests that match the settings in a Rule . Valid settings include the following:
ALLOW : AWS WAF allows requests
BLOCK : AWS WAF blocks requests
COUNT : AWS WAF increments a counter of the requests that match all of the conditions in the rule. AWS WAF then continues to inspect the web request based on the remaining rules in the web ACL. You can\'t specify COUNT for the default action for a WebACL .
ChangeToken (string) -- [REQUIRED]
The value returned by the most recent call to GetChangeToken .
Tags (list) --
(dict) --
Note
This is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.
For the latest version of AWS WAF , use the AWS WAFV2 API and see the AWS WAF Developer Guide . With the latest version, AWS WAF has a single set of endpoints for regional and global use.
A tag associated with an AWS resource. Tags are key:value pairs that you can use to categorize and manage your resources, for purposes like billing. For example, you might set the tag key to "customer" and the value to the customer name or ID. You can specify one or more tags to add to each AWS resource, up to 50 tags for a resource.
Tagging is only available through the API, SDKs, and CLI. You can\'t manage or view tags through the AWS WAF Classic console. You can tag the AWS resources that you manage through AWS WAF Classic: web ACLs, rule groups, and rules.
Key (string) -- [REQUIRED]
Value (string) -- [REQUIRED]
"""
pass
def create_web_acl_migration_stack(WebACLId=None, S3BucketName=None, IgnoreUnsupportedType=None):
"""
Creates an AWS CloudFormation WAFV2 template for the specified web ACL in the specified Amazon S3 bucket. Then, in CloudFormation, you create a stack from the template, to create the web ACL and its resources in AWS WAFV2. Use this to migrate your AWS WAF Classic web ACL to the latest version of AWS WAF.
This is part of a larger migration procedure for web ACLs from AWS WAF Classic to the latest version of AWS WAF. For the full procedure, including caveats and manual steps to complete the migration and switch over to the new web ACL, see Migrating your AWS WAF Classic resources to AWS WAF in the AWS WAF Developer Guide .
See also: AWS API Documentation
Exceptions
:example: response = client.create_web_acl_migration_stack(
WebACLId='string',
S3BucketName='string',
IgnoreUnsupportedType=True|False
)
:type WebACLId: string
:param WebACLId: [REQUIRED]\nThe UUID of the WAF Classic web ACL that you want to migrate to WAF v2.\n
:type S3BucketName: string
:param S3BucketName: [REQUIRED]\nThe name of the Amazon S3 bucket to store the CloudFormation template in. The S3 bucket must be configured as follows for the migration:\n\nThe bucket name must start with aws-waf-migration- . For example, aws-waf-migration-my-web-acl .\nThe bucket must be in the Region where you are deploying the template. For example, for a web ACL in us-west-2, you must use an Amazon S3 bucket in us-west-2 and you must deploy the template stack to us-west-2.\nThe bucket policies must permit the migration process to write data. For listings of the bucket policies, see the Examples section.\n\n
:type IgnoreUnsupportedType: boolean
:param IgnoreUnsupportedType: [REQUIRED]\nIndicates whether to exclude entities that can\'t be migrated or to stop the migration. Set this to true to ignore unsupported entities in the web ACL during the migration. Otherwise, if AWS WAF encounters unsupported entities, it stops the process and throws an exception.\n
:rtype: dict
ReturnsResponse Syntax
{
'S3ObjectUrl': 'string'
}
Response Structure
(dict) --
S3ObjectUrl (string) --
The URL of the template created in Amazon S3.
Exceptions
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidParameterException
WAFRegional.Client.exceptions.WAFInvalidOperationException
WAFRegional.Client.exceptions.WAFNonexistentItemException
WAFRegional.Client.exceptions.WAFEntityMigrationException
:return: {
'S3ObjectUrl': 'string'
}
:returns:
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidParameterException
WAFRegional.Client.exceptions.WAFInvalidOperationException
WAFRegional.Client.exceptions.WAFNonexistentItemException
WAFRegional.Client.exceptions.WAFEntityMigrationException
"""
pass
def create_xss_match_set(Name=None, ChangeToken=None):
"""
Creates an XssMatchSet , which you use to allow, block, or count requests that contain cross-site scripting attacks in the specified part of web requests. AWS WAF searches for character sequences that are likely to be malicious strings.
To create and configure an XssMatchSet , perform the following steps:
For more information about how to use the AWS WAF API to allow or block HTTP requests, see the AWS WAF Developer Guide .
See also: AWS API Documentation
Exceptions
Examples
The following example creates an XSS match set named MySampleXssMatchSet.
Expected Output:
:example: response = client.create_xss_match_set(
Name='string',
ChangeToken='string'
)
:type Name: string
:param Name: [REQUIRED]\nA friendly name or description for the XssMatchSet that you\'re creating. You can\'t change Name after you create the XssMatchSet .\n
:type ChangeToken: string
:param ChangeToken: [REQUIRED]\nThe value returned by the most recent call to GetChangeToken .\n
:rtype: dict
ReturnsResponse Syntax
{
'XssMatchSet': {
'XssMatchSetId': 'string',
'Name': 'string',
'XssMatchTuples': [
{
'FieldToMatch': {
'Type': 'URI'|'QUERY_STRING'|'HEADER'|'METHOD'|'BODY'|'SINGLE_QUERY_ARG'|'ALL_QUERY_ARGS',
'Data': 'string'
},
'TextTransformation': 'NONE'|'COMPRESS_WHITE_SPACE'|'HTML_ENTITY_DECODE'|'LOWERCASE'|'CMD_LINE'|'URL_DECODE'
},
]
},
'ChangeToken': 'string'
}
Response Structure
(dict) --
The response to a CreateXssMatchSet request.
XssMatchSet (dict) --
An XssMatchSet .
XssMatchSetId (string) --
A unique identifier for an XssMatchSet . You use XssMatchSetId to get information about an XssMatchSet (see GetXssMatchSet ), update an XssMatchSet (see UpdateXssMatchSet ), insert an XssMatchSet into a Rule or delete one from a Rule (see UpdateRule ), and delete an XssMatchSet from AWS WAF (see DeleteXssMatchSet ).
XssMatchSetId is returned by CreateXssMatchSet and by ListXssMatchSets .
Name (string) --
The name, if any, of the XssMatchSet .
XssMatchTuples (list) --
Specifies the parts of web requests that you want to inspect for cross-site scripting attacks.
(dict) --
Note
This is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.
For the latest version of AWS WAF , use the AWS WAFV2 API and see the AWS WAF Developer Guide . With the latest version, AWS WAF has a single set of endpoints for regional and global use.
Specifies the part of a web request that you want AWS WAF to inspect for cross-site scripting attacks and, if you want AWS WAF to inspect a header, the name of the header.
FieldToMatch (dict) --
Specifies where in a web request to look for cross-site scripting attacks.
Type (string) --
The part of the web request that you want AWS WAF to search for a specified string. Parts of a request that you can search include the following:
HEADER : A specified request header, for example, the value of the User-Agent or Referer header. If you choose HEADER for the type, specify the name of the header in Data .
METHOD : The HTTP method, which indicated the type of operation that the request is asking the origin to perform. Amazon CloudFront supports the following methods: DELETE , GET , HEAD , OPTIONS , PATCH , POST , and PUT .
QUERY_STRING : A query string, which is the part of a URL that appears after a ? character, if any.
URI : The part of a web request that identifies a resource, for example, /images/daily-ad.jpg .
BODY : The part of a request that contains any additional data that you want to send to your web server as the HTTP request body, such as data from a form. The request body immediately follows the request headers. Note that only the first 8192 bytes of the request body are forwarded to AWS WAF for inspection. To allow or block requests based on the length of the body, you can create a size constraint set. For more information, see CreateSizeConstraintSet .
SINGLE_QUERY_ARG : The parameter in the query string that you will inspect, such as UserName or SalesRegion . The maximum length for SINGLE_QUERY_ARG is 30 characters.
ALL_QUERY_ARGS : Similar to SINGLE_QUERY_ARG , but rather than inspecting a single parameter, AWS WAF will inspect all parameters within the query for the value or regex pattern that you specify in TargetString .
Data (string) --
When the value of Type is HEADER , enter the name of the header that you want AWS WAF to search, for example, User-Agent or Referer . The name of the header is not case sensitive.
When the value of Type is SINGLE_QUERY_ARG , enter the name of the parameter that you want AWS WAF to search, for example, UserName or SalesRegion . The parameter name is not case sensitive.
If the value of Type is any other value, omit Data .
TextTransformation (string) --
Text transformations eliminate some of the unusual formatting that attackers use in web requests in an effort to bypass AWS WAF. If you specify a transformation, AWS WAF performs the transformation on FieldToMatch before inspecting it for a match.
You can only specify a single type of TextTransformation.
CMD_LINE
When you\'re concerned that attackers are injecting an operating system command line command and using unusual formatting to disguise some or all of the command, use this option to perform the following transformations:
Delete the following characters: " \' ^
Delete spaces before the following characters: / (
Replace the following characters with a space: , ;
Replace multiple spaces with one space
Convert uppercase letters (A-Z) to lowercase (a-z)
COMPRESS_WHITE_SPACE
Use this option to replace the following characters with a space character (decimal 32):
f, formfeed, decimal 12
t, tab, decimal 9
n, newline, decimal 10
r, carriage return, decimal 13
v, vertical tab, decimal 11
non-breaking space, decimal 160
COMPRESS_WHITE_SPACE also replaces multiple spaces with one space.
HTML_ENTITY_DECODE
Use this option to replace HTML-encoded characters with unencoded characters. HTML_ENTITY_DECODE performs the following operations:
Replaces (ampersand)quot; with "
Replaces (ampersand)nbsp; with a non-breaking space, decimal 160
Replaces (ampersand)lt; with a "less than" symbol
Replaces (ampersand)gt; with >
Replaces characters that are represented in hexadecimal format, (ampersand)#xhhhh; , with the corresponding characters
Replaces characters that are represented in decimal format, (ampersand)#nnnn; , with the corresponding characters
LOWERCASE
Use this option to convert uppercase letters (A-Z) to lowercase (a-z).
URL_DECODE
Use this option to decode a URL-encoded value.
NONE
Specify NONE if you don\'t want to perform any text transformations.
ChangeToken (string) --
The ChangeToken that you used to submit the CreateXssMatchSet request. You can also use this value to query the status of the request. For more information, see GetChangeTokenStatus .
Exceptions
WAFRegional.Client.exceptions.WAFDisallowedNameException
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidAccountException
WAFRegional.Client.exceptions.WAFInvalidParameterException
WAFRegional.Client.exceptions.WAFStaleDataException
WAFRegional.Client.exceptions.WAFLimitsExceededException
Examples
The following example creates an XSS match set named MySampleXssMatchSet.
response = client.create_xss_match_set(
ChangeToken='abcd12f2-46da-4fdb-b8d5-fbd4c466928f',
Name='MySampleXssMatchSet',
)
print(response)
Expected Output:
{
'ChangeToken': 'abcd12f2-46da-4fdb-b8d5-fbd4c466928f',
'XssMatchSet': {
'Name': 'MySampleXssMatchSet',
'XssMatchSetId': 'example1ds3t-46da-4fdb-b8d5-abc321j569j5',
'XssMatchTuples': [
{
'FieldToMatch': {
'Type': 'QUERY_STRING',
},
'TextTransformation': 'URL_DECODE',
},
],
},
'ResponseMetadata': {
'...': '...',
},
}
:return: {
'XssMatchSet': {
'XssMatchSetId': 'string',
'Name': 'string',
'XssMatchTuples': [
{
'FieldToMatch': {
'Type': 'URI'|'QUERY_STRING'|'HEADER'|'METHOD'|'BODY'|'SINGLE_QUERY_ARG'|'ALL_QUERY_ARGS',
'Data': 'string'
},
'TextTransformation': 'NONE'|'COMPRESS_WHITE_SPACE'|'HTML_ENTITY_DECODE'|'LOWERCASE'|'CMD_LINE'|'URL_DECODE'
},
]
},
'ChangeToken': 'string'
}
:returns:
Name (string) -- [REQUIRED]
A friendly name or description for the XssMatchSet that you\'re creating. You can\'t change Name after you create the XssMatchSet .
ChangeToken (string) -- [REQUIRED]
The value returned by the most recent call to GetChangeToken .
"""
pass
def delete_byte_match_set(ByteMatchSetId=None, ChangeToken=None):
"""
Permanently deletes a ByteMatchSet . You can\'t delete a ByteMatchSet if it\'s still used in any Rules or if it still includes any ByteMatchTuple objects (any filters).
If you just want to remove a ByteMatchSet from a Rule , use UpdateRule .
To permanently delete a ByteMatchSet , perform the following steps:
See also: AWS API Documentation
Exceptions
Examples
The following example deletes a byte match set with the ID exampleIDs3t-46da-4fdb-b8d5-abc321j569j5.
Expected Output:
:example: response = client.delete_byte_match_set(
ByteMatchSetId='string',
ChangeToken='string'
)
:type ByteMatchSetId: string
:param ByteMatchSetId: [REQUIRED]\nThe ByteMatchSetId of the ByteMatchSet that you want to delete. ByteMatchSetId is returned by CreateByteMatchSet and by ListByteMatchSets .\n
:type ChangeToken: string
:param ChangeToken: [REQUIRED]\nThe value returned by the most recent call to GetChangeToken .\n
:rtype: dict
ReturnsResponse Syntax
{
'ChangeToken': 'string'
}
Response Structure
(dict) --
ChangeToken (string) --
The ChangeToken that you used to submit the DeleteByteMatchSet request. You can also use this value to query the status of the request. For more information, see GetChangeTokenStatus .
Exceptions
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidAccountException
WAFRegional.Client.exceptions.WAFNonexistentItemException
WAFRegional.Client.exceptions.WAFReferencedItemException
WAFRegional.Client.exceptions.WAFStaleDataException
WAFRegional.Client.exceptions.WAFNonEmptyEntityException
Examples
The following example deletes a byte match set with the ID exampleIDs3t-46da-4fdb-b8d5-abc321j569j5.
response = client.delete_byte_match_set(
ByteMatchSetId='exampleIDs3t-46da-4fdb-b8d5-abc321j569j5',
ChangeToken='abcd12f2-46da-4fdb-b8d5-fbd4c466928f',
)
print(response)
Expected Output:
{
'ChangeToken': 'abcd12f2-46da-4fdb-b8d5-fbd4c466928f',
'ResponseMetadata': {
'...': '...',
},
}
:return: {
'ChangeToken': 'string'
}
:returns:
ByteMatchSetId (string) -- [REQUIRED]
The ByteMatchSetId of the ByteMatchSet that you want to delete. ByteMatchSetId is returned by CreateByteMatchSet and by ListByteMatchSets .
ChangeToken (string) -- [REQUIRED]
The value returned by the most recent call to GetChangeToken .
"""
pass
def delete_geo_match_set(GeoMatchSetId=None, ChangeToken=None):
"""
Permanently deletes a GeoMatchSet . You can\'t delete a GeoMatchSet if it\'s still used in any Rules or if it still includes any countries.
If you just want to remove a GeoMatchSet from a Rule , use UpdateRule .
To permanently delete a GeoMatchSet from AWS WAF, perform the following steps:
See also: AWS API Documentation
Exceptions
:example: response = client.delete_geo_match_set(
GeoMatchSetId='string',
ChangeToken='string'
)
:type GeoMatchSetId: string
:param GeoMatchSetId: [REQUIRED]\nThe GeoMatchSetID of the GeoMatchSet that you want to delete. GeoMatchSetId is returned by CreateGeoMatchSet and by ListGeoMatchSets .\n
:type ChangeToken: string
:param ChangeToken: [REQUIRED]\nThe value returned by the most recent call to GetChangeToken .\n
:rtype: dict
ReturnsResponse Syntax
{
'ChangeToken': 'string'
}
Response Structure
(dict) --
ChangeToken (string) --
The ChangeToken that you used to submit the DeleteGeoMatchSet request. You can also use this value to query the status of the request. For more information, see GetChangeTokenStatus .
Exceptions
WAFRegional.Client.exceptions.WAFStaleDataException
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidAccountException
WAFRegional.Client.exceptions.WAFNonexistentItemException
WAFRegional.Client.exceptions.WAFReferencedItemException
WAFRegional.Client.exceptions.WAFNonEmptyEntityException
:return: {
'ChangeToken': 'string'
}
:returns:
GeoMatchSetId (string) -- [REQUIRED]
The GeoMatchSetID of the GeoMatchSet that you want to delete. GeoMatchSetId is returned by CreateGeoMatchSet and by ListGeoMatchSets .
ChangeToken (string) -- [REQUIRED]
The value returned by the most recent call to GetChangeToken .
"""
pass
def delete_ip_set(IPSetId=None, ChangeToken=None):
"""
Permanently deletes an IPSet . You can\'t delete an IPSet if it\'s still used in any Rules or if it still includes any IP addresses.
If you just want to remove an IPSet from a Rule , use UpdateRule .
To permanently delete an IPSet from AWS WAF, perform the following steps:
See also: AWS API Documentation
Exceptions
Examples
The following example deletes an IP match set with the ID example1ds3t-46da-4fdb-b8d5-abc321j569j5.
Expected Output:
:example: response = client.delete_ip_set(
IPSetId='string',
ChangeToken='string'
)
:type IPSetId: string
:param IPSetId: [REQUIRED]\nThe IPSetId of the IPSet that you want to delete. IPSetId is returned by CreateIPSet and by ListIPSets .\n
:type ChangeToken: string
:param ChangeToken: [REQUIRED]\nThe value returned by the most recent call to GetChangeToken .\n
:rtype: dict
ReturnsResponse Syntax
{
'ChangeToken': 'string'
}
Response Structure
(dict) --
ChangeToken (string) --
The ChangeToken that you used to submit the DeleteIPSet request. You can also use this value to query the status of the request. For more information, see GetChangeTokenStatus .
Exceptions
WAFRegional.Client.exceptions.WAFStaleDataException
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidAccountException
WAFRegional.Client.exceptions.WAFNonexistentItemException
WAFRegional.Client.exceptions.WAFReferencedItemException
WAFRegional.Client.exceptions.WAFNonEmptyEntityException
Examples
The following example deletes an IP match set with the ID example1ds3t-46da-4fdb-b8d5-abc321j569j5.
response = client.delete_ip_set(
ChangeToken='abcd12f2-46da-4fdb-b8d5-fbd4c466928f',
IPSetId='example1ds3t-46da-4fdb-b8d5-abc321j569j5',
)
print(response)
Expected Output:
{
'ChangeToken': 'abcd12f2-46da-4fdb-b8d5-fbd4c466928f',
'ResponseMetadata': {
'...': '...',
},
}
:return: {
'ChangeToken': 'string'
}
:returns:
IPSetId (string) -- [REQUIRED]
The IPSetId of the IPSet that you want to delete. IPSetId is returned by CreateIPSet and by ListIPSets .
ChangeToken (string) -- [REQUIRED]
The value returned by the most recent call to GetChangeToken .
"""
pass
def delete_logging_configuration(ResourceArn=None):
"""
Permanently deletes the LoggingConfiguration from the specified web ACL.
See also: AWS API Documentation
Exceptions
:example: response = client.delete_logging_configuration(
ResourceArn='string'
)
:type ResourceArn: string
:param ResourceArn: [REQUIRED]\nThe Amazon Resource Name (ARN) of the web ACL from which you want to delete the LoggingConfiguration .\n
:rtype: dict
ReturnsResponse Syntax{}
Response Structure
(dict) --
Exceptions
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFNonexistentItemException
WAFRegional.Client.exceptions.WAFStaleDataException
:return: {}
:returns:
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFNonexistentItemException
WAFRegional.Client.exceptions.WAFStaleDataException
"""
pass
def delete_permission_policy(ResourceArn=None):
"""
Permanently deletes an IAM policy from the specified RuleGroup.
The user making the request must be the owner of the RuleGroup.
See also: AWS API Documentation
Exceptions
:example: response = client.delete_permission_policy(
ResourceArn='string'
)
:type ResourceArn: string
:param ResourceArn: [REQUIRED]\nThe Amazon Resource Name (ARN) of the RuleGroup from which you want to delete the policy.\nThe user making the request must be the owner of the RuleGroup.\n
:rtype: dict
ReturnsResponse Syntax{}
Response Structure
(dict) --
Exceptions
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFStaleDataException
WAFRegional.Client.exceptions.WAFNonexistentItemException
:return: {}
:returns:
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFStaleDataException
WAFRegional.Client.exceptions.WAFNonexistentItemException
"""
pass
def delete_rate_based_rule(RuleId=None, ChangeToken=None):
"""
Permanently deletes a RateBasedRule . You can\'t delete a rule if it\'s still used in any WebACL objects or if it still includes any predicates, such as ByteMatchSet objects.
If you just want to remove a rule from a WebACL , use UpdateWebACL .
To permanently delete a RateBasedRule from AWS WAF, perform the following steps:
See also: AWS API Documentation
Exceptions
:example: response = client.delete_rate_based_rule(
RuleId='string',
ChangeToken='string'
)
:type RuleId: string
:param RuleId: [REQUIRED]\nThe RuleId of the RateBasedRule that you want to delete. RuleId is returned by CreateRateBasedRule and by ListRateBasedRules .\n
:type ChangeToken: string
:param ChangeToken: [REQUIRED]\nThe value returned by the most recent call to GetChangeToken .\n
:rtype: dict
ReturnsResponse Syntax
{
'ChangeToken': 'string'
}
Response Structure
(dict) --
ChangeToken (string) --
The ChangeToken that you used to submit the DeleteRateBasedRule request. You can also use this value to query the status of the request. For more information, see GetChangeTokenStatus .
Exceptions
WAFRegional.Client.exceptions.WAFStaleDataException
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidAccountException
WAFRegional.Client.exceptions.WAFNonexistentItemException
WAFRegional.Client.exceptions.WAFReferencedItemException
WAFRegional.Client.exceptions.WAFNonEmptyEntityException
WAFRegional.Client.exceptions.WAFTagOperationException
WAFRegional.Client.exceptions.WAFTagOperationInternalErrorException
:return: {
'ChangeToken': 'string'
}
:returns:
RuleId (string) -- [REQUIRED]
The RuleId of the RateBasedRule that you want to delete. RuleId is returned by CreateRateBasedRule and by ListRateBasedRules .
ChangeToken (string) -- [REQUIRED]
The value returned by the most recent call to GetChangeToken .
"""
pass
def delete_regex_match_set(RegexMatchSetId=None, ChangeToken=None):
"""
Permanently deletes a RegexMatchSet . You can\'t delete a RegexMatchSet if it\'s still used in any Rules or if it still includes any RegexMatchTuples objects (any filters).
If you just want to remove a RegexMatchSet from a Rule , use UpdateRule .
To permanently delete a RegexMatchSet , perform the following steps:
See also: AWS API Documentation
Exceptions
:example: response = client.delete_regex_match_set(
RegexMatchSetId='string',
ChangeToken='string'
)
:type RegexMatchSetId: string
:param RegexMatchSetId: [REQUIRED]\nThe RegexMatchSetId of the RegexMatchSet that you want to delete. RegexMatchSetId is returned by CreateRegexMatchSet and by ListRegexMatchSets .\n
:type ChangeToken: string
:param ChangeToken: [REQUIRED]\nThe value returned by the most recent call to GetChangeToken .\n
:rtype: dict
ReturnsResponse Syntax
{
'ChangeToken': 'string'
}
Response Structure
(dict) --
ChangeToken (string) --
The ChangeToken that you used to submit the DeleteRegexMatchSet request. You can also use this value to query the status of the request. For more information, see GetChangeTokenStatus .
Exceptions
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidAccountException
WAFRegional.Client.exceptions.WAFNonexistentItemException
WAFRegional.Client.exceptions.WAFReferencedItemException
WAFRegional.Client.exceptions.WAFStaleDataException
WAFRegional.Client.exceptions.WAFNonEmptyEntityException
:return: {
'ChangeToken': 'string'
}
:returns:
RegexMatchSetId (string) -- [REQUIRED]
The RegexMatchSetId of the RegexMatchSet that you want to delete. RegexMatchSetId is returned by CreateRegexMatchSet and by ListRegexMatchSets .
ChangeToken (string) -- [REQUIRED]
The value returned by the most recent call to GetChangeToken .
"""
pass
def delete_regex_pattern_set(RegexPatternSetId=None, ChangeToken=None):
"""
Permanently deletes a RegexPatternSet . You can\'t delete a RegexPatternSet if it\'s still used in any RegexMatchSet or if the RegexPatternSet is not empty.
See also: AWS API Documentation
Exceptions
:example: response = client.delete_regex_pattern_set(
RegexPatternSetId='string',
ChangeToken='string'
)
:type RegexPatternSetId: string
:param RegexPatternSetId: [REQUIRED]\nThe RegexPatternSetId of the RegexPatternSet that you want to delete. RegexPatternSetId is returned by CreateRegexPatternSet and by ListRegexPatternSets .\n
:type ChangeToken: string
:param ChangeToken: [REQUIRED]\nThe value returned by the most recent call to GetChangeToken .\n
:rtype: dict
ReturnsResponse Syntax
{
'ChangeToken': 'string'
}
Response Structure
(dict) --
ChangeToken (string) --
The ChangeToken that you used to submit the DeleteRegexPatternSet request. You can also use this value to query the status of the request. For more information, see GetChangeTokenStatus .
Exceptions
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidAccountException
WAFRegional.Client.exceptions.WAFNonexistentItemException
WAFRegional.Client.exceptions.WAFReferencedItemException
WAFRegional.Client.exceptions.WAFStaleDataException
WAFRegional.Client.exceptions.WAFNonEmptyEntityException
:return: {
'ChangeToken': 'string'
}
:returns:
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidAccountException
WAFRegional.Client.exceptions.WAFNonexistentItemException
WAFRegional.Client.exceptions.WAFReferencedItemException
WAFRegional.Client.exceptions.WAFStaleDataException
WAFRegional.Client.exceptions.WAFNonEmptyEntityException
"""
pass
def delete_rule(RuleId=None, ChangeToken=None):
"""
Permanently deletes a Rule . You can\'t delete a Rule if it\'s still used in any WebACL objects or if it still includes any predicates, such as ByteMatchSet objects.
If you just want to remove a Rule from a WebACL , use UpdateWebACL .
To permanently delete a Rule from AWS WAF, perform the following steps:
See also: AWS API Documentation
Exceptions
Examples
The following example deletes a rule with the ID WAFRule-1-Example.
Expected Output:
:example: response = client.delete_rule(
RuleId='string',
ChangeToken='string'
)
:type RuleId: string
:param RuleId: [REQUIRED]\nThe RuleId of the Rule that you want to delete. RuleId is returned by CreateRule and by ListRules .\n
:type ChangeToken: string
:param ChangeToken: [REQUIRED]\nThe value returned by the most recent call to GetChangeToken .\n
:rtype: dict
ReturnsResponse Syntax
{
'ChangeToken': 'string'
}
Response Structure
(dict) --
ChangeToken (string) --
The ChangeToken that you used to submit the DeleteRule request. You can also use this value to query the status of the request. For more information, see GetChangeTokenStatus .
Exceptions
WAFRegional.Client.exceptions.WAFStaleDataException
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidAccountException
WAFRegional.Client.exceptions.WAFNonexistentItemException
WAFRegional.Client.exceptions.WAFReferencedItemException
WAFRegional.Client.exceptions.WAFNonEmptyEntityException
WAFRegional.Client.exceptions.WAFTagOperationException
WAFRegional.Client.exceptions.WAFTagOperationInternalErrorException
Examples
The following example deletes a rule with the ID WAFRule-1-Example.
response = client.delete_rule(
ChangeToken='abcd12f2-46da-4fdb-b8d5-fbd4c466928f',
RuleId='WAFRule-1-Example',
)
print(response)
Expected Output:
{
'ChangeToken': 'abcd12f2-46da-4fdb-b8d5-fbd4c466928f',
'ResponseMetadata': {
'...': '...',
},
}
:return: {
'ChangeToken': 'string'
}
:returns:
RuleId (string) -- [REQUIRED]
The RuleId of the Rule that you want to delete. RuleId is returned by CreateRule and by ListRules .
ChangeToken (string) -- [REQUIRED]
The value returned by the most recent call to GetChangeToken .
"""
pass
def delete_rule_group(RuleGroupId=None, ChangeToken=None):
"""
Permanently deletes a RuleGroup . You can\'t delete a RuleGroup if it\'s still used in any WebACL objects or if it still includes any rules.
If you just want to remove a RuleGroup from a WebACL , use UpdateWebACL .
To permanently delete a RuleGroup from AWS WAF, perform the following steps:
See also: AWS API Documentation
Exceptions
:example: response = client.delete_rule_group(
RuleGroupId='string',
ChangeToken='string'
)
:type RuleGroupId: string
:param RuleGroupId: [REQUIRED]\nThe RuleGroupId of the RuleGroup that you want to delete. RuleGroupId is returned by CreateRuleGroup and by ListRuleGroups .\n
:type ChangeToken: string
:param ChangeToken: [REQUIRED]\nThe value returned by the most recent call to GetChangeToken .\n
:rtype: dict
ReturnsResponse Syntax
{
'ChangeToken': 'string'
}
Response Structure
(dict) --
ChangeToken (string) --
The ChangeToken that you used to submit the DeleteRuleGroup request. You can also use this value to query the status of the request. For more information, see GetChangeTokenStatus .
Exceptions
WAFRegional.Client.exceptions.WAFStaleDataException
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFNonexistentItemException
WAFRegional.Client.exceptions.WAFReferencedItemException
WAFRegional.Client.exceptions.WAFNonEmptyEntityException
WAFRegional.Client.exceptions.WAFInvalidOperationException
WAFRegional.Client.exceptions.WAFTagOperationException
WAFRegional.Client.exceptions.WAFTagOperationInternalErrorException
:return: {
'ChangeToken': 'string'
}
:returns:
RuleGroupId (string) -- [REQUIRED]
The RuleGroupId of the RuleGroup that you want to delete. RuleGroupId is returned by CreateRuleGroup and by ListRuleGroups .
ChangeToken (string) -- [REQUIRED]
The value returned by the most recent call to GetChangeToken .
"""
pass
def delete_size_constraint_set(SizeConstraintSetId=None, ChangeToken=None):
"""
Permanently deletes a SizeConstraintSet . You can\'t delete a SizeConstraintSet if it\'s still used in any Rules or if it still includes any SizeConstraint objects (any filters).
If you just want to remove a SizeConstraintSet from a Rule , use UpdateRule .
To permanently delete a SizeConstraintSet , perform the following steps:
See also: AWS API Documentation
Exceptions
Examples
The following example deletes a size constraint set with the ID example1ds3t-46da-4fdb-b8d5-abc321j569j5.
Expected Output:
:example: response = client.delete_size_constraint_set(
SizeConstraintSetId='string',
ChangeToken='string'
)
:type SizeConstraintSetId: string
:param SizeConstraintSetId: [REQUIRED]\nThe SizeConstraintSetId of the SizeConstraintSet that you want to delete. SizeConstraintSetId is returned by CreateSizeConstraintSet and by ListSizeConstraintSets .\n
:type ChangeToken: string
:param ChangeToken: [REQUIRED]\nThe value returned by the most recent call to GetChangeToken .\n
:rtype: dict
ReturnsResponse Syntax
{
'ChangeToken': 'string'
}
Response Structure
(dict) --
ChangeToken (string) --
The ChangeToken that you used to submit the DeleteSizeConstraintSet request. You can also use this value to query the status of the request. For more information, see GetChangeTokenStatus .
Exceptions
WAFRegional.Client.exceptions.WAFStaleDataException
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidAccountException
WAFRegional.Client.exceptions.WAFNonexistentItemException
WAFRegional.Client.exceptions.WAFReferencedItemException
WAFRegional.Client.exceptions.WAFNonEmptyEntityException
Examples
The following example deletes a size constraint set with the ID example1ds3t-46da-4fdb-b8d5-abc321j569j5.
response = client.delete_size_constraint_set(
ChangeToken='abcd12f2-46da-4fdb-b8d5-fbd4c466928f',
SizeConstraintSetId='example1ds3t-46da-4fdb-b8d5-abc321j569j5',
)
print(response)
Expected Output:
{
'ChangeToken': 'abcd12f2-46da-4fdb-b8d5-fbd4c466928f',
'ResponseMetadata': {
'...': '...',
},
}
:return: {
'ChangeToken': 'string'
}
:returns:
SizeConstraintSetId (string) -- [REQUIRED]
The SizeConstraintSetId of the SizeConstraintSet that you want to delete. SizeConstraintSetId is returned by CreateSizeConstraintSet and by ListSizeConstraintSets .
ChangeToken (string) -- [REQUIRED]
The value returned by the most recent call to GetChangeToken .
"""
pass
def delete_sql_injection_match_set(SqlInjectionMatchSetId=None, ChangeToken=None):
"""
Permanently deletes a SqlInjectionMatchSet . You can\'t delete a SqlInjectionMatchSet if it\'s still used in any Rules or if it still contains any SqlInjectionMatchTuple objects.
If you just want to remove a SqlInjectionMatchSet from a Rule , use UpdateRule .
To permanently delete a SqlInjectionMatchSet from AWS WAF, perform the following steps:
See also: AWS API Documentation
Exceptions
Examples
The following example deletes a SQL injection match set with the ID example1ds3t-46da-4fdb-b8d5-abc321j569j5.
Expected Output:
:example: response = client.delete_sql_injection_match_set(
SqlInjectionMatchSetId='string',
ChangeToken='string'
)
:type SqlInjectionMatchSetId: string
:param SqlInjectionMatchSetId: [REQUIRED]\nThe SqlInjectionMatchSetId of the SqlInjectionMatchSet that you want to delete. SqlInjectionMatchSetId is returned by CreateSqlInjectionMatchSet and by ListSqlInjectionMatchSets .\n
:type ChangeToken: string
:param ChangeToken: [REQUIRED]\nThe value returned by the most recent call to GetChangeToken .\n
:rtype: dict
ReturnsResponse Syntax
{
'ChangeToken': 'string'
}
Response Structure
(dict) --
The response to a request to delete a SqlInjectionMatchSet from AWS WAF.
ChangeToken (string) --
The ChangeToken that you used to submit the DeleteSqlInjectionMatchSet request. You can also use this value to query the status of the request. For more information, see GetChangeTokenStatus .
Exceptions
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidAccountException
WAFRegional.Client.exceptions.WAFNonexistentItemException
WAFRegional.Client.exceptions.WAFReferencedItemException
WAFRegional.Client.exceptions.WAFStaleDataException
WAFRegional.Client.exceptions.WAFNonEmptyEntityException
Examples
The following example deletes a SQL injection match set with the ID example1ds3t-46da-4fdb-b8d5-abc321j569j5.
response = client.delete_sql_injection_match_set(
ChangeToken='abcd12f2-46da-4fdb-b8d5-fbd4c466928f',
SqlInjectionMatchSetId='example1ds3t-46da-4fdb-b8d5-abc321j569j5',
)
print(response)
Expected Output:
{
'ChangeToken': 'abcd12f2-46da-4fdb-b8d5-fbd4c466928f',
'ResponseMetadata': {
'...': '...',
},
}
:return: {
'ChangeToken': 'string'
}
:returns:
SqlInjectionMatchSetId (string) -- [REQUIRED]
The SqlInjectionMatchSetId of the SqlInjectionMatchSet that you want to delete. SqlInjectionMatchSetId is returned by CreateSqlInjectionMatchSet and by ListSqlInjectionMatchSets .
ChangeToken (string) -- [REQUIRED]
The value returned by the most recent call to GetChangeToken .
"""
pass
def delete_web_acl(WebACLId=None, ChangeToken=None):
"""
Permanently deletes a WebACL . You can\'t delete a WebACL if it still contains any Rules .
To delete a WebACL , perform the following steps:
See also: AWS API Documentation
Exceptions
Examples
The following example deletes a web ACL with the ID example-46da-4444-5555-example.
Expected Output:
:example: response = client.delete_web_acl(
WebACLId='string',
ChangeToken='string'
)
:type WebACLId: string
:param WebACLId: [REQUIRED]\nThe WebACLId of the WebACL that you want to delete. WebACLId is returned by CreateWebACL and by ListWebACLs .\n
:type ChangeToken: string
:param ChangeToken: [REQUIRED]\nThe value returned by the most recent call to GetChangeToken .\n
:rtype: dict
ReturnsResponse Syntax
{
'ChangeToken': 'string'
}
Response Structure
(dict) --
ChangeToken (string) --
The ChangeToken that you used to submit the DeleteWebACL request. You can also use this value to query the status of the request. For more information, see GetChangeTokenStatus .
Exceptions
WAFRegional.Client.exceptions.WAFStaleDataException
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidAccountException
WAFRegional.Client.exceptions.WAFNonexistentItemException
WAFRegional.Client.exceptions.WAFReferencedItemException
WAFRegional.Client.exceptions.WAFNonEmptyEntityException
WAFRegional.Client.exceptions.WAFTagOperationException
WAFRegional.Client.exceptions.WAFTagOperationInternalErrorException
Examples
The following example deletes a web ACL with the ID example-46da-4444-5555-example.
response = client.delete_web_acl(
ChangeToken='abcd12f2-46da-4fdb-b8d5-fbd4c466928f',
WebACLId='example-46da-4444-5555-example',
)
print(response)
Expected Output:
{
'ChangeToken': 'abcd12f2-46da-4fdb-b8d5-fbd4c466928f',
'ResponseMetadata': {
'...': '...',
},
}
:return: {
'ChangeToken': 'string'
}
:returns:
WebACLId (string) -- [REQUIRED]
The WebACLId of the WebACL that you want to delete. WebACLId is returned by CreateWebACL and by ListWebACLs .
ChangeToken (string) -- [REQUIRED]
The value returned by the most recent call to GetChangeToken .
"""
pass
def delete_xss_match_set(XssMatchSetId=None, ChangeToken=None):
"""
Permanently deletes an XssMatchSet . You can\'t delete an XssMatchSet if it\'s still used in any Rules or if it still contains any XssMatchTuple objects.
If you just want to remove an XssMatchSet from a Rule , use UpdateRule .
To permanently delete an XssMatchSet from AWS WAF, perform the following steps:
See also: AWS API Documentation
Exceptions
Examples
The following example deletes an XSS match set with the ID example1ds3t-46da-4fdb-b8d5-abc321j569j5.
Expected Output:
:example: response = client.delete_xss_match_set(
XssMatchSetId='string',
ChangeToken='string'
)
:type XssMatchSetId: string
:param XssMatchSetId: [REQUIRED]\nThe XssMatchSetId of the XssMatchSet that you want to delete. XssMatchSetId is returned by CreateXssMatchSet and by ListXssMatchSets .\n
:type ChangeToken: string
:param ChangeToken: [REQUIRED]\nThe value returned by the most recent call to GetChangeToken .\n
:rtype: dict
ReturnsResponse Syntax
{
'ChangeToken': 'string'
}
Response Structure
(dict) --
The response to a request to delete an XssMatchSet from AWS WAF.
ChangeToken (string) --
The ChangeToken that you used to submit the DeleteXssMatchSet request. You can also use this value to query the status of the request. For more information, see GetChangeTokenStatus .
Exceptions
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidAccountException
WAFRegional.Client.exceptions.WAFNonexistentItemException
WAFRegional.Client.exceptions.WAFReferencedItemException
WAFRegional.Client.exceptions.WAFStaleDataException
WAFRegional.Client.exceptions.WAFNonEmptyEntityException
Examples
The following example deletes an XSS match set with the ID example1ds3t-46da-4fdb-b8d5-abc321j569j5.
response = client.delete_xss_match_set(
ChangeToken='abcd12f2-46da-4fdb-b8d5-fbd4c466928f',
XssMatchSetId='example1ds3t-46da-4fdb-b8d5-abc321j569j5',
)
print(response)
Expected Output:
{
'ChangeToken': 'abcd12f2-46da-4fdb-b8d5-fbd4c466928f',
'ResponseMetadata': {
'...': '...',
},
}
:return: {
'ChangeToken': 'string'
}
:returns:
XssMatchSetId (string) -- [REQUIRED]
The XssMatchSetId of the XssMatchSet that you want to delete. XssMatchSetId is returned by CreateXssMatchSet and by ListXssMatchSets .
ChangeToken (string) -- [REQUIRED]
The value returned by the most recent call to GetChangeToken .
"""
pass
def disassociate_web_acl(ResourceArn=None):
"""
Removes a web ACL from the specified resource, either an application load balancer or Amazon API Gateway stage.
See also: AWS API Documentation
Exceptions
:example: response = client.disassociate_web_acl(
ResourceArn='string'
)
:type ResourceArn: string
:param ResourceArn: [REQUIRED]\nThe ARN (Amazon Resource Name) of the resource from which the web ACL is being removed, either an application load balancer or Amazon API Gateway stage.\nThe ARN should be in one of the following formats:\n\nFor an Application Load Balancer: ``arn:aws:elasticloadbalancing:region :account-id :loadbalancer/app/load-balancer-name /load-balancer-id ``\nFor an Amazon API Gateway stage: ``arn:aws:apigateway:region ::/restapis/api-id /stages/stage-name ``\n\n
:rtype: dict
ReturnsResponse Syntax{}
Response Structure
(dict) --
Exceptions
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidAccountException
WAFRegional.Client.exceptions.WAFInvalidParameterException
WAFRegional.Client.exceptions.WAFNonexistentItemException
:return: {}
:returns:
(dict) --
"""
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\nClientMethod.
:type ExpiresIn: int
:param ExpiresIn: The number of seconds the presigned url is valid\nfor. By default it expires in an hour (3600 seconds)
:type HttpMethod: string
:param HttpMethod: The http method to use on the generated url. By\ndefault, the http method is whatever is used in the method\'s model.
"""
pass
def get_byte_match_set(ByteMatchSetId=None):
"""
Returns the ByteMatchSet specified by ByteMatchSetId .
See also: AWS API Documentation
Exceptions
Examples
The following example returns the details of a byte match set with the ID exampleIDs3t-46da-4fdb-b8d5-abc321j569j5.
Expected Output:
:example: response = client.get_byte_match_set(
ByteMatchSetId='string'
)
:type ByteMatchSetId: string
:param ByteMatchSetId: [REQUIRED]\nThe ByteMatchSetId of the ByteMatchSet that you want to get. ByteMatchSetId is returned by CreateByteMatchSet and by ListByteMatchSets .\n
:rtype: dict
ReturnsResponse Syntax{
'ByteMatchSet': {
'ByteMatchSetId': 'string',
'Name': 'string',
'ByteMatchTuples': [
{
'FieldToMatch': {
'Type': 'URI'|'QUERY_STRING'|'HEADER'|'METHOD'|'BODY'|'SINGLE_QUERY_ARG'|'ALL_QUERY_ARGS',
'Data': 'string'
},
'TargetString': b'bytes',
'TextTransformation': 'NONE'|'COMPRESS_WHITE_SPACE'|'HTML_ENTITY_DECODE'|'LOWERCASE'|'CMD_LINE'|'URL_DECODE',
'PositionalConstraint': 'EXACTLY'|'STARTS_WITH'|'ENDS_WITH'|'CONTAINS'|'CONTAINS_WORD'
},
]
}
}
Response Structure
(dict) --
ByteMatchSet (dict) --Information about the ByteMatchSet that you specified in the GetByteMatchSet request. For more information, see the following topics:
ByteMatchSet : Contains ByteMatchSetId , ByteMatchTuples , and Name
ByteMatchTuples : Contains an array of ByteMatchTuple objects. Each ByteMatchTuple object contains FieldToMatch , PositionalConstraint , TargetString , and TextTransformation
FieldToMatch : Contains Data and Type
ByteMatchSetId (string) --The ByteMatchSetId for a ByteMatchSet . You use ByteMatchSetId to get information about a ByteMatchSet (see GetByteMatchSet ), update a ByteMatchSet (see UpdateByteMatchSet ), insert a ByteMatchSet into a Rule or delete one from a Rule (see UpdateRule ), and delete a ByteMatchSet from AWS WAF (see DeleteByteMatchSet ).
ByteMatchSetId is returned by CreateByteMatchSet and by ListByteMatchSets .
Name (string) --A friendly name or description of the ByteMatchSet . You can\'t change Name after you create a ByteMatchSet .
ByteMatchTuples (list) --Specifies the bytes (typically a string that corresponds with ASCII characters) that you want AWS WAF to search for in web requests, the location in requests that you want AWS WAF to search, and other settings.
(dict) --
Note
This is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.
For the latest version of AWS WAF , use the AWS WAFV2 API and see the AWS WAF Developer Guide . With the latest version, AWS WAF has a single set of endpoints for regional and global use.
The bytes (typically a string that corresponds with ASCII characters) that you want AWS WAF to search for in web requests, the location in requests that you want AWS WAF to search, and other settings.
FieldToMatch (dict) --The part of a web request that you want AWS WAF to search, such as a specified header or a query string. For more information, see FieldToMatch .
Type (string) --The part of the web request that you want AWS WAF to search for a specified string. Parts of a request that you can search include the following:
HEADER : A specified request header, for example, the value of the User-Agent or Referer header. If you choose HEADER for the type, specify the name of the header in Data .
METHOD : The HTTP method, which indicated the type of operation that the request is asking the origin to perform. Amazon CloudFront supports the following methods: DELETE , GET , HEAD , OPTIONS , PATCH , POST , and PUT .
QUERY_STRING : A query string, which is the part of a URL that appears after a ? character, if any.
URI : The part of a web request that identifies a resource, for example, /images/daily-ad.jpg .
BODY : The part of a request that contains any additional data that you want to send to your web server as the HTTP request body, such as data from a form. The request body immediately follows the request headers. Note that only the first 8192 bytes of the request body are forwarded to AWS WAF for inspection. To allow or block requests based on the length of the body, you can create a size constraint set. For more information, see CreateSizeConstraintSet .
SINGLE_QUERY_ARG : The parameter in the query string that you will inspect, such as UserName or SalesRegion . The maximum length for SINGLE_QUERY_ARG is 30 characters.
ALL_QUERY_ARGS : Similar to SINGLE_QUERY_ARG , but rather than inspecting a single parameter, AWS WAF will inspect all parameters within the query for the value or regex pattern that you specify in TargetString .
Data (string) --When the value of Type is HEADER , enter the name of the header that you want AWS WAF to search, for example, User-Agent or Referer . The name of the header is not case sensitive.
When the value of Type is SINGLE_QUERY_ARG , enter the name of the parameter that you want AWS WAF to search, for example, UserName or SalesRegion . The parameter name is not case sensitive.
If the value of Type is any other value, omit Data .
TargetString (bytes) --The value that you want AWS WAF to search for. AWS WAF searches for the specified string in the part of web requests that you specified in FieldToMatch . The maximum length of the value is 50 bytes.
Valid values depend on the values that you specified for FieldToMatch :
HEADER : The value that you want AWS WAF to search for in the request header that you specified in FieldToMatch , for example, the value of the User-Agent or Referer header.
METHOD : The HTTP method, which indicates the type of operation specified in the request. CloudFront supports the following methods: DELETE , GET , HEAD , OPTIONS , PATCH , POST , and PUT .
QUERY_STRING : The value that you want AWS WAF to search for in the query string, which is the part of a URL that appears after a ? character.
URI : The value that you want AWS WAF to search for in the part of a URL that identifies a resource, for example, /images/daily-ad.jpg .
BODY : The part of a request that contains any additional data that you want to send to your web server as the HTTP request body, such as data from a form. The request body immediately follows the request headers. Note that only the first 8192 bytes of the request body are forwarded to AWS WAF for inspection. To allow or block requests based on the length of the body, you can create a size constraint set. For more information, see CreateSizeConstraintSet .
SINGLE_QUERY_ARG : The parameter in the query string that you will inspect, such as UserName or SalesRegion . The maximum length for SINGLE_QUERY_ARG is 30 characters.
ALL_QUERY_ARGS : Similar to SINGLE_QUERY_ARG , but instead of inspecting a single parameter, AWS WAF inspects all parameters within the query string for the value or regex pattern that you specify in TargetString .
If TargetString includes alphabetic characters A-Z and a-z, note that the value is case sensitive.
If you\'re using the AWS WAF API
Specify a base64-encoded version of the value. The maximum length of the value before you base64-encode it is 50 bytes.
For example, suppose the value of Type is HEADER and the value of Data is User-Agent . If you want to search the User-Agent header for the value BadBot , you base64-encode BadBot using MIME base64-encoding and include the resulting value, QmFkQm90 , in the value of TargetString .
If you\'re using the AWS CLI or one of the AWS SDKs
The value that you want AWS WAF to search for. The SDK automatically base64 encodes the value.
TextTransformation (string) --Text transformations eliminate some of the unusual formatting that attackers use in web requests in an effort to bypass AWS WAF. If you specify a transformation, AWS WAF performs the transformation on FieldToMatch before inspecting it for a match.
You can only specify a single type of TextTransformation.
CMD_LINE
When you\'re concerned that attackers are injecting an operating system command line command and using unusual formatting to disguise some or all of the command, use this option to perform the following transformations:
Delete the following characters: " \' ^
Delete spaces before the following characters: / (
Replace the following characters with a space: , ;
Replace multiple spaces with one space
Convert uppercase letters (A-Z) to lowercase (a-z)
COMPRESS_WHITE_SPACE
Use this option to replace the following characters with a space character (decimal 32):
f, formfeed, decimal 12
t, tab, decimal 9
n, newline, decimal 10
r, carriage return, decimal 13
v, vertical tab, decimal 11
non-breaking space, decimal 160
COMPRESS_WHITE_SPACE also replaces multiple spaces with one space.HTML_ENTITY_DECODE
Use this option to replace HTML-encoded characters with unencoded characters. HTML_ENTITY_DECODE performs the following operations:
Replaces (ampersand)quot; with "
Replaces (ampersand)nbsp; with a non-breaking space, decimal 160
Replaces (ampersand)lt; with a "less than" symbol
Replaces (ampersand)gt; with >
Replaces characters that are represented in hexadecimal format, (ampersand)#xhhhh; , with the corresponding characters
Replaces characters that are represented in decimal format, (ampersand)#nnnn; , with the corresponding characters
LOWERCASE
Use this option to convert uppercase letters (A-Z) to lowercase (a-z).
URL_DECODE
Use this option to decode a URL-encoded value.
NONE
Specify NONE if you don\'t want to perform any text transformations.
PositionalConstraint (string) --Within the portion of a web request that you want to search (for example, in the query string, if any), specify where you want AWS WAF to search. Valid values include the following:
CONTAINS
The specified part of the web request must include the value of TargetString , but the location doesn\'t matter.
CONTAINS_WORD
The specified part of the web request must include the value of TargetString , and TargetString must contain only alphanumeric characters or underscore (A-Z, a-z, 0-9, or _). In addition, TargetString must be a word, which means one of the following:
TargetString exactly matches the value of the specified part of the web request, such as the value of a header.
TargetString is at the beginning of the specified part of the web request and is followed by a character other than an alphanumeric character or underscore (_), for example, BadBot; .
TargetString is at the end of the specified part of the web request and is preceded by a character other than an alphanumeric character or underscore (_), for example, ;BadBot .
TargetString is in the middle of the specified part of the web request and is preceded and followed by characters other than alphanumeric characters or underscore (_), for example, -BadBot; .
EXACTLY
The value of the specified part of the web request must exactly match the value of TargetString .
STARTS_WITH
The value of TargetString must appear at the beginning of the specified part of the web request.
ENDS_WITH
The value of TargetString must appear at the end of the specified part of the web request.
Exceptions
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidAccountException
WAFRegional.Client.exceptions.WAFNonexistentItemException
Examples
The following example returns the details of a byte match set with the ID exampleIDs3t-46da-4fdb-b8d5-abc321j569j5.
response = client.get_byte_match_set(
ByteMatchSetId='exampleIDs3t-46da-4fdb-b8d5-abc321j569j5',
)
print(response)
Expected Output:
{
'ByteMatchSet': {
'ByteMatchSetId': 'exampleIDs3t-46da-4fdb-b8d5-abc321j569j5',
'ByteMatchTuples': [
{
'FieldToMatch': {
'Data': 'referer',
'Type': 'HEADER',
},
'PositionalConstraint': 'CONTAINS',
'TargetString': 'badrefer1',
'TextTransformation': 'NONE',
},
],
'Name': 'ByteMatchNameExample',
},
'ResponseMetadata': {
'...': '...',
},
}
:return: {
'ByteMatchSet': {
'ByteMatchSetId': 'string',
'Name': 'string',
'ByteMatchTuples': [
{
'FieldToMatch': {
'Type': 'URI'|'QUERY_STRING'|'HEADER'|'METHOD'|'BODY'|'SINGLE_QUERY_ARG'|'ALL_QUERY_ARGS',
'Data': 'string'
},
'TargetString': b'bytes',
'TextTransformation': 'NONE'|'COMPRESS_WHITE_SPACE'|'HTML_ENTITY_DECODE'|'LOWERCASE'|'CMD_LINE'|'URL_DECODE',
'PositionalConstraint': 'EXACTLY'|'STARTS_WITH'|'ENDS_WITH'|'CONTAINS'|'CONTAINS_WORD'
},
]
}
}
:returns:
HEADER : A specified request header, for example, the value of the User-Agent or Referer header. If you choose HEADER for the type, specify the name of the header in Data .
METHOD : The HTTP method, which indicated the type of operation that the request is asking the origin to perform. Amazon CloudFront supports the following methods: DELETE , GET , HEAD , OPTIONS , PATCH , POST , and PUT .
QUERY_STRING : A query string, which is the part of a URL that appears after a ? character, if any.
URI : The part of a web request that identifies a resource, for example, /images/daily-ad.jpg .
BODY : The part of a request that contains any additional data that you want to send to your web server as the HTTP request body, such as data from a form. The request body immediately follows the request headers. Note that only the first 8192 bytes of the request body are forwarded to AWS WAF for inspection. To allow or block requests based on the length of the body, you can create a size constraint set. For more information, see CreateSizeConstraintSet .
SINGLE_QUERY_ARG : The parameter in the query string that you will inspect, such as UserName or SalesRegion . The maximum length for SINGLE_QUERY_ARG is 30 characters.
ALL_QUERY_ARGS : Similar to SINGLE_QUERY_ARG , but rather than inspecting a single parameter, AWS WAF will inspect all parameters within the query for the value or regex pattern that you specify in TargetString .
"""
pass
def get_change_token():
"""
When you want to create, update, or delete AWS WAF objects, get a change token and include the change token in the create, update, or delete request. Change tokens ensure that your application doesn\'t submit conflicting requests to AWS WAF.
Each create, update, or delete request must use a unique change token. If your application submits a GetChangeToken request and then submits a second GetChangeToken request before submitting a create, update, or delete request, the second GetChangeToken request returns the same value as the first GetChangeToken request.
When you use a change token in a create, update, or delete request, the status of the change token changes to PENDING , which indicates that AWS WAF is propagating the change to all AWS WAF servers. Use GetChangeTokenStatus to determine the status of your change token.
See also: AWS API Documentation
Exceptions
Examples
The following example returns a change token to use for a create, update or delete operation.
Expected Output:
:example: response = client.get_change_token()
:rtype: dict
ReturnsResponse Syntax{
'ChangeToken': 'string'
}
Response Structure
(dict) --
ChangeToken (string) --The ChangeToken that you used in the request. Use this value in a GetChangeTokenStatus request to get the current status of the request.
Exceptions
WAFRegional.Client.exceptions.WAFInternalErrorException
Examples
The following example returns a change token to use for a create, update or delete operation.
response = client.get_change_token(
)
print(response)
Expected Output:
{
'ChangeToken': 'abcd12f2-46da-4fdb-b8d5-fbd4c466928f',
'ResponseMetadata': {
'...': '...',
},
}
:return: {
'ChangeToken': 'string'
}
"""
pass
def get_change_token_status(ChangeToken=None):
"""
Returns the status of a ChangeToken that you got by calling GetChangeToken . ChangeTokenStatus is one of the following values:
See also: AWS API Documentation
Exceptions
Examples
The following example returns the status of a change token with the ID abcd12f2-46da-4fdb-b8d5-fbd4c466928f.
Expected Output:
:example: response = client.get_change_token_status(
ChangeToken='string'
)
:type ChangeToken: string
:param ChangeToken: [REQUIRED]\nThe change token for which you want to get the status. This change token was previously returned in the GetChangeToken response.\n
:rtype: dict
ReturnsResponse Syntax{
'ChangeTokenStatus': 'PROVISIONED'|'PENDING'|'INSYNC'
}
Response Structure
(dict) --
ChangeTokenStatus (string) --The status of the change token.
Exceptions
WAFRegional.Client.exceptions.WAFNonexistentItemException
WAFRegional.Client.exceptions.WAFInternalErrorException
Examples
The following example returns the status of a change token with the ID abcd12f2-46da-4fdb-b8d5-fbd4c466928f.
response = client.get_change_token_status(
ChangeToken='abcd12f2-46da-4fdb-b8d5-fbd4c466928f',
)
print(response)
Expected Output:
{
'ChangeTokenStatus': 'PENDING',
'ResponseMetadata': {
'...': '...',
},
}
:return: {
'ChangeTokenStatus': 'PROVISIONED'|'PENDING'|'INSYNC'
}
:returns:
WAFRegional.Client.exceptions.WAFNonexistentItemException
WAFRegional.Client.exceptions.WAFInternalErrorException
"""
pass
def get_geo_match_set(GeoMatchSetId=None):
"""
Returns the GeoMatchSet that is specified by GeoMatchSetId .
See also: AWS API Documentation
Exceptions
:example: response = client.get_geo_match_set(
GeoMatchSetId='string'
)
:type GeoMatchSetId: string
:param GeoMatchSetId: [REQUIRED]\nThe GeoMatchSetId of the GeoMatchSet that you want to get. GeoMatchSetId is returned by CreateGeoMatchSet and by ListGeoMatchSets .\n
:rtype: dict
ReturnsResponse Syntax{
'GeoMatchSet': {
'GeoMatchSetId': 'string',
'Name': 'string',
'GeoMatchConstraints': [
{
'Type': 'Country',
'Value': 'AF'|'AX'|'AL'|'DZ'|'AS'|'AD'|'AO'|'AI'|'AQ'|'AG'|'AR'|'AM'|'AW'|'AU'|'AT'|'AZ'|'BS'|'BH'|'BD'|'BB'|'BY'|'BE'|'BZ'|'BJ'|'BM'|'BT'|'BO'|'BQ'|'BA'|'BW'|'BV'|'BR'|'IO'|'BN'|'BG'|'BF'|'BI'|'KH'|'CM'|'CA'|'CV'|'KY'|'CF'|'TD'|'CL'|'CN'|'CX'|'CC'|'CO'|'KM'|'CG'|'CD'|'CK'|'CR'|'CI'|'HR'|'CU'|'CW'|'CY'|'CZ'|'DK'|'DJ'|'DM'|'DO'|'EC'|'EG'|'SV'|'GQ'|'ER'|'EE'|'ET'|'FK'|'FO'|'FJ'|'FI'|'FR'|'GF'|'PF'|'TF'|'GA'|'GM'|'GE'|'DE'|'GH'|'GI'|'GR'|'GL'|'GD'|'GP'|'GU'|'GT'|'GG'|'GN'|'GW'|'GY'|'HT'|'HM'|'VA'|'HN'|'HK'|'HU'|'IS'|'IN'|'ID'|'IR'|'IQ'|'IE'|'IM'|'IL'|'IT'|'JM'|'JP'|'JE'|'JO'|'KZ'|'KE'|'KI'|'KP'|'KR'|'KW'|'KG'|'LA'|'LV'|'LB'|'LS'|'LR'|'LY'|'LI'|'LT'|'LU'|'MO'|'MK'|'MG'|'MW'|'MY'|'MV'|'ML'|'MT'|'MH'|'MQ'|'MR'|'MU'|'YT'|'MX'|'FM'|'MD'|'MC'|'MN'|'ME'|'MS'|'MA'|'MZ'|'MM'|'NA'|'NR'|'NP'|'NL'|'NC'|'NZ'|'NI'|'NE'|'NG'|'NU'|'NF'|'MP'|'NO'|'OM'|'PK'|'PW'|'PS'|'PA'|'PG'|'PY'|'PE'|'PH'|'PN'|'PL'|'PT'|'PR'|'QA'|'RE'|'RO'|'RU'|'RW'|'BL'|'SH'|'KN'|'LC'|'MF'|'PM'|'VC'|'WS'|'SM'|'ST'|'SA'|'SN'|'RS'|'SC'|'SL'|'SG'|'SX'|'SK'|'SI'|'SB'|'SO'|'ZA'|'GS'|'SS'|'ES'|'LK'|'SD'|'SR'|'SJ'|'SZ'|'SE'|'CH'|'SY'|'TW'|'TJ'|'TZ'|'TH'|'TL'|'TG'|'TK'|'TO'|'TT'|'TN'|'TR'|'TM'|'TC'|'TV'|'UG'|'UA'|'AE'|'GB'|'US'|'UM'|'UY'|'UZ'|'VU'|'VE'|'VN'|'VG'|'VI'|'WF'|'EH'|'YE'|'ZM'|'ZW'
},
]
}
}
Response Structure
(dict) --
GeoMatchSet (dict) --Information about the GeoMatchSet that you specified in the GetGeoMatchSet request. This includes the Type , which for a GeoMatchContraint is always Country , as well as the Value , which is the identifier for a specific country.
GeoMatchSetId (string) --The GeoMatchSetId for an GeoMatchSet . You use GeoMatchSetId to get information about a GeoMatchSet (see GeoMatchSet ), update a GeoMatchSet (see UpdateGeoMatchSet ), insert a GeoMatchSet into a Rule or delete one from a Rule (see UpdateRule ), and delete a GeoMatchSet from AWS WAF (see DeleteGeoMatchSet ).
GeoMatchSetId is returned by CreateGeoMatchSet and by ListGeoMatchSets .
Name (string) --A friendly name or description of the GeoMatchSet . You can\'t change the name of an GeoMatchSet after you create it.
GeoMatchConstraints (list) --An array of GeoMatchConstraint objects, which contain the country that you want AWS WAF to search for.
(dict) --
Note
This is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.
For the latest version of AWS WAF , use the AWS WAFV2 API and see the AWS WAF Developer Guide . With the latest version, AWS WAF has a single set of endpoints for regional and global use.
The country from which web requests originate that you want AWS WAF to search for.
Type (string) --The type of geographical area you want AWS WAF to search for. Currently Country is the only valid value.
Value (string) --The country that you want AWS WAF to search for.
Exceptions
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidAccountException
WAFRegional.Client.exceptions.WAFNonexistentItemException
:return: {
'GeoMatchSet': {
'GeoMatchSetId': 'string',
'Name': 'string',
'GeoMatchConstraints': [
{
'Type': 'Country',
'Value': 'AF'|'AX'|'AL'|'DZ'|'AS'|'AD'|'AO'|'AI'|'AQ'|'AG'|'AR'|'AM'|'AW'|'AU'|'AT'|'AZ'|'BS'|'BH'|'BD'|'BB'|'BY'|'BE'|'BZ'|'BJ'|'BM'|'BT'|'BO'|'BQ'|'BA'|'BW'|'BV'|'BR'|'IO'|'BN'|'BG'|'BF'|'BI'|'KH'|'CM'|'CA'|'CV'|'KY'|'CF'|'TD'|'CL'|'CN'|'CX'|'CC'|'CO'|'KM'|'CG'|'CD'|'CK'|'CR'|'CI'|'HR'|'CU'|'CW'|'CY'|'CZ'|'DK'|'DJ'|'DM'|'DO'|'EC'|'EG'|'SV'|'GQ'|'ER'|'EE'|'ET'|'FK'|'FO'|'FJ'|'FI'|'FR'|'GF'|'PF'|'TF'|'GA'|'GM'|'GE'|'DE'|'GH'|'GI'|'GR'|'GL'|'GD'|'GP'|'GU'|'GT'|'GG'|'GN'|'GW'|'GY'|'HT'|'HM'|'VA'|'HN'|'HK'|'HU'|'IS'|'IN'|'ID'|'IR'|'IQ'|'IE'|'IM'|'IL'|'IT'|'JM'|'JP'|'JE'|'JO'|'KZ'|'KE'|'KI'|'KP'|'KR'|'KW'|'KG'|'LA'|'LV'|'LB'|'LS'|'LR'|'LY'|'LI'|'LT'|'LU'|'MO'|'MK'|'MG'|'MW'|'MY'|'MV'|'ML'|'MT'|'MH'|'MQ'|'MR'|'MU'|'YT'|'MX'|'FM'|'MD'|'MC'|'MN'|'ME'|'MS'|'MA'|'MZ'|'MM'|'NA'|'NR'|'NP'|'NL'|'NC'|'NZ'|'NI'|'NE'|'NG'|'NU'|'NF'|'MP'|'NO'|'OM'|'PK'|'PW'|'PS'|'PA'|'PG'|'PY'|'PE'|'PH'|'PN'|'PL'|'PT'|'PR'|'QA'|'RE'|'RO'|'RU'|'RW'|'BL'|'SH'|'KN'|'LC'|'MF'|'PM'|'VC'|'WS'|'SM'|'ST'|'SA'|'SN'|'RS'|'SC'|'SL'|'SG'|'SX'|'SK'|'SI'|'SB'|'SO'|'ZA'|'GS'|'SS'|'ES'|'LK'|'SD'|'SR'|'SJ'|'SZ'|'SE'|'CH'|'SY'|'TW'|'TJ'|'TZ'|'TH'|'TL'|'TG'|'TK'|'TO'|'TT'|'TN'|'TR'|'TM'|'TC'|'TV'|'UG'|'UA'|'AE'|'GB'|'US'|'UM'|'UY'|'UZ'|'VU'|'VE'|'VN'|'VG'|'VI'|'WF'|'EH'|'YE'|'ZM'|'ZW'
},
]
}
}
"""
pass
def get_ip_set(IPSetId=None):
"""
Returns the IPSet that is specified by IPSetId .
See also: AWS API Documentation
Exceptions
Examples
The following example returns the details of an IP match set with the ID example1ds3t-46da-4fdb-b8d5-abc321j569j5.
Expected Output:
:example: response = client.get_ip_set(
IPSetId='string'
)
:type IPSetId: string
:param IPSetId: [REQUIRED]\nThe IPSetId of the IPSet that you want to get. IPSetId is returned by CreateIPSet and by ListIPSets .\n
:rtype: dict
ReturnsResponse Syntax{
'IPSet': {
'IPSetId': 'string',
'Name': 'string',
'IPSetDescriptors': [
{
'Type': 'IPV4'|'IPV6',
'Value': 'string'
},
]
}
}
Response Structure
(dict) --
IPSet (dict) --Information about the IPSet that you specified in the GetIPSet request. For more information, see the following topics:
IPSet : Contains IPSetDescriptors , IPSetId , and Name
IPSetDescriptors : Contains an array of IPSetDescriptor objects. Each IPSetDescriptor object contains Type and Value
IPSetId (string) --The IPSetId for an IPSet . You use IPSetId to get information about an IPSet (see GetIPSet ), update an IPSet (see UpdateIPSet ), insert an IPSet into a Rule or delete one from a Rule (see UpdateRule ), and delete an IPSet from AWS WAF (see DeleteIPSet ).
IPSetId is returned by CreateIPSet and by ListIPSets .
Name (string) --A friendly name or description of the IPSet . You can\'t change the name of an IPSet after you create it.
IPSetDescriptors (list) --The IP address type (IPV4 or IPV6 ) and the IP address range (in CIDR notation) that web requests originate from. If the WebACL is associated with a CloudFront distribution and the viewer did not use an HTTP proxy or a load balancer to send the request, this is the value of the c-ip field in the CloudFront access logs.
(dict) --
Note
This is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.
For the latest version of AWS WAF , use the AWS WAFV2 API and see the AWS WAF Developer Guide . With the latest version, AWS WAF has a single set of endpoints for regional and global use.
Specifies the IP address type (IPV4 or IPV6 ) and the IP address range (in CIDR format) that web requests originate from.
Type (string) --Specify IPV4 or IPV6 .
Value (string) --Specify an IPv4 address by using CIDR notation. For example:
To configure AWS WAF to allow, block, or count requests that originated from the IP address 192.0.2.44, specify 192.0.2.44/32 .
To configure AWS WAF to allow, block, or count requests that originated from IP addresses from 192.0.2.0 to 192.0.2.255, specify 192.0.2.0/24 .
For more information about CIDR notation, see the Wikipedia entry Classless Inter-Domain Routing .
Specify an IPv6 address by using CIDR notation. For example:
To configure AWS WAF to allow, block, or count requests that originated from the IP address 1111:0000:0000:0000:0000:0000:0000:0111, specify 1111:0000:0000:0000:0000:0000:0000:0111/128 .
To configure AWS WAF to allow, block, or count requests that originated from IP addresses 1111:0000:0000:0000:0000:0000:0000:0000 to 1111:0000:0000:0000:ffff:ffff:ffff:ffff, specify 1111:0000:0000:0000:0000:0000:0000:0000/64 .
Exceptions
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidAccountException
WAFRegional.Client.exceptions.WAFNonexistentItemException
Examples
The following example returns the details of an IP match set with the ID example1ds3t-46da-4fdb-b8d5-abc321j569j5.
response = client.get_ip_set(
IPSetId='example1ds3t-46da-4fdb-b8d5-abc321j569j5',
)
print(response)
Expected Output:
{
'IPSet': {
'IPSetDescriptors': [
{
'Type': 'IPV4',
'Value': '192.0.2.44/32',
},
],
'IPSetId': 'example1ds3t-46da-4fdb-b8d5-abc321j569j5',
'Name': 'MyIPSetFriendlyName',
},
'ResponseMetadata': {
'...': '...',
},
}
:return: {
'IPSet': {
'IPSetId': 'string',
'Name': 'string',
'IPSetDescriptors': [
{
'Type': 'IPV4'|'IPV6',
'Value': 'string'
},
]
}
}
:returns:
To configure AWS WAF to allow, block, or count requests that originated from the IP address 192.0.2.44, specify 192.0.2.44/32 .
To configure AWS WAF to allow, block, or count requests that originated from IP addresses from 192.0.2.0 to 192.0.2.255, specify 192.0.2.0/24 .
"""
pass
def get_logging_configuration(ResourceArn=None):
"""
Returns the LoggingConfiguration for the specified web ACL.
See also: AWS API Documentation
Exceptions
:example: response = client.get_logging_configuration(
ResourceArn='string'
)
:type ResourceArn: string
:param ResourceArn: [REQUIRED]\nThe Amazon Resource Name (ARN) of the web ACL for which you want to get the LoggingConfiguration .\n
:rtype: dict
ReturnsResponse Syntax{
'LoggingConfiguration': {
'ResourceArn': 'string',
'LogDestinationConfigs': [
'string',
],
'RedactedFields': [
{
'Type': 'URI'|'QUERY_STRING'|'HEADER'|'METHOD'|'BODY'|'SINGLE_QUERY_ARG'|'ALL_QUERY_ARGS',
'Data': 'string'
},
]
}
}
Response Structure
(dict) --
LoggingConfiguration (dict) --The LoggingConfiguration for the specified web ACL.
ResourceArn (string) --The Amazon Resource Name (ARN) of the web ACL that you want to associate with LogDestinationConfigs .
LogDestinationConfigs (list) --An array of Amazon Kinesis Data Firehose ARNs.
(string) --
RedactedFields (list) --The parts of the request that you want redacted from the logs. For example, if you redact the cookie field, the cookie field in the firehose will be xxx .
(dict) --
Note
This is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.
For the latest version of AWS WAF , use the AWS WAFV2 API and see the AWS WAF Developer Guide . With the latest version, AWS WAF has a single set of endpoints for regional and global use.
Specifies where in a web request to look for TargetString .
Type (string) --The part of the web request that you want AWS WAF to search for a specified string. Parts of a request that you can search include the following:
HEADER : A specified request header, for example, the value of the User-Agent or Referer header. If you choose HEADER for the type, specify the name of the header in Data .
METHOD : The HTTP method, which indicated the type of operation that the request is asking the origin to perform. Amazon CloudFront supports the following methods: DELETE , GET , HEAD , OPTIONS , PATCH , POST , and PUT .
QUERY_STRING : A query string, which is the part of a URL that appears after a ? character, if any.
URI : The part of a web request that identifies a resource, for example, /images/daily-ad.jpg .
BODY : The part of a request that contains any additional data that you want to send to your web server as the HTTP request body, such as data from a form. The request body immediately follows the request headers. Note that only the first 8192 bytes of the request body are forwarded to AWS WAF for inspection. To allow or block requests based on the length of the body, you can create a size constraint set. For more information, see CreateSizeConstraintSet .
SINGLE_QUERY_ARG : The parameter in the query string that you will inspect, such as UserName or SalesRegion . The maximum length for SINGLE_QUERY_ARG is 30 characters.
ALL_QUERY_ARGS : Similar to SINGLE_QUERY_ARG , but rather than inspecting a single parameter, AWS WAF will inspect all parameters within the query for the value or regex pattern that you specify in TargetString .
Data (string) --When the value of Type is HEADER , enter the name of the header that you want AWS WAF to search, for example, User-Agent or Referer . The name of the header is not case sensitive.
When the value of Type is SINGLE_QUERY_ARG , enter the name of the parameter that you want AWS WAF to search, for example, UserName or SalesRegion . The parameter name is not case sensitive.
If the value of Type is any other value, omit Data .
Exceptions
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFNonexistentItemException
:return: {
'LoggingConfiguration': {
'ResourceArn': 'string',
'LogDestinationConfigs': [
'string',
],
'RedactedFields': [
{
'Type': 'URI'|'QUERY_STRING'|'HEADER'|'METHOD'|'BODY'|'SINGLE_QUERY_ARG'|'ALL_QUERY_ARGS',
'Data': 'string'
},
]
}
}
:returns:
HEADER : A specified request header, for example, the value of the User-Agent or Referer header. If you choose HEADER for the type, specify the name of the header in Data .
METHOD : The HTTP method, which indicated the type of operation that the request is asking the origin to perform. Amazon CloudFront supports the following methods: DELETE , GET , HEAD , OPTIONS , PATCH , POST , and PUT .
QUERY_STRING : A query string, which is the part of a URL that appears after a ? character, if any.
URI : The part of a web request that identifies a resource, for example, /images/daily-ad.jpg .
BODY : The part of a request that contains any additional data that you want to send to your web server as the HTTP request body, such as data from a form. The request body immediately follows the request headers. Note that only the first 8192 bytes of the request body are forwarded to AWS WAF for inspection. To allow or block requests based on the length of the body, you can create a size constraint set. For more information, see CreateSizeConstraintSet .
SINGLE_QUERY_ARG : The parameter in the query string that you will inspect, such as UserName or SalesRegion . The maximum length for SINGLE_QUERY_ARG is 30 characters.
ALL_QUERY_ARGS : Similar to SINGLE_QUERY_ARG , but rather than inspecting a single parameter, AWS WAF will inspect all parameters within the query for the value or regex pattern that you specify in TargetString .
"""
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\nas the method name on the client. For example, if the\nmethod name is create_foo, and you\'d normally invoke the\noperation as client.create_foo(**kwargs), if the\ncreate_foo operation can be paginated, you can use the\ncall client.get_paginator('create_foo').
:rtype: L{botocore.paginate.Paginator}
ReturnsA paginator object.
"""
pass
def get_permission_policy(ResourceArn=None):
"""
Returns the IAM policy attached to the RuleGroup.
See also: AWS API Documentation
Exceptions
:example: response = client.get_permission_policy(
ResourceArn='string'
)
:type ResourceArn: string
:param ResourceArn: [REQUIRED]\nThe Amazon Resource Name (ARN) of the RuleGroup for which you want to get the policy.\n
:rtype: dict
ReturnsResponse Syntax{
'Policy': 'string'
}
Response Structure
(dict) --
Policy (string) --The IAM policy attached to the specified RuleGroup.
Exceptions
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFNonexistentItemException
:return: {
'Policy': 'string'
}
"""
pass
def get_rate_based_rule(RuleId=None):
"""
Returns the RateBasedRule that is specified by the RuleId that you included in the GetRateBasedRule request.
See also: AWS API Documentation
Exceptions
:example: response = client.get_rate_based_rule(
RuleId='string'
)
:type RuleId: string
:param RuleId: [REQUIRED]\nThe RuleId of the RateBasedRule that you want to get. RuleId is returned by CreateRateBasedRule and by ListRateBasedRules .\n
:rtype: dict
ReturnsResponse Syntax{
'Rule': {
'RuleId': 'string',
'Name': 'string',
'MetricName': 'string',
'MatchPredicates': [
{
'Negated': True|False,
'Type': 'IPMatch'|'ByteMatch'|'SqlInjectionMatch'|'GeoMatch'|'SizeConstraint'|'XssMatch'|'RegexMatch',
'DataId': 'string'
},
],
'RateKey': 'IP',
'RateLimit': 123
}
}
Response Structure
(dict) --
Rule (dict) --Information about the RateBasedRule that you specified in the GetRateBasedRule request.
RuleId (string) --A unique identifier for a RateBasedRule . You use RuleId to get more information about a RateBasedRule (see GetRateBasedRule ), update a RateBasedRule (see UpdateRateBasedRule ), insert a RateBasedRule into a WebACL or delete one from a WebACL (see UpdateWebACL ), or delete a RateBasedRule from AWS WAF (see DeleteRateBasedRule ).
Name (string) --A friendly name or description for a RateBasedRule . You can\'t change the name of a RateBasedRule after you create it.
MetricName (string) --A friendly name or description for the metrics for a RateBasedRule . The name can contain only alphanumeric characters (A-Z, a-z, 0-9), with maximum length 128 and minimum length one. It can\'t contain whitespace or metric names reserved for AWS WAF, including "All" and "Default_Action." You can\'t change the name of the metric after you create the RateBasedRule .
MatchPredicates (list) --The Predicates object contains one Predicate element for each ByteMatchSet , IPSet , or SqlInjectionMatchSet object that you want to include in a RateBasedRule .
(dict) --
Note
This is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.
For the latest version of AWS WAF , use the AWS WAFV2 API and see the AWS WAF Developer Guide . With the latest version, AWS WAF has a single set of endpoints for regional and global use.
Specifies the ByteMatchSet , IPSet , SqlInjectionMatchSet , XssMatchSet , RegexMatchSet , GeoMatchSet , and SizeConstraintSet objects that you want to add to a Rule and, for each object, indicates whether you want to negate the settings, for example, requests that do NOT originate from the IP address 192.0.2.44.
Negated (boolean) --Set Negated to False if you want AWS WAF to allow, block, or count requests based on the settings in the specified ByteMatchSet , IPSet , SqlInjectionMatchSet , XssMatchSet , RegexMatchSet , GeoMatchSet , or SizeConstraintSet . For example, if an IPSet includes the IP address 192.0.2.44 , AWS WAF will allow or block requests based on that IP address.
Set Negated to True if you want AWS WAF to allow or block a request based on the negation of the settings in the ByteMatchSet , IPSet , SqlInjectionMatchSet , XssMatchSet , RegexMatchSet , GeoMatchSet , or SizeConstraintSet . For example, if an IPSet includes the IP address 192.0.2.44 , AWS WAF will allow, block, or count requests based on all IP addresses except 192.0.2.44 .
Type (string) --The type of predicate in a Rule , such as ByteMatch or IPSet .
DataId (string) --A unique identifier for a predicate in a Rule , such as ByteMatchSetId or IPSetId . The ID is returned by the corresponding Create or List command.
RateKey (string) --The field that AWS WAF uses to determine if requests are likely arriving from single source and thus subject to rate monitoring. The only valid value for RateKey is IP . IP indicates that requests arriving from the same IP address are subject to the RateLimit that is specified in the RateBasedRule .
RateLimit (integer) --The maximum number of requests, which have an identical value in the field specified by the RateKey , allowed in a five-minute period. If the number of requests exceeds the RateLimit and the other predicates specified in the rule are also met, AWS WAF triggers the action that is specified for this rule.
Exceptions
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidAccountException
WAFRegional.Client.exceptions.WAFNonexistentItemException
:return: {
'Rule': {
'RuleId': 'string',
'Name': 'string',
'MetricName': 'string',
'MatchPredicates': [
{
'Negated': True|False,
'Type': 'IPMatch'|'ByteMatch'|'SqlInjectionMatch'|'GeoMatch'|'SizeConstraint'|'XssMatch'|'RegexMatch',
'DataId': 'string'
},
],
'RateKey': 'IP',
'RateLimit': 123
}
}
"""
pass
def get_rate_based_rule_managed_keys(RuleId=None, NextMarker=None):
"""
Returns an array of IP addresses currently being blocked by the RateBasedRule that is specified by the RuleId . The maximum number of managed keys that will be blocked is 10,000. If more than 10,000 addresses exceed the rate limit, the 10,000 addresses with the highest rates will be blocked.
See also: AWS API Documentation
Exceptions
:example: response = client.get_rate_based_rule_managed_keys(
RuleId='string',
NextMarker='string'
)
:type RuleId: string
:param RuleId: [REQUIRED]\nThe RuleId of the RateBasedRule for which you want to get a list of ManagedKeys . RuleId is returned by CreateRateBasedRule and by ListRateBasedRules .\n
:type NextMarker: string
:param NextMarker: A null value and not currently used. Do not include this in your request.
:rtype: dict
ReturnsResponse Syntax
{
'ManagedKeys': [
'string',
],
'NextMarker': 'string'
}
Response Structure
(dict) --
ManagedKeys (list) --
An array of IP addresses that currently are blocked by the specified RateBasedRule .
(string) --
NextMarker (string) --
A null value and not currently used.
Exceptions
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidAccountException
WAFRegional.Client.exceptions.WAFNonexistentItemException
WAFRegional.Client.exceptions.WAFInvalidParameterException
:return: {
'ManagedKeys': [
'string',
],
'NextMarker': 'string'
}
:returns:
(string) --
"""
pass
def get_regex_match_set(RegexMatchSetId=None):
"""
Returns the RegexMatchSet specified by RegexMatchSetId .
See also: AWS API Documentation
Exceptions
:example: response = client.get_regex_match_set(
RegexMatchSetId='string'
)
:type RegexMatchSetId: string
:param RegexMatchSetId: [REQUIRED]\nThe RegexMatchSetId of the RegexMatchSet that you want to get. RegexMatchSetId is returned by CreateRegexMatchSet and by ListRegexMatchSets .\n
:rtype: dict
ReturnsResponse Syntax{
'RegexMatchSet': {
'RegexMatchSetId': 'string',
'Name': 'string',
'RegexMatchTuples': [
{
'FieldToMatch': {
'Type': 'URI'|'QUERY_STRING'|'HEADER'|'METHOD'|'BODY'|'SINGLE_QUERY_ARG'|'ALL_QUERY_ARGS',
'Data': 'string'
},
'TextTransformation': 'NONE'|'COMPRESS_WHITE_SPACE'|'HTML_ENTITY_DECODE'|'LOWERCASE'|'CMD_LINE'|'URL_DECODE',
'RegexPatternSetId': 'string'
},
]
}
}
Response Structure
(dict) --
RegexMatchSet (dict) --Information about the RegexMatchSet that you specified in the GetRegexMatchSet request. For more information, see RegexMatchTuple .
RegexMatchSetId (string) --The RegexMatchSetId for a RegexMatchSet . You use RegexMatchSetId to get information about a RegexMatchSet (see GetRegexMatchSet ), update a RegexMatchSet (see UpdateRegexMatchSet ), insert a RegexMatchSet into a Rule or delete one from a Rule (see UpdateRule ), and delete a RegexMatchSet from AWS WAF (see DeleteRegexMatchSet ).
RegexMatchSetId is returned by CreateRegexMatchSet and by ListRegexMatchSets .
Name (string) --A friendly name or description of the RegexMatchSet . You can\'t change Name after you create a RegexMatchSet .
RegexMatchTuples (list) --Contains an array of RegexMatchTuple objects. Each RegexMatchTuple object contains:
The part of a web request that you want AWS WAF to inspect, such as a query string or the value of the User-Agent header.
The identifier of the pattern (a regular expression) that you want AWS WAF to look for. For more information, see RegexPatternSet .
Whether to perform any conversions on the request, such as converting it to lowercase, before inspecting it for the specified string.
(dict) --
Note
This is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.
For the latest version of AWS WAF , use the AWS WAFV2 API and see the AWS WAF Developer Guide . With the latest version, AWS WAF has a single set of endpoints for regional and global use.
The regular expression pattern that you want AWS WAF to search for in web requests, the location in requests that you want AWS WAF to search, and other settings. Each RegexMatchTuple object contains:
The part of a web request that you want AWS WAF to inspect, such as a query string or the value of the User-Agent header.
The identifier of the pattern (a regular expression) that you want AWS WAF to look for. For more information, see RegexPatternSet .
Whether to perform any conversions on the request, such as converting it to lowercase, before inspecting it for the specified string.
FieldToMatch (dict) --Specifies where in a web request to look for the RegexPatternSet .
Type (string) --The part of the web request that you want AWS WAF to search for a specified string. Parts of a request that you can search include the following:
HEADER : A specified request header, for example, the value of the User-Agent or Referer header. If you choose HEADER for the type, specify the name of the header in Data .
METHOD : The HTTP method, which indicated the type of operation that the request is asking the origin to perform. Amazon CloudFront supports the following methods: DELETE , GET , HEAD , OPTIONS , PATCH , POST , and PUT .
QUERY_STRING : A query string, which is the part of a URL that appears after a ? character, if any.
URI : The part of a web request that identifies a resource, for example, /images/daily-ad.jpg .
BODY : The part of a request that contains any additional data that you want to send to your web server as the HTTP request body, such as data from a form. The request body immediately follows the request headers. Note that only the first 8192 bytes of the request body are forwarded to AWS WAF for inspection. To allow or block requests based on the length of the body, you can create a size constraint set. For more information, see CreateSizeConstraintSet .
SINGLE_QUERY_ARG : The parameter in the query string that you will inspect, such as UserName or SalesRegion . The maximum length for SINGLE_QUERY_ARG is 30 characters.
ALL_QUERY_ARGS : Similar to SINGLE_QUERY_ARG , but rather than inspecting a single parameter, AWS WAF will inspect all parameters within the query for the value or regex pattern that you specify in TargetString .
Data (string) --When the value of Type is HEADER , enter the name of the header that you want AWS WAF to search, for example, User-Agent or Referer . The name of the header is not case sensitive.
When the value of Type is SINGLE_QUERY_ARG , enter the name of the parameter that you want AWS WAF to search, for example, UserName or SalesRegion . The parameter name is not case sensitive.
If the value of Type is any other value, omit Data .
TextTransformation (string) --Text transformations eliminate some of the unusual formatting that attackers use in web requests in an effort to bypass AWS WAF. If you specify a transformation, AWS WAF performs the transformation on RegexPatternSet before inspecting a request for a match.
You can only specify a single type of TextTransformation.
CMD_LINE
When you\'re concerned that attackers are injecting an operating system commandline command and using unusual formatting to disguise some or all of the command, use this option to perform the following transformations:
Delete the following characters: " \' ^
Delete spaces before the following characters: / (
Replace the following characters with a space: , ;
Replace multiple spaces with one space
Convert uppercase letters (A-Z) to lowercase (a-z)
COMPRESS_WHITE_SPACE
Use this option to replace the following characters with a space character (decimal 32):
f, formfeed, decimal 12
t, tab, decimal 9
n, newline, decimal 10
r, carriage return, decimal 13
v, vertical tab, decimal 11
non-breaking space, decimal 160
COMPRESS_WHITE_SPACE also replaces multiple spaces with one space.HTML_ENTITY_DECODE
Use this option to replace HTML-encoded characters with unencoded characters. HTML_ENTITY_DECODE performs the following operations:
Replaces (ampersand)quot; with "
Replaces (ampersand)nbsp; with a non-breaking space, decimal 160
Replaces (ampersand)lt; with a "less than" symbol
Replaces (ampersand)gt; with >
Replaces characters that are represented in hexadecimal format, (ampersand)#xhhhh; , with the corresponding characters
Replaces characters that are represented in decimal format, (ampersand)#nnnn; , with the corresponding characters
LOWERCASE
Use this option to convert uppercase letters (A-Z) to lowercase (a-z).
URL_DECODE
Use this option to decode a URL-encoded value.
NONE
Specify NONE if you don\'t want to perform any text transformations.
RegexPatternSetId (string) --The RegexPatternSetId for a RegexPatternSet . You use RegexPatternSetId to get information about a RegexPatternSet (see GetRegexPatternSet ), update a RegexPatternSet (see UpdateRegexPatternSet ), insert a RegexPatternSet into a RegexMatchSet or delete one from a RegexMatchSet (see UpdateRegexMatchSet ), and delete an RegexPatternSet from AWS WAF (see DeleteRegexPatternSet ).
RegexPatternSetId is returned by CreateRegexPatternSet and by ListRegexPatternSets .
Exceptions
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidAccountException
WAFRegional.Client.exceptions.WAFNonexistentItemException
:return: {
'RegexMatchSet': {
'RegexMatchSetId': 'string',
'Name': 'string',
'RegexMatchTuples': [
{
'FieldToMatch': {
'Type': 'URI'|'QUERY_STRING'|'HEADER'|'METHOD'|'BODY'|'SINGLE_QUERY_ARG'|'ALL_QUERY_ARGS',
'Data': 'string'
},
'TextTransformation': 'NONE'|'COMPRESS_WHITE_SPACE'|'HTML_ENTITY_DECODE'|'LOWERCASE'|'CMD_LINE'|'URL_DECODE',
'RegexPatternSetId': 'string'
},
]
}
}
:returns:
The part of a web request that you want AWS WAF to inspect, such as a query string or the value of the User-Agent header.
The identifier of the pattern (a regular expression) that you want AWS WAF to look for. For more information, see RegexPatternSet .
Whether to perform any conversions on the request, such as converting it to lowercase, before inspecting it for the specified string.
"""
pass
def get_regex_pattern_set(RegexPatternSetId=None):
"""
Returns the RegexPatternSet specified by RegexPatternSetId .
See also: AWS API Documentation
Exceptions
:example: response = client.get_regex_pattern_set(
RegexPatternSetId='string'
)
:type RegexPatternSetId: string
:param RegexPatternSetId: [REQUIRED]\nThe RegexPatternSetId of the RegexPatternSet that you want to get. RegexPatternSetId is returned by CreateRegexPatternSet and by ListRegexPatternSets .\n
:rtype: dict
ReturnsResponse Syntax{
'RegexPatternSet': {
'RegexPatternSetId': 'string',
'Name': 'string',
'RegexPatternStrings': [
'string',
]
}
}
Response Structure
(dict) --
RegexPatternSet (dict) --Information about the RegexPatternSet that you specified in the GetRegexPatternSet request, including the identifier of the pattern set and the regular expression patterns you want AWS WAF to search for.
RegexPatternSetId (string) --The identifier for the RegexPatternSet . You use RegexPatternSetId to get information about a RegexPatternSet , update a RegexPatternSet , remove a RegexPatternSet from a RegexMatchSet , and delete a RegexPatternSet from AWS WAF.
RegexMatchSetId is returned by CreateRegexPatternSet and by ListRegexPatternSets .
Name (string) --A friendly name or description of the RegexPatternSet . You can\'t change Name after you create a RegexPatternSet .
RegexPatternStrings (list) --Specifies the regular expression (regex) patterns that you want AWS WAF to search for, such as B[a@]dB[o0]t .
(string) --
Exceptions
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidAccountException
WAFRegional.Client.exceptions.WAFNonexistentItemException
:return: {
'RegexPatternSet': {
'RegexPatternSetId': 'string',
'Name': 'string',
'RegexPatternStrings': [
'string',
]
}
}
:returns:
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidAccountException
WAFRegional.Client.exceptions.WAFNonexistentItemException
"""
pass
def get_rule(RuleId=None):
"""
Returns the Rule that is specified by the RuleId that you included in the GetRule request.
See also: AWS API Documentation
Exceptions
Examples
The following example returns the details of a rule with the ID example1ds3t-46da-4fdb-b8d5-abc321j569j5.
Expected Output:
:example: response = client.get_rule(
RuleId='string'
)
:type RuleId: string
:param RuleId: [REQUIRED]\nThe RuleId of the Rule that you want to get. RuleId is returned by CreateRule and by ListRules .\n
:rtype: dict
ReturnsResponse Syntax{
'Rule': {
'RuleId': 'string',
'Name': 'string',
'MetricName': 'string',
'Predicates': [
{
'Negated': True|False,
'Type': 'IPMatch'|'ByteMatch'|'SqlInjectionMatch'|'GeoMatch'|'SizeConstraint'|'XssMatch'|'RegexMatch',
'DataId': 'string'
},
]
}
}
Response Structure
(dict) --
Rule (dict) --Information about the Rule that you specified in the GetRule request. For more information, see the following topics:
Rule : Contains MetricName , Name , an array of Predicate objects, and RuleId
Predicate : Each Predicate object contains DataId , Negated , and Type
RuleId (string) --A unique identifier for a Rule . You use RuleId to get more information about a Rule (see GetRule ), update a Rule (see UpdateRule ), insert a Rule into a WebACL or delete a one from a WebACL (see UpdateWebACL ), or delete a Rule from AWS WAF (see DeleteRule ).
RuleId is returned by CreateRule and by ListRules .
Name (string) --The friendly name or description for the Rule . You can\'t change the name of a Rule after you create it.
MetricName (string) --A friendly name or description for the metrics for this Rule . The name can contain only alphanumeric characters (A-Z, a-z, 0-9), with maximum length 128 and minimum length one. It can\'t contain whitespace or metric names reserved for AWS WAF, including "All" and "Default_Action." You can\'t change MetricName after you create the Rule .
Predicates (list) --The Predicates object contains one Predicate element for each ByteMatchSet , IPSet , or SqlInjectionMatchSet object that you want to include in a Rule .
(dict) --
Note
This is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.
For the latest version of AWS WAF , use the AWS WAFV2 API and see the AWS WAF Developer Guide . With the latest version, AWS WAF has a single set of endpoints for regional and global use.
Specifies the ByteMatchSet , IPSet , SqlInjectionMatchSet , XssMatchSet , RegexMatchSet , GeoMatchSet , and SizeConstraintSet objects that you want to add to a Rule and, for each object, indicates whether you want to negate the settings, for example, requests that do NOT originate from the IP address 192.0.2.44.
Negated (boolean) --Set Negated to False if you want AWS WAF to allow, block, or count requests based on the settings in the specified ByteMatchSet , IPSet , SqlInjectionMatchSet , XssMatchSet , RegexMatchSet , GeoMatchSet , or SizeConstraintSet . For example, if an IPSet includes the IP address 192.0.2.44 , AWS WAF will allow or block requests based on that IP address.
Set Negated to True if you want AWS WAF to allow or block a request based on the negation of the settings in the ByteMatchSet , IPSet , SqlInjectionMatchSet , XssMatchSet , RegexMatchSet , GeoMatchSet , or SizeConstraintSet . For example, if an IPSet includes the IP address 192.0.2.44 , AWS WAF will allow, block, or count requests based on all IP addresses except 192.0.2.44 .
Type (string) --The type of predicate in a Rule , such as ByteMatch or IPSet .
DataId (string) --A unique identifier for a predicate in a Rule , such as ByteMatchSetId or IPSetId . The ID is returned by the corresponding Create or List command.
Exceptions
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidAccountException
WAFRegional.Client.exceptions.WAFNonexistentItemException
Examples
The following example returns the details of a rule with the ID example1ds3t-46da-4fdb-b8d5-abc321j569j5.
response = client.get_rule(
RuleId='example1ds3t-46da-4fdb-b8d5-abc321j569j5',
)
print(response)
Expected Output:
{
'Rule': {
'MetricName': 'WAFByteHeaderRule',
'Name': 'WAFByteHeaderRule',
'Predicates': [
{
'DataId': 'MyByteMatchSetID',
'Negated': False,
'Type': 'ByteMatch',
},
],
'RuleId': 'example1ds3t-46da-4fdb-b8d5-abc321j569j5',
},
'ResponseMetadata': {
'...': '...',
},
}
:return: {
'Rule': {
'RuleId': 'string',
'Name': 'string',
'MetricName': 'string',
'Predicates': [
{
'Negated': True|False,
'Type': 'IPMatch'|'ByteMatch'|'SqlInjectionMatch'|'GeoMatch'|'SizeConstraint'|'XssMatch'|'RegexMatch',
'DataId': 'string'
},
]
}
}
:returns:
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidAccountException
WAFRegional.Client.exceptions.WAFNonexistentItemException
"""
pass
def get_rule_group(RuleGroupId=None):
"""
Returns the RuleGroup that is specified by the RuleGroupId that you included in the GetRuleGroup request.
To view the rules in a rule group, use ListActivatedRulesInRuleGroup .
See also: AWS API Documentation
Exceptions
:example: response = client.get_rule_group(
RuleGroupId='string'
)
:type RuleGroupId: string
:param RuleGroupId: [REQUIRED]\nThe RuleGroupId of the RuleGroup that you want to get. RuleGroupId is returned by CreateRuleGroup and by ListRuleGroups .\n
:rtype: dict
ReturnsResponse Syntax{
'RuleGroup': {
'RuleGroupId': 'string',
'Name': 'string',
'MetricName': 'string'
}
}
Response Structure
(dict) --
RuleGroup (dict) --Information about the RuleGroup that you specified in the GetRuleGroup request.
RuleGroupId (string) --A unique identifier for a RuleGroup . You use RuleGroupId to get more information about a RuleGroup (see GetRuleGroup ), update a RuleGroup (see UpdateRuleGroup ), insert a RuleGroup into a WebACL or delete a one from a WebACL (see UpdateWebACL ), or delete a RuleGroup from AWS WAF (see DeleteRuleGroup ).
RuleGroupId is returned by CreateRuleGroup and by ListRuleGroups .
Name (string) --The friendly name or description for the RuleGroup . You can\'t change the name of a RuleGroup after you create it.
MetricName (string) --A friendly name or description for the metrics for this RuleGroup . The name can contain only alphanumeric characters (A-Z, a-z, 0-9), with maximum length 128 and minimum length one. It can\'t contain whitespace or metric names reserved for AWS WAF, including "All" and "Default_Action." You can\'t change the name of the metric after you create the RuleGroup .
Exceptions
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFNonexistentItemException
:return: {
'RuleGroup': {
'RuleGroupId': 'string',
'Name': 'string',
'MetricName': 'string'
}
}
"""
pass
def get_sampled_requests(WebAclId=None, RuleId=None, TimeWindow=None, MaxItems=None):
"""
Gets detailed information about a specified number of requests--a sample--that AWS WAF randomly selects from among the first 5,000 requests that your AWS resource received during a time range that you choose. You can specify a sample size of up to 500 requests, and you can specify any time range in the previous three hours.
See also: AWS API Documentation
Exceptions
Examples
The following example returns detailed information about 100 requests --a sample-- that AWS WAF randomly selects from among the first 5,000 requests that your AWS resource received between the time period 2016-09-27T15:50Z to 2016-09-27T15:50Z.
Expected Output:
:example: response = client.get_sampled_requests(
WebAclId='string',
RuleId='string',
TimeWindow={
'StartTime': datetime(2015, 1, 1),
'EndTime': datetime(2015, 1, 1)
},
MaxItems=123
)
:type WebAclId: string
:param WebAclId: [REQUIRED]\nThe WebACLId of the WebACL for which you want GetSampledRequests to return a sample of requests.\n
:type RuleId: string
:param RuleId: [REQUIRED]\n\nRuleId is one of three values:\n\nThe RuleId of the Rule or the RuleGroupId of the RuleGroup for which you want GetSampledRequests to return a sample of requests.\nDefault_Action , which causes GetSampledRequests to return a sample of the requests that didn\'t match any of the rules in the specified WebACL .\n\n
:type TimeWindow: dict
:param TimeWindow: [REQUIRED]\nThe start date and time and the end date and time of the range for which you want GetSampledRequests to return a sample of requests. You must specify the times in Coordinated Universal Time (UTC) format. UTC format includes the special designator, Z . For example, '2016-09-27T14:50Z' . You can specify any time range in the previous three hours.\n\nStartTime (datetime) -- [REQUIRED]The beginning of the time range from which you want GetSampledRequests to return a sample of the requests that your AWS resource received. You must specify the date and time in Coordinated Universal Time (UTC) format. UTC format includes the special designator, Z . For example, '2016-09-27T14:50Z' . You can specify any time range in the previous three hours.\n\nEndTime (datetime) -- [REQUIRED]The end of the time range from which you want GetSampledRequests to return a sample of the requests that your AWS resource received. You must specify the date and time in Coordinated Universal Time (UTC) format. UTC format includes the special designator, Z . For example, '2016-09-27T14:50Z' . You can specify any time range in the previous three hours.\n\n\n
:type MaxItems: integer
:param MaxItems: [REQUIRED]\nThe number of requests that you want AWS WAF to return from among the first 5,000 requests that your AWS resource received during the time range. If your resource received fewer requests than the value of MaxItems , GetSampledRequests returns information about all of them.\n
:rtype: dict
ReturnsResponse Syntax
{
'SampledRequests': [
{
'Request': {
'ClientIP': 'string',
'Country': 'string',
'URI': 'string',
'Method': 'string',
'HTTPVersion': 'string',
'Headers': [
{
'Name': 'string',
'Value': 'string'
},
]
},
'Weight': 123,
'Timestamp': datetime(2015, 1, 1),
'Action': 'string',
'RuleWithinRuleGroup': 'string'
},
],
'PopulationSize': 123,
'TimeWindow': {
'StartTime': datetime(2015, 1, 1),
'EndTime': datetime(2015, 1, 1)
}
}
Response Structure
(dict) --
SampledRequests (list) --
A complex type that contains detailed information about each of the requests in the sample.
(dict) --
Note
This is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.
For the latest version of AWS WAF , use the AWS WAFV2 API and see the AWS WAF Developer Guide . With the latest version, AWS WAF has a single set of endpoints for regional and global use.
The response from a GetSampledRequests request includes a SampledHTTPRequests complex type that appears as SampledRequests in the response syntax. SampledHTTPRequests contains one SampledHTTPRequest object for each web request that is returned by GetSampledRequests .
Request (dict) --
A complex type that contains detailed information about the request.
ClientIP (string) --
The IP address that the request originated from. If the WebACL is associated with a CloudFront distribution, this is the value of one of the following fields in CloudFront access logs:
c-ip , if the viewer did not use an HTTP proxy or a load balancer to send the request
x-forwarded-for , if the viewer did use an HTTP proxy or a load balancer to send the request
Country (string) --
The two-letter country code for the country that the request originated from. For a current list of country codes, see the Wikipedia entry ISO 3166-1 alpha-2 .
URI (string) --
The part of a web request that identifies the resource, for example, /images/daily-ad.jpg .
Method (string) --
The HTTP method specified in the sampled web request. CloudFront supports the following methods: DELETE , GET , HEAD , OPTIONS , PATCH , POST , and PUT .
HTTPVersion (string) --
The HTTP version specified in the sampled web request, for example, HTTP/1.1 .
Headers (list) --
A complex type that contains two values for each header in the sampled web request: the name of the header and the value of the header.
(dict) --
Note
This is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.
For the latest version of AWS WAF , use the AWS WAFV2 API and see the AWS WAF Developer Guide . With the latest version, AWS WAF has a single set of endpoints for regional and global use.
The response from a GetSampledRequests request includes an HTTPHeader complex type that appears as Headers in the response syntax. HTTPHeader contains the names and values of all of the headers that appear in one of the web requests that were returned by GetSampledRequests .
Name (string) --
The name of one of the headers in the sampled web request.
Value (string) --
The value of one of the headers in the sampled web request.
Weight (integer) --
A value that indicates how one result in the response relates proportionally to other results in the response. A result that has a weight of 2 represents roughly twice as many CloudFront web requests as a result that has a weight of 1 .
Timestamp (datetime) --
The time at which AWS WAF received the request from your AWS resource, in Unix time format (in seconds).
Action (string) --
The action for the Rule that the request matched: ALLOW , BLOCK , or COUNT .
RuleWithinRuleGroup (string) --
This value is returned if the GetSampledRequests request specifies the ID of a RuleGroup rather than the ID of an individual rule. RuleWithinRuleGroup is the rule within the specified RuleGroup that matched the request listed in the response.
PopulationSize (integer) --
The total number of requests from which GetSampledRequests got a sample of MaxItems requests. If PopulationSize is less than MaxItems , the sample includes every request that your AWS resource received during the specified time range.
TimeWindow (dict) --
Usually, TimeWindow is the time range that you specified in the GetSampledRequests request. However, if your AWS resource received more than 5,000 requests during the time range that you specified in the request, GetSampledRequests returns the time range for the first 5,000 requests. Times are in Coordinated Universal Time (UTC) format.
StartTime (datetime) --
The beginning of the time range from which you want GetSampledRequests to return a sample of the requests that your AWS resource received. You must specify the date and time in Coordinated Universal Time (UTC) format. UTC format includes the special designator, Z . For example, "2016-09-27T14:50Z" . You can specify any time range in the previous three hours.
EndTime (datetime) --
The end of the time range from which you want GetSampledRequests to return a sample of the requests that your AWS resource received. You must specify the date and time in Coordinated Universal Time (UTC) format. UTC format includes the special designator, Z . For example, "2016-09-27T14:50Z" . You can specify any time range in the previous three hours.
Exceptions
WAFRegional.Client.exceptions.WAFNonexistentItemException
WAFRegional.Client.exceptions.WAFInternalErrorException
Examples
The following example returns detailed information about 100 requests --a sample-- that AWS WAF randomly selects from among the first 5,000 requests that your AWS resource received between the time period 2016-09-27T15:50Z to 2016-09-27T15:50Z.
response = client.get_sampled_requests(
MaxItems=100,
RuleId='WAFRule-1-Example',
TimeWindow={
'EndTime': datetime(2016, 9, 27, 15, 50, 0, 1, 271, 0),
'StartTime': datetime(2016, 9, 27, 15, 50, 0, 1, 271, 0),
},
WebAclId='createwebacl-1472061481310',
)
print(response)
Expected Output:
{
'PopulationSize': 50,
'SampledRequests': [
{
'Action': 'BLOCK',
'Request': {
'ClientIP': '192.0.2.44',
'Country': 'US',
'HTTPVersion': 'HTTP/1.1',
'Headers': [
{
'Name': 'User-Agent',
'Value': 'BadBot ',
},
],
'Method': 'HEAD',
},
'Timestamp': datetime(2016, 9, 27, 14, 55, 0, 1, 271, 0),
'Weight': 1,
},
],
'TimeWindow': {
'EndTime': datetime(2016, 9, 27, 15, 50, 0, 1, 271, 0),
'StartTime': datetime(2016, 9, 27, 14, 50, 0, 1, 271, 0),
},
'ResponseMetadata': {
'...': '...',
},
}
:return: {
'SampledRequests': [
{
'Request': {
'ClientIP': 'string',
'Country': 'string',
'URI': 'string',
'Method': 'string',
'HTTPVersion': 'string',
'Headers': [
{
'Name': 'string',
'Value': 'string'
},
]
},
'Weight': 123,
'Timestamp': datetime(2015, 1, 1),
'Action': 'string',
'RuleWithinRuleGroup': 'string'
},
],
'PopulationSize': 123,
'TimeWindow': {
'StartTime': datetime(2015, 1, 1),
'EndTime': datetime(2015, 1, 1)
}
}
:returns:
c-ip , if the viewer did not use an HTTP proxy or a load balancer to send the request
x-forwarded-for , if the viewer did use an HTTP proxy or a load balancer to send the request
"""
pass
def get_size_constraint_set(SizeConstraintSetId=None):
"""
Returns the SizeConstraintSet specified by SizeConstraintSetId .
See also: AWS API Documentation
Exceptions
Examples
The following example returns the details of a size constraint match set with the ID example1ds3t-46da-4fdb-b8d5-abc321j569j5.
Expected Output:
:example: response = client.get_size_constraint_set(
SizeConstraintSetId='string'
)
:type SizeConstraintSetId: string
:param SizeConstraintSetId: [REQUIRED]\nThe SizeConstraintSetId of the SizeConstraintSet that you want to get. SizeConstraintSetId is returned by CreateSizeConstraintSet and by ListSizeConstraintSets .\n
:rtype: dict
ReturnsResponse Syntax{
'SizeConstraintSet': {
'SizeConstraintSetId': 'string',
'Name': 'string',
'SizeConstraints': [
{
'FieldToMatch': {
'Type': 'URI'|'QUERY_STRING'|'HEADER'|'METHOD'|'BODY'|'SINGLE_QUERY_ARG'|'ALL_QUERY_ARGS',
'Data': 'string'
},
'TextTransformation': 'NONE'|'COMPRESS_WHITE_SPACE'|'HTML_ENTITY_DECODE'|'LOWERCASE'|'CMD_LINE'|'URL_DECODE',
'ComparisonOperator': 'EQ'|'NE'|'LE'|'LT'|'GE'|'GT',
'Size': 123
},
]
}
}
Response Structure
(dict) --
SizeConstraintSet (dict) --Information about the SizeConstraintSet that you specified in the GetSizeConstraintSet request. For more information, see the following topics:
SizeConstraintSet : Contains SizeConstraintSetId , SizeConstraints , and Name
SizeConstraints : Contains an array of SizeConstraint objects. Each SizeConstraint object contains FieldToMatch , TextTransformation , ComparisonOperator , and Size
FieldToMatch : Contains Data and Type
SizeConstraintSetId (string) --A unique identifier for a SizeConstraintSet . You use SizeConstraintSetId to get information about a SizeConstraintSet (see GetSizeConstraintSet ), update a SizeConstraintSet (see UpdateSizeConstraintSet ), insert a SizeConstraintSet into a Rule or delete one from a Rule (see UpdateRule ), and delete a SizeConstraintSet from AWS WAF (see DeleteSizeConstraintSet ).
SizeConstraintSetId is returned by CreateSizeConstraintSet and by ListSizeConstraintSets .
Name (string) --The name, if any, of the SizeConstraintSet .
SizeConstraints (list) --Specifies the parts of web requests that you want to inspect the size of.
(dict) --
Note
This is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.
For the latest version of AWS WAF , use the AWS WAFV2 API and see the AWS WAF Developer Guide . With the latest version, AWS WAF has a single set of endpoints for regional and global use.
Specifies a constraint on the size of a part of the web request. AWS WAF uses the Size , ComparisonOperator , and FieldToMatch to build an expression in the form of "Size ComparisonOperator size in bytes of FieldToMatch ". If that expression is true, the SizeConstraint is considered to match.
FieldToMatch (dict) --Specifies where in a web request to look for the size constraint.
Type (string) --The part of the web request that you want AWS WAF to search for a specified string. Parts of a request that you can search include the following:
HEADER : A specified request header, for example, the value of the User-Agent or Referer header. If you choose HEADER for the type, specify the name of the header in Data .
METHOD : The HTTP method, which indicated the type of operation that the request is asking the origin to perform. Amazon CloudFront supports the following methods: DELETE , GET , HEAD , OPTIONS , PATCH , POST , and PUT .
QUERY_STRING : A query string, which is the part of a URL that appears after a ? character, if any.
URI : The part of a web request that identifies a resource, for example, /images/daily-ad.jpg .
BODY : The part of a request that contains any additional data that you want to send to your web server as the HTTP request body, such as data from a form. The request body immediately follows the request headers. Note that only the first 8192 bytes of the request body are forwarded to AWS WAF for inspection. To allow or block requests based on the length of the body, you can create a size constraint set. For more information, see CreateSizeConstraintSet .
SINGLE_QUERY_ARG : The parameter in the query string that you will inspect, such as UserName or SalesRegion . The maximum length for SINGLE_QUERY_ARG is 30 characters.
ALL_QUERY_ARGS : Similar to SINGLE_QUERY_ARG , but rather than inspecting a single parameter, AWS WAF will inspect all parameters within the query for the value or regex pattern that you specify in TargetString .
Data (string) --When the value of Type is HEADER , enter the name of the header that you want AWS WAF to search, for example, User-Agent or Referer . The name of the header is not case sensitive.
When the value of Type is SINGLE_QUERY_ARG , enter the name of the parameter that you want AWS WAF to search, for example, UserName or SalesRegion . The parameter name is not case sensitive.
If the value of Type is any other value, omit Data .
TextTransformation (string) --Text transformations eliminate some of the unusual formatting that attackers use in web requests in an effort to bypass AWS WAF. If you specify a transformation, AWS WAF performs the transformation on FieldToMatch before inspecting it for a match.
You can only specify a single type of TextTransformation.
Note that if you choose BODY for the value of Type , you must choose NONE for TextTransformation because CloudFront forwards only the first 8192 bytes for inspection.
NONE
Specify NONE if you don\'t want to perform any text transformations.
CMD_LINE
When you\'re concerned that attackers are injecting an operating system command line command and using unusual formatting to disguise some or all of the command, use this option to perform the following transformations:
Delete the following characters: " \' ^
Delete spaces before the following characters: / (
Replace the following characters with a space: , ;
Replace multiple spaces with one space
Convert uppercase letters (A-Z) to lowercase (a-z)
COMPRESS_WHITE_SPACE
Use this option to replace the following characters with a space character (decimal 32):
f, formfeed, decimal 12
t, tab, decimal 9
n, newline, decimal 10
r, carriage return, decimal 13
v, vertical tab, decimal 11
non-breaking space, decimal 160
COMPRESS_WHITE_SPACE also replaces multiple spaces with one space.HTML_ENTITY_DECODE
Use this option to replace HTML-encoded characters with unencoded characters. HTML_ENTITY_DECODE performs the following operations:
Replaces (ampersand)quot; with "
Replaces (ampersand)nbsp; with a non-breaking space, decimal 160
Replaces (ampersand)lt; with a "less than" symbol
Replaces (ampersand)gt; with >
Replaces characters that are represented in hexadecimal format, (ampersand)#xhhhh; , with the corresponding characters
Replaces characters that are represented in decimal format, (ampersand)#nnnn; , with the corresponding characters
LOWERCASE
Use this option to convert uppercase letters (A-Z) to lowercase (a-z).
URL_DECODE
Use this option to decode a URL-encoded value.
ComparisonOperator (string) --The type of comparison you want AWS WAF to perform. AWS WAF uses this in combination with the provided Size and FieldToMatch to build an expression in the form of "Size ComparisonOperator size in bytes of FieldToMatch ". If that expression is true, the SizeConstraint is considered to match.
EQ : Used to test if the Size is equal to the size of the FieldToMatchNE : Used to test if the Size is not equal to the size of the FieldToMatch
LE : Used to test if the Size is less than or equal to the size of the FieldToMatch
LT : Used to test if the Size is strictly less than the size of the FieldToMatch
GE : Used to test if the Size is greater than or equal to the size of the FieldToMatch
GT : Used to test if the Size is strictly greater than the size of the FieldToMatch
Size (integer) --The size in bytes that you want AWS WAF to compare against the size of the specified FieldToMatch . AWS WAF uses this in combination with ComparisonOperator and FieldToMatch to build an expression in the form of "Size ComparisonOperator size in bytes of FieldToMatch ". If that expression is true, the SizeConstraint is considered to match.
Valid values for size are 0 - 21474836480 bytes (0 - 20 GB).
If you specify URI for the value of Type , the / in the URI counts as one character. For example, the URI /logo.jpg is nine characters long.
Exceptions
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidAccountException
WAFRegional.Client.exceptions.WAFNonexistentItemException
Examples
The following example returns the details of a size constraint match set with the ID example1ds3t-46da-4fdb-b8d5-abc321j569j5.
response = client.get_size_constraint_set(
SizeConstraintSetId='example1ds3t-46da-4fdb-b8d5-abc321j569j5',
)
print(response)
Expected Output:
{
'SizeConstraintSet': {
'Name': 'MySampleSizeConstraintSet',
'SizeConstraintSetId': 'example1ds3t-46da-4fdb-b8d5-abc321j569j5',
'SizeConstraints': [
{
'ComparisonOperator': 'GT',
'FieldToMatch': {
'Type': 'QUERY_STRING',
},
'Size': 0,
'TextTransformation': 'NONE',
},
],
},
'ResponseMetadata': {
'...': '...',
},
}
:return: {
'SizeConstraintSet': {
'SizeConstraintSetId': 'string',
'Name': 'string',
'SizeConstraints': [
{
'FieldToMatch': {
'Type': 'URI'|'QUERY_STRING'|'HEADER'|'METHOD'|'BODY'|'SINGLE_QUERY_ARG'|'ALL_QUERY_ARGS',
'Data': 'string'
},
'TextTransformation': 'NONE'|'COMPRESS_WHITE_SPACE'|'HTML_ENTITY_DECODE'|'LOWERCASE'|'CMD_LINE'|'URL_DECODE',
'ComparisonOperator': 'EQ'|'NE'|'LE'|'LT'|'GE'|'GT',
'Size': 123
},
]
}
}
:returns:
HEADER : A specified request header, for example, the value of the User-Agent or Referer header. If you choose HEADER for the type, specify the name of the header in Data .
METHOD : The HTTP method, which indicated the type of operation that the request is asking the origin to perform. Amazon CloudFront supports the following methods: DELETE , GET , HEAD , OPTIONS , PATCH , POST , and PUT .
QUERY_STRING : A query string, which is the part of a URL that appears after a ? character, if any.
URI : The part of a web request that identifies a resource, for example, /images/daily-ad.jpg .
BODY : The part of a request that contains any additional data that you want to send to your web server as the HTTP request body, such as data from a form. The request body immediately follows the request headers. Note that only the first 8192 bytes of the request body are forwarded to AWS WAF for inspection. To allow or block requests based on the length of the body, you can create a size constraint set. For more information, see CreateSizeConstraintSet .
SINGLE_QUERY_ARG : The parameter in the query string that you will inspect, such as UserName or SalesRegion . The maximum length for SINGLE_QUERY_ARG is 30 characters.
ALL_QUERY_ARGS : Similar to SINGLE_QUERY_ARG , but rather than inspecting a single parameter, AWS WAF will inspect all parameters within the query for the value or regex pattern that you specify in TargetString .
"""
pass
def get_sql_injection_match_set(SqlInjectionMatchSetId=None):
"""
Returns the SqlInjectionMatchSet that is specified by SqlInjectionMatchSetId .
See also: AWS API Documentation
Exceptions
Examples
The following example returns the details of a SQL injection match set with the ID example1ds3t-46da-4fdb-b8d5-abc321j569j5.
Expected Output:
:example: response = client.get_sql_injection_match_set(
SqlInjectionMatchSetId='string'
)
:type SqlInjectionMatchSetId: string
:param SqlInjectionMatchSetId: [REQUIRED]\nThe SqlInjectionMatchSetId of the SqlInjectionMatchSet that you want to get. SqlInjectionMatchSetId is returned by CreateSqlInjectionMatchSet and by ListSqlInjectionMatchSets .\n
:rtype: dict
ReturnsResponse Syntax{
'SqlInjectionMatchSet': {
'SqlInjectionMatchSetId': 'string',
'Name': 'string',
'SqlInjectionMatchTuples': [
{
'FieldToMatch': {
'Type': 'URI'|'QUERY_STRING'|'HEADER'|'METHOD'|'BODY'|'SINGLE_QUERY_ARG'|'ALL_QUERY_ARGS',
'Data': 'string'
},
'TextTransformation': 'NONE'|'COMPRESS_WHITE_SPACE'|'HTML_ENTITY_DECODE'|'LOWERCASE'|'CMD_LINE'|'URL_DECODE'
},
]
}
}
Response Structure
(dict) --The response to a GetSqlInjectionMatchSet request.
SqlInjectionMatchSet (dict) --Information about the SqlInjectionMatchSet that you specified in the GetSqlInjectionMatchSet request. For more information, see the following topics:
SqlInjectionMatchSet : Contains Name , SqlInjectionMatchSetId , and an array of SqlInjectionMatchTuple objects
SqlInjectionMatchTuple : Each SqlInjectionMatchTuple object contains FieldToMatch and TextTransformation
FieldToMatch : Contains Data and Type
SqlInjectionMatchSetId (string) --A unique identifier for a SqlInjectionMatchSet . You use SqlInjectionMatchSetId to get information about a SqlInjectionMatchSet (see GetSqlInjectionMatchSet ), update a SqlInjectionMatchSet (see UpdateSqlInjectionMatchSet ), insert a SqlInjectionMatchSet into a Rule or delete one from a Rule (see UpdateRule ), and delete a SqlInjectionMatchSet from AWS WAF (see DeleteSqlInjectionMatchSet ).
SqlInjectionMatchSetId is returned by CreateSqlInjectionMatchSet and by ListSqlInjectionMatchSets .
Name (string) --The name, if any, of the SqlInjectionMatchSet .
SqlInjectionMatchTuples (list) --Specifies the parts of web requests that you want to inspect for snippets of malicious SQL code.
(dict) --
Note
This is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.
For the latest version of AWS WAF , use the AWS WAFV2 API and see the AWS WAF Developer Guide . With the latest version, AWS WAF has a single set of endpoints for regional and global use.
Specifies the part of a web request that you want AWS WAF to inspect for snippets of malicious SQL code and, if you want AWS WAF to inspect a header, the name of the header.
FieldToMatch (dict) --Specifies where in a web request to look for snippets of malicious SQL code.
Type (string) --The part of the web request that you want AWS WAF to search for a specified string. Parts of a request that you can search include the following:
HEADER : A specified request header, for example, the value of the User-Agent or Referer header. If you choose HEADER for the type, specify the name of the header in Data .
METHOD : The HTTP method, which indicated the type of operation that the request is asking the origin to perform. Amazon CloudFront supports the following methods: DELETE , GET , HEAD , OPTIONS , PATCH , POST , and PUT .
QUERY_STRING : A query string, which is the part of a URL that appears after a ? character, if any.
URI : The part of a web request that identifies a resource, for example, /images/daily-ad.jpg .
BODY : The part of a request that contains any additional data that you want to send to your web server as the HTTP request body, such as data from a form. The request body immediately follows the request headers. Note that only the first 8192 bytes of the request body are forwarded to AWS WAF for inspection. To allow or block requests based on the length of the body, you can create a size constraint set. For more information, see CreateSizeConstraintSet .
SINGLE_QUERY_ARG : The parameter in the query string that you will inspect, such as UserName or SalesRegion . The maximum length for SINGLE_QUERY_ARG is 30 characters.
ALL_QUERY_ARGS : Similar to SINGLE_QUERY_ARG , but rather than inspecting a single parameter, AWS WAF will inspect all parameters within the query for the value or regex pattern that you specify in TargetString .
Data (string) --When the value of Type is HEADER , enter the name of the header that you want AWS WAF to search, for example, User-Agent or Referer . The name of the header is not case sensitive.
When the value of Type is SINGLE_QUERY_ARG , enter the name of the parameter that you want AWS WAF to search, for example, UserName or SalesRegion . The parameter name is not case sensitive.
If the value of Type is any other value, omit Data .
TextTransformation (string) --Text transformations eliminate some of the unusual formatting that attackers use in web requests in an effort to bypass AWS WAF. If you specify a transformation, AWS WAF performs the transformation on FieldToMatch before inspecting it for a match.
You can only specify a single type of TextTransformation.
CMD_LINE
When you\'re concerned that attackers are injecting an operating system command line command and using unusual formatting to disguise some or all of the command, use this option to perform the following transformations:
Delete the following characters: " \' ^
Delete spaces before the following characters: / (
Replace the following characters with a space: , ;
Replace multiple spaces with one space
Convert uppercase letters (A-Z) to lowercase (a-z)
COMPRESS_WHITE_SPACE
Use this option to replace the following characters with a space character (decimal 32):
f, formfeed, decimal 12
t, tab, decimal 9
n, newline, decimal 10
r, carriage return, decimal 13
v, vertical tab, decimal 11
non-breaking space, decimal 160
COMPRESS_WHITE_SPACE also replaces multiple spaces with one space.HTML_ENTITY_DECODE
Use this option to replace HTML-encoded characters with unencoded characters. HTML_ENTITY_DECODE performs the following operations:
Replaces (ampersand)quot; with "
Replaces (ampersand)nbsp; with a non-breaking space, decimal 160
Replaces (ampersand)lt; with a "less than" symbol
Replaces (ampersand)gt; with >
Replaces characters that are represented in hexadecimal format, (ampersand)#xhhhh; , with the corresponding characters
Replaces characters that are represented in decimal format, (ampersand)#nnnn; , with the corresponding characters
LOWERCASE
Use this option to convert uppercase letters (A-Z) to lowercase (a-z).
URL_DECODE
Use this option to decode a URL-encoded value.
NONE
Specify NONE if you don\'t want to perform any text transformations.
Exceptions
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidAccountException
WAFRegional.Client.exceptions.WAFNonexistentItemException
Examples
The following example returns the details of a SQL injection match set with the ID example1ds3t-46da-4fdb-b8d5-abc321j569j5.
response = client.get_sql_injection_match_set(
SqlInjectionMatchSetId='example1ds3t-46da-4fdb-b8d5-abc321j569j5',
)
print(response)
Expected Output:
{
'SqlInjectionMatchSet': {
'Name': 'MySQLInjectionMatchSet',
'SqlInjectionMatchSetId': 'example1ds3t-46da-4fdb-b8d5-abc321j569j5',
'SqlInjectionMatchTuples': [
{
'FieldToMatch': {
'Type': 'QUERY_STRING',
},
'TextTransformation': 'URL_DECODE',
},
],
},
'ResponseMetadata': {
'...': '...',
},
}
:return: {
'SqlInjectionMatchSet': {
'SqlInjectionMatchSetId': 'string',
'Name': 'string',
'SqlInjectionMatchTuples': [
{
'FieldToMatch': {
'Type': 'URI'|'QUERY_STRING'|'HEADER'|'METHOD'|'BODY'|'SINGLE_QUERY_ARG'|'ALL_QUERY_ARGS',
'Data': 'string'
},
'TextTransformation': 'NONE'|'COMPRESS_WHITE_SPACE'|'HTML_ENTITY_DECODE'|'LOWERCASE'|'CMD_LINE'|'URL_DECODE'
},
]
}
}
:returns:
HEADER : A specified request header, for example, the value of the User-Agent or Referer header. If you choose HEADER for the type, specify the name of the header in Data .
METHOD : The HTTP method, which indicated the type of operation that the request is asking the origin to perform. Amazon CloudFront supports the following methods: DELETE , GET , HEAD , OPTIONS , PATCH , POST , and PUT .
QUERY_STRING : A query string, which is the part of a URL that appears after a ? character, if any.
URI : The part of a web request that identifies a resource, for example, /images/daily-ad.jpg .
BODY : The part of a request that contains any additional data that you want to send to your web server as the HTTP request body, such as data from a form. The request body immediately follows the request headers. Note that only the first 8192 bytes of the request body are forwarded to AWS WAF for inspection. To allow or block requests based on the length of the body, you can create a size constraint set. For more information, see CreateSizeConstraintSet .
SINGLE_QUERY_ARG : The parameter in the query string that you will inspect, such as UserName or SalesRegion . The maximum length for SINGLE_QUERY_ARG is 30 characters.
ALL_QUERY_ARGS : Similar to SINGLE_QUERY_ARG , but rather than inspecting a single parameter, AWS WAF will inspect all parameters within the query for the value or regex pattern that you specify in TargetString .
"""
pass
def get_waiter(waiter_name=None):
"""
Returns an object that can wait for some condition.
:type waiter_name: str
:param waiter_name: The name of the waiter to get. See the waiters\nsection of the service docs for a list of available waiters.
:rtype: botocore.waiter.Waiter
"""
pass
def get_web_acl(WebACLId=None):
"""
Returns the WebACL that is specified by WebACLId .
See also: AWS API Documentation
Exceptions
Examples
The following example returns the details of a web ACL with the ID createwebacl-1472061481310.
Expected Output:
:example: response = client.get_web_acl(
WebACLId='string'
)
:type WebACLId: string
:param WebACLId: [REQUIRED]\nThe WebACLId of the WebACL that you want to get. WebACLId is returned by CreateWebACL and by ListWebACLs .\n
:rtype: dict
ReturnsResponse Syntax{
'WebACL': {
'WebACLId': 'string',
'Name': 'string',
'MetricName': 'string',
'DefaultAction': {
'Type': 'BLOCK'|'ALLOW'|'COUNT'
},
'Rules': [
{
'Priority': 123,
'RuleId': 'string',
'Action': {
'Type': 'BLOCK'|'ALLOW'|'COUNT'
},
'OverrideAction': {
'Type': 'NONE'|'COUNT'
},
'Type': 'REGULAR'|'RATE_BASED'|'GROUP',
'ExcludedRules': [
{
'RuleId': 'string'
},
]
},
],
'WebACLArn': 'string'
}
}
Response Structure
(dict) --
WebACL (dict) --Information about the WebACL that you specified in the GetWebACL request. For more information, see the following topics:
WebACL : Contains DefaultAction , MetricName , Name , an array of Rule objects, and WebACLId
DefaultAction (Data type is WafAction ): Contains Type
Rules : Contains an array of ActivatedRule objects, which contain Action , Priority , and RuleId
Action : Contains Type
WebACLId (string) --A unique identifier for a WebACL . You use WebACLId to get information about a WebACL (see GetWebACL ), update a WebACL (see UpdateWebACL ), and delete a WebACL from AWS WAF (see DeleteWebACL ).
WebACLId is returned by CreateWebACL and by ListWebACLs .
Name (string) --A friendly name or description of the WebACL . You can\'t change the name of a WebACL after you create it.
MetricName (string) --A friendly name or description for the metrics for this WebACL . The name can contain only alphanumeric characters (A-Z, a-z, 0-9), with maximum length 128 and minimum length one. It can\'t contain whitespace or metric names reserved for AWS WAF, including "All" and "Default_Action." You can\'t change MetricName after you create the WebACL .
DefaultAction (dict) --The action to perform if none of the Rules contained in the WebACL match. The action is specified by the WafAction object.
Type (string) --Specifies how you want AWS WAF to respond to requests that match the settings in a Rule . Valid settings include the following:
ALLOW : AWS WAF allows requests
BLOCK : AWS WAF blocks requests
COUNT : AWS WAF increments a counter of the requests that match all of the conditions in the rule. AWS WAF then continues to inspect the web request based on the remaining rules in the web ACL. You can\'t specify COUNT for the default action for a WebACL .
Rules (list) --An array that contains the action for each Rule in a WebACL , the priority of the Rule , and the ID of the Rule .
(dict) --
Note
This is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.
For the latest version of AWS WAF , use the AWS WAFV2 API and see the AWS WAF Developer Guide . With the latest version, AWS WAF has a single set of endpoints for regional and global use.
The ActivatedRule object in an UpdateWebACL request specifies a Rule that you want to insert or delete, the priority of the Rule in the WebACL , and the action that you want AWS WAF to take when a web request matches the Rule (ALLOW , BLOCK , or COUNT ).
To specify whether to insert or delete a Rule , use the Action parameter in the WebACLUpdate data type.
Priority (integer) --Specifies the order in which the Rules in a WebACL are evaluated. Rules with a lower value for Priority are evaluated before Rules with a higher value. The value must be a unique integer. If you add multiple Rules to a WebACL , the values don\'t need to be consecutive.
RuleId (string) --The RuleId for a Rule . You use RuleId to get more information about a Rule (see GetRule ), update a Rule (see UpdateRule ), insert a Rule into a WebACL or delete a one from a WebACL (see UpdateWebACL ), or delete a Rule from AWS WAF (see DeleteRule ).
RuleId is returned by CreateRule and by ListRules .
Action (dict) --Specifies the action that CloudFront or AWS WAF takes when a web request matches the conditions in the Rule . Valid values for Action include the following:
ALLOW : CloudFront responds with the requested object.
BLOCK : CloudFront responds with an HTTP 403 (Forbidden) status code.
COUNT : AWS WAF increments a counter of requests that match the conditions in the rule and then continues to inspect the web request based on the remaining rules in the web ACL.
ActivatedRule|OverrideAction applies only when updating or adding a RuleGroup to a WebACL . In this case, you do not use ActivatedRule|Action . For all other update requests, ActivatedRule|Action is used instead of ActivatedRule|OverrideAction .
Type (string) --Specifies how you want AWS WAF to respond to requests that match the settings in a Rule . Valid settings include the following:
ALLOW : AWS WAF allows requests
BLOCK : AWS WAF blocks requests
COUNT : AWS WAF increments a counter of the requests that match all of the conditions in the rule. AWS WAF then continues to inspect the web request based on the remaining rules in the web ACL. You can\'t specify COUNT for the default action for a WebACL .
OverrideAction (dict) --Use the OverrideAction to test your RuleGroup .
Any rule in a RuleGroup can potentially block a request. If you set the OverrideAction to None , the RuleGroup will block a request if any individual rule in the RuleGroup matches the request and is configured to block that request. However if you first want to test the RuleGroup , set the OverrideAction to Count . The RuleGroup will then override any block action specified by individual rules contained within the group. Instead of blocking matching requests, those requests will be counted. You can view a record of counted requests using GetSampledRequests .
ActivatedRule|OverrideAction applies only when updating or adding a RuleGroup to a WebACL . In this case you do not use ActivatedRule|Action . For all other update requests, ActivatedRule|Action is used instead of ActivatedRule|OverrideAction .
Type (string) --
COUNT overrides the action specified by the individual rule within a RuleGroup . If set to NONE , the rule\'s action will take place.
Type (string) --The rule type, either REGULAR , as defined by Rule , RATE_BASED , as defined by RateBasedRule , or GROUP , as defined by RuleGroup . The default is REGULAR. Although this field is optional, be aware that if you try to add a RATE_BASED rule to a web ACL without setting the type, the UpdateWebACL request will fail because the request tries to add a REGULAR rule with the specified ID, which does not exist.
ExcludedRules (list) --An array of rules to exclude from a rule group. This is applicable only when the ActivatedRule refers to a RuleGroup .
Sometimes it is necessary to troubleshoot rule groups that are blocking traffic unexpectedly (false positives). One troubleshooting technique is to identify the specific rule within the rule group that is blocking the legitimate traffic and then disable (exclude) that particular rule. You can exclude rules from both your own rule groups and AWS Marketplace rule groups that have been associated with a web ACL.
Specifying ExcludedRules does not remove those rules from the rule group. Rather, it changes the action for the rules to COUNT . Therefore, requests that match an ExcludedRule are counted but not blocked. The RuleGroup owner will receive COUNT metrics for each ExcludedRule .
If you want to exclude rules from a rule group that is already associated with a web ACL, perform the following steps:
Use the AWS WAF logs to identify the IDs of the rules that you want to exclude. For more information about the logs, see Logging Web ACL Traffic Information .
Submit an UpdateWebACL request that has two actions:
The first action deletes the existing rule group from the web ACL. That is, in the UpdateWebACL request, the first Updates:Action should be DELETE and Updates:ActivatedRule:RuleId should be the rule group that contains the rules that you want to exclude.
The second action inserts the same rule group back in, but specifying the rules to exclude. That is, the second Updates:Action should be INSERT , Updates:ActivatedRule:RuleId should be the rule group that you just removed, and ExcludedRules should contain the rules that you want to exclude.
(dict) --
Note
This is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.
For the latest version of AWS WAF , use the AWS WAFV2 API and see the AWS WAF Developer Guide . With the latest version, AWS WAF has a single set of endpoints for regional and global use.
The rule to exclude from a rule group. This is applicable only when the ActivatedRule refers to a RuleGroup . The rule must belong to the RuleGroup that is specified by the ActivatedRule .
RuleId (string) --The unique identifier for the rule to exclude from the rule group.
WebACLArn (string) --Tha Amazon Resource Name (ARN) of the web ACL.
Exceptions
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidAccountException
WAFRegional.Client.exceptions.WAFNonexistentItemException
Examples
The following example returns the details of a web ACL with the ID createwebacl-1472061481310.
response = client.get_web_acl(
WebACLId='createwebacl-1472061481310',
)
print(response)
Expected Output:
{
'WebACL': {
'DefaultAction': {
'Type': 'ALLOW',
},
'MetricName': 'CreateExample',
'Name': 'CreateExample',
'Rules': [
{
'Action': {
'Type': 'ALLOW',
},
'Priority': 1,
'RuleId': 'WAFRule-1-Example',
},
],
'WebACLId': 'createwebacl-1472061481310',
},
'ResponseMetadata': {
'...': '...',
},
}
:return: {
'WebACL': {
'WebACLId': 'string',
'Name': 'string',
'MetricName': 'string',
'DefaultAction': {
'Type': 'BLOCK'|'ALLOW'|'COUNT'
},
'Rules': [
{
'Priority': 123,
'RuleId': 'string',
'Action': {
'Type': 'BLOCK'|'ALLOW'|'COUNT'
},
'OverrideAction': {
'Type': 'NONE'|'COUNT'
},
'Type': 'REGULAR'|'RATE_BASED'|'GROUP',
'ExcludedRules': [
{
'RuleId': 'string'
},
]
},
],
'WebACLArn': 'string'
}
}
:returns:
ALLOW : AWS WAF allows requests
BLOCK : AWS WAF blocks requests
COUNT : AWS WAF increments a counter of the requests that match all of the conditions in the rule. AWS WAF then continues to inspect the web request based on the remaining rules in the web ACL. You can\'t specify COUNT for the default action for a WebACL .
"""
pass
def get_web_acl_for_resource(ResourceArn=None):
"""
Returns the web ACL for the specified resource, either an application load balancer or Amazon API Gateway stage.
See also: AWS API Documentation
Exceptions
:example: response = client.get_web_acl_for_resource(
ResourceArn='string'
)
:type ResourceArn: string
:param ResourceArn: [REQUIRED]\nThe ARN (Amazon Resource Name) of the resource for which to get the web ACL, either an application load balancer or Amazon API Gateway stage.\nThe ARN should be in one of the following formats:\n\nFor an Application Load Balancer: ``arn:aws:elasticloadbalancing:region :account-id :loadbalancer/app/load-balancer-name /load-balancer-id ``\nFor an Amazon API Gateway stage: ``arn:aws:apigateway:region ::/restapis/api-id /stages/stage-name ``\n\n
:rtype: dict
ReturnsResponse Syntax{
'WebACLSummary': {
'WebACLId': 'string',
'Name': 'string'
}
}
Response Structure
(dict) --
WebACLSummary (dict) --Information about the web ACL that you specified in the GetWebACLForResource request. If there is no associated resource, a null WebACLSummary is returned.
WebACLId (string) --A unique identifier for a WebACL . You use WebACLId to get information about a WebACL (see GetWebACL ), update a WebACL (see UpdateWebACL ), and delete a WebACL from AWS WAF (see DeleteWebACL ).
WebACLId is returned by CreateWebACL and by ListWebACLs .
Name (string) --A friendly name or description of the WebACL . You can\'t change the name of a WebACL after you create it.
Exceptions
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidAccountException
WAFRegional.Client.exceptions.WAFNonexistentItemException
WAFRegional.Client.exceptions.WAFInvalidParameterException
WAFRegional.Client.exceptions.WAFUnavailableEntityException
:return: {
'WebACLSummary': {
'WebACLId': 'string',
'Name': 'string'
}
}
:returns:
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidAccountException
WAFRegional.Client.exceptions.WAFNonexistentItemException
WAFRegional.Client.exceptions.WAFInvalidParameterException
WAFRegional.Client.exceptions.WAFUnavailableEntityException
"""
pass
def get_xss_match_set(XssMatchSetId=None):
"""
Returns the XssMatchSet that is specified by XssMatchSetId .
See also: AWS API Documentation
Exceptions
Examples
The following example returns the details of an XSS match set with the ID example1ds3t-46da-4fdb-b8d5-abc321j569j5.
Expected Output:
:example: response = client.get_xss_match_set(
XssMatchSetId='string'
)
:type XssMatchSetId: string
:param XssMatchSetId: [REQUIRED]\nThe XssMatchSetId of the XssMatchSet that you want to get. XssMatchSetId is returned by CreateXssMatchSet and by ListXssMatchSets .\n
:rtype: dict
ReturnsResponse Syntax{
'XssMatchSet': {
'XssMatchSetId': 'string',
'Name': 'string',
'XssMatchTuples': [
{
'FieldToMatch': {
'Type': 'URI'|'QUERY_STRING'|'HEADER'|'METHOD'|'BODY'|'SINGLE_QUERY_ARG'|'ALL_QUERY_ARGS',
'Data': 'string'
},
'TextTransformation': 'NONE'|'COMPRESS_WHITE_SPACE'|'HTML_ENTITY_DECODE'|'LOWERCASE'|'CMD_LINE'|'URL_DECODE'
},
]
}
}
Response Structure
(dict) --The response to a GetXssMatchSet request.
XssMatchSet (dict) --Information about the XssMatchSet that you specified in the GetXssMatchSet request. For more information, see the following topics:
XssMatchSet : Contains Name , XssMatchSetId , and an array of XssMatchTuple objects
XssMatchTuple : Each XssMatchTuple object contains FieldToMatch and TextTransformation
FieldToMatch : Contains Data and Type
XssMatchSetId (string) --A unique identifier for an XssMatchSet . You use XssMatchSetId to get information about an XssMatchSet (see GetXssMatchSet ), update an XssMatchSet (see UpdateXssMatchSet ), insert an XssMatchSet into a Rule or delete one from a Rule (see UpdateRule ), and delete an XssMatchSet from AWS WAF (see DeleteXssMatchSet ).
XssMatchSetId is returned by CreateXssMatchSet and by ListXssMatchSets .
Name (string) --The name, if any, of the XssMatchSet .
XssMatchTuples (list) --Specifies the parts of web requests that you want to inspect for cross-site scripting attacks.
(dict) --
Note
This is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.
For the latest version of AWS WAF , use the AWS WAFV2 API and see the AWS WAF Developer Guide . With the latest version, AWS WAF has a single set of endpoints for regional and global use.
Specifies the part of a web request that you want AWS WAF to inspect for cross-site scripting attacks and, if you want AWS WAF to inspect a header, the name of the header.
FieldToMatch (dict) --Specifies where in a web request to look for cross-site scripting attacks.
Type (string) --The part of the web request that you want AWS WAF to search for a specified string. Parts of a request that you can search include the following:
HEADER : A specified request header, for example, the value of the User-Agent or Referer header. If you choose HEADER for the type, specify the name of the header in Data .
METHOD : The HTTP method, which indicated the type of operation that the request is asking the origin to perform. Amazon CloudFront supports the following methods: DELETE , GET , HEAD , OPTIONS , PATCH , POST , and PUT .
QUERY_STRING : A query string, which is the part of a URL that appears after a ? character, if any.
URI : The part of a web request that identifies a resource, for example, /images/daily-ad.jpg .
BODY : The part of a request that contains any additional data that you want to send to your web server as the HTTP request body, such as data from a form. The request body immediately follows the request headers. Note that only the first 8192 bytes of the request body are forwarded to AWS WAF for inspection. To allow or block requests based on the length of the body, you can create a size constraint set. For more information, see CreateSizeConstraintSet .
SINGLE_QUERY_ARG : The parameter in the query string that you will inspect, such as UserName or SalesRegion . The maximum length for SINGLE_QUERY_ARG is 30 characters.
ALL_QUERY_ARGS : Similar to SINGLE_QUERY_ARG , but rather than inspecting a single parameter, AWS WAF will inspect all parameters within the query for the value or regex pattern that you specify in TargetString .
Data (string) --When the value of Type is HEADER , enter the name of the header that you want AWS WAF to search, for example, User-Agent or Referer . The name of the header is not case sensitive.
When the value of Type is SINGLE_QUERY_ARG , enter the name of the parameter that you want AWS WAF to search, for example, UserName or SalesRegion . The parameter name is not case sensitive.
If the value of Type is any other value, omit Data .
TextTransformation (string) --Text transformations eliminate some of the unusual formatting that attackers use in web requests in an effort to bypass AWS WAF. If you specify a transformation, AWS WAF performs the transformation on FieldToMatch before inspecting it for a match.
You can only specify a single type of TextTransformation.
CMD_LINE
When you\'re concerned that attackers are injecting an operating system command line command and using unusual formatting to disguise some or all of the command, use this option to perform the following transformations:
Delete the following characters: " \' ^
Delete spaces before the following characters: / (
Replace the following characters with a space: , ;
Replace multiple spaces with one space
Convert uppercase letters (A-Z) to lowercase (a-z)
COMPRESS_WHITE_SPACE
Use this option to replace the following characters with a space character (decimal 32):
f, formfeed, decimal 12
t, tab, decimal 9
n, newline, decimal 10
r, carriage return, decimal 13
v, vertical tab, decimal 11
non-breaking space, decimal 160
COMPRESS_WHITE_SPACE also replaces multiple spaces with one space.HTML_ENTITY_DECODE
Use this option to replace HTML-encoded characters with unencoded characters. HTML_ENTITY_DECODE performs the following operations:
Replaces (ampersand)quot; with "
Replaces (ampersand)nbsp; with a non-breaking space, decimal 160
Replaces (ampersand)lt; with a "less than" symbol
Replaces (ampersand)gt; with >
Replaces characters that are represented in hexadecimal format, (ampersand)#xhhhh; , with the corresponding characters
Replaces characters that are represented in decimal format, (ampersand)#nnnn; , with the corresponding characters
LOWERCASE
Use this option to convert uppercase letters (A-Z) to lowercase (a-z).
URL_DECODE
Use this option to decode a URL-encoded value.
NONE
Specify NONE if you don\'t want to perform any text transformations.
Exceptions
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidAccountException
WAFRegional.Client.exceptions.WAFNonexistentItemException
Examples
The following example returns the details of an XSS match set with the ID example1ds3t-46da-4fdb-b8d5-abc321j569j5.
response = client.get_xss_match_set(
XssMatchSetId='example1ds3t-46da-4fdb-b8d5-abc321j569j5',
)
print(response)
Expected Output:
{
'XssMatchSet': {
'Name': 'MySampleXssMatchSet',
'XssMatchSetId': 'example1ds3t-46da-4fdb-b8d5-abc321j569j5',
'XssMatchTuples': [
{
'FieldToMatch': {
'Type': 'QUERY_STRING',
},
'TextTransformation': 'URL_DECODE',
},
],
},
'ResponseMetadata': {
'...': '...',
},
}
:return: {
'XssMatchSet': {
'XssMatchSetId': 'string',
'Name': 'string',
'XssMatchTuples': [
{
'FieldToMatch': {
'Type': 'URI'|'QUERY_STRING'|'HEADER'|'METHOD'|'BODY'|'SINGLE_QUERY_ARG'|'ALL_QUERY_ARGS',
'Data': 'string'
},
'TextTransformation': 'NONE'|'COMPRESS_WHITE_SPACE'|'HTML_ENTITY_DECODE'|'LOWERCASE'|'CMD_LINE'|'URL_DECODE'
},
]
}
}
:returns:
HEADER : A specified request header, for example, the value of the User-Agent or Referer header. If you choose HEADER for the type, specify the name of the header in Data .
METHOD : The HTTP method, which indicated the type of operation that the request is asking the origin to perform. Amazon CloudFront supports the following methods: DELETE , GET , HEAD , OPTIONS , PATCH , POST , and PUT .
QUERY_STRING : A query string, which is the part of a URL that appears after a ? character, if any.
URI : The part of a web request that identifies a resource, for example, /images/daily-ad.jpg .
BODY : The part of a request that contains any additional data that you want to send to your web server as the HTTP request body, such as data from a form. The request body immediately follows the request headers. Note that only the first 8192 bytes of the request body are forwarded to AWS WAF for inspection. To allow or block requests based on the length of the body, you can create a size constraint set. For more information, see CreateSizeConstraintSet .
SINGLE_QUERY_ARG : The parameter in the query string that you will inspect, such as UserName or SalesRegion . The maximum length for SINGLE_QUERY_ARG is 30 characters.
ALL_QUERY_ARGS : Similar to SINGLE_QUERY_ARG , but rather than inspecting a single parameter, AWS WAF will inspect all parameters within the query for the value or regex pattern that you specify in TargetString .
"""
pass
def list_activated_rules_in_rule_group(RuleGroupId=None, NextMarker=None, Limit=None):
"""
Returns an array of ActivatedRule objects.
See also: AWS API Documentation
Exceptions
:example: response = client.list_activated_rules_in_rule_group(
RuleGroupId='string',
NextMarker='string',
Limit=123
)
:type RuleGroupId: string
:param RuleGroupId: The RuleGroupId of the RuleGroup for which you want to get a list of ActivatedRule objects.
:type NextMarker: string
:param NextMarker: If you specify a value for Limit and you have more ActivatedRules than the value of Limit , AWS WAF returns a NextMarker value in the response that allows you to list another group of ActivatedRules . For the second and subsequent ListActivatedRulesInRuleGroup requests, specify the value of NextMarker from the previous response to get information about another batch of ActivatedRules .
:type Limit: integer
:param Limit: Specifies the number of ActivatedRules that you want AWS WAF to return for this request. If you have more ActivatedRules than the number that you specify for Limit , the response includes a NextMarker value that you can use to get another batch of ActivatedRules .
:rtype: dict
ReturnsResponse Syntax
{
'NextMarker': 'string',
'ActivatedRules': [
{
'Priority': 123,
'RuleId': 'string',
'Action': {
'Type': 'BLOCK'|'ALLOW'|'COUNT'
},
'OverrideAction': {
'Type': 'NONE'|'COUNT'
},
'Type': 'REGULAR'|'RATE_BASED'|'GROUP',
'ExcludedRules': [
{
'RuleId': 'string'
},
]
},
]
}
Response Structure
(dict) --
NextMarker (string) --
If you have more ActivatedRules than the number that you specified for Limit in the request, the response includes a NextMarker value. To list more ActivatedRules , submit another ListActivatedRulesInRuleGroup request, and specify the NextMarker value from the response in the NextMarker value in the next request.
ActivatedRules (list) --
An array of ActivatedRules objects.
(dict) --
Note
This is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.
For the latest version of AWS WAF , use the AWS WAFV2 API and see the AWS WAF Developer Guide . With the latest version, AWS WAF has a single set of endpoints for regional and global use.
The ActivatedRule object in an UpdateWebACL request specifies a Rule that you want to insert or delete, the priority of the Rule in the WebACL , and the action that you want AWS WAF to take when a web request matches the Rule (ALLOW , BLOCK , or COUNT ).
To specify whether to insert or delete a Rule , use the Action parameter in the WebACLUpdate data type.
Priority (integer) --
Specifies the order in which the Rules in a WebACL are evaluated. Rules with a lower value for Priority are evaluated before Rules with a higher value. The value must be a unique integer. If you add multiple Rules to a WebACL , the values don\'t need to be consecutive.
RuleId (string) --
The RuleId for a Rule . You use RuleId to get more information about a Rule (see GetRule ), update a Rule (see UpdateRule ), insert a Rule into a WebACL or delete a one from a WebACL (see UpdateWebACL ), or delete a Rule from AWS WAF (see DeleteRule ).
RuleId is returned by CreateRule and by ListRules .
Action (dict) --
Specifies the action that CloudFront or AWS WAF takes when a web request matches the conditions in the Rule . Valid values for Action include the following:
ALLOW : CloudFront responds with the requested object.
BLOCK : CloudFront responds with an HTTP 403 (Forbidden) status code.
COUNT : AWS WAF increments a counter of requests that match the conditions in the rule and then continues to inspect the web request based on the remaining rules in the web ACL.
ActivatedRule|OverrideAction applies only when updating or adding a RuleGroup to a WebACL . In this case, you do not use ActivatedRule|Action . For all other update requests, ActivatedRule|Action is used instead of ActivatedRule|OverrideAction .
Type (string) --
Specifies how you want AWS WAF to respond to requests that match the settings in a Rule . Valid settings include the following:
ALLOW : AWS WAF allows requests
BLOCK : AWS WAF blocks requests
COUNT : AWS WAF increments a counter of the requests that match all of the conditions in the rule. AWS WAF then continues to inspect the web request based on the remaining rules in the web ACL. You can\'t specify COUNT for the default action for a WebACL .
OverrideAction (dict) --
Use the OverrideAction to test your RuleGroup .
Any rule in a RuleGroup can potentially block a request. If you set the OverrideAction to None , the RuleGroup will block a request if any individual rule in the RuleGroup matches the request and is configured to block that request. However if you first want to test the RuleGroup , set the OverrideAction to Count . The RuleGroup will then override any block action specified by individual rules contained within the group. Instead of blocking matching requests, those requests will be counted. You can view a record of counted requests using GetSampledRequests .
ActivatedRule|OverrideAction applies only when updating or adding a RuleGroup to a WebACL . In this case you do not use ActivatedRule|Action . For all other update requests, ActivatedRule|Action is used instead of ActivatedRule|OverrideAction .
Type (string) --
COUNT overrides the action specified by the individual rule within a RuleGroup . If set to NONE , the rule\'s action will take place.
Type (string) --
The rule type, either REGULAR , as defined by Rule , RATE_BASED , as defined by RateBasedRule , or GROUP , as defined by RuleGroup . The default is REGULAR. Although this field is optional, be aware that if you try to add a RATE_BASED rule to a web ACL without setting the type, the UpdateWebACL request will fail because the request tries to add a REGULAR rule with the specified ID, which does not exist.
ExcludedRules (list) --
An array of rules to exclude from a rule group. This is applicable only when the ActivatedRule refers to a RuleGroup .
Sometimes it is necessary to troubleshoot rule groups that are blocking traffic unexpectedly (false positives). One troubleshooting technique is to identify the specific rule within the rule group that is blocking the legitimate traffic and then disable (exclude) that particular rule. You can exclude rules from both your own rule groups and AWS Marketplace rule groups that have been associated with a web ACL.
Specifying ExcludedRules does not remove those rules from the rule group. Rather, it changes the action for the rules to COUNT . Therefore, requests that match an ExcludedRule are counted but not blocked. The RuleGroup owner will receive COUNT metrics for each ExcludedRule .
If you want to exclude rules from a rule group that is already associated with a web ACL, perform the following steps:
Use the AWS WAF logs to identify the IDs of the rules that you want to exclude. For more information about the logs, see Logging Web ACL Traffic Information .
Submit an UpdateWebACL request that has two actions:
The first action deletes the existing rule group from the web ACL. That is, in the UpdateWebACL request, the first Updates:Action should be DELETE and Updates:ActivatedRule:RuleId should be the rule group that contains the rules that you want to exclude.
The second action inserts the same rule group back in, but specifying the rules to exclude. That is, the second Updates:Action should be INSERT , Updates:ActivatedRule:RuleId should be the rule group that you just removed, and ExcludedRules should contain the rules that you want to exclude.
(dict) --
Note
This is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.
For the latest version of AWS WAF , use the AWS WAFV2 API and see the AWS WAF Developer Guide . With the latest version, AWS WAF has a single set of endpoints for regional and global use.
The rule to exclude from a rule group. This is applicable only when the ActivatedRule refers to a RuleGroup . The rule must belong to the RuleGroup that is specified by the ActivatedRule .
RuleId (string) --
The unique identifier for the rule to exclude from the rule group.
Exceptions
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFNonexistentItemException
WAFRegional.Client.exceptions.WAFInvalidParameterException
:return: {
'NextMarker': 'string',
'ActivatedRules': [
{
'Priority': 123,
'RuleId': 'string',
'Action': {
'Type': 'BLOCK'|'ALLOW'|'COUNT'
},
'OverrideAction': {
'Type': 'NONE'|'COUNT'
},
'Type': 'REGULAR'|'RATE_BASED'|'GROUP',
'ExcludedRules': [
{
'RuleId': 'string'
},
]
},
]
}
:returns:
ALLOW : CloudFront responds with the requested object.
BLOCK : CloudFront responds with an HTTP 403 (Forbidden) status code.
COUNT : AWS WAF increments a counter of requests that match the conditions in the rule and then continues to inspect the web request based on the remaining rules in the web ACL.
"""
pass
def list_byte_match_sets(NextMarker=None, Limit=None):
"""
Returns an array of ByteMatchSetSummary objects.
See also: AWS API Documentation
Exceptions
:example: response = client.list_byte_match_sets(
NextMarker='string',
Limit=123
)
:type NextMarker: string
:param NextMarker: If you specify a value for Limit and you have more ByteMatchSets than the value of Limit , AWS WAF returns a NextMarker value in the response that allows you to list another group of ByteMatchSets . For the second and subsequent ListByteMatchSets requests, specify the value of NextMarker from the previous response to get information about another batch of ByteMatchSets .
:type Limit: integer
:param Limit: Specifies the number of ByteMatchSet objects that you want AWS WAF to return for this request. If you have more ByteMatchSets objects than the number you specify for Limit , the response includes a NextMarker value that you can use to get another batch of ByteMatchSet objects.
:rtype: dict
ReturnsResponse Syntax
{
'NextMarker': 'string',
'ByteMatchSets': [
{
'ByteMatchSetId': 'string',
'Name': 'string'
},
]
}
Response Structure
(dict) --
NextMarker (string) --
If you have more ByteMatchSet objects than the number that you specified for Limit in the request, the response includes a NextMarker value. To list more ByteMatchSet objects, submit another ListByteMatchSets request, and specify the NextMarker value from the response in the NextMarker value in the next request.
ByteMatchSets (list) --
An array of ByteMatchSetSummary objects.
(dict) --
Note
This is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.
For the latest version of AWS WAF , use the AWS WAFV2 API and see the AWS WAF Developer Guide . With the latest version, AWS WAF has a single set of endpoints for regional and global use.
Returned by ListByteMatchSets . Each ByteMatchSetSummary object includes the Name and ByteMatchSetId for one ByteMatchSet .
ByteMatchSetId (string) --
The ByteMatchSetId for a ByteMatchSet . You use ByteMatchSetId to get information about a ByteMatchSet , update a ByteMatchSet , remove a ByteMatchSet from a Rule , and delete a ByteMatchSet from AWS WAF.
ByteMatchSetId is returned by CreateByteMatchSet and by ListByteMatchSets .
Name (string) --
A friendly name or description of the ByteMatchSet . You can\'t change Name after you create a ByteMatchSet .
Exceptions
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidAccountException
:return: {
'NextMarker': 'string',
'ByteMatchSets': [
{
'ByteMatchSetId': 'string',
'Name': 'string'
},
]
}
:returns:
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidAccountException
"""
pass
def list_geo_match_sets(NextMarker=None, Limit=None):
"""
Returns an array of GeoMatchSetSummary objects in the response.
See also: AWS API Documentation
Exceptions
:example: response = client.list_geo_match_sets(
NextMarker='string',
Limit=123
)
:type NextMarker: string
:param NextMarker: If you specify a value for Limit and you have more GeoMatchSet s than the value of Limit , AWS WAF returns a NextMarker value in the response that allows you to list another group of GeoMatchSet objects. For the second and subsequent ListGeoMatchSets requests, specify the value of NextMarker from the previous response to get information about another batch of GeoMatchSet objects.
:type Limit: integer
:param Limit: Specifies the number of GeoMatchSet objects that you want AWS WAF to return for this request. If you have more GeoMatchSet objects than the number you specify for Limit , the response includes a NextMarker value that you can use to get another batch of GeoMatchSet objects.
:rtype: dict
ReturnsResponse Syntax
{
'NextMarker': 'string',
'GeoMatchSets': [
{
'GeoMatchSetId': 'string',
'Name': 'string'
},
]
}
Response Structure
(dict) --
NextMarker (string) --
If you have more GeoMatchSet objects than the number that you specified for Limit in the request, the response includes a NextMarker value. To list more GeoMatchSet objects, submit another ListGeoMatchSets request, and specify the NextMarker value from the response in the NextMarker value in the next request.
GeoMatchSets (list) --
An array of GeoMatchSetSummary objects.
(dict) --
Note
This is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.
For the latest version of AWS WAF , use the AWS WAFV2 API and see the AWS WAF Developer Guide . With the latest version, AWS WAF has a single set of endpoints for regional and global use.
Contains the identifier and the name of the GeoMatchSet .
GeoMatchSetId (string) --
The GeoMatchSetId for an GeoMatchSet . You can use GeoMatchSetId in a GetGeoMatchSet request to get detailed information about an GeoMatchSet .
Name (string) --
A friendly name or description of the GeoMatchSet . You can\'t change the name of an GeoMatchSet after you create it.
Exceptions
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidAccountException
:return: {
'NextMarker': 'string',
'GeoMatchSets': [
{
'GeoMatchSetId': 'string',
'Name': 'string'
},
]
}
:returns:
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidAccountException
"""
pass
def list_ip_sets(NextMarker=None, Limit=None):
"""
Returns an array of IPSetSummary objects in the response.
See also: AWS API Documentation
Exceptions
Examples
The following example returns an array of up to 100 IP match sets.
Expected Output:
:example: response = client.list_ip_sets(
NextMarker='string',
Limit=123
)
:type NextMarker: string
:param NextMarker: AWS WAF returns a NextMarker value in the response that allows you to list another group of IPSets . For the second and subsequent ListIPSets requests, specify the value of NextMarker from the previous response to get information about another batch of IPSets .
:type Limit: integer
:param Limit: Specifies the number of IPSet objects that you want AWS WAF to return for this request. If you have more IPSet objects than the number you specify for Limit , the response includes a NextMarker value that you can use to get another batch of IPSet objects.
:rtype: dict
ReturnsResponse Syntax
{
'NextMarker': 'string',
'IPSets': [
{
'IPSetId': 'string',
'Name': 'string'
},
]
}
Response Structure
(dict) --
NextMarker (string) --
To list more IPSet objects, submit another ListIPSets request, and in the next request use the NextMarker response value as the NextMarker value.
IPSets (list) --
An array of IPSetSummary objects.
(dict) --
Note
This is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.
For the latest version of AWS WAF , use the AWS WAFV2 API and see the AWS WAF Developer Guide . With the latest version, AWS WAF has a single set of endpoints for regional and global use.
Contains the identifier and the name of the IPSet .
IPSetId (string) --
The IPSetId for an IPSet . You can use IPSetId in a GetIPSet request to get detailed information about an IPSet .
Name (string) --
A friendly name or description of the IPSet . You can\'t change the name of an IPSet after you create it.
Exceptions
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidAccountException
Examples
The following example returns an array of up to 100 IP match sets.
response = client.list_ip_sets(
Limit=100,
)
print(response)
Expected Output:
{
'IPSets': [
{
'IPSetId': 'abcd12f2-46da-4fdb-b8d5-fbd4c466928f',
'Name': 'MyIPSetFriendlyName',
},
],
'ResponseMetadata': {
'...': '...',
},
}
:return: {
'NextMarker': 'string',
'IPSets': [
{
'IPSetId': 'string',
'Name': 'string'
},
]
}
:returns:
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidAccountException
"""
pass
def list_logging_configurations(NextMarker=None, Limit=None):
"""
Returns an array of LoggingConfiguration objects.
See also: AWS API Documentation
Exceptions
:example: response = client.list_logging_configurations(
NextMarker='string',
Limit=123
)
:type NextMarker: string
:param NextMarker: If you specify a value for Limit and you have more LoggingConfigurations than the value of Limit , AWS WAF returns a NextMarker value in the response that allows you to list another group of LoggingConfigurations . For the second and subsequent ListLoggingConfigurations requests, specify the value of NextMarker from the previous response to get information about another batch of ListLoggingConfigurations .
:type Limit: integer
:param Limit: Specifies the number of LoggingConfigurations that you want AWS WAF to return for this request. If you have more LoggingConfigurations than the number that you specify for Limit , the response includes a NextMarker value that you can use to get another batch of LoggingConfigurations .
:rtype: dict
ReturnsResponse Syntax
{
'LoggingConfigurations': [
{
'ResourceArn': 'string',
'LogDestinationConfigs': [
'string',
],
'RedactedFields': [
{
'Type': 'URI'|'QUERY_STRING'|'HEADER'|'METHOD'|'BODY'|'SINGLE_QUERY_ARG'|'ALL_QUERY_ARGS',
'Data': 'string'
},
]
},
],
'NextMarker': 'string'
}
Response Structure
(dict) --
LoggingConfigurations (list) --
An array of LoggingConfiguration objects.
(dict) --
Note
This is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.
For the latest version of AWS WAF , use the AWS WAFV2 API and see the AWS WAF Developer Guide . With the latest version, AWS WAF has a single set of endpoints for regional and global use.
The Amazon Kinesis Data Firehose, RedactedFields information, and the web ACL Amazon Resource Name (ARN).
ResourceArn (string) --
The Amazon Resource Name (ARN) of the web ACL that you want to associate with LogDestinationConfigs .
LogDestinationConfigs (list) --
An array of Amazon Kinesis Data Firehose ARNs.
(string) --
RedactedFields (list) --
The parts of the request that you want redacted from the logs. For example, if you redact the cookie field, the cookie field in the firehose will be xxx .
(dict) --
Note
This is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.
For the latest version of AWS WAF , use the AWS WAFV2 API and see the AWS WAF Developer Guide . With the latest version, AWS WAF has a single set of endpoints for regional and global use.
Specifies where in a web request to look for TargetString .
Type (string) --
The part of the web request that you want AWS WAF to search for a specified string. Parts of a request that you can search include the following:
HEADER : A specified request header, for example, the value of the User-Agent or Referer header. If you choose HEADER for the type, specify the name of the header in Data .
METHOD : The HTTP method, which indicated the type of operation that the request is asking the origin to perform. Amazon CloudFront supports the following methods: DELETE , GET , HEAD , OPTIONS , PATCH , POST , and PUT .
QUERY_STRING : A query string, which is the part of a URL that appears after a ? character, if any.
URI : The part of a web request that identifies a resource, for example, /images/daily-ad.jpg .
BODY : The part of a request that contains any additional data that you want to send to your web server as the HTTP request body, such as data from a form. The request body immediately follows the request headers. Note that only the first 8192 bytes of the request body are forwarded to AWS WAF for inspection. To allow or block requests based on the length of the body, you can create a size constraint set. For more information, see CreateSizeConstraintSet .
SINGLE_QUERY_ARG : The parameter in the query string that you will inspect, such as UserName or SalesRegion . The maximum length for SINGLE_QUERY_ARG is 30 characters.
ALL_QUERY_ARGS : Similar to SINGLE_QUERY_ARG , but rather than inspecting a single parameter, AWS WAF will inspect all parameters within the query for the value or regex pattern that you specify in TargetString .
Data (string) --
When the value of Type is HEADER , enter the name of the header that you want AWS WAF to search, for example, User-Agent or Referer . The name of the header is not case sensitive.
When the value of Type is SINGLE_QUERY_ARG , enter the name of the parameter that you want AWS WAF to search, for example, UserName or SalesRegion . The parameter name is not case sensitive.
If the value of Type is any other value, omit Data .
NextMarker (string) --
If you have more LoggingConfigurations than the number that you specified for Limit in the request, the response includes a NextMarker value. To list more LoggingConfigurations , submit another ListLoggingConfigurations request, and specify the NextMarker value from the response in the NextMarker value in the next request.
Exceptions
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFNonexistentItemException
WAFRegional.Client.exceptions.WAFInvalidParameterException
:return: {
'LoggingConfigurations': [
{
'ResourceArn': 'string',
'LogDestinationConfigs': [
'string',
],
'RedactedFields': [
{
'Type': 'URI'|'QUERY_STRING'|'HEADER'|'METHOD'|'BODY'|'SINGLE_QUERY_ARG'|'ALL_QUERY_ARGS',
'Data': 'string'
},
]
},
],
'NextMarker': 'string'
}
:returns:
(string) --
"""
pass
def list_rate_based_rules(NextMarker=None, Limit=None):
"""
Returns an array of RuleSummary objects.
See also: AWS API Documentation
Exceptions
:example: response = client.list_rate_based_rules(
NextMarker='string',
Limit=123
)
:type NextMarker: string
:param NextMarker: If you specify a value for Limit and you have more Rules than the value of Limit , AWS WAF returns a NextMarker value in the response that allows you to list another group of Rules . For the second and subsequent ListRateBasedRules requests, specify the value of NextMarker from the previous response to get information about another batch of Rules .
:type Limit: integer
:param Limit: Specifies the number of Rules that you want AWS WAF to return for this request. If you have more Rules than the number that you specify for Limit , the response includes a NextMarker value that you can use to get another batch of Rules .
:rtype: dict
ReturnsResponse Syntax
{
'NextMarker': 'string',
'Rules': [
{
'RuleId': 'string',
'Name': 'string'
},
]
}
Response Structure
(dict) --
NextMarker (string) --
If you have more Rules than the number that you specified for Limit in the request, the response includes a NextMarker value. To list more Rules , submit another ListRateBasedRules request, and specify the NextMarker value from the response in the NextMarker value in the next request.
Rules (list) --
An array of RuleSummary objects.
(dict) --
Note
This is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.
For the latest version of AWS WAF , use the AWS WAFV2 API and see the AWS WAF Developer Guide . With the latest version, AWS WAF has a single set of endpoints for regional and global use.
Contains the identifier and the friendly name or description of the Rule .
RuleId (string) --
A unique identifier for a Rule . You use RuleId to get more information about a Rule (see GetRule ), update a Rule (see UpdateRule ), insert a Rule into a WebACL or delete one from a WebACL (see UpdateWebACL ), or delete a Rule from AWS WAF (see DeleteRule ).
RuleId is returned by CreateRule and by ListRules .
Name (string) --
A friendly name or description of the Rule . You can\'t change the name of a Rule after you create it.
Exceptions
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidAccountException
:return: {
'NextMarker': 'string',
'Rules': [
{
'RuleId': 'string',
'Name': 'string'
},
]
}
:returns:
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidAccountException
"""
pass
def list_regex_match_sets(NextMarker=None, Limit=None):
"""
Returns an array of RegexMatchSetSummary objects.
See also: AWS API Documentation
Exceptions
:example: response = client.list_regex_match_sets(
NextMarker='string',
Limit=123
)
:type NextMarker: string
:param NextMarker: If you specify a value for Limit and you have more RegexMatchSet objects than the value of Limit , AWS WAF returns a NextMarker value in the response that allows you to list another group of ByteMatchSets . For the second and subsequent ListRegexMatchSets requests, specify the value of NextMarker from the previous response to get information about another batch of RegexMatchSet objects.
:type Limit: integer
:param Limit: Specifies the number of RegexMatchSet objects that you want AWS WAF to return for this request. If you have more RegexMatchSet objects than the number you specify for Limit , the response includes a NextMarker value that you can use to get another batch of RegexMatchSet objects.
:rtype: dict
ReturnsResponse Syntax
{
'NextMarker': 'string',
'RegexMatchSets': [
{
'RegexMatchSetId': 'string',
'Name': 'string'
},
]
}
Response Structure
(dict) --
NextMarker (string) --
If you have more RegexMatchSet objects than the number that you specified for Limit in the request, the response includes a NextMarker value. To list more RegexMatchSet objects, submit another ListRegexMatchSets request, and specify the NextMarker value from the response in the NextMarker value in the next request.
RegexMatchSets (list) --
An array of RegexMatchSetSummary objects.
(dict) --
Note
This is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.
For the latest version of AWS WAF , use the AWS WAFV2 API and see the AWS WAF Developer Guide . With the latest version, AWS WAF has a single set of endpoints for regional and global use.
Returned by ListRegexMatchSets . Each RegexMatchSetSummary object includes the Name and RegexMatchSetId for one RegexMatchSet .
RegexMatchSetId (string) --
The RegexMatchSetId for a RegexMatchSet . You use RegexMatchSetId to get information about a RegexMatchSet , update a RegexMatchSet , remove a RegexMatchSet from a Rule , and delete a RegexMatchSet from AWS WAF.
RegexMatchSetId is returned by CreateRegexMatchSet and by ListRegexMatchSets .
Name (string) --
A friendly name or description of the RegexMatchSet . You can\'t change Name after you create a RegexMatchSet .
Exceptions
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidAccountException
:return: {
'NextMarker': 'string',
'RegexMatchSets': [
{
'RegexMatchSetId': 'string',
'Name': 'string'
},
]
}
:returns:
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidAccountException
"""
pass
def list_regex_pattern_sets(NextMarker=None, Limit=None):
"""
Returns an array of RegexPatternSetSummary objects.
See also: AWS API Documentation
Exceptions
:example: response = client.list_regex_pattern_sets(
NextMarker='string',
Limit=123
)
:type NextMarker: string
:param NextMarker: If you specify a value for Limit and you have more RegexPatternSet objects than the value of Limit , AWS WAF returns a NextMarker value in the response that allows you to list another group of RegexPatternSet objects. For the second and subsequent ListRegexPatternSets requests, specify the value of NextMarker from the previous response to get information about another batch of RegexPatternSet objects.
:type Limit: integer
:param Limit: Specifies the number of RegexPatternSet objects that you want AWS WAF to return for this request. If you have more RegexPatternSet objects than the number you specify for Limit , the response includes a NextMarker value that you can use to get another batch of RegexPatternSet objects.
:rtype: dict
ReturnsResponse Syntax
{
'NextMarker': 'string',
'RegexPatternSets': [
{
'RegexPatternSetId': 'string',
'Name': 'string'
},
]
}
Response Structure
(dict) --
NextMarker (string) --
If you have more RegexPatternSet objects than the number that you specified for Limit in the request, the response includes a NextMarker value. To list more RegexPatternSet objects, submit another ListRegexPatternSets request, and specify the NextMarker value from the response in the NextMarker value in the next request.
RegexPatternSets (list) --
An array of RegexPatternSetSummary objects.
(dict) --
Note
This is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.
For the latest version of AWS WAF , use the AWS WAFV2 API and see the AWS WAF Developer Guide . With the latest version, AWS WAF has a single set of endpoints for regional and global use.
Returned by ListRegexPatternSets . Each RegexPatternSetSummary object includes the Name and RegexPatternSetId for one RegexPatternSet .
RegexPatternSetId (string) --
The RegexPatternSetId for a RegexPatternSet . You use RegexPatternSetId to get information about a RegexPatternSet , update a RegexPatternSet , remove a RegexPatternSet from a RegexMatchSet , and delete a RegexPatternSet from AWS WAF.
RegexPatternSetId is returned by CreateRegexPatternSet and by ListRegexPatternSets .
Name (string) --
A friendly name or description of the RegexPatternSet . You can\'t change Name after you create a RegexPatternSet .
Exceptions
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidAccountException
:return: {
'NextMarker': 'string',
'RegexPatternSets': [
{
'RegexPatternSetId': 'string',
'Name': 'string'
},
]
}
:returns:
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidAccountException
"""
pass
def list_resources_for_web_acl(WebACLId=None, ResourceType=None):
"""
Returns an array of resources associated with the specified web ACL.
See also: AWS API Documentation
Exceptions
:example: response = client.list_resources_for_web_acl(
WebACLId='string',
ResourceType='APPLICATION_LOAD_BALANCER'|'API_GATEWAY'
)
:type WebACLId: string
:param WebACLId: [REQUIRED]\nThe unique identifier (ID) of the web ACL for which to list the associated resources.\n
:type ResourceType: string
:param ResourceType: The type of resource to list, either an application load balancer or Amazon API Gateway.
:rtype: dict
ReturnsResponse Syntax
{
'ResourceArns': [
'string',
]
}
Response Structure
(dict) --
ResourceArns (list) --
An array of ARNs (Amazon Resource Names) of the resources associated with the specified web ACL. An array with zero elements is returned if there are no resources associated with the web ACL.
(string) --
Exceptions
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidAccountException
WAFRegional.Client.exceptions.WAFNonexistentItemException
WAFRegional.Client.exceptions.WAFInvalidParameterException
:return: {
'ResourceArns': [
'string',
]
}
:returns:
(string) --
"""
pass
def list_rule_groups(NextMarker=None, Limit=None):
"""
Returns an array of RuleGroup objects.
See also: AWS API Documentation
Exceptions
:example: response = client.list_rule_groups(
NextMarker='string',
Limit=123
)
:type NextMarker: string
:param NextMarker: If you specify a value for Limit and you have more RuleGroups than the value of Limit , AWS WAF returns a NextMarker value in the response that allows you to list another group of RuleGroups . For the second and subsequent ListRuleGroups requests, specify the value of NextMarker from the previous response to get information about another batch of RuleGroups .
:type Limit: integer
:param Limit: Specifies the number of RuleGroups that you want AWS WAF to return for this request. If you have more RuleGroups than the number that you specify for Limit , the response includes a NextMarker value that you can use to get another batch of RuleGroups .
:rtype: dict
ReturnsResponse Syntax
{
'NextMarker': 'string',
'RuleGroups': [
{
'RuleGroupId': 'string',
'Name': 'string'
},
]
}
Response Structure
(dict) --
NextMarker (string) --
If you have more RuleGroups than the number that you specified for Limit in the request, the response includes a NextMarker value. To list more RuleGroups , submit another ListRuleGroups request, and specify the NextMarker value from the response in the NextMarker value in the next request.
RuleGroups (list) --
An array of RuleGroup objects.
(dict) --
Note
This is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.
For the latest version of AWS WAF , use the AWS WAFV2 API and see the AWS WAF Developer Guide . With the latest version, AWS WAF has a single set of endpoints for regional and global use.
Contains the identifier and the friendly name or description of the RuleGroup .
RuleGroupId (string) --
A unique identifier for a RuleGroup . You use RuleGroupId to get more information about a RuleGroup (see GetRuleGroup ), update a RuleGroup (see UpdateRuleGroup ), insert a RuleGroup into a WebACL or delete one from a WebACL (see UpdateWebACL ), or delete a RuleGroup from AWS WAF (see DeleteRuleGroup ).
RuleGroupId is returned by CreateRuleGroup and by ListRuleGroups .
Name (string) --
A friendly name or description of the RuleGroup . You can\'t change the name of a RuleGroup after you create it.
Exceptions
WAFRegional.Client.exceptions.WAFInternalErrorException
:return: {
'NextMarker': 'string',
'RuleGroups': [
{
'RuleGroupId': 'string',
'Name': 'string'
},
]
}
:returns:
WAFRegional.Client.exceptions.WAFInternalErrorException
"""
pass
def list_rules(NextMarker=None, Limit=None):
"""
Returns an array of RuleSummary objects.
See also: AWS API Documentation
Exceptions
Examples
The following example returns an array of up to 100 rules.
Expected Output:
:example: response = client.list_rules(
NextMarker='string',
Limit=123
)
:type NextMarker: string
:param NextMarker: If you specify a value for Limit and you have more Rules than the value of Limit , AWS WAF returns a NextMarker value in the response that allows you to list another group of Rules . For the second and subsequent ListRules requests, specify the value of NextMarker from the previous response to get information about another batch of Rules .
:type Limit: integer
:param Limit: Specifies the number of Rules that you want AWS WAF to return for this request. If you have more Rules than the number that you specify for Limit , the response includes a NextMarker value that you can use to get another batch of Rules .
:rtype: dict
ReturnsResponse Syntax
{
'NextMarker': 'string',
'Rules': [
{
'RuleId': 'string',
'Name': 'string'
},
]
}
Response Structure
(dict) --
NextMarker (string) --
If you have more Rules than the number that you specified for Limit in the request, the response includes a NextMarker value. To list more Rules , submit another ListRules request, and specify the NextMarker value from the response in the NextMarker value in the next request.
Rules (list) --
An array of RuleSummary objects.
(dict) --
Note
This is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.
For the latest version of AWS WAF , use the AWS WAFV2 API and see the AWS WAF Developer Guide . With the latest version, AWS WAF has a single set of endpoints for regional and global use.
Contains the identifier and the friendly name or description of the Rule .
RuleId (string) --
A unique identifier for a Rule . You use RuleId to get more information about a Rule (see GetRule ), update a Rule (see UpdateRule ), insert a Rule into a WebACL or delete one from a WebACL (see UpdateWebACL ), or delete a Rule from AWS WAF (see DeleteRule ).
RuleId is returned by CreateRule and by ListRules .
Name (string) --
A friendly name or description of the Rule . You can\'t change the name of a Rule after you create it.
Exceptions
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidAccountException
Examples
The following example returns an array of up to 100 rules.
response = client.list_rules(
Limit=100,
)
print(response)
Expected Output:
{
'Rules': [
{
'Name': 'WAFByteHeaderRule',
'RuleId': 'WAFRule-1-Example',
},
],
'ResponseMetadata': {
'...': '...',
},
}
:return: {
'NextMarker': 'string',
'Rules': [
{
'RuleId': 'string',
'Name': 'string'
},
]
}
:returns:
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidAccountException
"""
pass
def list_size_constraint_sets(NextMarker=None, Limit=None):
"""
Returns an array of SizeConstraintSetSummary objects.
See also: AWS API Documentation
Exceptions
Examples
The following example returns an array of up to 100 size contraint match sets.
Expected Output:
:example: response = client.list_size_constraint_sets(
NextMarker='string',
Limit=123
)
:type NextMarker: string
:param NextMarker: If you specify a value for Limit and you have more SizeConstraintSets than the value of Limit , AWS WAF returns a NextMarker value in the response that allows you to list another group of SizeConstraintSets . For the second and subsequent ListSizeConstraintSets requests, specify the value of NextMarker from the previous response to get information about another batch of SizeConstraintSets .
:type Limit: integer
:param Limit: Specifies the number of SizeConstraintSet objects that you want AWS WAF to return for this request. If you have more SizeConstraintSets objects than the number you specify for Limit , the response includes a NextMarker value that you can use to get another batch of SizeConstraintSet objects.
:rtype: dict
ReturnsResponse Syntax
{
'NextMarker': 'string',
'SizeConstraintSets': [
{
'SizeConstraintSetId': 'string',
'Name': 'string'
},
]
}
Response Structure
(dict) --
NextMarker (string) --
If you have more SizeConstraintSet objects than the number that you specified for Limit in the request, the response includes a NextMarker value. To list more SizeConstraintSet objects, submit another ListSizeConstraintSets request, and specify the NextMarker value from the response in the NextMarker value in the next request.
SizeConstraintSets (list) --
An array of SizeConstraintSetSummary objects.
(dict) --
Note
This is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.
For the latest version of AWS WAF , use the AWS WAFV2 API and see the AWS WAF Developer Guide . With the latest version, AWS WAF has a single set of endpoints for regional and global use.
The Id and Name of a SizeConstraintSet .
SizeConstraintSetId (string) --
A unique identifier for a SizeConstraintSet . You use SizeConstraintSetId to get information about a SizeConstraintSet (see GetSizeConstraintSet ), update a SizeConstraintSet (see UpdateSizeConstraintSet ), insert a SizeConstraintSet into a Rule or delete one from a Rule (see UpdateRule ), and delete a SizeConstraintSet from AWS WAF (see DeleteSizeConstraintSet ).
SizeConstraintSetId is returned by CreateSizeConstraintSet and by ListSizeConstraintSets .
Name (string) --
The name of the SizeConstraintSet , if any.
Exceptions
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidAccountException
Examples
The following example returns an array of up to 100 size contraint match sets.
response = client.list_size_constraint_sets(
Limit=100,
)
print(response)
Expected Output:
{
'SizeConstraintSets': [
{
'Name': 'MySampleSizeConstraintSet',
'SizeConstraintSetId': 'example1ds3t-46da-4fdb-b8d5-abc321j569j5',
},
],
'ResponseMetadata': {
'...': '...',
},
}
:return: {
'NextMarker': 'string',
'SizeConstraintSets': [
{
'SizeConstraintSetId': 'string',
'Name': 'string'
},
]
}
:returns:
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidAccountException
"""
pass
def list_sql_injection_match_sets(NextMarker=None, Limit=None):
"""
Returns an array of SqlInjectionMatchSet objects.
See also: AWS API Documentation
Exceptions
Examples
The following example returns an array of up to 100 SQL injection match sets.
Expected Output:
:example: response = client.list_sql_injection_match_sets(
NextMarker='string',
Limit=123
)
:type NextMarker: string
:param NextMarker: If you specify a value for Limit and you have more SqlInjectionMatchSet objects than the value of Limit , AWS WAF returns a NextMarker value in the response that allows you to list another group of SqlInjectionMatchSets . For the second and subsequent ListSqlInjectionMatchSets requests, specify the value of NextMarker from the previous response to get information about another batch of SqlInjectionMatchSets .
:type Limit: integer
:param Limit: Specifies the number of SqlInjectionMatchSet objects that you want AWS WAF to return for this request. If you have more SqlInjectionMatchSet objects than the number you specify for Limit , the response includes a NextMarker value that you can use to get another batch of Rules .
:rtype: dict
ReturnsResponse Syntax
{
'NextMarker': 'string',
'SqlInjectionMatchSets': [
{
'SqlInjectionMatchSetId': 'string',
'Name': 'string'
},
]
}
Response Structure
(dict) --
The response to a ListSqlInjectionMatchSets request.
NextMarker (string) --
If you have more SqlInjectionMatchSet objects than the number that you specified for Limit in the request, the response includes a NextMarker value. To list more SqlInjectionMatchSet objects, submit another ListSqlInjectionMatchSets request, and specify the NextMarker value from the response in the NextMarker value in the next request.
SqlInjectionMatchSets (list) --
An array of SqlInjectionMatchSetSummary objects.
(dict) --
Note
This is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.
For the latest version of AWS WAF , use the AWS WAFV2 API and see the AWS WAF Developer Guide . With the latest version, AWS WAF has a single set of endpoints for regional and global use.
The Id and Name of a SqlInjectionMatchSet .
SqlInjectionMatchSetId (string) --
A unique identifier for a SqlInjectionMatchSet . You use SqlInjectionMatchSetId to get information about a SqlInjectionMatchSet (see GetSqlInjectionMatchSet ), update a SqlInjectionMatchSet (see UpdateSqlInjectionMatchSet ), insert a SqlInjectionMatchSet into a Rule or delete one from a Rule (see UpdateRule ), and delete a SqlInjectionMatchSet from AWS WAF (see DeleteSqlInjectionMatchSet ).
SqlInjectionMatchSetId is returned by CreateSqlInjectionMatchSet and by ListSqlInjectionMatchSets .
Name (string) --
The name of the SqlInjectionMatchSet , if any, specified by Id .
Exceptions
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidAccountException
Examples
The following example returns an array of up to 100 SQL injection match sets.
response = client.list_sql_injection_match_sets(
Limit=100,
)
print(response)
Expected Output:
{
'SqlInjectionMatchSets': [
{
'Name': 'MySQLInjectionMatchSet',
'SqlInjectionMatchSetId': 'example1ds3t-46da-4fdb-b8d5-abc321j569j5',
},
],
'ResponseMetadata': {
'...': '...',
},
}
:return: {
'NextMarker': 'string',
'SqlInjectionMatchSets': [
{
'SqlInjectionMatchSetId': 'string',
'Name': 'string'
},
]
}
:returns:
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidAccountException
"""
pass
def list_subscribed_rule_groups(NextMarker=None, Limit=None):
"""
Returns an array of RuleGroup objects that you are subscribed to.
See also: AWS API Documentation
Exceptions
:example: response = client.list_subscribed_rule_groups(
NextMarker='string',
Limit=123
)
:type NextMarker: string
:param NextMarker: If you specify a value for Limit and you have more ByteMatchSets subscribed rule groups than the value of Limit , AWS WAF returns a NextMarker value in the response that allows you to list another group of subscribed rule groups. For the second and subsequent ListSubscribedRuleGroupsRequest requests, specify the value of NextMarker from the previous response to get information about another batch of subscribed rule groups.
:type Limit: integer
:param Limit: Specifies the number of subscribed rule groups that you want AWS WAF to return for this request. If you have more objects than the number you specify for Limit , the response includes a NextMarker value that you can use to get another batch of objects.
:rtype: dict
ReturnsResponse Syntax
{
'NextMarker': 'string',
'RuleGroups': [
{
'RuleGroupId': 'string',
'Name': 'string',
'MetricName': 'string'
},
]
}
Response Structure
(dict) --
NextMarker (string) --
If you have more objects than the number that you specified for Limit in the request, the response includes a NextMarker value. To list more objects, submit another ListSubscribedRuleGroups request, and specify the NextMarker value from the response in the NextMarker value in the next request.
RuleGroups (list) --
An array of RuleGroup objects.
(dict) --
Note
This is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.
For the latest version of AWS WAF , use the AWS WAFV2 API and see the AWS WAF Developer Guide . With the latest version, AWS WAF has a single set of endpoints for regional and global use.
A summary of the rule groups you are subscribed to.
RuleGroupId (string) --
A unique identifier for a RuleGroup .
Name (string) --
A friendly name or description of the RuleGroup . You can\'t change the name of a RuleGroup after you create it.
MetricName (string) --
A friendly name or description for the metrics for this RuleGroup . The name can contain only alphanumeric characters (A-Z, a-z, 0-9), with maximum length 128 and minimum length one. It can\'t contain whitespace or metric names reserved for AWS WAF, including "All" and "Default_Action." You can\'t change the name of the metric after you create the RuleGroup .
Exceptions
WAFRegional.Client.exceptions.WAFNonexistentItemException
WAFRegional.Client.exceptions.WAFInternalErrorException
:return: {
'NextMarker': 'string',
'RuleGroups': [
{
'RuleGroupId': 'string',
'Name': 'string',
'MetricName': 'string'
},
]
}
:returns:
WAFRegional.Client.exceptions.WAFNonexistentItemException
WAFRegional.Client.exceptions.WAFInternalErrorException
"""
pass
def list_tags_for_resource(NextMarker=None, Limit=None, ResourceARN=None):
"""
Retrieves the tags associated with the specified AWS resource. Tags are key:value pairs that you can use to categorize and manage your resources, for purposes like billing. For example, you might set the tag key to "customer" and the value to the customer name or ID. You can specify one or more tags to add to each AWS resource, up to 50 tags for a resource.
Tagging is only available through the API, SDKs, and CLI. You can\'t manage or view tags through the AWS WAF Classic console. You can tag the AWS resources that you manage through AWS WAF Classic: web ACLs, rule groups, and rules.
See also: AWS API Documentation
Exceptions
:example: response = client.list_tags_for_resource(
NextMarker='string',
Limit=123,
ResourceARN='string'
)
:type NextMarker: string
:param NextMarker:
:type Limit: integer
:param Limit:
:type ResourceARN: string
:param ResourceARN: [REQUIRED]
:rtype: dict
ReturnsResponse Syntax
{
'NextMarker': 'string',
'TagInfoForResource': {
'ResourceARN': 'string',
'TagList': [
{
'Key': 'string',
'Value': 'string'
},
]
}
}
Response Structure
(dict) --
NextMarker (string) --
TagInfoForResource (dict) --
ResourceARN (string) --
TagList (list) --
(dict) --
Note
This is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.
For the latest version of AWS WAF , use the AWS WAFV2 API and see the AWS WAF Developer Guide . With the latest version, AWS WAF has a single set of endpoints for regional and global use.
A tag associated with an AWS resource. Tags are key:value pairs that you can use to categorize and manage your resources, for purposes like billing. For example, you might set the tag key to "customer" and the value to the customer name or ID. You can specify one or more tags to add to each AWS resource, up to 50 tags for a resource.
Tagging is only available through the API, SDKs, and CLI. You can\'t manage or view tags through the AWS WAF Classic console. You can tag the AWS resources that you manage through AWS WAF Classic: web ACLs, rule groups, and rules.
Key (string) --
Value (string) --
Exceptions
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidParameterException
WAFRegional.Client.exceptions.WAFNonexistentItemException
WAFRegional.Client.exceptions.WAFBadRequestException
WAFRegional.Client.exceptions.WAFTagOperationException
WAFRegional.Client.exceptions.WAFTagOperationInternalErrorException
:return: {
'NextMarker': 'string',
'TagInfoForResource': {
'ResourceARN': 'string',
'TagList': [
{
'Key': 'string',
'Value': 'string'
},
]
}
}
:returns:
Key (string) --
Value (string) --
"""
pass
def list_web_acls(NextMarker=None, Limit=None):
"""
Returns an array of WebACLSummary objects in the response.
See also: AWS API Documentation
Exceptions
Examples
The following example returns an array of up to 100 web ACLs.
Expected Output:
:example: response = client.list_web_acls(
NextMarker='string',
Limit=123
)
:type NextMarker: string
:param NextMarker: If you specify a value for Limit and you have more WebACL objects than the number that you specify for Limit , AWS WAF returns a NextMarker value in the response that allows you to list another group of WebACL objects. For the second and subsequent ListWebACLs requests, specify the value of NextMarker from the previous response to get information about another batch of WebACL objects.
:type Limit: integer
:param Limit: Specifies the number of WebACL objects that you want AWS WAF to return for this request. If you have more WebACL objects than the number that you specify for Limit , the response includes a NextMarker value that you can use to get another batch of WebACL objects.
:rtype: dict
ReturnsResponse Syntax
{
'NextMarker': 'string',
'WebACLs': [
{
'WebACLId': 'string',
'Name': 'string'
},
]
}
Response Structure
(dict) --
NextMarker (string) --
If you have more WebACL objects than the number that you specified for Limit in the request, the response includes a NextMarker value. To list more WebACL objects, submit another ListWebACLs request, and specify the NextMarker value from the response in the NextMarker value in the next request.
WebACLs (list) --
An array of WebACLSummary objects.
(dict) --
Note
This is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.
For the latest version of AWS WAF , use the AWS WAFV2 API and see the AWS WAF Developer Guide . With the latest version, AWS WAF has a single set of endpoints for regional and global use.
Contains the identifier and the name or description of the WebACL .
WebACLId (string) --
A unique identifier for a WebACL . You use WebACLId to get information about a WebACL (see GetWebACL ), update a WebACL (see UpdateWebACL ), and delete a WebACL from AWS WAF (see DeleteWebACL ).
WebACLId is returned by CreateWebACL and by ListWebACLs .
Name (string) --
A friendly name or description of the WebACL . You can\'t change the name of a WebACL after you create it.
Exceptions
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidAccountException
Examples
The following example returns an array of up to 100 web ACLs.
response = client.list_web_acls(
Limit=100,
)
print(response)
Expected Output:
{
'WebACLs': [
{
'Name': 'WebACLexample',
'WebACLId': 'webacl-1472061481310',
},
],
'ResponseMetadata': {
'...': '...',
},
}
:return: {
'NextMarker': 'string',
'WebACLs': [
{
'WebACLId': 'string',
'Name': 'string'
},
]
}
:returns:
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidAccountException
"""
pass
def list_xss_match_sets(NextMarker=None, Limit=None):
"""
Returns an array of XssMatchSet objects.
See also: AWS API Documentation
Exceptions
Examples
The following example returns an array of up to 100 XSS match sets.
Expected Output:
:example: response = client.list_xss_match_sets(
NextMarker='string',
Limit=123
)
:type NextMarker: string
:param NextMarker: If you specify a value for Limit and you have more XssMatchSet objects than the value of Limit , AWS WAF returns a NextMarker value in the response that allows you to list another group of XssMatchSets . For the second and subsequent ListXssMatchSets requests, specify the value of NextMarker from the previous response to get information about another batch of XssMatchSets .
:type Limit: integer
:param Limit: Specifies the number of XssMatchSet objects that you want AWS WAF to return for this request. If you have more XssMatchSet objects than the number you specify for Limit , the response includes a NextMarker value that you can use to get another batch of Rules .
:rtype: dict
ReturnsResponse Syntax
{
'NextMarker': 'string',
'XssMatchSets': [
{
'XssMatchSetId': 'string',
'Name': 'string'
},
]
}
Response Structure
(dict) --
The response to a ListXssMatchSets request.
NextMarker (string) --
If you have more XssMatchSet objects than the number that you specified for Limit in the request, the response includes a NextMarker value. To list more XssMatchSet objects, submit another ListXssMatchSets request, and specify the NextMarker value from the response in the NextMarker value in the next request.
XssMatchSets (list) --
An array of XssMatchSetSummary objects.
(dict) --
Note
This is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.
For the latest version of AWS WAF , use the AWS WAFV2 API and see the AWS WAF Developer Guide . With the latest version, AWS WAF has a single set of endpoints for regional and global use.
The Id and Name of an XssMatchSet .
XssMatchSetId (string) --
A unique identifier for an XssMatchSet . You use XssMatchSetId to get information about a XssMatchSet (see GetXssMatchSet ), update an XssMatchSet (see UpdateXssMatchSet ), insert an XssMatchSet into a Rule or delete one from a Rule (see UpdateRule ), and delete an XssMatchSet from AWS WAF (see DeleteXssMatchSet ).
XssMatchSetId is returned by CreateXssMatchSet and by ListXssMatchSets .
Name (string) --
The name of the XssMatchSet , if any, specified by Id .
Exceptions
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidAccountException
Examples
The following example returns an array of up to 100 XSS match sets.
response = client.list_xss_match_sets(
Limit=100,
)
print(response)
Expected Output:
{
'XssMatchSets': [
{
'Name': 'MySampleXssMatchSet',
'XssMatchSetId': 'example1ds3t-46da-4fdb-b8d5-abc321j569j5',
},
],
'ResponseMetadata': {
'...': '...',
},
}
:return: {
'NextMarker': 'string',
'XssMatchSets': [
{
'XssMatchSetId': 'string',
'Name': 'string'
},
]
}
:returns:
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidAccountException
"""
pass
def put_logging_configuration(LoggingConfiguration=None):
"""
Associates a LoggingConfiguration with a specified web ACL.
You can access information about all traffic that AWS WAF inspects using the following steps:
When you successfully enable logging using a PutLoggingConfiguration request, AWS WAF will create a service linked role with the necessary permissions to write logs to the Amazon Kinesis Data Firehose. For more information, see Logging Web ACL Traffic Information in the AWS WAF Developer Guide .
See also: AWS API Documentation
Exceptions
:example: response = client.put_logging_configuration(
LoggingConfiguration={
'ResourceArn': 'string',
'LogDestinationConfigs': [
'string',
],
'RedactedFields': [
{
'Type': 'URI'|'QUERY_STRING'|'HEADER'|'METHOD'|'BODY'|'SINGLE_QUERY_ARG'|'ALL_QUERY_ARGS',
'Data': 'string'
},
]
}
)
:type LoggingConfiguration: dict
:param LoggingConfiguration: [REQUIRED]\nThe Amazon Kinesis Data Firehose that contains the inspected traffic information, the redacted fields details, and the Amazon Resource Name (ARN) of the web ACL to monitor.\n\nNote\nWhen specifying Type in RedactedFields , you must use one of the following values: URI , QUERY_STRING , HEADER , or METHOD .\n\n\nResourceArn (string) -- [REQUIRED]The Amazon Resource Name (ARN) of the web ACL that you want to associate with LogDestinationConfigs .\n\nLogDestinationConfigs (list) -- [REQUIRED]An array of Amazon Kinesis Data Firehose ARNs.\n\n(string) --\n\n\nRedactedFields (list) --The parts of the request that you want redacted from the logs. For example, if you redact the cookie field, the cookie field in the firehose will be xxx .\n\n(dict) --\nNote\nThis is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.\n\nFor the latest version of AWS WAF , use the AWS WAFV2 API and see the AWS WAF Developer Guide . With the latest version, AWS WAF has a single set of endpoints for regional and global use.\n\nSpecifies where in a web request to look for TargetString .\n\nType (string) -- [REQUIRED]The part of the web request that you want AWS WAF to search for a specified string. Parts of a request that you can search include the following:\n\nHEADER : A specified request header, for example, the value of the User-Agent or Referer header. If you choose HEADER for the type, specify the name of the header in Data .\nMETHOD : The HTTP method, which indicated the type of operation that the request is asking the origin to perform. Amazon CloudFront supports the following methods: DELETE , GET , HEAD , OPTIONS , PATCH , POST , and PUT .\nQUERY_STRING : A query string, which is the part of a URL that appears after a ? character, if any.\nURI : The part of a web request that identifies a resource, for example, /images/daily-ad.jpg .\nBODY : The part of a request that contains any additional data that you want to send to your web server as the HTTP request body, such as data from a form. The request body immediately follows the request headers. Note that only the first 8192 bytes of the request body are forwarded to AWS WAF for inspection. To allow or block requests based on the length of the body, you can create a size constraint set. For more information, see CreateSizeConstraintSet .\nSINGLE_QUERY_ARG : The parameter in the query string that you will inspect, such as UserName or SalesRegion . The maximum length for SINGLE_QUERY_ARG is 30 characters.\nALL_QUERY_ARGS : Similar to SINGLE_QUERY_ARG , but rather than inspecting a single parameter, AWS WAF will inspect all parameters within the query for the value or regex pattern that you specify in TargetString .\n\n\nData (string) --When the value of Type is HEADER , enter the name of the header that you want AWS WAF to search, for example, User-Agent or Referer . The name of the header is not case sensitive.\nWhen the value of Type is SINGLE_QUERY_ARG , enter the name of the parameter that you want AWS WAF to search, for example, UserName or SalesRegion . The parameter name is not case sensitive.\nIf the value of Type is any other value, omit Data .\n\n\n\n\n\n\n
:rtype: dict
ReturnsResponse Syntax{
'LoggingConfiguration': {
'ResourceArn': 'string',
'LogDestinationConfigs': [
'string',
],
'RedactedFields': [
{
'Type': 'URI'|'QUERY_STRING'|'HEADER'|'METHOD'|'BODY'|'SINGLE_QUERY_ARG'|'ALL_QUERY_ARGS',
'Data': 'string'
},
]
}
}
Response Structure
(dict) --
LoggingConfiguration (dict) --The LoggingConfiguration that you submitted in the request.
ResourceArn (string) --The Amazon Resource Name (ARN) of the web ACL that you want to associate with LogDestinationConfigs .
LogDestinationConfigs (list) --An array of Amazon Kinesis Data Firehose ARNs.
(string) --
RedactedFields (list) --The parts of the request that you want redacted from the logs. For example, if you redact the cookie field, the cookie field in the firehose will be xxx .
(dict) --
Note
This is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.
For the latest version of AWS WAF , use the AWS WAFV2 API and see the AWS WAF Developer Guide . With the latest version, AWS WAF has a single set of endpoints for regional and global use.
Specifies where in a web request to look for TargetString .
Type (string) --The part of the web request that you want AWS WAF to search for a specified string. Parts of a request that you can search include the following:
HEADER : A specified request header, for example, the value of the User-Agent or Referer header. If you choose HEADER for the type, specify the name of the header in Data .
METHOD : The HTTP method, which indicated the type of operation that the request is asking the origin to perform. Amazon CloudFront supports the following methods: DELETE , GET , HEAD , OPTIONS , PATCH , POST , and PUT .
QUERY_STRING : A query string, which is the part of a URL that appears after a ? character, if any.
URI : The part of a web request that identifies a resource, for example, /images/daily-ad.jpg .
BODY : The part of a request that contains any additional data that you want to send to your web server as the HTTP request body, such as data from a form. The request body immediately follows the request headers. Note that only the first 8192 bytes of the request body are forwarded to AWS WAF for inspection. To allow or block requests based on the length of the body, you can create a size constraint set. For more information, see CreateSizeConstraintSet .
SINGLE_QUERY_ARG : The parameter in the query string that you will inspect, such as UserName or SalesRegion . The maximum length for SINGLE_QUERY_ARG is 30 characters.
ALL_QUERY_ARGS : Similar to SINGLE_QUERY_ARG , but rather than inspecting a single parameter, AWS WAF will inspect all parameters within the query for the value or regex pattern that you specify in TargetString .
Data (string) --When the value of Type is HEADER , enter the name of the header that you want AWS WAF to search, for example, User-Agent or Referer . The name of the header is not case sensitive.
When the value of Type is SINGLE_QUERY_ARG , enter the name of the parameter that you want AWS WAF to search, for example, UserName or SalesRegion . The parameter name is not case sensitive.
If the value of Type is any other value, omit Data .
Exceptions
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFNonexistentItemException
WAFRegional.Client.exceptions.WAFStaleDataException
WAFRegional.Client.exceptions.WAFServiceLinkedRoleErrorException
:return: {
'LoggingConfiguration': {
'ResourceArn': 'string',
'LogDestinationConfigs': [
'string',
],
'RedactedFields': [
{
'Type': 'URI'|'QUERY_STRING'|'HEADER'|'METHOD'|'BODY'|'SINGLE_QUERY_ARG'|'ALL_QUERY_ARGS',
'Data': 'string'
},
]
}
}
:returns:
Associate that firehose to your web ACL using a PutLoggingConfiguration request.
"""
pass
def put_permission_policy(ResourceArn=None, Policy=None):
"""
Attaches an IAM policy to the specified resource. The only supported use for this action is to share a RuleGroup across accounts.
The PutPermissionPolicy is subject to the following restrictions:
For more information, see IAM Policies .
An example of a valid policy parameter is shown in the Examples section below.
See also: AWS API Documentation
Exceptions
:example: response = client.put_permission_policy(
ResourceArn='string',
Policy='string'
)
:type ResourceArn: string
:param ResourceArn: [REQUIRED]\nThe Amazon Resource Name (ARN) of the RuleGroup to which you want to attach the policy.\n
:type Policy: string
:param Policy: [REQUIRED]\nThe policy to attach to the specified RuleGroup.\n
:rtype: dict
ReturnsResponse Syntax
{}
Response Structure
(dict) --
Exceptions
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFStaleDataException
WAFRegional.Client.exceptions.WAFNonexistentItemException
WAFRegional.Client.exceptions.WAFInvalidPermissionPolicyException
:return: {}
:returns:
ResourceArn (string) -- [REQUIRED]
The Amazon Resource Name (ARN) of the RuleGroup to which you want to attach the policy.
Policy (string) -- [REQUIRED]
The policy to attach to the specified RuleGroup.
"""
pass
def tag_resource(ResourceARN=None, Tags=None):
"""
Associates tags with the specified AWS resource. Tags are key:value pairs that you can use to categorize and manage your resources, for purposes like billing. For example, you might set the tag key to "customer" and the value to the customer name or ID. You can specify one or more tags to add to each AWS resource, up to 50 tags for a resource.
Tagging is only available through the API, SDKs, and CLI. You can\'t manage or view tags through the AWS WAF Classic console. You can use this action to tag the AWS resources that you manage through AWS WAF Classic: web ACLs, rule groups, and rules.
See also: AWS API Documentation
Exceptions
:example: response = client.tag_resource(
ResourceARN='string',
Tags=[
{
'Key': 'string',
'Value': 'string'
},
]
)
:type ResourceARN: string
:param ResourceARN: [REQUIRED]
:type Tags: list
:param Tags: [REQUIRED]\n\n(dict) --\nNote\nThis is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.\n\nFor the latest version of AWS WAF , use the AWS WAFV2 API and see the AWS WAF Developer Guide . With the latest version, AWS WAF has a single set of endpoints for regional and global use.\n\nA tag associated with an AWS resource. Tags are key:value pairs that you can use to categorize and manage your resources, for purposes like billing. For example, you might set the tag key to 'customer' and the value to the customer name or ID. You can specify one or more tags to add to each AWS resource, up to 50 tags for a resource.\nTagging is only available through the API, SDKs, and CLI. You can\'t manage or view tags through the AWS WAF Classic console. You can tag the AWS resources that you manage through AWS WAF Classic: web ACLs, rule groups, and rules.\n\nKey (string) -- [REQUIRED]\nValue (string) -- [REQUIRED]\n\n\n\n
:rtype: dict
ReturnsResponse Syntax
{}
Response Structure
(dict) --
Exceptions
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidParameterException
WAFRegional.Client.exceptions.WAFLimitsExceededException
WAFRegional.Client.exceptions.WAFNonexistentItemException
WAFRegional.Client.exceptions.WAFBadRequestException
WAFRegional.Client.exceptions.WAFTagOperationException
WAFRegional.Client.exceptions.WAFTagOperationInternalErrorException
:return: {}
:returns:
(dict) --
"""
pass
def untag_resource(ResourceARN=None, TagKeys=None):
"""
See also: AWS API Documentation
Exceptions
:example: response = client.untag_resource(
ResourceARN='string',
TagKeys=[
'string',
]
)
:type ResourceARN: string
:param ResourceARN: [REQUIRED]
:type TagKeys: list
:param TagKeys: [REQUIRED]\n\n(string) --\n\n
:rtype: dict
ReturnsResponse Syntax
{}
Response Structure
(dict) --
Exceptions
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidParameterException
WAFRegional.Client.exceptions.WAFNonexistentItemException
WAFRegional.Client.exceptions.WAFBadRequestException
WAFRegional.Client.exceptions.WAFTagOperationException
WAFRegional.Client.exceptions.WAFTagOperationInternalErrorException
:return: {}
:returns:
(dict) --
"""
pass
def update_byte_match_set(ByteMatchSetId=None, ChangeToken=None, Updates=None):
"""
Inserts or deletes ByteMatchTuple objects (filters) in a ByteMatchSet . For each ByteMatchTuple object, you specify the following values:
For example, you can add a ByteMatchSetUpdate object that matches web requests in which User-Agent headers contain the string BadBot . You can then configure AWS WAF to block those requests.
To create and configure a ByteMatchSet , perform the following steps:
For more information about how to use the AWS WAF API to allow or block HTTP requests, see the AWS WAF Developer Guide .
See also: AWS API Documentation
Exceptions
Examples
The following example deletes a ByteMatchTuple object (filters) in an byte match set with the ID exampleIDs3t-46da-4fdb-b8d5-abc321j569j5.
Expected Output:
:example: response = client.update_byte_match_set(
ByteMatchSetId='string',
ChangeToken='string',
Updates=[
{
'Action': 'INSERT'|'DELETE',
'ByteMatchTuple': {
'FieldToMatch': {
'Type': 'URI'|'QUERY_STRING'|'HEADER'|'METHOD'|'BODY'|'SINGLE_QUERY_ARG'|'ALL_QUERY_ARGS',
'Data': 'string'
},
'TargetString': b'bytes',
'TextTransformation': 'NONE'|'COMPRESS_WHITE_SPACE'|'HTML_ENTITY_DECODE'|'LOWERCASE'|'CMD_LINE'|'URL_DECODE',
'PositionalConstraint': 'EXACTLY'|'STARTS_WITH'|'ENDS_WITH'|'CONTAINS'|'CONTAINS_WORD'
}
},
]
)
:type ByteMatchSetId: string
:param ByteMatchSetId: [REQUIRED]\nThe ByteMatchSetId of the ByteMatchSet that you want to update. ByteMatchSetId is returned by CreateByteMatchSet and by ListByteMatchSets .\n
:type ChangeToken: string
:param ChangeToken: [REQUIRED]\nThe value returned by the most recent call to GetChangeToken .\n
:type Updates: list
:param Updates: [REQUIRED]\nAn array of ByteMatchSetUpdate objects that you want to insert into or delete from a ByteMatchSet . For more information, see the applicable data types:\n\nByteMatchSetUpdate : Contains Action and ByteMatchTuple\nByteMatchTuple : Contains FieldToMatch , PositionalConstraint , TargetString , and TextTransformation\nFieldToMatch : Contains Data and Type\n\n\n(dict) --\nNote\nThis is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.\n\nFor the latest version of AWS WAF , use the AWS WAFV2 API and see the AWS WAF Developer Guide . With the latest version, AWS WAF has a single set of endpoints for regional and global use.\n\nIn an UpdateByteMatchSet request, ByteMatchSetUpdate specifies whether to insert or delete a ByteMatchTuple and includes the settings for the ByteMatchTuple .\n\nAction (string) -- [REQUIRED]Specifies whether to insert or delete a ByteMatchTuple .\n\nByteMatchTuple (dict) -- [REQUIRED]Information about the part of a web request that you want AWS WAF to inspect and the value that you want AWS WAF to search for. If you specify DELETE for the value of Action , the ByteMatchTuple values must exactly match the values in the ByteMatchTuple that you want to delete from the ByteMatchSet .\n\nFieldToMatch (dict) -- [REQUIRED]The part of a web request that you want AWS WAF to search, such as a specified header or a query string. For more information, see FieldToMatch .\n\nType (string) -- [REQUIRED]The part of the web request that you want AWS WAF to search for a specified string. Parts of a request that you can search include the following:\n\nHEADER : A specified request header, for example, the value of the User-Agent or Referer header. If you choose HEADER for the type, specify the name of the header in Data .\nMETHOD : The HTTP method, which indicated the type of operation that the request is asking the origin to perform. Amazon CloudFront supports the following methods: DELETE , GET , HEAD , OPTIONS , PATCH , POST , and PUT .\nQUERY_STRING : A query string, which is the part of a URL that appears after a ? character, if any.\nURI : The part of a web request that identifies a resource, for example, /images/daily-ad.jpg .\nBODY : The part of a request that contains any additional data that you want to send to your web server as the HTTP request body, such as data from a form. The request body immediately follows the request headers. Note that only the first 8192 bytes of the request body are forwarded to AWS WAF for inspection. To allow or block requests based on the length of the body, you can create a size constraint set. For more information, see CreateSizeConstraintSet .\nSINGLE_QUERY_ARG : The parameter in the query string that you will inspect, such as UserName or SalesRegion . The maximum length for SINGLE_QUERY_ARG is 30 characters.\nALL_QUERY_ARGS : Similar to SINGLE_QUERY_ARG , but rather than inspecting a single parameter, AWS WAF will inspect all parameters within the query for the value or regex pattern that you specify in TargetString .\n\n\nData (string) --When the value of Type is HEADER , enter the name of the header that you want AWS WAF to search, for example, User-Agent or Referer . The name of the header is not case sensitive.\nWhen the value of Type is SINGLE_QUERY_ARG , enter the name of the parameter that you want AWS WAF to search, for example, UserName or SalesRegion . The parameter name is not case sensitive.\nIf the value of Type is any other value, omit Data .\n\n\n\nTargetString (bytes) -- [REQUIRED]The value that you want AWS WAF to search for. AWS WAF searches for the specified string in the part of web requests that you specified in FieldToMatch . The maximum length of the value is 50 bytes.\nValid values depend on the values that you specified for FieldToMatch :\n\nHEADER : The value that you want AWS WAF to search for in the request header that you specified in FieldToMatch , for example, the value of the User-Agent or Referer header.\nMETHOD : The HTTP method, which indicates the type of operation specified in the request. CloudFront supports the following methods: DELETE , GET , HEAD , OPTIONS , PATCH , POST , and PUT .\nQUERY_STRING : The value that you want AWS WAF to search for in the query string, which is the part of a URL that appears after a ? character.\nURI : The value that you want AWS WAF to search for in the part of a URL that identifies a resource, for example, /images/daily-ad.jpg .\nBODY : The part of a request that contains any additional data that you want to send to your web server as the HTTP request body, such as data from a form. The request body immediately follows the request headers. Note that only the first 8192 bytes of the request body are forwarded to AWS WAF for inspection. To allow or block requests based on the length of the body, you can create a size constraint set. For more information, see CreateSizeConstraintSet .\nSINGLE_QUERY_ARG : The parameter in the query string that you will inspect, such as UserName or SalesRegion . The maximum length for SINGLE_QUERY_ARG is 30 characters.\nALL_QUERY_ARGS : Similar to SINGLE_QUERY_ARG , but instead of inspecting a single parameter, AWS WAF inspects all parameters within the query string for the value or regex pattern that you specify in TargetString .\n\nIf TargetString includes alphabetic characters A-Z and a-z, note that the value is case sensitive.\n\nIf you\'re using the AWS WAF API\nSpecify a base64-encoded version of the value. The maximum length of the value before you base64-encode it is 50 bytes.\nFor example, suppose the value of Type is HEADER and the value of Data is User-Agent . If you want to search the User-Agent header for the value BadBot , you base64-encode BadBot using MIME base64-encoding and include the resulting value, QmFkQm90 , in the value of TargetString .\n\nIf you\'re using the AWS CLI or one of the AWS SDKs\nThe value that you want AWS WAF to search for. The SDK automatically base64 encodes the value.\n\nTextTransformation (string) -- [REQUIRED]Text transformations eliminate some of the unusual formatting that attackers use in web requests in an effort to bypass AWS WAF. If you specify a transformation, AWS WAF performs the transformation on FieldToMatch before inspecting it for a match.\nYou can only specify a single type of TextTransformation.\n\nCMD_LINE\nWhen you\'re concerned that attackers are injecting an operating system command line command and using unusual formatting to disguise some or all of the command, use this option to perform the following transformations:\n\nDelete the following characters: ' \' ^\nDelete spaces before the following characters: / (\nReplace the following characters with a space: , ;\nReplace multiple spaces with one space\nConvert uppercase letters (A-Z) to lowercase (a-z)\n\n\nCOMPRESS_WHITE_SPACE\nUse this option to replace the following characters with a space character (decimal 32):\n\nf, formfeed, decimal 12\nt, tab, decimal 9\nn, newline, decimal 10\nr, carriage return, decimal 13\nv, vertical tab, decimal 11\nnon-breaking space, decimal 160\n\n\nCOMPRESS_WHITE_SPACE also replaces multiple spaces with one space.HTML_ENTITY_DECODE\n\nUse this option to replace HTML-encoded characters with unencoded characters. HTML_ENTITY_DECODE performs the following operations:\n\nReplaces (ampersand)quot; with '\nReplaces (ampersand)nbsp; with a non-breaking space, decimal 160\nReplaces (ampersand)lt; with a 'less than' symbol\nReplaces (ampersand)gt; with >\nReplaces characters that are represented in hexadecimal format, (ampersand)#xhhhh; , with the corresponding characters\nReplaces characters that are represented in decimal format, (ampersand)#nnnn; , with the corresponding characters\n\n\nLOWERCASE\nUse this option to convert uppercase letters (A-Z) to lowercase (a-z).\n\nURL_DECODE\nUse this option to decode a URL-encoded value.\n\nNONE\nSpecify NONE if you don\'t want to perform any text transformations.\n\nPositionalConstraint (string) -- [REQUIRED]Within the portion of a web request that you want to search (for example, in the query string, if any), specify where you want AWS WAF to search. Valid values include the following:\n\nCONTAINS\nThe specified part of the web request must include the value of TargetString , but the location doesn\'t matter.\n\nCONTAINS_WORD\nThe specified part of the web request must include the value of TargetString , and TargetString must contain only alphanumeric characters or underscore (A-Z, a-z, 0-9, or _). In addition, TargetString must be a word, which means one of the following:\n\nTargetString exactly matches the value of the specified part of the web request, such as the value of a header.\nTargetString is at the beginning of the specified part of the web request and is followed by a character other than an alphanumeric character or underscore (_), for example, BadBot; .\nTargetString is at the end of the specified part of the web request and is preceded by a character other than an alphanumeric character or underscore (_), for example, ;BadBot .\nTargetString is in the middle of the specified part of the web request and is preceded and followed by characters other than alphanumeric characters or underscore (_), for example, -BadBot; .\n\n\nEXACTLY\nThe value of the specified part of the web request must exactly match the value of TargetString .\n\nSTARTS_WITH\nThe value of TargetString must appear at the beginning of the specified part of the web request.\n\nENDS_WITH\nThe value of TargetString must appear at the end of the specified part of the web request.\n\n\n\n\n\n\n
:rtype: dict
ReturnsResponse Syntax
{
'ChangeToken': 'string'
}
Response Structure
(dict) --
ChangeToken (string) --
The ChangeToken that you used to submit the UpdateByteMatchSet request. You can also use this value to query the status of the request. For more information, see GetChangeTokenStatus .
Exceptions
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidAccountException
WAFRegional.Client.exceptions.WAFInvalidOperationException
WAFRegional.Client.exceptions.WAFInvalidParameterException
WAFRegional.Client.exceptions.WAFNonexistentContainerException
WAFRegional.Client.exceptions.WAFNonexistentItemException
WAFRegional.Client.exceptions.WAFStaleDataException
WAFRegional.Client.exceptions.WAFLimitsExceededException
Examples
The following example deletes a ByteMatchTuple object (filters) in an byte match set with the ID exampleIDs3t-46da-4fdb-b8d5-abc321j569j5.
response = client.update_byte_match_set(
ByteMatchSetId='exampleIDs3t-46da-4fdb-b8d5-abc321j569j5',
ChangeToken='abcd12f2-46da-4fdb-b8d5-fbd4c466928f',
Updates=[
{
'Action': 'DELETE',
'ByteMatchTuple': {
'FieldToMatch': {
'Data': 'referer',
'Type': 'HEADER',
},
'PositionalConstraint': 'CONTAINS',
'TargetString': 'badrefer1',
'TextTransformation': 'NONE',
},
},
],
)
print(response)
Expected Output:
{
'ChangeToken': 'abcd12f2-46da-4fdb-b8d5-fbd4c466928f',
'ResponseMetadata': {
'...': '...',
},
}
:return: {
'ChangeToken': 'string'
}
:returns:
Create a ByteMatchSet. For more information, see CreateByteMatchSet .
Use GetChangeToken to get the change token that you provide in the ChangeToken parameter of an UpdateByteMatchSet request.
Submit an UpdateByteMatchSet request to specify the part of the request that you want AWS WAF to inspect (for example, the header or the URI) and the value that you want AWS WAF to watch for.
"""
pass
def update_geo_match_set(GeoMatchSetId=None, ChangeToken=None, Updates=None):
"""
Inserts or deletes GeoMatchConstraint objects in an GeoMatchSet . For each GeoMatchConstraint object, you specify the following values:
To create and configure an GeoMatchSet , perform the following steps:
When you update an GeoMatchSet , you specify the country that you want to add and/or the country that you want to delete. If you want to change a country, you delete the existing country and add the new one.
For more information about how to use the AWS WAF API to allow or block HTTP requests, see the AWS WAF Developer Guide .
See also: AWS API Documentation
Exceptions
:example: response = client.update_geo_match_set(
GeoMatchSetId='string',
ChangeToken='string',
Updates=[
{
'Action': 'INSERT'|'DELETE',
'GeoMatchConstraint': {
'Type': 'Country',
'Value': 'AF'|'AX'|'AL'|'DZ'|'AS'|'AD'|'AO'|'AI'|'AQ'|'AG'|'AR'|'AM'|'AW'|'AU'|'AT'|'AZ'|'BS'|'BH'|'BD'|'BB'|'BY'|'BE'|'BZ'|'BJ'|'BM'|'BT'|'BO'|'BQ'|'BA'|'BW'|'BV'|'BR'|'IO'|'BN'|'BG'|'BF'|'BI'|'KH'|'CM'|'CA'|'CV'|'KY'|'CF'|'TD'|'CL'|'CN'|'CX'|'CC'|'CO'|'KM'|'CG'|'CD'|'CK'|'CR'|'CI'|'HR'|'CU'|'CW'|'CY'|'CZ'|'DK'|'DJ'|'DM'|'DO'|'EC'|'EG'|'SV'|'GQ'|'ER'|'EE'|'ET'|'FK'|'FO'|'FJ'|'FI'|'FR'|'GF'|'PF'|'TF'|'GA'|'GM'|'GE'|'DE'|'GH'|'GI'|'GR'|'GL'|'GD'|'GP'|'GU'|'GT'|'GG'|'GN'|'GW'|'GY'|'HT'|'HM'|'VA'|'HN'|'HK'|'HU'|'IS'|'IN'|'ID'|'IR'|'IQ'|'IE'|'IM'|'IL'|'IT'|'JM'|'JP'|'JE'|'JO'|'KZ'|'KE'|'KI'|'KP'|'KR'|'KW'|'KG'|'LA'|'LV'|'LB'|'LS'|'LR'|'LY'|'LI'|'LT'|'LU'|'MO'|'MK'|'MG'|'MW'|'MY'|'MV'|'ML'|'MT'|'MH'|'MQ'|'MR'|'MU'|'YT'|'MX'|'FM'|'MD'|'MC'|'MN'|'ME'|'MS'|'MA'|'MZ'|'MM'|'NA'|'NR'|'NP'|'NL'|'NC'|'NZ'|'NI'|'NE'|'NG'|'NU'|'NF'|'MP'|'NO'|'OM'|'PK'|'PW'|'PS'|'PA'|'PG'|'PY'|'PE'|'PH'|'PN'|'PL'|'PT'|'PR'|'QA'|'RE'|'RO'|'RU'|'RW'|'BL'|'SH'|'KN'|'LC'|'MF'|'PM'|'VC'|'WS'|'SM'|'ST'|'SA'|'SN'|'RS'|'SC'|'SL'|'SG'|'SX'|'SK'|'SI'|'SB'|'SO'|'ZA'|'GS'|'SS'|'ES'|'LK'|'SD'|'SR'|'SJ'|'SZ'|'SE'|'CH'|'SY'|'TW'|'TJ'|'TZ'|'TH'|'TL'|'TG'|'TK'|'TO'|'TT'|'TN'|'TR'|'TM'|'TC'|'TV'|'UG'|'UA'|'AE'|'GB'|'US'|'UM'|'UY'|'UZ'|'VU'|'VE'|'VN'|'VG'|'VI'|'WF'|'EH'|'YE'|'ZM'|'ZW'
}
},
]
)
:type GeoMatchSetId: string
:param GeoMatchSetId: [REQUIRED]\nThe GeoMatchSetId of the GeoMatchSet that you want to update. GeoMatchSetId is returned by CreateGeoMatchSet and by ListGeoMatchSets .\n
:type ChangeToken: string
:param ChangeToken: [REQUIRED]\nThe value returned by the most recent call to GetChangeToken .\n
:type Updates: list
:param Updates: [REQUIRED]\nAn array of GeoMatchSetUpdate objects that you want to insert into or delete from an GeoMatchSet . For more information, see the applicable data types:\n\nGeoMatchSetUpdate : Contains Action and GeoMatchConstraint\nGeoMatchConstraint : Contains Type and Value You can have only one Type and Value per GeoMatchConstraint . To add multiple countries, include multiple GeoMatchSetUpdate objects in your request.\n\n\n(dict) --\nNote\nThis is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.\n\nFor the latest version of AWS WAF , use the AWS WAFV2 API and see the AWS WAF Developer Guide . With the latest version, AWS WAF has a single set of endpoints for regional and global use.\n\nSpecifies the type of update to perform to an GeoMatchSet with UpdateGeoMatchSet .\n\nAction (string) -- [REQUIRED]Specifies whether to insert or delete a country with UpdateGeoMatchSet .\n\nGeoMatchConstraint (dict) -- [REQUIRED]The country from which web requests originate that you want AWS WAF to search for.\n\nType (string) -- [REQUIRED]The type of geographical area you want AWS WAF to search for. Currently Country is the only valid value.\n\nValue (string) -- [REQUIRED]The country that you want AWS WAF to search for.\n\n\n\n\n\n\n
:rtype: dict
ReturnsResponse Syntax
{
'ChangeToken': 'string'
}
Response Structure
(dict) --
ChangeToken (string) --
The ChangeToken that you used to submit the UpdateGeoMatchSet request. You can also use this value to query the status of the request. For more information, see GetChangeTokenStatus .
Exceptions
WAFRegional.Client.exceptions.WAFStaleDataException
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidAccountException
WAFRegional.Client.exceptions.WAFInvalidOperationException
WAFRegional.Client.exceptions.WAFInvalidParameterException
WAFRegional.Client.exceptions.WAFNonexistentContainerException
WAFRegional.Client.exceptions.WAFNonexistentItemException
WAFRegional.Client.exceptions.WAFReferencedItemException
WAFRegional.Client.exceptions.WAFLimitsExceededException
:return: {
'ChangeToken': 'string'
}
:returns:
Submit a CreateGeoMatchSet request.
Use GetChangeToken to get the change token that you provide in the ChangeToken parameter of an UpdateGeoMatchSet request.
Submit an UpdateGeoMatchSet request to specify the country that you want AWS WAF to watch for.
"""
pass
def update_ip_set(IPSetId=None, ChangeToken=None, Updates=None):
"""
Inserts or deletes IPSetDescriptor objects in an IPSet . For each IPSetDescriptor object, you specify the following values:
AWS WAF supports IPv4 address ranges: /8 and any range between /16 through /32. AWS WAF supports IPv6 address ranges: /24, /32, /48, /56, /64, and /128. For more information about CIDR notation, see the Wikipedia entry Classless Inter-Domain Routing .
IPv6 addresses can be represented using any of the following formats:
You use an IPSet to specify which web requests you want to allow or block based on the IP addresses that the requests originated from. For example, if you\'re receiving a lot of requests from one or a small number of IP addresses and you want to block the requests, you can create an IPSet that specifies those IP addresses, and then configure AWS WAF to block the requests.
To create and configure an IPSet , perform the following steps:
When you update an IPSet , you specify the IP addresses that you want to add and/or the IP addresses that you want to delete. If you want to change an IP address, you delete the existing IP address and add the new one.
You can insert a maximum of 1000 addresses in a single request.
For more information about how to use the AWS WAF API to allow or block HTTP requests, see the AWS WAF Developer Guide .
See also: AWS API Documentation
Exceptions
Examples
The following example deletes an IPSetDescriptor object in an IP match set with the ID example1ds3t-46da-4fdb-b8d5-abc321j569j5.
Expected Output:
:example: response = client.update_ip_set(
IPSetId='string',
ChangeToken='string',
Updates=[
{
'Action': 'INSERT'|'DELETE',
'IPSetDescriptor': {
'Type': 'IPV4'|'IPV6',
'Value': 'string'
}
},
]
)
:type IPSetId: string
:param IPSetId: [REQUIRED]\nThe IPSetId of the IPSet that you want to update. IPSetId is returned by CreateIPSet and by ListIPSets .\n
:type ChangeToken: string
:param ChangeToken: [REQUIRED]\nThe value returned by the most recent call to GetChangeToken .\n
:type Updates: list
:param Updates: [REQUIRED]\nAn array of IPSetUpdate objects that you want to insert into or delete from an IPSet . For more information, see the applicable data types:\n\nIPSetUpdate : Contains Action and IPSetDescriptor\nIPSetDescriptor : Contains Type and Value\n\nYou can insert a maximum of 1000 addresses in a single request.\n\n(dict) --\nNote\nThis is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.\n\nFor the latest version of AWS WAF , use the AWS WAFV2 API and see the AWS WAF Developer Guide . With the latest version, AWS WAF has a single set of endpoints for regional and global use.\n\nSpecifies the type of update to perform to an IPSet with UpdateIPSet .\n\nAction (string) -- [REQUIRED]Specifies whether to insert or delete an IP address with UpdateIPSet .\n\nIPSetDescriptor (dict) -- [REQUIRED]The IP address type (IPV4 or IPV6 ) and the IP address range (in CIDR notation) that web requests originate from.\n\nType (string) -- [REQUIRED]Specify IPV4 or IPV6 .\n\nValue (string) -- [REQUIRED]Specify an IPv4 address by using CIDR notation. For example:\n\nTo configure AWS WAF to allow, block, or count requests that originated from the IP address 192.0.2.44, specify 192.0.2.44/32 .\nTo configure AWS WAF to allow, block, or count requests that originated from IP addresses from 192.0.2.0 to 192.0.2.255, specify 192.0.2.0/24 .\n\nFor more information about CIDR notation, see the Wikipedia entry Classless Inter-Domain Routing .\nSpecify an IPv6 address by using CIDR notation. For example:\n\nTo configure AWS WAF to allow, block, or count requests that originated from the IP address 1111:0000:0000:0000:0000:0000:0000:0111, specify 1111:0000:0000:0000:0000:0000:0000:0111/128 .\nTo configure AWS WAF to allow, block, or count requests that originated from IP addresses 1111:0000:0000:0000:0000:0000:0000:0000 to 1111:0000:0000:0000:ffff:ffff:ffff:ffff, specify 1111:0000:0000:0000:0000:0000:0000:0000/64 .\n\n\n\n\n\n\n\n
:rtype: dict
ReturnsResponse Syntax
{
'ChangeToken': 'string'
}
Response Structure
(dict) --
ChangeToken (string) --
The ChangeToken that you used to submit the UpdateIPSet request. You can also use this value to query the status of the request. For more information, see GetChangeTokenStatus .
Exceptions
WAFRegional.Client.exceptions.WAFStaleDataException
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidAccountException
WAFRegional.Client.exceptions.WAFInvalidOperationException
WAFRegional.Client.exceptions.WAFInvalidParameterException
WAFRegional.Client.exceptions.WAFNonexistentContainerException
WAFRegional.Client.exceptions.WAFNonexistentItemException
WAFRegional.Client.exceptions.WAFReferencedItemException
WAFRegional.Client.exceptions.WAFLimitsExceededException
Examples
The following example deletes an IPSetDescriptor object in an IP match set with the ID example1ds3t-46da-4fdb-b8d5-abc321j569j5.
response = client.update_ip_set(
ChangeToken='abcd12f2-46da-4fdb-b8d5-fbd4c466928f',
IPSetId='example1ds3t-46da-4fdb-b8d5-abc321j569j5',
Updates=[
{
'Action': 'DELETE',
'IPSetDescriptor': {
'Type': 'IPV4',
'Value': '192.0.2.44/32',
},
},
],
)
print(response)
Expected Output:
{
'ChangeToken': 'abcd12f2-46da-4fdb-b8d5-fbd4c466928f',
'ResponseMetadata': {
'...': '...',
},
}
:return: {
'ChangeToken': 'string'
}
:returns:
1111:0000:0000:0000:0000:0000:0000:0111/128
1111:0:0:0:0:0:0:0111/128
1111::0111/128
1111::111/128
"""
pass
def update_rate_based_rule(RuleId=None, ChangeToken=None, Updates=None, RateLimit=None):
"""
Inserts or deletes Predicate objects in a rule and updates the RateLimit in the rule.
Each Predicate object identifies a predicate, such as a ByteMatchSet or an IPSet , that specifies the web requests that you want to block or count. The RateLimit specifies the number of requests every five minutes that triggers the rule.
If you add more than one predicate to a RateBasedRule , a request must match all the predicates and exceed the RateLimit to be counted or blocked. For example, suppose you add the following to a RateBasedRule :
Further, you specify a RateLimit of 1,000.
You then add the RateBasedRule to a WebACL and specify that you want to block requests that satisfy the rule. For a request to be blocked, it must come from the IP address 192.0.2.44 and the User-Agent header in the request must contain the value BadBot . Further, requests that match these two conditions much be received at a rate of more than 1,000 every five minutes. If the rate drops below this limit, AWS WAF no longer blocks the requests.
As a second example, suppose you want to limit requests to a particular page on your site. To do this, you could add the following to a RateBasedRule :
Further, you specify a RateLimit of 1,000.
By adding this RateBasedRule to a WebACL , you could limit requests to your login page without affecting the rest of your site.
See also: AWS API Documentation
Exceptions
:example: response = client.update_rate_based_rule(
RuleId='string',
ChangeToken='string',
Updates=[
{
'Action': 'INSERT'|'DELETE',
'Predicate': {
'Negated': True|False,
'Type': 'IPMatch'|'ByteMatch'|'SqlInjectionMatch'|'GeoMatch'|'SizeConstraint'|'XssMatch'|'RegexMatch',
'DataId': 'string'
}
},
],
RateLimit=123
)
:type RuleId: string
:param RuleId: [REQUIRED]\nThe RuleId of the RateBasedRule that you want to update. RuleId is returned by CreateRateBasedRule and by ListRateBasedRules .\n
:type ChangeToken: string
:param ChangeToken: [REQUIRED]\nThe value returned by the most recent call to GetChangeToken .\n
:type Updates: list
:param Updates: [REQUIRED]\nAn array of RuleUpdate objects that you want to insert into or delete from a RateBasedRule .\n\n(dict) --\nNote\nThis is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.\n\nFor the latest version of AWS WAF , use the AWS WAFV2 API and see the AWS WAF Developer Guide . With the latest version, AWS WAF has a single set of endpoints for regional and global use.\n\nSpecifies a Predicate (such as an IPSet ) and indicates whether you want to add it to a Rule or delete it from a Rule .\n\nAction (string) -- [REQUIRED]Specify INSERT to add a Predicate to a Rule . Use DELETE to remove a Predicate from a Rule .\n\nPredicate (dict) -- [REQUIRED]The ID of the Predicate (such as an IPSet ) that you want to add to a Rule .\n\nNegated (boolean) -- [REQUIRED]Set Negated to False if you want AWS WAF to allow, block, or count requests based on the settings in the specified ByteMatchSet , IPSet , SqlInjectionMatchSet , XssMatchSet , RegexMatchSet , GeoMatchSet , or SizeConstraintSet . For example, if an IPSet includes the IP address 192.0.2.44 , AWS WAF will allow or block requests based on that IP address.\nSet Negated to True if you want AWS WAF to allow or block a request based on the negation of the settings in the ByteMatchSet , IPSet , SqlInjectionMatchSet , XssMatchSet , RegexMatchSet , GeoMatchSet , or SizeConstraintSet . For example, if an IPSet includes the IP address 192.0.2.44 , AWS WAF will allow, block, or count requests based on all IP addresses except 192.0.2.44 .\n\nType (string) -- [REQUIRED]The type of predicate in a Rule , such as ByteMatch or IPSet .\n\nDataId (string) -- [REQUIRED]A unique identifier for a predicate in a Rule , such as ByteMatchSetId or IPSetId . The ID is returned by the corresponding Create or List command.\n\n\n\n\n\n\n
:type RateLimit: integer
:param RateLimit: [REQUIRED]\nThe maximum number of requests, which have an identical value in the field specified by the RateKey , allowed in a five-minute period. If the number of requests exceeds the RateLimit and the other predicates specified in the rule are also met, AWS WAF triggers the action that is specified for this rule.\n
:rtype: dict
ReturnsResponse Syntax
{
'ChangeToken': 'string'
}
Response Structure
(dict) --
ChangeToken (string) --
The ChangeToken that you used to submit the UpdateRateBasedRule request. You can also use this value to query the status of the request. For more information, see GetChangeTokenStatus .
Exceptions
WAFRegional.Client.exceptions.WAFStaleDataException
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidAccountException
WAFRegional.Client.exceptions.WAFInvalidOperationException
WAFRegional.Client.exceptions.WAFInvalidParameterException
WAFRegional.Client.exceptions.WAFNonexistentContainerException
WAFRegional.Client.exceptions.WAFNonexistentItemException
WAFRegional.Client.exceptions.WAFReferencedItemException
WAFRegional.Client.exceptions.WAFLimitsExceededException
:return: {
'ChangeToken': 'string'
}
:returns:
A ByteMatchSet with FieldToMatch of URI
A PositionalConstraint of STARTS_WITH
A TargetString of login
"""
pass
def update_regex_match_set(RegexMatchSetId=None, Updates=None, ChangeToken=None):
"""
Inserts or deletes RegexMatchTuple objects (filters) in a RegexMatchSet . For each RegexMatchSetUpdate object, you specify the following values:
For example, you can create a RegexPatternSet that matches any requests with User-Agent headers that contain the string B[a@]dB[o0]t . You can then configure AWS WAF to reject those requests.
To create and configure a RegexMatchSet , perform the following steps:
For more information about how to use the AWS WAF API to allow or block HTTP requests, see the AWS WAF Developer Guide .
See also: AWS API Documentation
Exceptions
:example: response = client.update_regex_match_set(
RegexMatchSetId='string',
Updates=[
{
'Action': 'INSERT'|'DELETE',
'RegexMatchTuple': {
'FieldToMatch': {
'Type': 'URI'|'QUERY_STRING'|'HEADER'|'METHOD'|'BODY'|'SINGLE_QUERY_ARG'|'ALL_QUERY_ARGS',
'Data': 'string'
},
'TextTransformation': 'NONE'|'COMPRESS_WHITE_SPACE'|'HTML_ENTITY_DECODE'|'LOWERCASE'|'CMD_LINE'|'URL_DECODE',
'RegexPatternSetId': 'string'
}
},
],
ChangeToken='string'
)
:type RegexMatchSetId: string
:param RegexMatchSetId: [REQUIRED]\nThe RegexMatchSetId of the RegexMatchSet that you want to update. RegexMatchSetId is returned by CreateRegexMatchSet and by ListRegexMatchSets .\n
:type Updates: list
:param Updates: [REQUIRED]\nAn array of RegexMatchSetUpdate objects that you want to insert into or delete from a RegexMatchSet . For more information, see RegexMatchTuple .\n\n(dict) --\nNote\nThis is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.\n\nFor the latest version of AWS WAF , use the AWS WAFV2 API and see the AWS WAF Developer Guide . With the latest version, AWS WAF has a single set of endpoints for regional and global use.\n\nIn an UpdateRegexMatchSet request, RegexMatchSetUpdate specifies whether to insert or delete a RegexMatchTuple and includes the settings for the RegexMatchTuple .\n\nAction (string) -- [REQUIRED]Specifies whether to insert or delete a RegexMatchTuple .\n\nRegexMatchTuple (dict) -- [REQUIRED]Information about the part of a web request that you want AWS WAF to inspect and the identifier of the regular expression (regex) pattern that you want AWS WAF to search for. If you specify DELETE for the value of Action , the RegexMatchTuple values must exactly match the values in the RegexMatchTuple that you want to delete from the RegexMatchSet .\n\nFieldToMatch (dict) -- [REQUIRED]Specifies where in a web request to look for the RegexPatternSet .\n\nType (string) -- [REQUIRED]The part of the web request that you want AWS WAF to search for a specified string. Parts of a request that you can search include the following:\n\nHEADER : A specified request header, for example, the value of the User-Agent or Referer header. If you choose HEADER for the type, specify the name of the header in Data .\nMETHOD : The HTTP method, which indicated the type of operation that the request is asking the origin to perform. Amazon CloudFront supports the following methods: DELETE , GET , HEAD , OPTIONS , PATCH , POST , and PUT .\nQUERY_STRING : A query string, which is the part of a URL that appears after a ? character, if any.\nURI : The part of a web request that identifies a resource, for example, /images/daily-ad.jpg .\nBODY : The part of a request that contains any additional data that you want to send to your web server as the HTTP request body, such as data from a form. The request body immediately follows the request headers. Note that only the first 8192 bytes of the request body are forwarded to AWS WAF for inspection. To allow or block requests based on the length of the body, you can create a size constraint set. For more information, see CreateSizeConstraintSet .\nSINGLE_QUERY_ARG : The parameter in the query string that you will inspect, such as UserName or SalesRegion . The maximum length for SINGLE_QUERY_ARG is 30 characters.\nALL_QUERY_ARGS : Similar to SINGLE_QUERY_ARG , but rather than inspecting a single parameter, AWS WAF will inspect all parameters within the query for the value or regex pattern that you specify in TargetString .\n\n\nData (string) --When the value of Type is HEADER , enter the name of the header that you want AWS WAF to search, for example, User-Agent or Referer . The name of the header is not case sensitive.\nWhen the value of Type is SINGLE_QUERY_ARG , enter the name of the parameter that you want AWS WAF to search, for example, UserName or SalesRegion . The parameter name is not case sensitive.\nIf the value of Type is any other value, omit Data .\n\n\n\nTextTransformation (string) -- [REQUIRED]Text transformations eliminate some of the unusual formatting that attackers use in web requests in an effort to bypass AWS WAF. If you specify a transformation, AWS WAF performs the transformation on RegexPatternSet before inspecting a request for a match.\nYou can only specify a single type of TextTransformation.\n\nCMD_LINE\nWhen you\'re concerned that attackers are injecting an operating system commandline command and using unusual formatting to disguise some or all of the command, use this option to perform the following transformations:\n\nDelete the following characters: ' \' ^\nDelete spaces before the following characters: / (\nReplace the following characters with a space: , ;\nReplace multiple spaces with one space\nConvert uppercase letters (A-Z) to lowercase (a-z)\n\n\nCOMPRESS_WHITE_SPACE\nUse this option to replace the following characters with a space character (decimal 32):\n\nf, formfeed, decimal 12\nt, tab, decimal 9\nn, newline, decimal 10\nr, carriage return, decimal 13\nv, vertical tab, decimal 11\nnon-breaking space, decimal 160\n\n\nCOMPRESS_WHITE_SPACE also replaces multiple spaces with one space.HTML_ENTITY_DECODE\n\nUse this option to replace HTML-encoded characters with unencoded characters. HTML_ENTITY_DECODE performs the following operations:\n\nReplaces (ampersand)quot; with '\nReplaces (ampersand)nbsp; with a non-breaking space, decimal 160\nReplaces (ampersand)lt; with a 'less than' symbol\nReplaces (ampersand)gt; with >\nReplaces characters that are represented in hexadecimal format, (ampersand)#xhhhh; , with the corresponding characters\nReplaces characters that are represented in decimal format, (ampersand)#nnnn; , with the corresponding characters\n\n\nLOWERCASE\nUse this option to convert uppercase letters (A-Z) to lowercase (a-z).\n\nURL_DECODE\nUse this option to decode a URL-encoded value.\n\nNONE\nSpecify NONE if you don\'t want to perform any text transformations.\n\nRegexPatternSetId (string) -- [REQUIRED]The RegexPatternSetId for a RegexPatternSet . You use RegexPatternSetId to get information about a RegexPatternSet (see GetRegexPatternSet ), update a RegexPatternSet (see UpdateRegexPatternSet ), insert a RegexPatternSet into a RegexMatchSet or delete one from a RegexMatchSet (see UpdateRegexMatchSet ), and delete an RegexPatternSet from AWS WAF (see DeleteRegexPatternSet ).\n\nRegexPatternSetId is returned by CreateRegexPatternSet and by ListRegexPatternSets .\n\n\n\n\n\n\n
:type ChangeToken: string
:param ChangeToken: [REQUIRED]\nThe value returned by the most recent call to GetChangeToken .\n
:rtype: dict
ReturnsResponse Syntax
{
'ChangeToken': 'string'
}
Response Structure
(dict) --
ChangeToken (string) --
The ChangeToken that you used to submit the UpdateRegexMatchSet request. You can also use this value to query the status of the request. For more information, see GetChangeTokenStatus .
Exceptions
WAFRegional.Client.exceptions.WAFStaleDataException
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFDisallowedNameException
WAFRegional.Client.exceptions.WAFLimitsExceededException
WAFRegional.Client.exceptions.WAFNonexistentItemException
WAFRegional.Client.exceptions.WAFNonexistentContainerException
WAFRegional.Client.exceptions.WAFInvalidOperationException
WAFRegional.Client.exceptions.WAFInvalidAccountException
:return: {
'ChangeToken': 'string'
}
:returns:
Create a RegexMatchSet. For more information, see CreateRegexMatchSet .
Use GetChangeToken to get the change token that you provide in the ChangeToken parameter of an UpdateRegexMatchSet request.
Submit an UpdateRegexMatchSet request to specify the part of the request that you want AWS WAF to inspect (for example, the header or the URI) and the identifier of the RegexPatternSet that contain the regular expression patters you want AWS WAF to watch for.
"""
pass
def update_regex_pattern_set(RegexPatternSetId=None, Updates=None, ChangeToken=None):
"""
Inserts or deletes RegexPatternString objects in a RegexPatternSet . For each RegexPatternString object, you specify the following values:
For example, you can create a RegexPatternString such as B[a@]dB[o0]t . AWS WAF will match this RegexPatternString to:
To create and configure a RegexPatternSet , perform the following steps:
For more information about how to use the AWS WAF API to allow or block HTTP requests, see the AWS WAF Developer Guide .
See also: AWS API Documentation
Exceptions
:example: response = client.update_regex_pattern_set(
RegexPatternSetId='string',
Updates=[
{
'Action': 'INSERT'|'DELETE',
'RegexPatternString': 'string'
},
],
ChangeToken='string'
)
:type RegexPatternSetId: string
:param RegexPatternSetId: [REQUIRED]\nThe RegexPatternSetId of the RegexPatternSet that you want to update. RegexPatternSetId is returned by CreateRegexPatternSet and by ListRegexPatternSets .\n
:type Updates: list
:param Updates: [REQUIRED]\nAn array of RegexPatternSetUpdate objects that you want to insert into or delete from a RegexPatternSet .\n\n(dict) --\nNote\nThis is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.\n\nFor the latest version of AWS WAF , use the AWS WAFV2 API and see the AWS WAF Developer Guide . With the latest version, AWS WAF has a single set of endpoints for regional and global use.\n\nIn an UpdateRegexPatternSet request, RegexPatternSetUpdate specifies whether to insert or delete a RegexPatternString and includes the settings for the RegexPatternString .\n\nAction (string) -- [REQUIRED]Specifies whether to insert or delete a RegexPatternString .\n\nRegexPatternString (string) -- [REQUIRED]Specifies the regular expression (regex) pattern that you want AWS WAF to search for, such as B[a@]dB[o0]t .\n\n\n\n\n
:type ChangeToken: string
:param ChangeToken: [REQUIRED]\nThe value returned by the most recent call to GetChangeToken .\n
:rtype: dict
ReturnsResponse Syntax
{
'ChangeToken': 'string'
}
Response Structure
(dict) --
ChangeToken (string) --
The ChangeToken that you used to submit the UpdateRegexPatternSet request. You can also use this value to query the status of the request. For more information, see GetChangeTokenStatus .
Exceptions
WAFRegional.Client.exceptions.WAFStaleDataException
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFLimitsExceededException
WAFRegional.Client.exceptions.WAFNonexistentItemException
WAFRegional.Client.exceptions.WAFNonexistentContainerException
WAFRegional.Client.exceptions.WAFInvalidOperationException
WAFRegional.Client.exceptions.WAFInvalidAccountException
WAFRegional.Client.exceptions.WAFInvalidRegexPatternException
:return: {
'ChangeToken': 'string'
}
:returns:
BadBot
BadB0t
B@dBot
B@dB0t
"""
pass
def update_rule(RuleId=None, ChangeToken=None, Updates=None):
"""
Inserts or deletes Predicate objects in a Rule . Each Predicate object identifies a predicate, such as a ByteMatchSet or an IPSet , that specifies the web requests that you want to allow, block, or count. If you add more than one predicate to a Rule , a request must match all of the specifications to be allowed, blocked, or counted. For example, suppose that you add the following to a Rule :
You then add the Rule to a WebACL and specify that you want to block requests that satisfy the Rule . For a request to be blocked, the User-Agent header in the request must contain the value BadBot and the request must originate from the IP address 192.0.2.44.
To create and configure a Rule , perform the following steps:
If you want to replace one ByteMatchSet or IPSet with another, you delete the existing one and add the new one.
For more information about how to use the AWS WAF API to allow or block HTTP requests, see the AWS WAF Developer Guide .
See also: AWS API Documentation
Exceptions
Examples
The following example deletes a Predicate object in a rule with the ID example1ds3t-46da-4fdb-b8d5-abc321j569j5.
Expected Output:
:example: response = client.update_rule(
RuleId='string',
ChangeToken='string',
Updates=[
{
'Action': 'INSERT'|'DELETE',
'Predicate': {
'Negated': True|False,
'Type': 'IPMatch'|'ByteMatch'|'SqlInjectionMatch'|'GeoMatch'|'SizeConstraint'|'XssMatch'|'RegexMatch',
'DataId': 'string'
}
},
]
)
:type RuleId: string
:param RuleId: [REQUIRED]\nThe RuleId of the Rule that you want to update. RuleId is returned by CreateRule and by ListRules .\n
:type ChangeToken: string
:param ChangeToken: [REQUIRED]\nThe value returned by the most recent call to GetChangeToken .\n
:type Updates: list
:param Updates: [REQUIRED]\nAn array of RuleUpdate objects that you want to insert into or delete from a Rule . For more information, see the applicable data types:\n\nRuleUpdate : Contains Action and Predicate\nPredicate : Contains DataId , Negated , and Type\nFieldToMatch : Contains Data and Type\n\n\n(dict) --\nNote\nThis is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.\n\nFor the latest version of AWS WAF , use the AWS WAFV2 API and see the AWS WAF Developer Guide . With the latest version, AWS WAF has a single set of endpoints for regional and global use.\n\nSpecifies a Predicate (such as an IPSet ) and indicates whether you want to add it to a Rule or delete it from a Rule .\n\nAction (string) -- [REQUIRED]Specify INSERT to add a Predicate to a Rule . Use DELETE to remove a Predicate from a Rule .\n\nPredicate (dict) -- [REQUIRED]The ID of the Predicate (such as an IPSet ) that you want to add to a Rule .\n\nNegated (boolean) -- [REQUIRED]Set Negated to False if you want AWS WAF to allow, block, or count requests based on the settings in the specified ByteMatchSet , IPSet , SqlInjectionMatchSet , XssMatchSet , RegexMatchSet , GeoMatchSet , or SizeConstraintSet . For example, if an IPSet includes the IP address 192.0.2.44 , AWS WAF will allow or block requests based on that IP address.\nSet Negated to True if you want AWS WAF to allow or block a request based on the negation of the settings in the ByteMatchSet , IPSet , SqlInjectionMatchSet , XssMatchSet , RegexMatchSet , GeoMatchSet , or SizeConstraintSet . For example, if an IPSet includes the IP address 192.0.2.44 , AWS WAF will allow, block, or count requests based on all IP addresses except 192.0.2.44 .\n\nType (string) -- [REQUIRED]The type of predicate in a Rule , such as ByteMatch or IPSet .\n\nDataId (string) -- [REQUIRED]A unique identifier for a predicate in a Rule , such as ByteMatchSetId or IPSetId . The ID is returned by the corresponding Create or List command.\n\n\n\n\n\n\n
:rtype: dict
ReturnsResponse Syntax
{
'ChangeToken': 'string'
}
Response Structure
(dict) --
ChangeToken (string) --
The ChangeToken that you used to submit the UpdateRule request. You can also use this value to query the status of the request. For more information, see GetChangeTokenStatus .
Exceptions
WAFRegional.Client.exceptions.WAFStaleDataException
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidAccountException
WAFRegional.Client.exceptions.WAFInvalidOperationException
WAFRegional.Client.exceptions.WAFInvalidParameterException
WAFRegional.Client.exceptions.WAFNonexistentContainerException
WAFRegional.Client.exceptions.WAFNonexistentItemException
WAFRegional.Client.exceptions.WAFReferencedItemException
WAFRegional.Client.exceptions.WAFLimitsExceededException
Examples
The following example deletes a Predicate object in a rule with the ID example1ds3t-46da-4fdb-b8d5-abc321j569j5.
response = client.update_rule(
ChangeToken='abcd12f2-46da-4fdb-b8d5-fbd4c466928f',
RuleId='example1ds3t-46da-4fdb-b8d5-abc321j569j5',
Updates=[
{
'Action': 'DELETE',
'Predicate': {
'DataId': 'MyByteMatchSetID',
'Negated': False,
'Type': 'ByteMatch',
},
},
],
)
print(response)
Expected Output:
{
'ChangeToken': 'abcd12f2-46da-4fdb-b8d5-fbd4c466928f',
'ResponseMetadata': {
'...': '...',
},
}
:return: {
'ChangeToken': 'string'
}
:returns:
Create and update the predicates that you want to include in the Rule .
Create the Rule . See CreateRule .
Use GetChangeToken to get the change token that you provide in the ChangeToken parameter of an UpdateRule request.
Submit an UpdateRule request to add predicates to the Rule .
Create and update a WebACL that contains the Rule . See CreateWebACL .
"""
pass
def update_rule_group(RuleGroupId=None, Updates=None, ChangeToken=None):
"""
Inserts or deletes ActivatedRule objects in a RuleGroup .
You can only insert REGULAR rules into a rule group.
You can have a maximum of ten rules per rule group.
To create and configure a RuleGroup , perform the following steps:
If you want to replace one Rule with another, you delete the existing one and add the new one.
For more information about how to use the AWS WAF API to allow or block HTTP requests, see the AWS WAF Developer Guide .
See also: AWS API Documentation
Exceptions
:example: response = client.update_rule_group(
RuleGroupId='string',
Updates=[
{
'Action': 'INSERT'|'DELETE',
'ActivatedRule': {
'Priority': 123,
'RuleId': 'string',
'Action': {
'Type': 'BLOCK'|'ALLOW'|'COUNT'
},
'OverrideAction': {
'Type': 'NONE'|'COUNT'
},
'Type': 'REGULAR'|'RATE_BASED'|'GROUP',
'ExcludedRules': [
{
'RuleId': 'string'
},
]
}
},
],
ChangeToken='string'
)
:type RuleGroupId: string
:param RuleGroupId: [REQUIRED]\nThe RuleGroupId of the RuleGroup that you want to update. RuleGroupId is returned by CreateRuleGroup and by ListRuleGroups .\n
:type Updates: list
:param Updates: [REQUIRED]\nAn array of RuleGroupUpdate objects that you want to insert into or delete from a RuleGroup .\nYou can only insert REGULAR rules into a rule group.\n\nActivatedRule|OverrideAction applies only when updating or adding a RuleGroup to a WebACL . In this case you do not use ActivatedRule|Action . For all other update requests, ActivatedRule|Action is used instead of ActivatedRule|OverrideAction .\n\n(dict) --\nNote\nThis is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.\n\nFor the latest version of AWS WAF , use the AWS WAFV2 API and see the AWS WAF Developer Guide . With the latest version, AWS WAF has a single set of endpoints for regional and global use.\n\nSpecifies an ActivatedRule and indicates whether you want to add it to a RuleGroup or delete it from a RuleGroup .\n\nAction (string) -- [REQUIRED]Specify INSERT to add an ActivatedRule to a RuleGroup . Use DELETE to remove an ActivatedRule from a RuleGroup .\n\nActivatedRule (dict) -- [REQUIRED]The ActivatedRule object specifies a Rule that you want to insert or delete, the priority of the Rule in the WebACL , and the action that you want AWS WAF to take when a web request matches the Rule (ALLOW , BLOCK , or COUNT ).\n\nPriority (integer) -- [REQUIRED]Specifies the order in which the Rules in a WebACL are evaluated. Rules with a lower value for Priority are evaluated before Rules with a higher value. The value must be a unique integer. If you add multiple Rules to a WebACL , the values don\'t need to be consecutive.\n\nRuleId (string) -- [REQUIRED]The RuleId for a Rule . You use RuleId to get more information about a Rule (see GetRule ), update a Rule (see UpdateRule ), insert a Rule into a WebACL or delete a one from a WebACL (see UpdateWebACL ), or delete a Rule from AWS WAF (see DeleteRule ).\n\nRuleId is returned by CreateRule and by ListRules .\n\nAction (dict) --Specifies the action that CloudFront or AWS WAF takes when a web request matches the conditions in the Rule . Valid values for Action include the following:\n\nALLOW : CloudFront responds with the requested object.\nBLOCK : CloudFront responds with an HTTP 403 (Forbidden) status code.\nCOUNT : AWS WAF increments a counter of requests that match the conditions in the rule and then continues to inspect the web request based on the remaining rules in the web ACL.\n\n\nActivatedRule|OverrideAction applies only when updating or adding a RuleGroup to a WebACL . In this case, you do not use ActivatedRule|Action . For all other update requests, ActivatedRule|Action is used instead of ActivatedRule|OverrideAction .\n\nType (string) -- [REQUIRED]Specifies how you want AWS WAF to respond to requests that match the settings in a Rule . Valid settings include the following:\n\nALLOW : AWS WAF allows requests\nBLOCK : AWS WAF blocks requests\nCOUNT : AWS WAF increments a counter of the requests that match all of the conditions in the rule. AWS WAF then continues to inspect the web request based on the remaining rules in the web ACL. You can\'t specify COUNT for the default action for a WebACL .\n\n\n\n\nOverrideAction (dict) --Use the OverrideAction to test your RuleGroup .\nAny rule in a RuleGroup can potentially block a request. If you set the OverrideAction to None , the RuleGroup will block a request if any individual rule in the RuleGroup matches the request and is configured to block that request. However if you first want to test the RuleGroup , set the OverrideAction to Count . The RuleGroup will then override any block action specified by individual rules contained within the group. Instead of blocking matching requests, those requests will be counted. You can view a record of counted requests using GetSampledRequests .\n\nActivatedRule|OverrideAction applies only when updating or adding a RuleGroup to a WebACL . In this case you do not use ActivatedRule|Action . For all other update requests, ActivatedRule|Action is used instead of ActivatedRule|OverrideAction .\n\nType (string) -- [REQUIRED]\nCOUNT overrides the action specified by the individual rule within a RuleGroup . If set to NONE , the rule\'s action will take place.\n\n\n\nType (string) --The rule type, either REGULAR , as defined by Rule , RATE_BASED , as defined by RateBasedRule , or GROUP , as defined by RuleGroup . The default is REGULAR. Although this field is optional, be aware that if you try to add a RATE_BASED rule to a web ACL without setting the type, the UpdateWebACL request will fail because the request tries to add a REGULAR rule with the specified ID, which does not exist.\n\nExcludedRules (list) --An array of rules to exclude from a rule group. This is applicable only when the ActivatedRule refers to a RuleGroup .\nSometimes it is necessary to troubleshoot rule groups that are blocking traffic unexpectedly (false positives). One troubleshooting technique is to identify the specific rule within the rule group that is blocking the legitimate traffic and then disable (exclude) that particular rule. You can exclude rules from both your own rule groups and AWS Marketplace rule groups that have been associated with a web ACL.\nSpecifying ExcludedRules does not remove those rules from the rule group. Rather, it changes the action for the rules to COUNT . Therefore, requests that match an ExcludedRule are counted but not blocked. The RuleGroup owner will receive COUNT metrics for each ExcludedRule .\nIf you want to exclude rules from a rule group that is already associated with a web ACL, perform the following steps:\n\nUse the AWS WAF logs to identify the IDs of the rules that you want to exclude. For more information about the logs, see Logging Web ACL Traffic Information .\nSubmit an UpdateWebACL request that has two actions:\nThe first action deletes the existing rule group from the web ACL. That is, in the UpdateWebACL request, the first Updates:Action should be DELETE and Updates:ActivatedRule:RuleId should be the rule group that contains the rules that you want to exclude.\nThe second action inserts the same rule group back in, but specifying the rules to exclude. That is, the second Updates:Action should be INSERT , Updates:ActivatedRule:RuleId should be the rule group that you just removed, and ExcludedRules should contain the rules that you want to exclude.\n\n\n\n\n(dict) --\nNote\nThis is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.\n\nFor the latest version of AWS WAF , use the AWS WAFV2 API and see the AWS WAF Developer Guide . With the latest version, AWS WAF has a single set of endpoints for regional and global use.\n\nThe rule to exclude from a rule group. This is applicable only when the ActivatedRule refers to a RuleGroup . The rule must belong to the RuleGroup that is specified by the ActivatedRule .\n\nRuleId (string) -- [REQUIRED]The unique identifier for the rule to exclude from the rule group.\n\n\n\n\n\n\n\n\n\n\n
:type ChangeToken: string
:param ChangeToken: [REQUIRED]\nThe value returned by the most recent call to GetChangeToken .\n
:rtype: dict
ReturnsResponse Syntax
{
'ChangeToken': 'string'
}
Response Structure
(dict) --
ChangeToken (string) --
The ChangeToken that you used to submit the UpdateRuleGroup request. You can also use this value to query the status of the request. For more information, see GetChangeTokenStatus .
Exceptions
WAFRegional.Client.exceptions.WAFStaleDataException
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFNonexistentContainerException
WAFRegional.Client.exceptions.WAFNonexistentItemException
WAFRegional.Client.exceptions.WAFInvalidOperationException
WAFRegional.Client.exceptions.WAFLimitsExceededException
WAFRegional.Client.exceptions.WAFInvalidParameterException
:return: {
'ChangeToken': 'string'
}
:returns:
RuleGroupId (string) -- [REQUIRED]
The RuleGroupId of the RuleGroup that you want to update. RuleGroupId is returned by CreateRuleGroup and by ListRuleGroups .
Updates (list) -- [REQUIRED]
An array of RuleGroupUpdate objects that you want to insert into or delete from a RuleGroup .
You can only insert REGULAR rules into a rule group.
ActivatedRule|OverrideAction applies only when updating or adding a RuleGroup to a WebACL . In this case you do not use ActivatedRule|Action . For all other update requests, ActivatedRule|Action is used instead of ActivatedRule|OverrideAction .
(dict) --
Note
This is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.
For the latest version of AWS WAF , use the AWS WAFV2 API and see the AWS WAF Developer Guide . With the latest version, AWS WAF has a single set of endpoints for regional and global use.
Specifies an ActivatedRule and indicates whether you want to add it to a RuleGroup or delete it from a RuleGroup .
Action (string) -- [REQUIRED]Specify INSERT to add an ActivatedRule to a RuleGroup . Use DELETE to remove an ActivatedRule from a RuleGroup .
ActivatedRule (dict) -- [REQUIRED]The ActivatedRule object specifies a Rule that you want to insert or delete, the priority of the Rule in the WebACL , and the action that you want AWS WAF to take when a web request matches the Rule (ALLOW , BLOCK , or COUNT ).
Priority (integer) -- [REQUIRED]Specifies the order in which the Rules in a WebACL are evaluated. Rules with a lower value for Priority are evaluated before Rules with a higher value. The value must be a unique integer. If you add multiple Rules to a WebACL , the values don\'t need to be consecutive.
RuleId (string) -- [REQUIRED]The RuleId for a Rule . You use RuleId to get more information about a Rule (see GetRule ), update a Rule (see UpdateRule ), insert a Rule into a WebACL or delete a one from a WebACL (see UpdateWebACL ), or delete a Rule from AWS WAF (see DeleteRule ).
RuleId is returned by CreateRule and by ListRules .
Action (dict) --Specifies the action that CloudFront or AWS WAF takes when a web request matches the conditions in the Rule . Valid values for Action include the following:
ALLOW : CloudFront responds with the requested object.
BLOCK : CloudFront responds with an HTTP 403 (Forbidden) status code.
COUNT : AWS WAF increments a counter of requests that match the conditions in the rule and then continues to inspect the web request based on the remaining rules in the web ACL.
ActivatedRule|OverrideAction applies only when updating or adding a RuleGroup to a WebACL . In this case, you do not use ActivatedRule|Action . For all other update requests, ActivatedRule|Action is used instead of ActivatedRule|OverrideAction .
Type (string) -- [REQUIRED]Specifies how you want AWS WAF to respond to requests that match the settings in a Rule . Valid settings include the following:
ALLOW : AWS WAF allows requests
BLOCK : AWS WAF blocks requests
COUNT : AWS WAF increments a counter of the requests that match all of the conditions in the rule. AWS WAF then continues to inspect the web request based on the remaining rules in the web ACL. You can\'t specify COUNT for the default action for a WebACL .
OverrideAction (dict) --Use the OverrideAction to test your RuleGroup .
Any rule in a RuleGroup can potentially block a request. If you set the OverrideAction to None , the RuleGroup will block a request if any individual rule in the RuleGroup matches the request and is configured to block that request. However if you first want to test the RuleGroup , set the OverrideAction to Count . The RuleGroup will then override any block action specified by individual rules contained within the group. Instead of blocking matching requests, those requests will be counted. You can view a record of counted requests using GetSampledRequests .
ActivatedRule|OverrideAction applies only when updating or adding a RuleGroup to a WebACL . In this case you do not use ActivatedRule|Action . For all other update requests, ActivatedRule|Action is used instead of ActivatedRule|OverrideAction .
Type (string) -- [REQUIRED]
COUNT overrides the action specified by the individual rule within a RuleGroup . If set to NONE , the rule\'s action will take place.
Type (string) --The rule type, either REGULAR , as defined by Rule , RATE_BASED , as defined by RateBasedRule , or GROUP , as defined by RuleGroup . The default is REGULAR. Although this field is optional, be aware that if you try to add a RATE_BASED rule to a web ACL without setting the type, the UpdateWebACL request will fail because the request tries to add a REGULAR rule with the specified ID, which does not exist.
ExcludedRules (list) --An array of rules to exclude from a rule group. This is applicable only when the ActivatedRule refers to a RuleGroup .
Sometimes it is necessary to troubleshoot rule groups that are blocking traffic unexpectedly (false positives). One troubleshooting technique is to identify the specific rule within the rule group that is blocking the legitimate traffic and then disable (exclude) that particular rule. You can exclude rules from both your own rule groups and AWS Marketplace rule groups that have been associated with a web ACL.
Specifying ExcludedRules does not remove those rules from the rule group. Rather, it changes the action for the rules to COUNT . Therefore, requests that match an ExcludedRule are counted but not blocked. The RuleGroup owner will receive COUNT metrics for each ExcludedRule .
If you want to exclude rules from a rule group that is already associated with a web ACL, perform the following steps:
Use the AWS WAF logs to identify the IDs of the rules that you want to exclude. For more information about the logs, see Logging Web ACL Traffic Information .
Submit an UpdateWebACL request that has two actions:
The first action deletes the existing rule group from the web ACL. That is, in the UpdateWebACL request, the first Updates:Action should be DELETE and Updates:ActivatedRule:RuleId should be the rule group that contains the rules that you want to exclude.
The second action inserts the same rule group back in, but specifying the rules to exclude. That is, the second Updates:Action should be INSERT , Updates:ActivatedRule:RuleId should be the rule group that you just removed, and ExcludedRules should contain the rules that you want to exclude.
(dict) --
Note
This is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.
For the latest version of AWS WAF , use the AWS WAFV2 API and see the AWS WAF Developer Guide . With the latest version, AWS WAF has a single set of endpoints for regional and global use.
The rule to exclude from a rule group. This is applicable only when the ActivatedRule refers to a RuleGroup . The rule must belong to the RuleGroup that is specified by the ActivatedRule .
RuleId (string) -- [REQUIRED]The unique identifier for the rule to exclude from the rule group.
ChangeToken (string) -- [REQUIRED]
The value returned by the most recent call to GetChangeToken .
"""
pass
def update_size_constraint_set(SizeConstraintSetId=None, ChangeToken=None, Updates=None):
"""
Inserts or deletes SizeConstraint objects (filters) in a SizeConstraintSet . For each SizeConstraint object, you specify the following values:
For example, you can add a SizeConstraintSetUpdate object that matches web requests in which the length of the User-Agent header is greater than 100 bytes. You can then configure AWS WAF to block those requests.
To create and configure a SizeConstraintSet , perform the following steps:
For more information about how to use the AWS WAF API to allow or block HTTP requests, see the AWS WAF Developer Guide .
See also: AWS API Documentation
Exceptions
Examples
The following example deletes a SizeConstraint object (filters) in a size constraint set with the ID example1ds3t-46da-4fdb-b8d5-abc321j569j5.
Expected Output:
:example: response = client.update_size_constraint_set(
SizeConstraintSetId='string',
ChangeToken='string',
Updates=[
{
'Action': 'INSERT'|'DELETE',
'SizeConstraint': {
'FieldToMatch': {
'Type': 'URI'|'QUERY_STRING'|'HEADER'|'METHOD'|'BODY'|'SINGLE_QUERY_ARG'|'ALL_QUERY_ARGS',
'Data': 'string'
},
'TextTransformation': 'NONE'|'COMPRESS_WHITE_SPACE'|'HTML_ENTITY_DECODE'|'LOWERCASE'|'CMD_LINE'|'URL_DECODE',
'ComparisonOperator': 'EQ'|'NE'|'LE'|'LT'|'GE'|'GT',
'Size': 123
}
},
]
)
:type SizeConstraintSetId: string
:param SizeConstraintSetId: [REQUIRED]\nThe SizeConstraintSetId of the SizeConstraintSet that you want to update. SizeConstraintSetId is returned by CreateSizeConstraintSet and by ListSizeConstraintSets .\n
:type ChangeToken: string
:param ChangeToken: [REQUIRED]\nThe value returned by the most recent call to GetChangeToken .\n
:type Updates: list
:param Updates: [REQUIRED]\nAn array of SizeConstraintSetUpdate objects that you want to insert into or delete from a SizeConstraintSet . For more information, see the applicable data types:\n\nSizeConstraintSetUpdate : Contains Action and SizeConstraint\nSizeConstraint : Contains FieldToMatch , TextTransformation , ComparisonOperator , and Size\nFieldToMatch : Contains Data and Type\n\n\n(dict) --\nNote\nThis is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.\n\nFor the latest version of AWS WAF , use the AWS WAFV2 API and see the AWS WAF Developer Guide . With the latest version, AWS WAF has a single set of endpoints for regional and global use.\n\nSpecifies the part of a web request that you want to inspect the size of and indicates whether you want to add the specification to a SizeConstraintSet or delete it from a SizeConstraintSet .\n\nAction (string) -- [REQUIRED]Specify INSERT to add a SizeConstraintSetUpdate to a SizeConstraintSet . Use DELETE to remove a SizeConstraintSetUpdate from a SizeConstraintSet .\n\nSizeConstraint (dict) -- [REQUIRED]Specifies a constraint on the size of a part of the web request. AWS WAF uses the Size , ComparisonOperator , and FieldToMatch to build an expression in the form of 'Size ComparisonOperator size in bytes of FieldToMatch '. If that expression is true, the SizeConstraint is considered to match.\n\nFieldToMatch (dict) -- [REQUIRED]Specifies where in a web request to look for the size constraint.\n\nType (string) -- [REQUIRED]The part of the web request that you want AWS WAF to search for a specified string. Parts of a request that you can search include the following:\n\nHEADER : A specified request header, for example, the value of the User-Agent or Referer header. If you choose HEADER for the type, specify the name of the header in Data .\nMETHOD : The HTTP method, which indicated the type of operation that the request is asking the origin to perform. Amazon CloudFront supports the following methods: DELETE , GET , HEAD , OPTIONS , PATCH , POST , and PUT .\nQUERY_STRING : A query string, which is the part of a URL that appears after a ? character, if any.\nURI : The part of a web request that identifies a resource, for example, /images/daily-ad.jpg .\nBODY : The part of a request that contains any additional data that you want to send to your web server as the HTTP request body, such as data from a form. The request body immediately follows the request headers. Note that only the first 8192 bytes of the request body are forwarded to AWS WAF for inspection. To allow or block requests based on the length of the body, you can create a size constraint set. For more information, see CreateSizeConstraintSet .\nSINGLE_QUERY_ARG : The parameter in the query string that you will inspect, such as UserName or SalesRegion . The maximum length for SINGLE_QUERY_ARG is 30 characters.\nALL_QUERY_ARGS : Similar to SINGLE_QUERY_ARG , but rather than inspecting a single parameter, AWS WAF will inspect all parameters within the query for the value or regex pattern that you specify in TargetString .\n\n\nData (string) --When the value of Type is HEADER , enter the name of the header that you want AWS WAF to search, for example, User-Agent or Referer . The name of the header is not case sensitive.\nWhen the value of Type is SINGLE_QUERY_ARG , enter the name of the parameter that you want AWS WAF to search, for example, UserName or SalesRegion . The parameter name is not case sensitive.\nIf the value of Type is any other value, omit Data .\n\n\n\nTextTransformation (string) -- [REQUIRED]Text transformations eliminate some of the unusual formatting that attackers use in web requests in an effort to bypass AWS WAF. If you specify a transformation, AWS WAF performs the transformation on FieldToMatch before inspecting it for a match.\nYou can only specify a single type of TextTransformation.\nNote that if you choose BODY for the value of Type , you must choose NONE for TextTransformation because CloudFront forwards only the first 8192 bytes for inspection.\n\nNONE\nSpecify NONE if you don\'t want to perform any text transformations.\n\nCMD_LINE\nWhen you\'re concerned that attackers are injecting an operating system command line command and using unusual formatting to disguise some or all of the command, use this option to perform the following transformations:\n\nDelete the following characters: ' \' ^\nDelete spaces before the following characters: / (\nReplace the following characters with a space: , ;\nReplace multiple spaces with one space\nConvert uppercase letters (A-Z) to lowercase (a-z)\n\n\nCOMPRESS_WHITE_SPACE\nUse this option to replace the following characters with a space character (decimal 32):\n\nf, formfeed, decimal 12\nt, tab, decimal 9\nn, newline, decimal 10\nr, carriage return, decimal 13\nv, vertical tab, decimal 11\nnon-breaking space, decimal 160\n\n\nCOMPRESS_WHITE_SPACE also replaces multiple spaces with one space.HTML_ENTITY_DECODE\n\nUse this option to replace HTML-encoded characters with unencoded characters. HTML_ENTITY_DECODE performs the following operations:\n\nReplaces (ampersand)quot; with '\nReplaces (ampersand)nbsp; with a non-breaking space, decimal 160\nReplaces (ampersand)lt; with a 'less than' symbol\nReplaces (ampersand)gt; with >\nReplaces characters that are represented in hexadecimal format, (ampersand)#xhhhh; , with the corresponding characters\nReplaces characters that are represented in decimal format, (ampersand)#nnnn; , with the corresponding characters\n\n\nLOWERCASE\nUse this option to convert uppercase letters (A-Z) to lowercase (a-z).\n\nURL_DECODE\nUse this option to decode a URL-encoded value.\n\nComparisonOperator (string) -- [REQUIRED]The type of comparison you want AWS WAF to perform. AWS WAF uses this in combination with the provided Size and FieldToMatch to build an expression in the form of 'Size ComparisonOperator size in bytes of FieldToMatch '. If that expression is true, the SizeConstraint is considered to match.\n\nEQ : Used to test if the Size is equal to the size of the FieldToMatchNE : Used to test if the Size is not equal to the size of the FieldToMatch\nLE : Used to test if the Size is less than or equal to the size of the FieldToMatch\nLT : Used to test if the Size is strictly less than the size of the FieldToMatch\nGE : Used to test if the Size is greater than or equal to the size of the FieldToMatch\nGT : Used to test if the Size is strictly greater than the size of the FieldToMatch\n\n\nSize (integer) -- [REQUIRED]The size in bytes that you want AWS WAF to compare against the size of the specified FieldToMatch . AWS WAF uses this in combination with ComparisonOperator and FieldToMatch to build an expression in the form of 'Size ComparisonOperator size in bytes of FieldToMatch '. If that expression is true, the SizeConstraint is considered to match.\nValid values for size are 0 - 21474836480 bytes (0 - 20 GB).\nIf you specify URI for the value of Type , the / in the URI counts as one character. For example, the URI /logo.jpg is nine characters long.\n\n\n\n\n\n\n
:rtype: dict
ReturnsResponse Syntax
{
'ChangeToken': 'string'
}
Response Structure
(dict) --
ChangeToken (string) --
The ChangeToken that you used to submit the UpdateSizeConstraintSet request. You can also use this value to query the status of the request. For more information, see GetChangeTokenStatus .
Exceptions
WAFRegional.Client.exceptions.WAFStaleDataException
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidAccountException
WAFRegional.Client.exceptions.WAFInvalidOperationException
WAFRegional.Client.exceptions.WAFInvalidParameterException
WAFRegional.Client.exceptions.WAFNonexistentContainerException
WAFRegional.Client.exceptions.WAFNonexistentItemException
WAFRegional.Client.exceptions.WAFReferencedItemException
WAFRegional.Client.exceptions.WAFLimitsExceededException
Examples
The following example deletes a SizeConstraint object (filters) in a size constraint set with the ID example1ds3t-46da-4fdb-b8d5-abc321j569j5.
response = client.update_size_constraint_set(
ChangeToken='abcd12f2-46da-4fdb-b8d5-fbd4c466928f',
SizeConstraintSetId='example1ds3t-46da-4fdb-b8d5-abc321j569j5',
Updates=[
{
'Action': 'DELETE',
'SizeConstraint': {
'ComparisonOperator': 'GT',
'FieldToMatch': {
'Type': 'QUERY_STRING',
},
'Size': 0,
'TextTransformation': 'NONE',
},
},
],
)
print(response)
Expected Output:
{
'ChangeToken': 'abcd12f2-46da-4fdb-b8d5-fbd4c466928f',
'ResponseMetadata': {
'...': '...',
},
}
:return: {
'ChangeToken': 'string'
}
:returns:
Create a SizeConstraintSet. For more information, see CreateSizeConstraintSet .
Use GetChangeToken to get the change token that you provide in the ChangeToken parameter of an UpdateSizeConstraintSet request.
Submit an UpdateSizeConstraintSet request to specify the part of the request that you want AWS WAF to inspect (for example, the header or the URI) and the value that you want AWS WAF to watch for.
"""
pass
def update_sql_injection_match_set(SqlInjectionMatchSetId=None, ChangeToken=None, Updates=None):
"""
Inserts or deletes SqlInjectionMatchTuple objects (filters) in a SqlInjectionMatchSet . For each SqlInjectionMatchTuple object, you specify the following values:
You use SqlInjectionMatchSet objects to specify which CloudFront requests that you want to allow, block, or count. For example, if you\'re receiving requests that contain snippets of SQL code in the query string and you want to block the requests, you can create a SqlInjectionMatchSet with the applicable settings, and then configure AWS WAF to block the requests.
To create and configure a SqlInjectionMatchSet , perform the following steps:
For more information about how to use the AWS WAF API to allow or block HTTP requests, see the AWS WAF Developer Guide .
See also: AWS API Documentation
Exceptions
Examples
The following example deletes a SqlInjectionMatchTuple object (filters) in a SQL injection match set with the ID example1ds3t-46da-4fdb-b8d5-abc321j569j5.
Expected Output:
:example: response = client.update_sql_injection_match_set(
SqlInjectionMatchSetId='string',
ChangeToken='string',
Updates=[
{
'Action': 'INSERT'|'DELETE',
'SqlInjectionMatchTuple': {
'FieldToMatch': {
'Type': 'URI'|'QUERY_STRING'|'HEADER'|'METHOD'|'BODY'|'SINGLE_QUERY_ARG'|'ALL_QUERY_ARGS',
'Data': 'string'
},
'TextTransformation': 'NONE'|'COMPRESS_WHITE_SPACE'|'HTML_ENTITY_DECODE'|'LOWERCASE'|'CMD_LINE'|'URL_DECODE'
}
},
]
)
:type SqlInjectionMatchSetId: string
:param SqlInjectionMatchSetId: [REQUIRED]\nThe SqlInjectionMatchSetId of the SqlInjectionMatchSet that you want to update. SqlInjectionMatchSetId is returned by CreateSqlInjectionMatchSet and by ListSqlInjectionMatchSets .\n
:type ChangeToken: string
:param ChangeToken: [REQUIRED]\nThe value returned by the most recent call to GetChangeToken .\n
:type Updates: list
:param Updates: [REQUIRED]\nAn array of SqlInjectionMatchSetUpdate objects that you want to insert into or delete from a SqlInjectionMatchSet . For more information, see the applicable data types:\n\nSqlInjectionMatchSetUpdate : Contains Action and SqlInjectionMatchTuple\nSqlInjectionMatchTuple : Contains FieldToMatch and TextTransformation\nFieldToMatch : Contains Data and Type\n\n\n(dict) --\nNote\nThis is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.\n\nFor the latest version of AWS WAF , use the AWS WAFV2 API and see the AWS WAF Developer Guide . With the latest version, AWS WAF has a single set of endpoints for regional and global use.\n\nSpecifies the part of a web request that you want to inspect for snippets of malicious SQL code and indicates whether you want to add the specification to a SqlInjectionMatchSet or delete it from a SqlInjectionMatchSet .\n\nAction (string) -- [REQUIRED]Specify INSERT to add a SqlInjectionMatchSetUpdate to a SqlInjectionMatchSet . Use DELETE to remove a SqlInjectionMatchSetUpdate from a SqlInjectionMatchSet .\n\nSqlInjectionMatchTuple (dict) -- [REQUIRED]Specifies the part of a web request that you want AWS WAF to inspect for snippets of malicious SQL code and, if you want AWS WAF to inspect a header, the name of the header.\n\nFieldToMatch (dict) -- [REQUIRED]Specifies where in a web request to look for snippets of malicious SQL code.\n\nType (string) -- [REQUIRED]The part of the web request that you want AWS WAF to search for a specified string. Parts of a request that you can search include the following:\n\nHEADER : A specified request header, for example, the value of the User-Agent or Referer header. If you choose HEADER for the type, specify the name of the header in Data .\nMETHOD : The HTTP method, which indicated the type of operation that the request is asking the origin to perform. Amazon CloudFront supports the following methods: DELETE , GET , HEAD , OPTIONS , PATCH , POST , and PUT .\nQUERY_STRING : A query string, which is the part of a URL that appears after a ? character, if any.\nURI : The part of a web request that identifies a resource, for example, /images/daily-ad.jpg .\nBODY : The part of a request that contains any additional data that you want to send to your web server as the HTTP request body, such as data from a form. The request body immediately follows the request headers. Note that only the first 8192 bytes of the request body are forwarded to AWS WAF for inspection. To allow or block requests based on the length of the body, you can create a size constraint set. For more information, see CreateSizeConstraintSet .\nSINGLE_QUERY_ARG : The parameter in the query string that you will inspect, such as UserName or SalesRegion . The maximum length for SINGLE_QUERY_ARG is 30 characters.\nALL_QUERY_ARGS : Similar to SINGLE_QUERY_ARG , but rather than inspecting a single parameter, AWS WAF will inspect all parameters within the query for the value or regex pattern that you specify in TargetString .\n\n\nData (string) --When the value of Type is HEADER , enter the name of the header that you want AWS WAF to search, for example, User-Agent or Referer . The name of the header is not case sensitive.\nWhen the value of Type is SINGLE_QUERY_ARG , enter the name of the parameter that you want AWS WAF to search, for example, UserName or SalesRegion . The parameter name is not case sensitive.\nIf the value of Type is any other value, omit Data .\n\n\n\nTextTransformation (string) -- [REQUIRED]Text transformations eliminate some of the unusual formatting that attackers use in web requests in an effort to bypass AWS WAF. If you specify a transformation, AWS WAF performs the transformation on FieldToMatch before inspecting it for a match.\nYou can only specify a single type of TextTransformation.\n\nCMD_LINE\nWhen you\'re concerned that attackers are injecting an operating system command line command and using unusual formatting to disguise some or all of the command, use this option to perform the following transformations:\n\nDelete the following characters: ' \' ^\nDelete spaces before the following characters: / (\nReplace the following characters with a space: , ;\nReplace multiple spaces with one space\nConvert uppercase letters (A-Z) to lowercase (a-z)\n\n\nCOMPRESS_WHITE_SPACE\nUse this option to replace the following characters with a space character (decimal 32):\n\nf, formfeed, decimal 12\nt, tab, decimal 9\nn, newline, decimal 10\nr, carriage return, decimal 13\nv, vertical tab, decimal 11\nnon-breaking space, decimal 160\n\n\nCOMPRESS_WHITE_SPACE also replaces multiple spaces with one space.HTML_ENTITY_DECODE\n\nUse this option to replace HTML-encoded characters with unencoded characters. HTML_ENTITY_DECODE performs the following operations:\n\nReplaces (ampersand)quot; with '\nReplaces (ampersand)nbsp; with a non-breaking space, decimal 160\nReplaces (ampersand)lt; with a 'less than' symbol\nReplaces (ampersand)gt; with >\nReplaces characters that are represented in hexadecimal format, (ampersand)#xhhhh; , with the corresponding characters\nReplaces characters that are represented in decimal format, (ampersand)#nnnn; , with the corresponding characters\n\n\nLOWERCASE\nUse this option to convert uppercase letters (A-Z) to lowercase (a-z).\n\nURL_DECODE\nUse this option to decode a URL-encoded value.\n\nNONE\nSpecify NONE if you don\'t want to perform any text transformations.\n\n\n\n\n\n\n
:rtype: dict
ReturnsResponse Syntax
{
'ChangeToken': 'string'
}
Response Structure
(dict) --
The response to an UpdateSqlInjectionMatchSets request.
ChangeToken (string) --
The ChangeToken that you used to submit the UpdateSqlInjectionMatchSet request. You can also use this value to query the status of the request. For more information, see GetChangeTokenStatus .
Exceptions
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidAccountException
WAFRegional.Client.exceptions.WAFInvalidOperationException
WAFRegional.Client.exceptions.WAFInvalidParameterException
WAFRegional.Client.exceptions.WAFNonexistentContainerException
WAFRegional.Client.exceptions.WAFNonexistentItemException
WAFRegional.Client.exceptions.WAFStaleDataException
WAFRegional.Client.exceptions.WAFLimitsExceededException
Examples
The following example deletes a SqlInjectionMatchTuple object (filters) in a SQL injection match set with the ID example1ds3t-46da-4fdb-b8d5-abc321j569j5.
response = client.update_sql_injection_match_set(
ChangeToken='abcd12f2-46da-4fdb-b8d5-fbd4c466928f',
SqlInjectionMatchSetId='example1ds3t-46da-4fdb-b8d5-abc321j569j5',
Updates=[
{
'Action': 'DELETE',
'SqlInjectionMatchTuple': {
'FieldToMatch': {
'Type': 'QUERY_STRING',
},
'TextTransformation': 'URL_DECODE',
},
},
],
)
print(response)
Expected Output:
{
'ChangeToken': 'abcd12f2-46da-4fdb-b8d5-fbd4c466928f',
'ResponseMetadata': {
'...': '...',
},
}
:return: {
'ChangeToken': 'string'
}
:returns:
Submit a CreateSqlInjectionMatchSet request.
Use GetChangeToken to get the change token that you provide in the ChangeToken parameter of an UpdateIPSet request.
Submit an UpdateSqlInjectionMatchSet request to specify the parts of web requests that you want AWS WAF to inspect for snippets of SQL code.
"""
pass
def update_web_acl(WebACLId=None, ChangeToken=None, Updates=None, DefaultAction=None):
"""
Inserts or deletes ActivatedRule objects in a WebACL . Each Rule identifies web requests that you want to allow, block, or count. When you update a WebACL , you specify the following values:
To create and configure a WebACL , perform the following steps:
Be aware that if you try to add a RATE_BASED rule to a web ACL without setting the rule type when first creating the rule, the UpdateWebACL request will fail because the request tries to add a REGULAR rule (the default rule type) with the specified ID, which does not exist.
For more information about how to use the AWS WAF API to allow or block HTTP requests, see the AWS WAF Developer Guide .
See also: AWS API Documentation
Exceptions
Examples
The following example deletes an ActivatedRule object in a WebACL with the ID webacl-1472061481310.
Expected Output:
:example: response = client.update_web_acl(
WebACLId='string',
ChangeToken='string',
Updates=[
{
'Action': 'INSERT'|'DELETE',
'ActivatedRule': {
'Priority': 123,
'RuleId': 'string',
'Action': {
'Type': 'BLOCK'|'ALLOW'|'COUNT'
},
'OverrideAction': {
'Type': 'NONE'|'COUNT'
},
'Type': 'REGULAR'|'RATE_BASED'|'GROUP',
'ExcludedRules': [
{
'RuleId': 'string'
},
]
}
},
],
DefaultAction={
'Type': 'BLOCK'|'ALLOW'|'COUNT'
}
)
:type WebACLId: string
:param WebACLId: [REQUIRED]\nThe WebACLId of the WebACL that you want to update. WebACLId is returned by CreateWebACL and by ListWebACLs .\n
:type ChangeToken: string
:param ChangeToken: [REQUIRED]\nThe value returned by the most recent call to GetChangeToken .\n
:type Updates: list
:param Updates: An array of updates to make to the WebACL .\nAn array of WebACLUpdate objects that you want to insert into or delete from a WebACL . For more information, see the applicable data types:\n\nWebACLUpdate : Contains Action and ActivatedRule\nActivatedRule : Contains Action , OverrideAction , Priority , RuleId , and Type . ActivatedRule|OverrideAction applies only when updating or adding a RuleGroup to a WebACL . In this case, you do not use ActivatedRule|Action . For all other update requests, ActivatedRule|Action is used instead of ActivatedRule|OverrideAction .\nWafAction : Contains Type\n\n\n(dict) --\nNote\nThis is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.\n\nFor the latest version of AWS WAF , use the AWS WAFV2 API and see the AWS WAF Developer Guide . With the latest version, AWS WAF has a single set of endpoints for regional and global use.\n\nSpecifies whether to insert a Rule into or delete a Rule from a WebACL .\n\nAction (string) -- [REQUIRED]Specifies whether to insert a Rule into or delete a Rule from a WebACL .\n\nActivatedRule (dict) -- [REQUIRED]The ActivatedRule object in an UpdateWebACL request specifies a Rule that you want to insert or delete, the priority of the Rule in the WebACL , and the action that you want AWS WAF to take when a web request matches the Rule (ALLOW , BLOCK , or COUNT ).\n\nPriority (integer) -- [REQUIRED]Specifies the order in which the Rules in a WebACL are evaluated. Rules with a lower value for Priority are evaluated before Rules with a higher value. The value must be a unique integer. If you add multiple Rules to a WebACL , the values don\'t need to be consecutive.\n\nRuleId (string) -- [REQUIRED]The RuleId for a Rule . You use RuleId to get more information about a Rule (see GetRule ), update a Rule (see UpdateRule ), insert a Rule into a WebACL or delete a one from a WebACL (see UpdateWebACL ), or delete a Rule from AWS WAF (see DeleteRule ).\n\nRuleId is returned by CreateRule and by ListRules .\n\nAction (dict) --Specifies the action that CloudFront or AWS WAF takes when a web request matches the conditions in the Rule . Valid values for Action include the following:\n\nALLOW : CloudFront responds with the requested object.\nBLOCK : CloudFront responds with an HTTP 403 (Forbidden) status code.\nCOUNT : AWS WAF increments a counter of requests that match the conditions in the rule and then continues to inspect the web request based on the remaining rules in the web ACL.\n\n\nActivatedRule|OverrideAction applies only when updating or adding a RuleGroup to a WebACL . In this case, you do not use ActivatedRule|Action . For all other update requests, ActivatedRule|Action is used instead of ActivatedRule|OverrideAction .\n\nType (string) -- [REQUIRED]Specifies how you want AWS WAF to respond to requests that match the settings in a Rule . Valid settings include the following:\n\nALLOW : AWS WAF allows requests\nBLOCK : AWS WAF blocks requests\nCOUNT : AWS WAF increments a counter of the requests that match all of the conditions in the rule. AWS WAF then continues to inspect the web request based on the remaining rules in the web ACL. You can\'t specify COUNT for the default action for a WebACL .\n\n\n\n\nOverrideAction (dict) --Use the OverrideAction to test your RuleGroup .\nAny rule in a RuleGroup can potentially block a request. If you set the OverrideAction to None , the RuleGroup will block a request if any individual rule in the RuleGroup matches the request and is configured to block that request. However if you first want to test the RuleGroup , set the OverrideAction to Count . The RuleGroup will then override any block action specified by individual rules contained within the group. Instead of blocking matching requests, those requests will be counted. You can view a record of counted requests using GetSampledRequests .\n\nActivatedRule|OverrideAction applies only when updating or adding a RuleGroup to a WebACL . In this case you do not use ActivatedRule|Action . For all other update requests, ActivatedRule|Action is used instead of ActivatedRule|OverrideAction .\n\nType (string) -- [REQUIRED]\nCOUNT overrides the action specified by the individual rule within a RuleGroup . If set to NONE , the rule\'s action will take place.\n\n\n\nType (string) --The rule type, either REGULAR , as defined by Rule , RATE_BASED , as defined by RateBasedRule , or GROUP , as defined by RuleGroup . The default is REGULAR. Although this field is optional, be aware that if you try to add a RATE_BASED rule to a web ACL without setting the type, the UpdateWebACL request will fail because the request tries to add a REGULAR rule with the specified ID, which does not exist.\n\nExcludedRules (list) --An array of rules to exclude from a rule group. This is applicable only when the ActivatedRule refers to a RuleGroup .\nSometimes it is necessary to troubleshoot rule groups that are blocking traffic unexpectedly (false positives). One troubleshooting technique is to identify the specific rule within the rule group that is blocking the legitimate traffic and then disable (exclude) that particular rule. You can exclude rules from both your own rule groups and AWS Marketplace rule groups that have been associated with a web ACL.\nSpecifying ExcludedRules does not remove those rules from the rule group. Rather, it changes the action for the rules to COUNT . Therefore, requests that match an ExcludedRule are counted but not blocked. The RuleGroup owner will receive COUNT metrics for each ExcludedRule .\nIf you want to exclude rules from a rule group that is already associated with a web ACL, perform the following steps:\n\nUse the AWS WAF logs to identify the IDs of the rules that you want to exclude. For more information about the logs, see Logging Web ACL Traffic Information .\nSubmit an UpdateWebACL request that has two actions:\nThe first action deletes the existing rule group from the web ACL. That is, in the UpdateWebACL request, the first Updates:Action should be DELETE and Updates:ActivatedRule:RuleId should be the rule group that contains the rules that you want to exclude.\nThe second action inserts the same rule group back in, but specifying the rules to exclude. That is, the second Updates:Action should be INSERT , Updates:ActivatedRule:RuleId should be the rule group that you just removed, and ExcludedRules should contain the rules that you want to exclude.\n\n\n\n\n(dict) --\nNote\nThis is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.\n\nFor the latest version of AWS WAF , use the AWS WAFV2 API and see the AWS WAF Developer Guide . With the latest version, AWS WAF has a single set of endpoints for regional and global use.\n\nThe rule to exclude from a rule group. This is applicable only when the ActivatedRule refers to a RuleGroup . The rule must belong to the RuleGroup that is specified by the ActivatedRule .\n\nRuleId (string) -- [REQUIRED]The unique identifier for the rule to exclude from the rule group.\n\n\n\n\n\n\n\n\n\n\n
:type DefaultAction: dict
:param DefaultAction: A default action for the web ACL, either ALLOW or BLOCK. AWS WAF performs the default action if a request doesn\'t match the criteria in any of the rules in a web ACL.\n\nType (string) -- [REQUIRED]Specifies how you want AWS WAF to respond to requests that match the settings in a Rule . Valid settings include the following:\n\nALLOW : AWS WAF allows requests\nBLOCK : AWS WAF blocks requests\nCOUNT : AWS WAF increments a counter of the requests that match all of the conditions in the rule. AWS WAF then continues to inspect the web request based on the remaining rules in the web ACL. You can\'t specify COUNT for the default action for a WebACL .\n\n\n\n
:rtype: dict
ReturnsResponse Syntax
{
'ChangeToken': 'string'
}
Response Structure
(dict) --
ChangeToken (string) --
The ChangeToken that you used to submit the UpdateWebACL request. You can also use this value to query the status of the request. For more information, see GetChangeTokenStatus .
Exceptions
WAFRegional.Client.exceptions.WAFStaleDataException
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidAccountException
WAFRegional.Client.exceptions.WAFInvalidOperationException
WAFRegional.Client.exceptions.WAFInvalidParameterException
WAFRegional.Client.exceptions.WAFNonexistentContainerException
WAFRegional.Client.exceptions.WAFNonexistentItemException
WAFRegional.Client.exceptions.WAFReferencedItemException
WAFRegional.Client.exceptions.WAFLimitsExceededException
WAFRegional.Client.exceptions.WAFSubscriptionNotFoundException
Examples
The following example deletes an ActivatedRule object in a WebACL with the ID webacl-1472061481310.
response = client.update_web_acl(
ChangeToken='abcd12f2-46da-4fdb-b8d5-fbd4c466928f',
DefaultAction={
'Type': 'ALLOW',
},
Updates=[
{
'Action': 'DELETE',
'ActivatedRule': {
'Action': {
'Type': 'ALLOW',
},
'Priority': 1,
'RuleId': 'WAFRule-1-Example',
},
},
],
WebACLId='webacl-1472061481310',
)
print(response)
Expected Output:
{
'ChangeToken': 'abcd12f2-46da-4fdb-b8d5-fbd4c466928f',
'ResponseMetadata': {
'...': '...',
},
}
:return: {
'ChangeToken': 'string'
}
:returns:
Create and update the predicates that you want to include in Rules . For more information, see CreateByteMatchSet , UpdateByteMatchSet , CreateIPSet , UpdateIPSet , CreateSqlInjectionMatchSet , and UpdateSqlInjectionMatchSet .
Create and update the Rules that you want to include in the WebACL . For more information, see CreateRule and UpdateRule .
Create a WebACL . See CreateWebACL .
Use GetChangeToken to get the change token that you provide in the ChangeToken parameter of an UpdateWebACL request.
Submit an UpdateWebACL request to specify the Rules that you want to include in the WebACL , to specify the default action, and to associate the WebACL with a CloudFront distribution. The ActivatedRule can be a rule group. If you specify a rule group as your ActivatedRule , you can exclude specific rules from that rule group. If you already have a rule group associated with a web ACL and want to submit an UpdateWebACL request to exclude certain rules from that rule group, you must first remove the rule group from the web ACL, the re-insert it again, specifying the excluded rules. For details, see ActivatedRule$ExcludedRules .
"""
pass
def update_xss_match_set(XssMatchSetId=None, ChangeToken=None, Updates=None):
"""
Inserts or deletes XssMatchTuple objects (filters) in an XssMatchSet . For each XssMatchTuple object, you specify the following values:
You use XssMatchSet objects to specify which CloudFront requests that you want to allow, block, or count. For example, if you\'re receiving requests that contain cross-site scripting attacks in the request body and you want to block the requests, you can create an XssMatchSet with the applicable settings, and then configure AWS WAF to block the requests.
To create and configure an XssMatchSet , perform the following steps:
For more information about how to use the AWS WAF API to allow or block HTTP requests, see the AWS WAF Developer Guide .
See also: AWS API Documentation
Exceptions
Examples
The following example deletes an XssMatchTuple object (filters) in an XssMatchSet with the ID example1ds3t-46da-4fdb-b8d5-abc321j569j5.
Expected Output:
:example: response = client.update_xss_match_set(
XssMatchSetId='string',
ChangeToken='string',
Updates=[
{
'Action': 'INSERT'|'DELETE',
'XssMatchTuple': {
'FieldToMatch': {
'Type': 'URI'|'QUERY_STRING'|'HEADER'|'METHOD'|'BODY'|'SINGLE_QUERY_ARG'|'ALL_QUERY_ARGS',
'Data': 'string'
},
'TextTransformation': 'NONE'|'COMPRESS_WHITE_SPACE'|'HTML_ENTITY_DECODE'|'LOWERCASE'|'CMD_LINE'|'URL_DECODE'
}
},
]
)
:type XssMatchSetId: string
:param XssMatchSetId: [REQUIRED]\nThe XssMatchSetId of the XssMatchSet that you want to update. XssMatchSetId is returned by CreateXssMatchSet and by ListXssMatchSets .\n
:type ChangeToken: string
:param ChangeToken: [REQUIRED]\nThe value returned by the most recent call to GetChangeToken .\n
:type Updates: list
:param Updates: [REQUIRED]\nAn array of XssMatchSetUpdate objects that you want to insert into or delete from an XssMatchSet . For more information, see the applicable data types:\n\nXssMatchSetUpdate : Contains Action and XssMatchTuple\nXssMatchTuple : Contains FieldToMatch and TextTransformation\nFieldToMatch : Contains Data and Type\n\n\n(dict) --\nNote\nThis is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.\n\nFor the latest version of AWS WAF , use the AWS WAFV2 API and see the AWS WAF Developer Guide . With the latest version, AWS WAF has a single set of endpoints for regional and global use.\n\nSpecifies the part of a web request that you want to inspect for cross-site scripting attacks and indicates whether you want to add the specification to an XssMatchSet or delete it from an XssMatchSet .\n\nAction (string) -- [REQUIRED]Specify INSERT to add an XssMatchSetUpdate to an XssMatchSet . Use DELETE to remove an XssMatchSetUpdate from an XssMatchSet .\n\nXssMatchTuple (dict) -- [REQUIRED]Specifies the part of a web request that you want AWS WAF to inspect for cross-site scripting attacks and, if you want AWS WAF to inspect a header, the name of the header.\n\nFieldToMatch (dict) -- [REQUIRED]Specifies where in a web request to look for cross-site scripting attacks.\n\nType (string) -- [REQUIRED]The part of the web request that you want AWS WAF to search for a specified string. Parts of a request that you can search include the following:\n\nHEADER : A specified request header, for example, the value of the User-Agent or Referer header. If you choose HEADER for the type, specify the name of the header in Data .\nMETHOD : The HTTP method, which indicated the type of operation that the request is asking the origin to perform. Amazon CloudFront supports the following methods: DELETE , GET , HEAD , OPTIONS , PATCH , POST , and PUT .\nQUERY_STRING : A query string, which is the part of a URL that appears after a ? character, if any.\nURI : The part of a web request that identifies a resource, for example, /images/daily-ad.jpg .\nBODY : The part of a request that contains any additional data that you want to send to your web server as the HTTP request body, such as data from a form. The request body immediately follows the request headers. Note that only the first 8192 bytes of the request body are forwarded to AWS WAF for inspection. To allow or block requests based on the length of the body, you can create a size constraint set. For more information, see CreateSizeConstraintSet .\nSINGLE_QUERY_ARG : The parameter in the query string that you will inspect, such as UserName or SalesRegion . The maximum length for SINGLE_QUERY_ARG is 30 characters.\nALL_QUERY_ARGS : Similar to SINGLE_QUERY_ARG , but rather than inspecting a single parameter, AWS WAF will inspect all parameters within the query for the value or regex pattern that you specify in TargetString .\n\n\nData (string) --When the value of Type is HEADER , enter the name of the header that you want AWS WAF to search, for example, User-Agent or Referer . The name of the header is not case sensitive.\nWhen the value of Type is SINGLE_QUERY_ARG , enter the name of the parameter that you want AWS WAF to search, for example, UserName or SalesRegion . The parameter name is not case sensitive.\nIf the value of Type is any other value, omit Data .\n\n\n\nTextTransformation (string) -- [REQUIRED]Text transformations eliminate some of the unusual formatting that attackers use in web requests in an effort to bypass AWS WAF. If you specify a transformation, AWS WAF performs the transformation on FieldToMatch before inspecting it for a match.\nYou can only specify a single type of TextTransformation.\n\nCMD_LINE\nWhen you\'re concerned that attackers are injecting an operating system command line command and using unusual formatting to disguise some or all of the command, use this option to perform the following transformations:\n\nDelete the following characters: ' \' ^\nDelete spaces before the following characters: / (\nReplace the following characters with a space: , ;\nReplace multiple spaces with one space\nConvert uppercase letters (A-Z) to lowercase (a-z)\n\n\nCOMPRESS_WHITE_SPACE\nUse this option to replace the following characters with a space character (decimal 32):\n\nf, formfeed, decimal 12\nt, tab, decimal 9\nn, newline, decimal 10\nr, carriage return, decimal 13\nv, vertical tab, decimal 11\nnon-breaking space, decimal 160\n\n\nCOMPRESS_WHITE_SPACE also replaces multiple spaces with one space.HTML_ENTITY_DECODE\n\nUse this option to replace HTML-encoded characters with unencoded characters. HTML_ENTITY_DECODE performs the following operations:\n\nReplaces (ampersand)quot; with '\nReplaces (ampersand)nbsp; with a non-breaking space, decimal 160\nReplaces (ampersand)lt; with a 'less than' symbol\nReplaces (ampersand)gt; with >\nReplaces characters that are represented in hexadecimal format, (ampersand)#xhhhh; , with the corresponding characters\nReplaces characters that are represented in decimal format, (ampersand)#nnnn; , with the corresponding characters\n\n\nLOWERCASE\nUse this option to convert uppercase letters (A-Z) to lowercase (a-z).\n\nURL_DECODE\nUse this option to decode a URL-encoded value.\n\nNONE\nSpecify NONE if you don\'t want to perform any text transformations.\n\n\n\n\n\n\n
:rtype: dict
ReturnsResponse Syntax
{
'ChangeToken': 'string'
}
Response Structure
(dict) --
The response to an UpdateXssMatchSets request.
ChangeToken (string) --
The ChangeToken that you used to submit the UpdateXssMatchSet request. You can also use this value to query the status of the request. For more information, see GetChangeTokenStatus .
Exceptions
WAFRegional.Client.exceptions.WAFInternalErrorException
WAFRegional.Client.exceptions.WAFInvalidAccountException
WAFRegional.Client.exceptions.WAFInvalidOperationException
WAFRegional.Client.exceptions.WAFInvalidParameterException
WAFRegional.Client.exceptions.WAFNonexistentContainerException
WAFRegional.Client.exceptions.WAFNonexistentItemException
WAFRegional.Client.exceptions.WAFStaleDataException
WAFRegional.Client.exceptions.WAFLimitsExceededException
Examples
The following example deletes an XssMatchTuple object (filters) in an XssMatchSet with the ID example1ds3t-46da-4fdb-b8d5-abc321j569j5.
response = client.update_xss_match_set(
ChangeToken='abcd12f2-46da-4fdb-b8d5-fbd4c466928f',
Updates=[
{
'Action': 'DELETE',
'XssMatchTuple': {
'FieldToMatch': {
'Type': 'QUERY_STRING',
},
'TextTransformation': 'URL_DECODE',
},
},
],
XssMatchSetId='example1ds3t-46da-4fdb-b8d5-abc321j569j5',
)
print(response)
Expected Output:
{
'ChangeToken': 'abcd12f2-46da-4fdb-b8d5-fbd4c466928f',
'ResponseMetadata': {
'...': '...',
},
}
:return: {
'ChangeToken': 'string'
}
:returns:
Submit a CreateXssMatchSet request.
Use GetChangeToken to get the change token that you provide in the ChangeToken parameter of an UpdateIPSet request.
Submit an UpdateXssMatchSet request to specify the parts of web requests that you want AWS WAF to inspect for cross-site scripting attacks.
"""
pass
|
"""
0489. Robot Room Cleaner
Given a robot cleaner in a room modeled as a grid.
Each cell in the grid can be empty or blocked.
The robot cleaner with 4 given APIs can move forward, turn left or turn right. Each turn it made is 90 degrees.
When it tries to move into a blocked cell, its bumper sensor detects the obstacle and it stays on the current cell.
Design an algorithm to clean the entire room using only the 4 given APIs shown below.
interface Robot {
// returns true if next cell is open and robot moves into the cell.
// returns false if next cell is obstacle and robot stays on the current cell.
boolean move();
// Robot will stay on the same cell after calling turnLeft/turnRight.
// Each turn will be 90 degrees.
void turnLeft();
void turnRight();
// Clean the current cell.
void clean();
}
Example:
Input:
room = [
[1,1,1,1,1,0,1,1],
[1,1,1,1,1,0,1,1],
[1,0,1,1,1,1,1,1],
[0,0,0,1,0,0,0,0],
[1,1,1,1,1,1,1,1]
],
row = 1,
col = 3
Explanation:
All grids in the room are marked by either 0 or 1.
0 means the cell is blocked, while 1 means the cell is accessible.
The robot initially starts at the position of row=1, col=3.
From the top left corner, its position is one row below and three columns right.
Notes:
The input is only given to initialize the room and the robot's position internally. You must solve this problem "blindfolded". In other words, you must control the robot using only the mentioned 4 APIs, without knowing the room layout and the initial robot's position.
The robot's initial position will always be in an accessible cell.
The initial direction of the robot will be facing up.
All accessible cells are connected, which means the all cells marked as 1 will be accessible by the robot.
Assume all four edges of the grid are all surrounded by wall.
"""
# """
# This is the robot's control interface.
# You should not implement it, or speculate about its implementation
# """
#class Robot:
# def move(self):
# """
# Returns true if the cell in front is open and robot moves into the cell.
# Returns false if the cell in front is blocked and robot stays in the current cell.
# :rtype bool
# """
#
# def turnLeft(self):
# """
# Robot will stay in the same cell after calling turnLeft/turnRight.
# Each turn will be 90 degrees.
# :rtype void
# """
#
# def turnRight(self):
# """
# Robot will stay in the same cell after calling turnLeft/turnRight.
# Each turn will be 90 degrees.
# :rtype void
# """
#
# def clean(self):
# """
# Clean the current cell.
# :rtype void
# """
class Solution:
def cleanRoom(self, robot):
def dfs(robot, i, j, d, cleaned):
robot.clean()
cleaned.add((i, j))
left = True
for nd in ((d + k) % 4 for k in (3, 0, 1, 2)):
robot.turnLeft() if left else robot.turnRight()
di, dj = ((-1, 0), (0, 1), (1, 0), (0, -1))[nd]
if (i + di, j + dj) not in cleaned and robot.move():
dfs(robot, i + di, j + dj, nd, cleaned)
robot.move()
left = True
else:
left = False
dfs(robot, 0, 0, 0, set())
class Solution:
def cleanRoom(self, robot, move=[(-1, 0), (0, -1), (1, 0), (0, 1)]):
"""
:type robot: Robot
:rtype: None
"""
def helper(i, j, cleaned, ind):
robot.clean()
cleaned.add((i, j))
for k in range(4):
x, y = move[(ind + k) % 4]
if (i + x, j + y) not in cleaned and robot.move():
helper(i + x, j + y, cleaned, (ind + k) % 4)
robot.turnLeft()
robot.turnLeft()
robot.move()
robot.turnRight()
robot.turnRight()
robot.turnLeft()
helper(0, 0, set(), 0)
|
# microbit.py 15/01/2021 D.J.Whale
# Simulator for a micro:bit - will be replaced with BITIO
class Radio():
# RCNNABGRR+SS (12 chars)
# 0123456789AB
TESTDATA = (
"RC0000F99+00",
None,
None,
"RC0000F00+99",
"RC0000F99-99",
"RC0000S00+00",
"RC0000B99+00",
"RC0000B99-99",
"RC0000B99+99"
)
def __init__(self):
self._index = 0
def receive(self):
v = self.TESTDATA[self._index]
self._index += 1
if self._index >= len(self.TESTDATA):
self._index = 0
return v
radio = Radio()
# END
|
# Exercício 12 lista 1
print("----------Calcula a quantidade de litros necessário para fazer um refresco--------")
qtdLitros = float(input("Digite a quantidade de litros necessária:"))
concentracaoAgua = float(input("Digite o percentual de concentração da água:"))
concentracaoSuco = float(input("Digite o percentual de concentração do suco:"))
totalConcentracao = concentracaoAgua + concentracaoSuco
controle = 1
# Validando o total de concentração
if(totalConcentracao < 100):
print("As concentrações não totalizam 100%")
resposta=input("Deseja enquadrar os valores em escala de 100%[s|n]?")
if(resposta == 's') :
# Enquadrando o valor de água lido:
concentracaoEqAgua = concentracaoAgua/ ( concentracaoAgua + concentracaoSuco)
concentracaoEqSuco = concentracaoSuco/ ( concentracaoAgua + concentracaoSuco)
print("Novo percentual da água: %.2f"%round(concentracaoEqAgua, 2))
print("Novo percentual do suco: %.2f"%round(concentracaoEqSuco, 2))
qtdAgua = concentracaoEqAgua * qtdLitros
qtdSuco = concentracaoEqSuco * qtdLitros
else:
controle = -1
print("Valores de concentracao incorretos. Processo finalizado!")
else:
qtdAgua = (concentracaoAgua/100) * qtdLitros
qtdSuco = (concentracaoSuco/100) * qtdLitros
#fazendo o controle da saída
if(controle == 1) :
print("A quantidade de água necessária para fazer %.2f"%round(qtdLitros, 2), " de suco é: %.2f"%round(qtdAgua, 2))
print("A quantidade de suco concentrado de maracujá é: %.2f"%round(qtdSuco)) |
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
=================================================
@Project :span-aste
@IDE :PyCharm
@Author :Mr. Wireless
@Date :2022/1/19 13:49
@Desc :
==================================================
"""
|
class Solution:
def pivotIndex(self, nums):
left = 0
right = 0
left_sum = 0
right_sum = sum(nums)
while right < len(nums):
right_sum -= nums[right]
right += 1
if right_sum == left_sum:
return left
else:
left_sum += nums[left]
left += 1
return -1
|
A, B = map(int, input().split())
diff = abs(A - B)
ans = diff // 10
diff %= 10
ans = ans + [0, 1, 2, 3, 2, 1, 2, 3, 3, 2][diff]
print(ans)
|
# https://www.hackerrank.com/challenges/python-quest-1/problem
# Condition
# 1 <= int(input()) <= 9
# String is not allowed.
# More than 1 for-statement is not allowed.
# More than 2 lines are not allowed. (Do not leave a blank line also.)
""" Mathmatical Answer
for i in range(1, int(input())):
print(10**i // 9 * i)
"""
""" Cheating Answer
for i in range(1, int(input())):
print([0, 1, 22, 333, 4444, 55555, 666666, 7777777, 88888888, 999999999][i])
"""
for i in range(1, int(input())):
print(sum(map(lambda num: i * 10 ** num, range(i))))
# 5
# 1
# 22
# 333
# 4444
""" Note
for i in range(1, int(input())):
print(*map(lambda num: i * 10 ** num, range(i)))
# 5
# 1
# 2 20
# 3 30 300
# 4 40 400 4000
"""
|
class RobotException(Exception):
pass
class UnitGuardCollision(RobotException):
def __init__(self, other_robot):
self.other_robot = other_robot
class UnitMoveCollision(RobotException):
def __init__(self, other_robots):
self.other_robots = other_robots
class UnitBlockCollision(RobotException):
def __init__(self, other_robot):
self.other_robot = other_robot
|
""" Asked by: Apple [Medium].
Gray code is a binary code where each successive value differ in only one bit, as well as when wrapping around.
Gray code is common in hardware so that we don't see temporary spurious values during transitions.
Given a number of bits n, generate a possible gray code for it.
For example, for n = 2, one gray code would be [00, 01, 11, 10].
"""
|
class Solution:
def findPairs(self, nums: List[int], k: int) -> int:
result, frequencyMap = 0, Counter(nums)
for i in frequencyMap:
if k == 0 and frequencyMap[i] > 1:
result += 1
elif k > 0 and i + k in frequencyMap:
result += 1
return result |
class Scorer(object):
def __init__(self, cards):
self.cards = cards
def flush(self):
suits = [card.suit for card in self.cards]
if len(set(suits)) == 1:
return True
return False
def straight(self):
values = [card.value for card in self.cards]
values.sort()
if not len(set(values)) == 5:
return False
if values[4] == 14 and values[0] == 2 and values[1] == 3 and values[2] == 4 and values[3] == 5:
return 5
else:
if not values[0] + 1 == values[1]:
return False
if not values[1] + 1 == values[2]:
return False
if not values[2] + 1 == values[3]:
return False
if not values[3] + 1 == values[4]:
return False
return values[4]
def high_card(self):
values = [card.value for card in self.cards]
high_card = None
for card in self.cards:
if high_card is None:
high_card = card
elif high_card.value < card.value:
high_card = card
return high_card
def highest_count(self):
count = 0
values = [card.value for card in self.cards]
for value in values:
if values.count(value) > count:
count = values.count(value)
return count
def pairs(self):
pairs = []
values = [card.value for card in self.cards]
for value in values:
if values.count(value) == 2 and value not in pairs:
pairs.append(value)
return pairs
def four_kind(self):
values = [card.value for card in self.cards]
for value in values:
if values.count(value) == 4:
return True
def full_house(self):
two = False
three = False
values = [card.value for card in self.cards]
if values.count(values) == 2:
two = True
elif values.count(values) == 3:
three = True
if two and three:
return True
return False
|
#!/usr/bin/env python
# coding=utf-8
# author: damonchen
# date: 2018-02-07
# 给公司内部做培训,编写一个Hierarchical Timing Wheels的timer的实现
class Slot(list):
pass
class Wheel(object):
def __init__(self, size):
self.size = size # 0~59, or 0~23
self.pointer = 0 # wheel指针,达到wheel_buffer尾部后会重新重头开始
self._init_wheel_buffer(size)
def _init_wheel_buffer(self, size):
self.wheel_buffer = [Slot() for i in xrange(size)]
def add(self, index, time, data):
i = index % self.size
self.wheel_buffer[i].append((time, data))
def ticket(self):
self.pointer = (self.pointer + 1) % self.size
slot = self.wheel_buffer[self.pointer]
self.wheel_buffer[self.pointer] = Slot()
return slot
def is_end(self):
return (self.pointer + 1) % self.size == 0
class SecondWheel(Wheel):
def __init__(self):
super(SecondWheel, self).__init__(60)
class MinuteWheel(Wheel):
def __init__(self):
super(MinuteWheel, self).__init__(60)
class HourWheel(Wheel):
def __init__(self):
super(HourWheel, self).__init__(24)
class DayWheel(Wheel):
def __init__(self):
super(DayWheel, self).__init__(365)
class InvalidTime(StandardError):
pass
class Time(object):
def __init__(self, second, minute=0, hour=0, day=0):
self.second = second
self.minute = minute
self.hour = hour
self.day = day
def __repr__(self):
return '<time %dd-%dh-%dd-%ds>' % (self.day, self.hour, self.minute, self.second)
class WheelTimer(object):
def __init__(self):
self.second_wheel = SecondWheel()
self.minute_wheel = MinuteWheel()
self.hour_wheel = HourWheel()
self.day_wheel = DayWheel()
def adjust_second(self, time):
day = time.day
hour = time.hour
minute = time.minute
second = time.second
second = self.second_wheel.pointer + second
if second >= 60:
second -= 60
minute += 1
if minute >= 60:
minute -= 60
hour += 1
if hour >= 24:
hour -= 24
day += 1
if day > 365:
raise InvalidTime("invalid time")
return Time(second, minute, hour, day)
def add(self, time, data):
time = self.adjust_second(time)
if time.day > 0 and time.day < 365:
self.day_wheel.add(time.day, time, data)
elif time.hour > 0:
self.hour_wheel.add(time.hour, time, data)
elif time.minute > 0:
self.minute_wheel.add(time.minute, time, data)
elif time.second > 0:
self.second_wheel.add(time.second, time, data)
else:
raise InvalidTime('invalid time %s', time)
def second_ticket(self):
if self.second_wheel.is_end():
minute_slot = self.minute_ticket()
for time, data in minute_slot:
self.second_wheel.add(time.second, time, data)
slot = self.second_wheel.ticket()
return slot
def minute_ticket(self):
if self.minute_wheel.is_end():
hour_slot = self.hour_ticket()
for time, data in hour_slot:
self.minute_wheel.add(time.minute, time, data)
slot = self.minute_wheel.ticket()
return slot
def hour_ticket(self):
if self.hour_wheel.is_end():
day_slot = self.day_ticket()
for time, data in day_slot:
self.hour_wheel.add(time.hour, time, data)
slot = self.hour_wheel.ticket()
return slot
def day_ticket(self):
slot = self.day_wheel.ticket()
return slot
def ticket(self):
slot = self.second_ticket()
return slot
|
class Solution(object):
def canJump(self, nums):
"""
:type nums: List[int]
:rtype: bool
"""
n = len(nums)
if n < 2:
return True
target_i = n - 1
for i in range(n - 2, -1, -1):
if nums[i] >= target_i - i:
target_i = i
return target_i == 0
def test_can_jump():
s = Solution()
assert s.canJump([2, 3, 1, 1, 4]) is True
assert s.canJump([3, 2, 1, 0, 4]) is False
|
class InvalidPhoneNumber(Exception):
def __init__(self, phone_number):
self.phone_number = phone_number
self.message = phone_number + ' is an invalid phone number'
super().__init__(self.message)
|
def list():
'''Returns a list of streams
'''
return 'TO BE IMPLEMENTED'
def add():
'''Set an stream
'''
return 'TO BE IMPLEMENTED'
def find_by_name(name):
'''Returns the named stream
Params:
name - The name of the stream
'''
return 'TO BE IMPLEMENTED'
def delete_by_name(name):
'''Deletes the named stream
Params:
name - The name of the stream
'''
return 'TO BE IMPLEMENTED'
|
# -*- coding: utf-8 -*-
"""
Created on Thu Jun 20 21:16:13 2019
@author: CLIENTE
"""
def fatorial(n):
if n == 1:
return 1
else:
return n*fatorial(n-1) |
# Count Substrings That Differ by One Character
class Solution:
def countSubstrings(self, s, t):
# brute force
slen = len(s)
tlen = len(t)
count = 0
for si in range(slen):
for ti in range(tlen):
index = 0
diffCount = 0
while si + index < slen and ti + index < tlen:
if s[si + index] != t[ti + index]:
if diffCount == 1:
break
diffCount += 1
if diffCount == 1:
count += 1
index += 1
return count
if __name__ == "__main__":
sol = Solution()
s = "abbab"
t = "bbbbb"
print(sol.countSubstrings(s, t))
|
#!/usr/bin/python3
"""
Given a non-negative integer N, find the largest number that is less than or
equal to N with monotone increasing digits.
(Recall that an integer has monotone increasing digits if and only if each pair
of adjacent digits x and y satisfy x <= y.)
Example 1:
Input: N = 10
Output: 9
Example 2:
Input: N = 1234
Output: 1234
Example 3:
Input: N = 332
Output: 299
Note: N is an integer in the range [0, 10^9].
"""
class Solution:
def monotoneIncreasingDigits(self, N: int) -> int:
"""
332
322
222
fill 9
299
"""
digits = [int(e) for e in str(N)]
pointer = len(digits)
for i in range(len(digits) - 1, 0, -1):
if digits[i - 1] > digits[i]:
pointer = i
digits[i - 1] -= 1
for i in range(pointer, len(digits)):
digits[i] = 9
return int("".join(map(str, digits)))
if __name__ == "__main__":
assert Solution().monotoneIncreasingDigits(10) == 9
assert Solution().monotoneIncreasingDigits(332) == 299
|
# Description
# 中文
# English
# Given a binary tree, find its maximum depth.
# The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.
# Have you met this question in a real interview?
# Example
# Example 1:
# Input: tree = {}
# Output: 0
# Explanation: The height of empty tree is 0.
# Example 2:
# Input: tree = {1,2,3,#,#,4,5}
# Output: 3
# Explanation: Like this:
# 1
# / \
# 2 3
# / \
# 4 5
# # it will be serialized {1,2,3,#,#,4,5}
"""
Definition of TreeNode:
class TreeNode:
def __init__(self, val):
self.val = val
self.left, self.right = None, None
"""
class Solution:
"""
@param root: The root of binary tree.
@return: An integer
"""
def maxDepth(self, root):
# write your code here
if root is None:
return 0
left = self.maxDepth(root.left)
right = self.maxDepth(root.right)
return max(left, right) + 1
# 本参考程序来自九章算法,由 @九章算法 提供。版权所有,转发请注明出处。
# - 九章算法致力于帮助更多中国人找到好的工作,教师团队均来自硅谷和国内的一线大公司在职工程师。
# - 现有的面试培训课程包括:九章算法班,系统设计班,算法强化班,Java入门与基础算法班,Android 项目实战班,
# - Big Data 项目实战班,算法面试高频题班, 动态规划专题班
# - 更多详情请见官方网站:http://www.jiuzhang.com/?source=code
"""
Definition of TreeNode:
class TreeNode:
def __init__(self, val):
this.val = val
this.left, this.right = None, None
"""
class Solution:
"""
@param root: The root of binary tree.
@return: An integer
"""
def maxDepth(self, root):
if root is None:
return 0
return max(self.maxDepth(root.left), self.maxDepth(root.right)) + 1 |
"""
* Assignment: Decorator Class Type Check
* Complexity: medium
* Lines of code: 15 lines
* Time: 21 min
English:
1. Refactor decorator `decorator` to decorator `TypeCheck`
2. Decorator checks types of all arguments (`*args` oraz `**kwargs`)
3. Decorator checks return type
4. In case when received type is not expected throw an exception `TypeError` with:
a. argument name
b. actual type
c. expected type
5. Run doctests - all must succeed
Polish:
1. Przerób dekorator `decorator` na klasę `TypeCheck`
2. Dekorator sprawdza typy wszystkich argumentów (`*args` oraz `**kwargs`)
3. Dekorator sprawdza typ zwracany
4. W przypadku gdy otrzymany typ nie jest równy oczekiwanemu wyrzuć wyjątek `TypeError` z:
a. nazwa argumentu
b. aktualny typ
c. oczekiwany typ
5. Uruchom doctesty - wszystkie muszą się powieść
Hints:
* `echo.__annotations__`
Tests:
>>> import sys; sys.tracebacklimit = 0
>>> @TypeCheck
... def echo(a: str, b: int, c: float = 0.0) -> bool:
... return bool(a * b)
>>> echo('one', 1)
True
>>> echo('one', 1, 1.1)
True
>>> echo('one', b=1)
True
>>> echo('one', 1, c=1.1)
True
>>> echo('one', b=1, c=1.1)
True
>>> echo(a='one', b=1, c=1.1)
True
>>> echo(c=1.1, b=1, a='one')
True
>>> echo(b=1, c=1.1, a='one')
True
>>> echo('one', c=1.1, b=1)
True
>>> echo(1, 1)
Traceback (most recent call last):
TypeError: "a" is <class 'int'>, but <class 'str'> was expected
>>> echo('one', 'two')
Traceback (most recent call last):
TypeError: "b" is <class 'str'>, but <class 'int'> was expected
>>> echo('one', 1, 'two')
Traceback (most recent call last):
TypeError: "c" is <class 'str'>, but <class 'float'> was expected
>>> echo(b='one', a='two')
Traceback (most recent call last):
TypeError: "b" is <class 'str'>, but <class 'int'> was expected
>>> echo('one', c=1.1, b=1.1)
Traceback (most recent call last):
TypeError: "b" is <class 'float'>, but <class 'int'> was expected
>>> @TypeCheck
... def echo(a: str, b: int, c: float = 0.0) -> bool:
... return str(a * b)
>>>
>>> echo('one', 1, 1.1)
Traceback (most recent call last):
TypeError: "return" is <class 'str'>, but <class 'bool'> was expected
"""
def decorator(func):
def validate(argname, argval):
argtype = type(argval)
expected = func.__annotations__[argname]
if argtype is not expected:
raise TypeError(f'"{argname}" is {argtype}, but {expected} was expected')
def merge(*args, **kwargs):
args = dict(zip(func.__annotations__.keys(), args))
return kwargs | args # Python 3.9
# return {**args, **kwargs)} # Python 3.7, 3.8
def wrapper(*args, **kwargs):
for argname, argval in merge(*args, **kwargs).items():
validate(argname, argval)
result = func(*args, **kwargs)
validate('return', result)
return result
return wrapper
|
# Copyright 2020 Cognite AS
#
# 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.
"""
A module containing utilities meant for use inside the extractor-utils package
"""
def _resolve_log_level(level: str) -> int:
return {"NOTSET": 0, "DEBUG": 10, "INFO": 20, "WARNING": 30, "ERROR": 40, "CRITICAL": 50}[level.upper()]
|
#! /usr/bin/env python
class Template:
"""invite templates"""
def __init__(self):
self.profile_templates = {
'th invite templates' : u"{{{{subst:Wikipedia:Teahouse/HostBot_Invitation|personal=The Teahouse is a friendly space where new editors can ask questions about contributing to Wikipedia and get help from experienced editors like {{{{noping|{inviter:s}}}}} ([[User_talk:{inviter:s}|talk]]). |bot={{{{noping|HostBot}}}}|timestamp=~~~~~}}}}",
'test invite templates' : u"{{{{subst:User:HostBot/Invitation|personal=The Teahouse is a friendly space where new editors can ask questions about contributing to Wikipedia and get help from experienced editors like {{{{noping|{inviter:s}}}}} ([[User_talk:{inviter:s}|talk]]). |bot={{{{noping|HostBot}}}}|timestamp=~~~~~}}}}", #only use when hostbot_settings urls set to testwiki
'tm invite template' : "{{{{subst:Training_modules_invitation|signed=~~~~}}}}",
}
def getTemplate(self, member):
tmplt = self.profile_templates[member]
return tmplt
|
def o_signo(a, b):
if a == 3:
if b <= 20:
return f'Peixes'
else:
return f'Aries'
elif a == 4:
if b <= 19:
return f'Aries'
else:
return f'Touro'
elif a == 5:
if b <= 20:
return f'Touro'
else:
return f'Gemeos'
elif a == 6:
if b <= 21:
return f'Gemeos'
else:
return f'Cancer'
elif a == 7:
if b <= 22:
return f'Cancer'
else:
return f'Leão'
elif a == 8:
if b <= 22:
return f'Leão'
else:
return f'Virgem'
elif a == 9:
if b <= 22:
return f'Virgem'
else:
return f'Libra'
elif a == 10:
if b <= 22:
return f'Libra'
else:
return f'Escorpião'
elif a == 11:
if b <= 21:
return f'Escorpião'
else:
return f'Sargitario'
elif a == 12:
if b <= 21:
return f'Sargitario'
else:
return f'Capricornio'
elif a == 1:
if b <= 19:
return f'Capricornio'
else:
return f'Aquario'
elif a == 2:
if b <= 18:
return f'Aquario'
else:
return f'Peixes'
elif a == 3:
if b <= 20:
return f'Peixes'
else:
return f'Aries'
def main():
mes = int(input("Digite o mês do seu aniversario: "))
dia = int(input("Digite o dia do seu aniversario: "))
resultado = o_signo(mes, dia)
print(f'{resultado}')
if __name__ == '__main__':
main()
|
"""Tracks devices by sending a ICMP echo request (ping)."""
PING_TIMEOUT = 3
PING_ATTEMPTS_COUNT = 3
|
set_name(0x80122CDC, "PreGameOnlyTestRoutine__Fv", SN_NOWARN)
set_name(0x80124DA0, "DRLG_PlaceDoor__Fii", SN_NOWARN)
set_name(0x80125274, "DRLG_L1Shadows__Fv", SN_NOWARN)
set_name(0x8012568C, "DRLG_PlaceMiniSet__FPCUciiiiiii", SN_NOWARN)
set_name(0x80125AF8, "DRLG_L1Floor__Fv", SN_NOWARN)
set_name(0x80125BE4, "StoreBlock__FPiii", SN_NOWARN)
set_name(0x80125C90, "DRLG_L1Pass3__Fv", SN_NOWARN)
set_name(0x80125E44, "DRLG_LoadL1SP__Fv", SN_NOWARN)
set_name(0x80125F20, "DRLG_FreeL1SP__Fv", SN_NOWARN)
set_name(0x80125F50, "DRLG_Init_Globals__Fv", SN_NOWARN)
set_name(0x80125FF4, "set_restore_lighting__Fv", SN_NOWARN)
set_name(0x80126084, "DRLG_InitL1Vals__Fv", SN_NOWARN)
set_name(0x8012608C, "LoadL1Dungeon__FPcii", SN_NOWARN)
set_name(0x80126258, "LoadPreL1Dungeon__FPcii", SN_NOWARN)
set_name(0x80126410, "InitL5Dungeon__Fv", SN_NOWARN)
set_name(0x80126470, "L5ClearFlags__Fv", SN_NOWARN)
set_name(0x801264BC, "L5drawRoom__Fiiii", SN_NOWARN)
set_name(0x80126528, "L5checkRoom__Fiiii", SN_NOWARN)
set_name(0x801265BC, "L5roomGen__Fiiiii", SN_NOWARN)
set_name(0x801268B8, "L5firstRoom__Fv", SN_NOWARN)
set_name(0x80126C74, "L5GetArea__Fv", SN_NOWARN)
set_name(0x80126CD4, "L5makeDungeon__Fv", SN_NOWARN)
set_name(0x80126D60, "L5makeDmt__Fv", SN_NOWARN)
set_name(0x80126E48, "L5HWallOk__Fii", SN_NOWARN)
set_name(0x80126F84, "L5VWallOk__Fii", SN_NOWARN)
set_name(0x801270D0, "L5HorizWall__Fiici", SN_NOWARN)
set_name(0x80127310, "L5VertWall__Fiici", SN_NOWARN)
set_name(0x80127544, "L5AddWall__Fv", SN_NOWARN)
set_name(0x801277B4, "DRLG_L5GChamber__Fiiiiii", SN_NOWARN)
set_name(0x80127A74, "DRLG_L5GHall__Fiiii", SN_NOWARN)
set_name(0x80127B28, "L5tileFix__Fv", SN_NOWARN)
set_name(0x801283EC, "DRLG_L5Subs__Fv", SN_NOWARN)
set_name(0x801285E4, "DRLG_L5SetRoom__Fii", SN_NOWARN)
set_name(0x801286E4, "L5FillChambers__Fv", SN_NOWARN)
set_name(0x80128DD0, "DRLG_L5FTVR__Fiiiii", SN_NOWARN)
set_name(0x80129320, "DRLG_L5FloodTVal__Fv", SN_NOWARN)
set_name(0x80129424, "DRLG_L5TransFix__Fv", SN_NOWARN)
set_name(0x80129634, "DRLG_L5DirtFix__Fv", SN_NOWARN)
set_name(0x80129790, "DRLG_L5CornerFix__Fv", SN_NOWARN)
set_name(0x801298A0, "DRLG_L5__Fi", SN_NOWARN)
set_name(0x80129DC0, "CreateL5Dungeon__FUii", SN_NOWARN)
set_name(0x8012C364, "DRLG_L2PlaceMiniSet__FPUciiiiii", SN_NOWARN)
set_name(0x8012C758, "DRLG_L2PlaceRndSet__FPUci", SN_NOWARN)
set_name(0x8012CA58, "DRLG_L2Subs__Fv", SN_NOWARN)
set_name(0x8012CC4C, "DRLG_L2Shadows__Fv", SN_NOWARN)
set_name(0x8012CE10, "InitDungeon__Fv", SN_NOWARN)
set_name(0x8012CE70, "DRLG_LoadL2SP__Fv", SN_NOWARN)
set_name(0x8012CF10, "DRLG_FreeL2SP__Fv", SN_NOWARN)
set_name(0x8012CF40, "DRLG_L2SetRoom__Fii", SN_NOWARN)
set_name(0x8012D040, "DefineRoom__Fiiiii", SN_NOWARN)
set_name(0x8012D24C, "CreateDoorType__Fii", SN_NOWARN)
set_name(0x8012D330, "PlaceHallExt__Fii", SN_NOWARN)
set_name(0x8012D368, "AddHall__Fiiiii", SN_NOWARN)
set_name(0x8012D440, "CreateRoom__Fiiiiiiiii", SN_NOWARN)
set_name(0x8012DAC8, "GetHall__FPiN40", SN_NOWARN)
set_name(0x8012DB60, "ConnectHall__Fiiiii", SN_NOWARN)
set_name(0x8012E1C8, "DoPatternCheck__Fii", SN_NOWARN)
set_name(0x8012E47C, "L2TileFix__Fv", SN_NOWARN)
set_name(0x8012E5A0, "DL2_Cont__FUcUcUcUc", SN_NOWARN)
set_name(0x8012E620, "DL2_NumNoChar__Fv", SN_NOWARN)
set_name(0x8012E67C, "DL2_DrawRoom__Fiiii", SN_NOWARN)
set_name(0x8012E780, "DL2_KnockWalls__Fiiii", SN_NOWARN)
set_name(0x8012E950, "DL2_FillVoids__Fv", SN_NOWARN)
set_name(0x8012F2D4, "CreateDungeon__Fv", SN_NOWARN)
set_name(0x8012F5E0, "DRLG_L2Pass3__Fv", SN_NOWARN)
set_name(0x8012F778, "DRLG_L2FTVR__Fiiiii", SN_NOWARN)
set_name(0x8012FCC0, "DRLG_L2FloodTVal__Fv", SN_NOWARN)
set_name(0x8012FDC4, "DRLG_L2TransFix__Fv", SN_NOWARN)
set_name(0x8012FFD4, "L2DirtFix__Fv", SN_NOWARN)
set_name(0x80130134, "L2LockoutFix__Fv", SN_NOWARN)
set_name(0x801304C0, "L2DoorFix__Fv", SN_NOWARN)
set_name(0x80130570, "DRLG_L2__Fi", SN_NOWARN)
set_name(0x80130FBC, "DRLG_InitL2Vals__Fv", SN_NOWARN)
set_name(0x80130FC4, "LoadL2Dungeon__FPcii", SN_NOWARN)
set_name(0x801311B4, "LoadPreL2Dungeon__FPcii", SN_NOWARN)
set_name(0x801313A0, "CreateL2Dungeon__FUii", SN_NOWARN)
set_name(0x80131D58, "InitL3Dungeon__Fv", SN_NOWARN)
set_name(0x80131DE0, "DRLG_L3FillRoom__Fiiii", SN_NOWARN)
set_name(0x8013203C, "DRLG_L3CreateBlock__Fiiii", SN_NOWARN)
set_name(0x801322D8, "DRLG_L3FloorArea__Fiiii", SN_NOWARN)
set_name(0x80132340, "DRLG_L3FillDiags__Fv", SN_NOWARN)
set_name(0x80132470, "DRLG_L3FillSingles__Fv", SN_NOWARN)
set_name(0x8013253C, "DRLG_L3FillStraights__Fv", SN_NOWARN)
set_name(0x80132900, "DRLG_L3Edges__Fv", SN_NOWARN)
set_name(0x80132940, "DRLG_L3GetFloorArea__Fv", SN_NOWARN)
set_name(0x80132990, "DRLG_L3MakeMegas__Fv", SN_NOWARN)
set_name(0x80132AD4, "DRLG_L3River__Fv", SN_NOWARN)
set_name(0x80133514, "DRLG_L3SpawnEdge__FiiPi", SN_NOWARN)
set_name(0x801337A0, "DRLG_L3Spawn__FiiPi", SN_NOWARN)
set_name(0x801339B4, "DRLG_L3Pool__Fv", SN_NOWARN)
set_name(0x80133C08, "DRLG_L3PoolFix__Fv", SN_NOWARN)
set_name(0x80133D3C, "DRLG_L3PlaceMiniSet__FPCUciiiiii", SN_NOWARN)
set_name(0x801340BC, "DRLG_L3PlaceRndSet__FPCUci", SN_NOWARN)
set_name(0x80134404, "WoodVertU__Fii", SN_NOWARN)
set_name(0x801344B0, "WoodVertD__Fii", SN_NOWARN)
set_name(0x8013454C, "WoodHorizL__Fii", SN_NOWARN)
set_name(0x801345E0, "WoodHorizR__Fii", SN_NOWARN)
set_name(0x80134664, "AddFenceDoors__Fv", SN_NOWARN)
set_name(0x80134748, "FenceDoorFix__Fv", SN_NOWARN)
set_name(0x8013493C, "DRLG_L3Wood__Fv", SN_NOWARN)
set_name(0x8013512C, "DRLG_L3Anvil__Fv", SN_NOWARN)
set_name(0x80135388, "FixL3Warp__Fv", SN_NOWARN)
set_name(0x80135470, "FixL3HallofHeroes__Fv", SN_NOWARN)
set_name(0x801355C4, "DRLG_L3LockRec__Fii", SN_NOWARN)
set_name(0x80135660, "DRLG_L3Lockout__Fv", SN_NOWARN)
set_name(0x80135720, "DRLG_L3__Fi", SN_NOWARN)
set_name(0x80135E40, "DRLG_L3Pass3__Fv", SN_NOWARN)
set_name(0x80135FE4, "CreateL3Dungeon__FUii", SN_NOWARN)
set_name(0x801360F8, "LoadL3Dungeon__FPcii", SN_NOWARN)
set_name(0x8013631C, "LoadPreL3Dungeon__FPcii", SN_NOWARN)
set_name(0x80138168, "DRLG_L4Shadows__Fv", SN_NOWARN)
set_name(0x8013822C, "InitL4Dungeon__Fv", SN_NOWARN)
set_name(0x801382C8, "DRLG_LoadL4SP__Fv", SN_NOWARN)
set_name(0x8013836C, "DRLG_FreeL4SP__Fv", SN_NOWARN)
set_name(0x80138394, "DRLG_L4SetSPRoom__Fii", SN_NOWARN)
set_name(0x80138494, "L4makeDmt__Fv", SN_NOWARN)
set_name(0x80138538, "L4HWallOk__Fii", SN_NOWARN)
set_name(0x80138688, "L4VWallOk__Fii", SN_NOWARN)
set_name(0x80138804, "L4HorizWall__Fiii", SN_NOWARN)
set_name(0x801389D4, "L4VertWall__Fiii", SN_NOWARN)
set_name(0x80138B9C, "L4AddWall__Fv", SN_NOWARN)
set_name(0x8013907C, "L4tileFix__Fv", SN_NOWARN)
set_name(0x8013B264, "DRLG_L4Subs__Fv", SN_NOWARN)
set_name(0x8013B43C, "L4makeDungeon__Fv", SN_NOWARN)
set_name(0x8013B674, "uShape__Fv", SN_NOWARN)
set_name(0x8013B918, "GetArea__Fv", SN_NOWARN)
set_name(0x8013B974, "L4drawRoom__Fiiii", SN_NOWARN)
set_name(0x8013B9DC, "L4checkRoom__Fiiii", SN_NOWARN)
set_name(0x8013BA78, "L4roomGen__Fiiiii", SN_NOWARN)
set_name(0x8013BD74, "L4firstRoom__Fv", SN_NOWARN)
set_name(0x8013BF90, "L4SaveQuads__Fv", SN_NOWARN)
set_name(0x8013C030, "DRLG_L4SetRoom__FPUcii", SN_NOWARN)
set_name(0x8013C104, "DRLG_LoadDiabQuads__FUc", SN_NOWARN)
set_name(0x8013C268, "DRLG_L4PlaceMiniSet__FPCUciiiiii", SN_NOWARN)
set_name(0x8013C680, "DRLG_L4FTVR__Fiiiii", SN_NOWARN)
set_name(0x8013CBC8, "DRLG_L4FloodTVal__Fv", SN_NOWARN)
set_name(0x8013CCCC, "IsDURWall__Fc", SN_NOWARN)
set_name(0x8013CCFC, "IsDLLWall__Fc", SN_NOWARN)
set_name(0x8013CD2C, "DRLG_L4TransFix__Fv", SN_NOWARN)
set_name(0x8013D084, "DRLG_L4Corners__Fv", SN_NOWARN)
set_name(0x8013D118, "L4FixRim__Fv", SN_NOWARN)
set_name(0x8013D154, "DRLG_L4GeneralFix__Fv", SN_NOWARN)
set_name(0x8013D1F8, "DRLG_L4__Fi", SN_NOWARN)
set_name(0x8013DAF4, "DRLG_L4Pass3__Fv", SN_NOWARN)
set_name(0x8013DC98, "CreateL4Dungeon__FUii", SN_NOWARN)
set_name(0x8013DD28, "ObjIndex__Fii", SN_NOWARN)
set_name(0x8013DDDC, "AddSKingObjs__Fv", SN_NOWARN)
set_name(0x8013DF0C, "AddSChamObjs__Fv", SN_NOWARN)
set_name(0x8013DF88, "AddVileObjs__Fv", SN_NOWARN)
set_name(0x8013E034, "DRLG_SetMapTrans__FPc", SN_NOWARN)
set_name(0x8013E0F8, "LoadSetMap__Fv", SN_NOWARN)
set_name(0x8013E400, "CM_QuestToBitPattern__Fi", SN_NOWARN)
set_name(0x8013E4D0, "CM_ShowMonsterList__Fii", SN_NOWARN)
set_name(0x8013E548, "CM_ChooseMonsterList__FiUl", SN_NOWARN)
set_name(0x8013E5E8, "NoUiListChoose__FiUl", SN_NOWARN)
set_name(0x8013E5F0, "ChooseTask__FP4TASK", SN_NOWARN)
set_name(0x8013E6F8, "ShowTask__FP4TASK", SN_NOWARN)
set_name(0x8013E914, "GetListsAvailable__FiUlPUc", SN_NOWARN)
set_name(0x8013EA38, "GetDown__C4CPad", SN_NOWARN)
set_name(0x8013EA60, "AddL1Door__Fiiii", SN_NOWARN)
set_name(0x8013EB98, "AddSCambBook__Fi", SN_NOWARN)
set_name(0x8013EC38, "AddChest__Fii", SN_NOWARN)
set_name(0x8013EE18, "AddL2Door__Fiiii", SN_NOWARN)
set_name(0x8013EF64, "AddL3Door__Fiiii", SN_NOWARN)
set_name(0x8013EFF8, "AddSarc__Fi", SN_NOWARN)
set_name(0x8013F0D4, "AddFlameTrap__Fi", SN_NOWARN)
set_name(0x8013F130, "AddTrap__Fii", SN_NOWARN)
set_name(0x8013F228, "AddObjLight__Fii", SN_NOWARN)
set_name(0x8013F2D0, "AddBarrel__Fii", SN_NOWARN)
set_name(0x8013F380, "AddShrine__Fi", SN_NOWARN)
set_name(0x8013F4D0, "AddBookcase__Fi", SN_NOWARN)
set_name(0x8013F528, "AddBookstand__Fi", SN_NOWARN)
set_name(0x8013F570, "AddBloodFtn__Fi", SN_NOWARN)
set_name(0x8013F5B8, "AddPurifyingFountain__Fi", SN_NOWARN)
set_name(0x8013F694, "AddArmorStand__Fi", SN_NOWARN)
set_name(0x8013F71C, "AddGoatShrine__Fi", SN_NOWARN)
set_name(0x8013F764, "AddCauldron__Fi", SN_NOWARN)
set_name(0x8013F7AC, "AddMurkyFountain__Fi", SN_NOWARN)
set_name(0x8013F888, "AddTearFountain__Fi", SN_NOWARN)
set_name(0x8013F8D0, "AddDecap__Fi", SN_NOWARN)
set_name(0x8013F94C, "AddVilebook__Fi", SN_NOWARN)
set_name(0x8013F99C, "AddMagicCircle__Fi", SN_NOWARN)
set_name(0x8013FA10, "AddBrnCross__Fi", SN_NOWARN)
set_name(0x8013FA58, "AddPedistal__Fi", SN_NOWARN)
set_name(0x8013FACC, "AddStoryBook__Fi", SN_NOWARN)
set_name(0x8013FC9C, "AddWeaponRack__Fi", SN_NOWARN)
set_name(0x8013FD24, "AddTorturedBody__Fi", SN_NOWARN)
set_name(0x8013FDA0, "AddFlameLvr__Fi", SN_NOWARN)
set_name(0x8013FDE0, "GetRndObjLoc__FiRiT1", SN_NOWARN)
set_name(0x8013FEEC, "AddMushPatch__Fv", SN_NOWARN)
set_name(0x80140010, "AddSlainHero__Fv", SN_NOWARN)
set_name(0x80140050, "RndLocOk__Fii", SN_NOWARN)
set_name(0x80140134, "TrapLocOk__Fii", SN_NOWARN)
set_name(0x8014019C, "RoomLocOk__Fii", SN_NOWARN)
set_name(0x80140234, "InitRndLocObj__Fiii", SN_NOWARN)
set_name(0x801403E0, "InitRndLocBigObj__Fiii", SN_NOWARN)
set_name(0x801405D8, "InitRndLocObj5x5__Fiii", SN_NOWARN)
set_name(0x80140700, "SetMapObjects__FPUcii", SN_NOWARN)
set_name(0x801409A0, "ClrAllObjects__Fv", SN_NOWARN)
set_name(0x80140A90, "AddTortures__Fv", SN_NOWARN)
set_name(0x80140C1C, "AddCandles__Fv", SN_NOWARN)
set_name(0x80140CA4, "AddTrapLine__Fiiii", SN_NOWARN)
set_name(0x80141040, "AddLeverObj__Fiiiiiiii", SN_NOWARN)
set_name(0x80141048, "AddBookLever__Fiiiiiiiii", SN_NOWARN)
set_name(0x8014125C, "InitRndBarrels__Fv", SN_NOWARN)
set_name(0x801413F8, "AddL1Objs__Fiiii", SN_NOWARN)
set_name(0x80141530, "AddL2Objs__Fiiii", SN_NOWARN)
set_name(0x80141644, "AddL3Objs__Fiiii", SN_NOWARN)
set_name(0x80141744, "TorchLocOK__Fii", SN_NOWARN)
set_name(0x80141784, "AddL2Torches__Fv", SN_NOWARN)
set_name(0x80141938, "WallTrapLocOk__Fii", SN_NOWARN)
set_name(0x801419A0, "AddObjTraps__Fv", SN_NOWARN)
set_name(0x80141D18, "AddChestTraps__Fv", SN_NOWARN)
set_name(0x80141E68, "LoadMapObjects__FPUciiiiiii", SN_NOWARN)
set_name(0x80141FD4, "AddDiabObjs__Fv", SN_NOWARN)
set_name(0x80142128, "AddStoryBooks__Fv", SN_NOWARN)
set_name(0x80142278, "AddHookedBodies__Fi", SN_NOWARN)
set_name(0x80142470, "AddL4Goodies__Fv", SN_NOWARN)
set_name(0x80142520, "AddLazStand__Fv", SN_NOWARN)
set_name(0x801426B4, "InitObjects__Fv", SN_NOWARN)
set_name(0x80142D18, "PreObjObjAddSwitch__Fiiii", SN_NOWARN)
set_name(0x80143020, "FillSolidBlockTbls__Fv", SN_NOWARN)
set_name(0x801431CC, "SetDungeonMicros__Fv", SN_NOWARN)
set_name(0x801431D4, "DRLG_InitTrans__Fv", SN_NOWARN)
set_name(0x80143248, "DRLG_MRectTrans__Fiiii", SN_NOWARN)
set_name(0x801432E8, "DRLG_RectTrans__Fiiii", SN_NOWARN)
set_name(0x80143368, "DRLG_CopyTrans__Fiiii", SN_NOWARN)
set_name(0x801433D0, "DRLG_ListTrans__FiPUc", SN_NOWARN)
set_name(0x80143444, "DRLG_AreaTrans__FiPUc", SN_NOWARN)
set_name(0x801434D4, "DRLG_InitSetPC__Fv", SN_NOWARN)
set_name(0x801434EC, "DRLG_SetPC__Fv", SN_NOWARN)
set_name(0x8014359C, "Make_SetPC__Fiiii", SN_NOWARN)
set_name(0x8014363C, "DRLG_WillThemeRoomFit__FiiiiiPiT5", SN_NOWARN)
set_name(0x80143904, "DRLG_CreateThemeRoom__Fi", SN_NOWARN)
set_name(0x8014490C, "DRLG_PlaceThemeRooms__FiiiiUc", SN_NOWARN)
set_name(0x80144BB4, "DRLG_HoldThemeRooms__Fv", SN_NOWARN)
set_name(0x80144D68, "SkipThemeRoom__Fii", SN_NOWARN)
set_name(0x80144E34, "InitLevels__Fv", SN_NOWARN)
set_name(0x80144F38, "TFit_Shrine__Fi", SN_NOWARN)
set_name(0x801451A8, "TFit_Obj5__Fi", SN_NOWARN)
set_name(0x8014537C, "TFit_SkelRoom__Fi", SN_NOWARN)
set_name(0x8014542C, "TFit_GoatShrine__Fi", SN_NOWARN)
set_name(0x801454C4, "CheckThemeObj3__Fiiii", SN_NOWARN)
set_name(0x80145614, "TFit_Obj3__Fi", SN_NOWARN)
set_name(0x801456D4, "CheckThemeReqs__Fi", SN_NOWARN)
set_name(0x801457A0, "SpecialThemeFit__Fii", SN_NOWARN)
set_name(0x8014597C, "CheckThemeRoom__Fi", SN_NOWARN)
set_name(0x80145C28, "InitThemes__Fv", SN_NOWARN)
set_name(0x80145F74, "HoldThemeRooms__Fv", SN_NOWARN)
set_name(0x8014605C, "PlaceThemeMonsts__Fii", SN_NOWARN)
set_name(0x80146200, "Theme_Barrel__Fi", SN_NOWARN)
set_name(0x80146378, "Theme_Shrine__Fi", SN_NOWARN)
set_name(0x80146460, "Theme_MonstPit__Fi", SN_NOWARN)
set_name(0x8014658C, "Theme_SkelRoom__Fi", SN_NOWARN)
set_name(0x80146890, "Theme_Treasure__Fi", SN_NOWARN)
set_name(0x80146AF4, "Theme_Library__Fi", SN_NOWARN)
set_name(0x80146D64, "Theme_Torture__Fi", SN_NOWARN)
set_name(0x80146ED4, "Theme_BloodFountain__Fi", SN_NOWARN)
set_name(0x80146F48, "Theme_Decap__Fi", SN_NOWARN)
set_name(0x801470B8, "Theme_PurifyingFountain__Fi", SN_NOWARN)
set_name(0x8014712C, "Theme_ArmorStand__Fi", SN_NOWARN)
set_name(0x801472C4, "Theme_GoatShrine__Fi", SN_NOWARN)
set_name(0x80147414, "Theme_Cauldron__Fi", SN_NOWARN)
set_name(0x80147488, "Theme_MurkyFountain__Fi", SN_NOWARN)
set_name(0x801474FC, "Theme_TearFountain__Fi", SN_NOWARN)
set_name(0x80147570, "Theme_BrnCross__Fi", SN_NOWARN)
set_name(0x801476E8, "Theme_WeaponRack__Fi", SN_NOWARN)
set_name(0x80147880, "UpdateL4Trans__Fv", SN_NOWARN)
set_name(0x801478E0, "CreateThemeRooms__Fv", SN_NOWARN)
set_name(0x80147AC4, "InitPortals__Fv", SN_NOWARN)
set_name(0x80147B24, "InitQuests__Fv", SN_NOWARN)
set_name(0x80147F28, "DrawButcher__Fv", SN_NOWARN)
set_name(0x80147F6C, "DrawSkelKing__Fiii", SN_NOWARN)
set_name(0x80147FA8, "DrawWarLord__Fii", SN_NOWARN)
set_name(0x801480A4, "DrawSChamber__Fiii", SN_NOWARN)
set_name(0x801481E0, "DrawLTBanner__Fii", SN_NOWARN)
set_name(0x801482BC, "DrawBlind__Fii", SN_NOWARN)
set_name(0x80148398, "DrawBlood__Fii", SN_NOWARN)
set_name(0x80148478, "DRLG_CheckQuests__Fii", SN_NOWARN)
set_name(0x801485B4, "InitInv__Fv", SN_NOWARN)
set_name(0x80148614, "InitAutomap__Fv", SN_NOWARN)
set_name(0x801487D8, "InitAutomapOnce__Fv", SN_NOWARN)
set_name(0x801487E8, "MonstPlace__Fii", SN_NOWARN)
set_name(0x801488A4, "InitMonsterGFX__Fi", SN_NOWARN)
set_name(0x8014897C, "PlaceMonster__Fiiii", SN_NOWARN)
set_name(0x80148A1C, "AddMonsterType__Fii", SN_NOWARN)
set_name(0x80148B18, "GetMonsterTypes__FUl", SN_NOWARN)
set_name(0x80148BC8, "ClrAllMonsters__Fv", SN_NOWARN)
set_name(0x80148D08, "InitLevelMonsters__Fv", SN_NOWARN)
set_name(0x80148D8C, "GetLevelMTypes__Fv", SN_NOWARN)
set_name(0x801491F4, "PlaceQuestMonsters__Fv", SN_NOWARN)
set_name(0x801495B8, "LoadDiabMonsts__Fv", SN_NOWARN)
set_name(0x801496C8, "PlaceGroup__FiiUci", SN_NOWARN)
set_name(0x80149BFC, "SetMapMonsters__FPUcii", SN_NOWARN)
set_name(0x80149E20, "InitMonsters__Fv", SN_NOWARN)
set_name(0x8014A1D0, "PlaceUniqueMonst__Fiii", SN_NOWARN)
set_name(0x8014A93C, "PlaceUniques__Fv", SN_NOWARN)
set_name(0x8014AACC, "PreSpawnSkeleton__Fv", SN_NOWARN)
set_name(0x8014AC0C, "encode_enemy__Fi", SN_NOWARN)
set_name(0x8014AC64, "decode_enemy__Fii", SN_NOWARN)
set_name(0x8014AD7C, "IsGoat__Fi", SN_NOWARN)
set_name(0x8014ADA8, "InitMissiles__Fv", SN_NOWARN)
set_name(0x8014AF80, "InitNoTriggers__Fv", SN_NOWARN)
set_name(0x8014AFA4, "InitTownTriggers__Fv", SN_NOWARN)
set_name(0x8014B304, "InitL1Triggers__Fv", SN_NOWARN)
set_name(0x8014B418, "InitL2Triggers__Fv", SN_NOWARN)
set_name(0x8014B5A8, "InitL3Triggers__Fv", SN_NOWARN)
set_name(0x8014B704, "InitL4Triggers__Fv", SN_NOWARN)
set_name(0x8014B918, "InitSKingTriggers__Fv", SN_NOWARN)
set_name(0x8014B964, "InitSChambTriggers__Fv", SN_NOWARN)
set_name(0x8014B9B0, "InitPWaterTriggers__Fv", SN_NOWARN)
set_name(0x8014B9FC, "InitVPTriggers__Fv", SN_NOWARN)
set_name(0x8014BA48, "InitStores__Fv", SN_NOWARN)
set_name(0x8014BAC8, "SetupTownStores__Fv", SN_NOWARN)
set_name(0x8014BC78, "DeltaLoadLevel__Fv", SN_NOWARN)
set_name(0x8014C46C, "SmithItemOk__Fi", SN_NOWARN)
set_name(0x8014C4D0, "RndSmithItem__Fi", SN_NOWARN)
set_name(0x8014C5DC, "WitchItemOk__Fi", SN_NOWARN)
set_name(0x8014C71C, "RndWitchItem__Fi", SN_NOWARN)
set_name(0x8014C81C, "BubbleSwapItem__FP10ItemStructT0", SN_NOWARN)
set_name(0x8014C900, "SortWitch__Fv", SN_NOWARN)
set_name(0x8014CA20, "RndBoyItem__Fi", SN_NOWARN)
set_name(0x8014CB44, "HealerItemOk__Fi", SN_NOWARN)
set_name(0x8014CCF8, "RndHealerItem__Fi", SN_NOWARN)
set_name(0x8014CDF8, "RecreatePremiumItem__Fiiii", SN_NOWARN)
set_name(0x8014CEC0, "RecreateWitchItem__Fiiii", SN_NOWARN)
set_name(0x8014D018, "RecreateSmithItem__Fiiii", SN_NOWARN)
set_name(0x8014D0B4, "RecreateHealerItem__Fiiii", SN_NOWARN)
set_name(0x8014D174, "RecreateBoyItem__Fiiii", SN_NOWARN)
set_name(0x8014D238, "RecreateTownItem__FiiUsii", SN_NOWARN)
set_name(0x8014D2C4, "SpawnSmith__Fi", SN_NOWARN)
set_name(0x8014D460, "SpawnWitch__Fi", SN_NOWARN)
set_name(0x8014D7CC, "SpawnHealer__Fi", SN_NOWARN)
set_name(0x8014DAE8, "SpawnBoy__Fi", SN_NOWARN)
set_name(0x8014DC3C, "SortSmith__Fv", SN_NOWARN)
set_name(0x8014DD50, "SortHealer__Fv", SN_NOWARN)
set_name(0x8014DE70, "RecreateItem__FiiUsii", SN_NOWARN)
set_name(0x80122D48, "themeLoc", SN_NOWARN)
set_name(0x80123490, "OldBlock", SN_NOWARN)
set_name(0x801234A0, "L5dungeon", SN_NOWARN)
set_name(0x80123130, "SPATS", SN_NOWARN)
set_name(0x80123234, "BSTYPES", SN_NOWARN)
set_name(0x80123304, "L5BTYPES", SN_NOWARN)
set_name(0x801233D4, "STAIRSUP", SN_NOWARN)
set_name(0x801233F8, "L5STAIRSUP", SN_NOWARN)
set_name(0x8012341C, "STAIRSDOWN", SN_NOWARN)
set_name(0x80123438, "LAMPS", SN_NOWARN)
set_name(0x80123444, "PWATERIN", SN_NOWARN)
set_name(0x80122D38, "L5ConvTbl", SN_NOWARN)
set_name(0x8012B6D0, "RoomList", SN_NOWARN)
set_name(0x8012BD24, "predungeon", SN_NOWARN)
set_name(0x80129E60, "Dir_Xadd", SN_NOWARN)
set_name(0x80129E74, "Dir_Yadd", SN_NOWARN)
set_name(0x80129E88, "SPATSL2", SN_NOWARN)
set_name(0x80129E98, "BTYPESL2", SN_NOWARN)
set_name(0x80129F3C, "BSTYPESL2", SN_NOWARN)
set_name(0x80129FE0, "VARCH1", SN_NOWARN)
set_name(0x80129FF4, "VARCH2", SN_NOWARN)
set_name(0x8012A008, "VARCH3", SN_NOWARN)
set_name(0x8012A01C, "VARCH4", SN_NOWARN)
set_name(0x8012A030, "VARCH5", SN_NOWARN)
set_name(0x8012A044, "VARCH6", SN_NOWARN)
set_name(0x8012A058, "VARCH7", SN_NOWARN)
set_name(0x8012A06C, "VARCH8", SN_NOWARN)
set_name(0x8012A080, "VARCH9", SN_NOWARN)
set_name(0x8012A094, "VARCH10", SN_NOWARN)
set_name(0x8012A0A8, "VARCH11", SN_NOWARN)
set_name(0x8012A0BC, "VARCH12", SN_NOWARN)
set_name(0x8012A0D0, "VARCH13", SN_NOWARN)
set_name(0x8012A0E4, "VARCH14", SN_NOWARN)
set_name(0x8012A0F8, "VARCH15", SN_NOWARN)
set_name(0x8012A10C, "VARCH16", SN_NOWARN)
set_name(0x8012A120, "VARCH17", SN_NOWARN)
set_name(0x8012A130, "VARCH18", SN_NOWARN)
set_name(0x8012A140, "VARCH19", SN_NOWARN)
set_name(0x8012A150, "VARCH20", SN_NOWARN)
set_name(0x8012A160, "VARCH21", SN_NOWARN)
set_name(0x8012A170, "VARCH22", SN_NOWARN)
set_name(0x8012A180, "VARCH23", SN_NOWARN)
set_name(0x8012A190, "VARCH24", SN_NOWARN)
set_name(0x8012A1A0, "VARCH25", SN_NOWARN)
set_name(0x8012A1B4, "VARCH26", SN_NOWARN)
set_name(0x8012A1C8, "VARCH27", SN_NOWARN)
set_name(0x8012A1DC, "VARCH28", SN_NOWARN)
set_name(0x8012A1F0, "VARCH29", SN_NOWARN)
set_name(0x8012A204, "VARCH30", SN_NOWARN)
set_name(0x8012A218, "VARCH31", SN_NOWARN)
set_name(0x8012A22C, "VARCH32", SN_NOWARN)
set_name(0x8012A240, "VARCH33", SN_NOWARN)
set_name(0x8012A254, "VARCH34", SN_NOWARN)
set_name(0x8012A268, "VARCH35", SN_NOWARN)
set_name(0x8012A27C, "VARCH36", SN_NOWARN)
set_name(0x8012A290, "VARCH37", SN_NOWARN)
set_name(0x8012A2A4, "VARCH38", SN_NOWARN)
set_name(0x8012A2B8, "VARCH39", SN_NOWARN)
set_name(0x8012A2CC, "VARCH40", SN_NOWARN)
set_name(0x8012A2E0, "HARCH1", SN_NOWARN)
set_name(0x8012A2F0, "HARCH2", SN_NOWARN)
set_name(0x8012A300, "HARCH3", SN_NOWARN)
set_name(0x8012A310, "HARCH4", SN_NOWARN)
set_name(0x8012A320, "HARCH5", SN_NOWARN)
set_name(0x8012A330, "HARCH6", SN_NOWARN)
set_name(0x8012A340, "HARCH7", SN_NOWARN)
set_name(0x8012A350, "HARCH8", SN_NOWARN)
set_name(0x8012A360, "HARCH9", SN_NOWARN)
set_name(0x8012A370, "HARCH10", SN_NOWARN)
set_name(0x8012A380, "HARCH11", SN_NOWARN)
set_name(0x8012A390, "HARCH12", SN_NOWARN)
set_name(0x8012A3A0, "HARCH13", SN_NOWARN)
set_name(0x8012A3B0, "HARCH14", SN_NOWARN)
set_name(0x8012A3C0, "HARCH15", SN_NOWARN)
set_name(0x8012A3D0, "HARCH16", SN_NOWARN)
set_name(0x8012A3E0, "HARCH17", SN_NOWARN)
set_name(0x8012A3F0, "HARCH18", SN_NOWARN)
set_name(0x8012A400, "HARCH19", SN_NOWARN)
set_name(0x8012A410, "HARCH20", SN_NOWARN)
set_name(0x8012A420, "HARCH21", SN_NOWARN)
set_name(0x8012A430, "HARCH22", SN_NOWARN)
set_name(0x8012A440, "HARCH23", SN_NOWARN)
set_name(0x8012A450, "HARCH24", SN_NOWARN)
set_name(0x8012A460, "HARCH25", SN_NOWARN)
set_name(0x8012A470, "HARCH26", SN_NOWARN)
set_name(0x8012A480, "HARCH27", SN_NOWARN)
set_name(0x8012A490, "HARCH28", SN_NOWARN)
set_name(0x8012A4A0, "HARCH29", SN_NOWARN)
set_name(0x8012A4B0, "HARCH30", SN_NOWARN)
set_name(0x8012A4C0, "HARCH31", SN_NOWARN)
set_name(0x8012A4D0, "HARCH32", SN_NOWARN)
set_name(0x8012A4E0, "HARCH33", SN_NOWARN)
set_name(0x8012A4F0, "HARCH34", SN_NOWARN)
set_name(0x8012A500, "HARCH35", SN_NOWARN)
set_name(0x8012A510, "HARCH36", SN_NOWARN)
set_name(0x8012A520, "HARCH37", SN_NOWARN)
set_name(0x8012A530, "HARCH38", SN_NOWARN)
set_name(0x8012A540, "HARCH39", SN_NOWARN)
set_name(0x8012A550, "HARCH40", SN_NOWARN)
set_name(0x8012A560, "USTAIRS", SN_NOWARN)
set_name(0x8012A584, "DSTAIRS", SN_NOWARN)
set_name(0x8012A5A8, "WARPSTAIRS", SN_NOWARN)
set_name(0x8012A5CC, "CRUSHCOL", SN_NOWARN)
set_name(0x8012A5E0, "BIG1", SN_NOWARN)
set_name(0x8012A5EC, "BIG2", SN_NOWARN)
set_name(0x8012A5F8, "BIG5", SN_NOWARN)
set_name(0x8012A604, "BIG8", SN_NOWARN)
set_name(0x8012A610, "BIG9", SN_NOWARN)
set_name(0x8012A61C, "BIG10", SN_NOWARN)
set_name(0x8012A628, "PANCREAS1", SN_NOWARN)
set_name(0x8012A648, "PANCREAS2", SN_NOWARN)
set_name(0x8012A668, "CTRDOOR1", SN_NOWARN)
set_name(0x8012A67C, "CTRDOOR2", SN_NOWARN)
set_name(0x8012A690, "CTRDOOR3", SN_NOWARN)
set_name(0x8012A6A4, "CTRDOOR4", SN_NOWARN)
set_name(0x8012A6B8, "CTRDOOR5", SN_NOWARN)
set_name(0x8012A6CC, "CTRDOOR6", SN_NOWARN)
set_name(0x8012A6E0, "CTRDOOR7", SN_NOWARN)
set_name(0x8012A6F4, "CTRDOOR8", SN_NOWARN)
set_name(0x8012A708, "Patterns", SN_NOWARN)
set_name(0x80131718, "lockout", SN_NOWARN)
set_name(0x80131478, "L3ConvTbl", SN_NOWARN)
set_name(0x80131488, "L3UP", SN_NOWARN)
set_name(0x8013149C, "L3DOWN", SN_NOWARN)
set_name(0x801314B0, "L3HOLDWARP", SN_NOWARN)
set_name(0x801314C4, "L3TITE1", SN_NOWARN)
set_name(0x801314E8, "L3TITE2", SN_NOWARN)
set_name(0x8013150C, "L3TITE3", SN_NOWARN)
set_name(0x80131530, "L3TITE6", SN_NOWARN)
set_name(0x8013155C, "L3TITE7", SN_NOWARN)
set_name(0x80131588, "L3TITE8", SN_NOWARN)
set_name(0x8013159C, "L3TITE9", SN_NOWARN)
set_name(0x801315B0, "L3TITE10", SN_NOWARN)
set_name(0x801315C4, "L3TITE11", SN_NOWARN)
set_name(0x801315D8, "L3ISLE1", SN_NOWARN)
set_name(0x801315E8, "L3ISLE2", SN_NOWARN)
set_name(0x801315F8, "L3ISLE3", SN_NOWARN)
set_name(0x80131608, "L3ISLE4", SN_NOWARN)
set_name(0x80131618, "L3ISLE5", SN_NOWARN)
set_name(0x80131624, "L3ANVIL", SN_NOWARN)
set_name(0x80136534, "dung", SN_NOWARN)
set_name(0x801366C4, "hallok", SN_NOWARN)
set_name(0x801366D8, "L4dungeon", SN_NOWARN)
set_name(0x80137FD8, "L4ConvTbl", SN_NOWARN)
set_name(0x80137FE8, "L4USTAIRS", SN_NOWARN)
set_name(0x80138014, "L4TWARP", SN_NOWARN)
set_name(0x80138040, "L4DSTAIRS", SN_NOWARN)
set_name(0x80138074, "L4PENTA", SN_NOWARN)
set_name(0x801380A8, "L4PENTA2", SN_NOWARN)
set_name(0x801380DC, "L4BTYPES", SN_NOWARN)
|
# -*- coding: utf-8 -*-
class Solution(object):
def reverse(self, x):
"""
:type x: int
:rtype: int
"""
ans = 0
flag = 1
if x < 0:
flag = -1
x = - x
while x != 0:
cur = x % 10
ans = ans * 10 + cur
x = x // 10
ans = ans * flag
# print("ans", ans)
if -2 ** 31 <= ans <= 2 ** 31:
return ans
else:
return 0
if "__main__" == __name__:
solution = Solution()
input1 = 123
input2= -123
input3 = 120
# 2 ** 31 = 2147483648
input4 = 2147483648
1534236469
input5 = -2147483649
input6 = 2147483647
input7 = -2147483648
print(solution.reverse(input1))
print(solution.reverse(input2))
print(solution.reverse(input3))
print(solution.reverse(input4))
print(solution.reverse(input5))
print(solution.reverse(input6))
print(solution.reverse(input7))
print(solution.reverse(1534236469))
|
#
# PySNMP MIB module ALCATEL-IND1-AUTO-FABRIC-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ALCATEL-IND1-AUTO-FABRIC-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 17:01:26 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)
#
softentIND1AutoFabric, = mibBuilder.importSymbols("ALCATEL-IND1-BASE", "softentIND1AutoFabric")
ObjectIdentifier, OctetString, Integer = mibBuilder.importSymbols("ASN1", "ObjectIdentifier", "OctetString", "Integer")
NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues")
ValueRangeConstraint, ConstraintsIntersection, ConstraintsUnion, SingleValueConstraint, ValueSizeConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ValueRangeConstraint", "ConstraintsIntersection", "ConstraintsUnion", "SingleValueConstraint", "ValueSizeConstraint")
InterfaceIndex, = mibBuilder.importSymbols("IF-MIB", "InterfaceIndex")
SnmpAdminString, = mibBuilder.importSymbols("SNMP-FRAMEWORK-MIB", "SnmpAdminString")
ModuleCompliance, NotificationGroup, ObjectGroup = mibBuilder.importSymbols("SNMPv2-CONF", "ModuleCompliance", "NotificationGroup", "ObjectGroup")
MibScalar, MibTable, MibTableRow, MibTableColumn, Integer32, ObjectIdentity, NotificationType, Unsigned32, iso, Counter32, MibIdentifier, Counter64, IpAddress, TimeTicks, Gauge32, Bits, ModuleIdentity = mibBuilder.importSymbols("SNMPv2-SMI", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "Integer32", "ObjectIdentity", "NotificationType", "Unsigned32", "iso", "Counter32", "MibIdentifier", "Counter64", "IpAddress", "TimeTicks", "Gauge32", "Bits", "ModuleIdentity")
TextualConvention, DisplayString = mibBuilder.importSymbols("SNMPv2-TC", "TextualConvention", "DisplayString")
alcatelIND1AUTOFABRICMIB = ModuleIdentity((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 75, 1))
alcatelIND1AUTOFABRICMIB.setRevisions(('2012-11-25 00:00',))
if mibBuilder.loadTexts: alcatelIND1AUTOFABRICMIB.setLastUpdated('201211260000Z')
if mibBuilder.loadTexts: alcatelIND1AUTOFABRICMIB.setOrganization('Alcatel - Architects Of An Internet World')
alcatelIND1AUTOFABRICMIBObjects = ObjectIdentity((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 75, 1, 1))
if mibBuilder.loadTexts: alcatelIND1AUTOFABRICMIBObjects.setStatus('current')
alcatelIND1AUTOFABRICMIBConformance = ObjectIdentity((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 75, 1, 2))
if mibBuilder.loadTexts: alcatelIND1AUTOFABRICMIBConformance.setStatus('current')
alcatelIND1AUTOFABRICMIBGroups = ObjectIdentity((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 75, 1, 2, 1))
if mibBuilder.loadTexts: alcatelIND1AUTOFABRICMIBGroups.setStatus('current')
alcatelIND1AUTOFABRICMIBCompliances = ObjectIdentity((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 75, 1, 2, 2))
if mibBuilder.loadTexts: alcatelIND1AUTOFABRICMIBCompliances.setStatus('current')
alaAutoFabricGlobalStatus = MibScalar((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 75, 1, 1, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enable", 1), ("disable", 2))).clone('enable')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: alaAutoFabricGlobalStatus.setStatus('current')
alaAutoFabricGlobalDiscovery = MibScalar((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 75, 1, 1, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("default", 1), ("restart", 2))).clone('default')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: alaAutoFabricGlobalDiscovery.setStatus('current')
alaAutoFabricGlobalLACPProtocolStatus = MibScalar((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 75, 1, 1, 3), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enable", 1), ("disable", 2))).clone('enable')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: alaAutoFabricGlobalLACPProtocolStatus.setStatus('current')
alaAutoFabricGlobalSPBProtocolStatus = MibScalar((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 75, 1, 1, 4), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enable", 1), ("disable", 2))).clone('enable')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: alaAutoFabricGlobalSPBProtocolStatus.setStatus('current')
alaAutoFabricGlobalMVRPProtocolStatus = MibScalar((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 75, 1, 1, 5), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enable", 1), ("disable", 2))).clone('enable')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: alaAutoFabricGlobalMVRPProtocolStatus.setStatus('current')
alaAutoFabricGlobalConfigSaveTimer = MibScalar((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 75, 1, 1, 6), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(60, 3600)).clone(300)).setUnits('seconds').setMaxAccess("readwrite")
if mibBuilder.loadTexts: alaAutoFabricGlobalConfigSaveTimer.setStatus('current')
alaAutoFabricGlobalConfigSaveTimerStatus = MibScalar((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 75, 1, 1, 7), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enable", 1), ("disable", 2))).clone('enable')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: alaAutoFabricGlobalConfigSaveTimerStatus.setStatus('current')
alaAutoFabricGlobalDiscoveryTimer = MibScalar((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 75, 1, 1, 8), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(1, 3600)).clone(1)).setUnits('Minutes').setMaxAccess("readwrite")
if mibBuilder.loadTexts: alaAutoFabricGlobalDiscoveryTimer.setStatus('current')
alaAutoFabricRemoveGlobalConfig = MibScalar((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 75, 1, 1, 10), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("default", 1), ("removeGlobalConfig", 2))).clone('default')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: alaAutoFabricRemoveGlobalConfig.setStatus('current')
alaAutoFabricPortConfig = MibIdentifier((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 75, 1, 1, 9))
alaAutoFabricPortConfigTable = MibTable((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 75, 1, 1, 9, 1), )
if mibBuilder.loadTexts: alaAutoFabricPortConfigTable.setStatus('current')
alaAutoFabricPortConfigEntry = MibTableRow((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 75, 1, 1, 9, 1, 1), ).setIndexNames((0, "ALCATEL-IND1-AUTO-FABRIC-MIB", "alaAutoFabricPortConfigIfIndex"))
if mibBuilder.loadTexts: alaAutoFabricPortConfigEntry.setStatus('current')
alaAutoFabricPortConfigIfIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 75, 1, 1, 9, 1, 1, 1), InterfaceIndex())
if mibBuilder.loadTexts: alaAutoFabricPortConfigIfIndex.setStatus('current')
alaAutoFabricPortConfigStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 75, 1, 1, 9, 1, 1, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enable", 1), ("disable", 2))).clone('enable')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: alaAutoFabricPortConfigStatus.setStatus('current')
alaAutoFabricPortLACPProtocolStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 75, 1, 1, 9, 1, 1, 3), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enable", 1), ("disable", 2))).clone('enable')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: alaAutoFabricPortLACPProtocolStatus.setStatus('current')
alaAutoFabricPortSPBProtocolStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 75, 1, 1, 9, 1, 1, 4), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enable", 1), ("disable", 2))).clone('enable')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: alaAutoFabricPortSPBProtocolStatus.setStatus('current')
alaAutoFabricPortMVRPProtocolStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 75, 1, 1, 9, 1, 1, 5), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enable", 1), ("disable", 2))).clone('enable')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: alaAutoFabricPortMVRPProtocolStatus.setStatus('current')
alaAutoFabricPortStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 75, 1, 1, 9, 1, 1, 6), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("disabled", 1), ("pending", 2), ("complete", 3)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: alaAutoFabricPortStatus.setStatus('current')
alcatelIND1AUTOFABRICMIBCompliance = ModuleCompliance((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 75, 1, 2, 2, 1)).setObjects(("ALCATEL-IND1-AUTO-FABRIC-MIB", "alaAutoFabricBaseGroup"), ("ALCATEL-IND1-AUTO-FABRIC-MIB", "alaAutoFabricPortConfigGroup"))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
alcatelIND1AUTOFABRICMIBCompliance = alcatelIND1AUTOFABRICMIBCompliance.setStatus('current')
alaAutoFabricBaseGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 75, 1, 2, 1, 1)).setObjects(("ALCATEL-IND1-AUTO-FABRIC-MIB", "alaAutoFabricGlobalStatus"), ("ALCATEL-IND1-AUTO-FABRIC-MIB", "alaAutoFabricGlobalDiscovery"), ("ALCATEL-IND1-AUTO-FABRIC-MIB", "alaAutoFabricGlobalLACPProtocolStatus"), ("ALCATEL-IND1-AUTO-FABRIC-MIB", "alaAutoFabricGlobalSPBProtocolStatus"), ("ALCATEL-IND1-AUTO-FABRIC-MIB", "alaAutoFabricGlobalMVRPProtocolStatus"), ("ALCATEL-IND1-AUTO-FABRIC-MIB", "alaAutoFabricGlobalConfigSaveTimer"), ("ALCATEL-IND1-AUTO-FABRIC-MIB", "alaAutoFabricGlobalConfigSaveTimerStatus"), ("ALCATEL-IND1-AUTO-FABRIC-MIB", "alaAutoFabricGlobalDiscoveryTimer"), ("ALCATEL-IND1-AUTO-FABRIC-MIB", "alaAutoFabricRemoveGlobalConfig"))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
alaAutoFabricBaseGroup = alaAutoFabricBaseGroup.setStatus('current')
alaAutoFabricPortConfigGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 75, 1, 2, 1, 2)).setObjects(("ALCATEL-IND1-AUTO-FABRIC-MIB", "alaAutoFabricPortConfigStatus"), ("ALCATEL-IND1-AUTO-FABRIC-MIB", "alaAutoFabricPortLACPProtocolStatus"), ("ALCATEL-IND1-AUTO-FABRIC-MIB", "alaAutoFabricPortSPBProtocolStatus"), ("ALCATEL-IND1-AUTO-FABRIC-MIB", "alaAutoFabricPortMVRPProtocolStatus"), ("ALCATEL-IND1-AUTO-FABRIC-MIB", "alaAutoFabricPortStatus"))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
alaAutoFabricPortConfigGroup = alaAutoFabricPortConfigGroup.setStatus('current')
mibBuilder.exportSymbols("ALCATEL-IND1-AUTO-FABRIC-MIB", alcatelIND1AUTOFABRICMIB=alcatelIND1AUTOFABRICMIB, PYSNMP_MODULE_ID=alcatelIND1AUTOFABRICMIB, alaAutoFabricGlobalLACPProtocolStatus=alaAutoFabricGlobalLACPProtocolStatus, alaAutoFabricPortConfigGroup=alaAutoFabricPortConfigGroup, alaAutoFabricPortConfigStatus=alaAutoFabricPortConfigStatus, alcatelIND1AUTOFABRICMIBConformance=alcatelIND1AUTOFABRICMIBConformance, alaAutoFabricPortConfigEntry=alaAutoFabricPortConfigEntry, alaAutoFabricRemoveGlobalConfig=alaAutoFabricRemoveGlobalConfig, alaAutoFabricPortStatus=alaAutoFabricPortStatus, alaAutoFabricPortConfigTable=alaAutoFabricPortConfigTable, alcatelIND1AUTOFABRICMIBGroups=alcatelIND1AUTOFABRICMIBGroups, alaAutoFabricPortLACPProtocolStatus=alaAutoFabricPortLACPProtocolStatus, alaAutoFabricGlobalConfigSaveTimer=alaAutoFabricGlobalConfigSaveTimer, alcatelIND1AUTOFABRICMIBObjects=alcatelIND1AUTOFABRICMIBObjects, alaAutoFabricGlobalMVRPProtocolStatus=alaAutoFabricGlobalMVRPProtocolStatus, alaAutoFabricGlobalConfigSaveTimerStatus=alaAutoFabricGlobalConfigSaveTimerStatus, alaAutoFabricPortConfigIfIndex=alaAutoFabricPortConfigIfIndex, alaAutoFabricPortConfig=alaAutoFabricPortConfig, alaAutoFabricBaseGroup=alaAutoFabricBaseGroup, alaAutoFabricGlobalDiscovery=alaAutoFabricGlobalDiscovery, alaAutoFabricGlobalStatus=alaAutoFabricGlobalStatus, alcatelIND1AUTOFABRICMIBCompliance=alcatelIND1AUTOFABRICMIBCompliance, alcatelIND1AUTOFABRICMIBCompliances=alcatelIND1AUTOFABRICMIBCompliances, alaAutoFabricGlobalSPBProtocolStatus=alaAutoFabricGlobalSPBProtocolStatus, alaAutoFabricPortMVRPProtocolStatus=alaAutoFabricPortMVRPProtocolStatus, alaAutoFabricPortSPBProtocolStatus=alaAutoFabricPortSPBProtocolStatus, alaAutoFabricGlobalDiscoveryTimer=alaAutoFabricGlobalDiscoveryTimer)
|
"""settings.py - Contains MAILGUN settings"""
MAILGUN_DOMAIN_NAME = "sandbox301369dd8c464b87b7874ba72a5e3039.mailgun.org"
MAILGUN_PRIVATE_API_KEY = "key-de714a26093d427c84abcb980d3f3f0a"
MAILGUN_PUBLIC_API_KEY = "pubkey-2b308844086ef26cee582ce10ac7303b"
MAILGUN_SANDBOX_SENDER = "Mailgun Sandbox <[email protected]>"
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Cambia el formato de fecha dd/mm/aaaa por aaaa-mm-dd
ejemplo:
entrada = 20/04/2021
salida = 2021-20-04
"""
def plugin_main(*args, **kwargs):
# print ('args : ',args)
# print ('kwargs: ',kwargs)
fecha = kwargs['fecha'][0]
fecha = '{}-{}-{}'.format(fecha[-4:], fecha[3:5], fecha[:2])
#print (fecha)
return 'fecha',fecha
|
# Copyright (c) 2014, Charles Duyk
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
def dictFind(dictionary, name, exact=True):
lowerName = name.lower()
result = []
if exact:
try:
result.append(dictionary[lowerName])
except KeyError:
pass
else:
for key in dictionary:
if lowerName in key:
result.append(dictionary[key])
return result
def isIter(obj):
try:
iter(obj)
return True
except:
return False
def getIDs(items):
if isIter(items):
return map(lambda item: item.getID(), items)
else:
return [items.getID()]
|
AWS_DOCKER_HOST = "308535385114.dkr.ecr.us-east-1.amazonaws.com"
def gen_docker_image(container_type):
return (
"/".join([AWS_DOCKER_HOST, "pytorch", container_type]),
f"docker-{container_type}",
)
def gen_docker_image_requires(image_name):
return [f"docker-{image_name}"]
DOCKER_IMAGE_BASIC, DOCKER_REQUIREMENT_BASE = gen_docker_image(
"pytorch-linux-xenial-py3.7-gcc5.4"
)
DOCKER_IMAGE_CUDA_10_2, DOCKER_REQUIREMENT_CUDA_10_2 = gen_docker_image(
"pytorch-linux-xenial-cuda10.2-cudnn7-py3-gcc7"
)
DOCKER_IMAGE_GCC7, DOCKER_REQUIREMENT_GCC7 = gen_docker_image(
"pytorch-linux-xenial-py3.7-gcc7"
)
def gen_mobile_docker(specifier):
container_type = "pytorch-linux-xenial-py3-clang5-" + specifier
return gen_docker_image(container_type)
DOCKER_IMAGE_ASAN, DOCKER_REQUIREMENT_ASAN = gen_mobile_docker("asan")
DOCKER_IMAGE_NDK, DOCKER_REQUIREMENT_NDK = gen_mobile_docker("android-ndk-r19c")
|
#
# PySNMP MIB module DNOS-KEYING-PRIVATE-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/DNOS-KEYING-PRIVATE-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 18:36:48 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)
#
Integer, ObjectIdentifier, OctetString = mibBuilder.importSymbols("ASN1", "Integer", "ObjectIdentifier", "OctetString")
NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues")
ValueSizeConstraint, SingleValueConstraint, ConstraintsIntersection, ValueRangeConstraint, ConstraintsUnion = mibBuilder.importSymbols("ASN1-REFINEMENT", "ValueSizeConstraint", "SingleValueConstraint", "ConstraintsIntersection", "ValueRangeConstraint", "ConstraintsUnion")
dnOS, = mibBuilder.importSymbols("DELL-REF-MIB", "dnOS")
NotificationGroup, ModuleCompliance = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance")
Gauge32, Integer32, iso, ObjectIdentity, MibIdentifier, TimeTicks, NotificationType, Bits, Counter32, IpAddress, ModuleIdentity, MibScalar, MibTable, MibTableRow, MibTableColumn, Counter64, Unsigned32 = mibBuilder.importSymbols("SNMPv2-SMI", "Gauge32", "Integer32", "iso", "ObjectIdentity", "MibIdentifier", "TimeTicks", "NotificationType", "Bits", "Counter32", "IpAddress", "ModuleIdentity", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "Counter64", "Unsigned32")
RowPointer, RowStatus, DisplayString, TextualConvention = mibBuilder.importSymbols("SNMPv2-TC", "RowPointer", "RowStatus", "DisplayString", "TextualConvention")
fastPathKeyingPrivate = ModuleIdentity((1, 3, 6, 1, 4, 1, 674, 10895, 5000, 2, 6132, 1, 1, 24))
fastPathKeyingPrivate.setRevisions(('2011-01-26 00:00', '2007-05-23 00:00',))
if mibBuilder.loadTexts: fastPathKeyingPrivate.setLastUpdated('201101260000Z')
if mibBuilder.loadTexts: fastPathKeyingPrivate.setOrganization('Dell, Inc.')
agentFeatureKeyingGroup = MibIdentifier((1, 3, 6, 1, 4, 1, 674, 10895, 5000, 2, 6132, 1, 1, 24, 1))
agentFeatureKeyingEnableKey = MibScalar((1, 3, 6, 1, 4, 1, 674, 10895, 5000, 2, 6132, 1, 1, 24, 1, 1), DisplayString()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: agentFeatureKeyingEnableKey.setStatus('current')
agentFeatureKeyingDisableKey = MibScalar((1, 3, 6, 1, 4, 1, 674, 10895, 5000, 2, 6132, 1, 1, 24, 1, 2), DisplayString()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: agentFeatureKeyingDisableKey.setStatus('current')
agentFeatureKeyingTable = MibTable((1, 3, 6, 1, 4, 1, 674, 10895, 5000, 2, 6132, 1, 1, 24, 1, 3), )
if mibBuilder.loadTexts: agentFeatureKeyingTable.setStatus('current')
agentFeatureKeyingEntry = MibTableRow((1, 3, 6, 1, 4, 1, 674, 10895, 5000, 2, 6132, 1, 1, 24, 1, 3, 1), ).setIndexNames((0, "DNOS-KEYING-PRIVATE-MIB", "agentFeatureKeyingIndex"))
if mibBuilder.loadTexts: agentFeatureKeyingEntry.setStatus('current')
agentFeatureKeyingIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 674, 10895, 5000, 2, 6132, 1, 1, 24, 1, 3, 1, 1), Unsigned32())
if mibBuilder.loadTexts: agentFeatureKeyingIndex.setStatus('current')
agentFeatureKeyingName = MibTableColumn((1, 3, 6, 1, 4, 1, 674, 10895, 5000, 2, 6132, 1, 1, 24, 1, 3, 1, 2), DisplayString()).setMaxAccess("readonly")
if mibBuilder.loadTexts: agentFeatureKeyingName.setStatus('current')
agentFeatureKeyingStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 674, 10895, 5000, 2, 6132, 1, 1, 24, 1, 3, 1, 3), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enable", 1), ("disable", 2)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: agentFeatureKeyingStatus.setStatus('current')
mibBuilder.exportSymbols("DNOS-KEYING-PRIVATE-MIB", agentFeatureKeyingIndex=agentFeatureKeyingIndex, agentFeatureKeyingTable=agentFeatureKeyingTable, agentFeatureKeyingEntry=agentFeatureKeyingEntry, agentFeatureKeyingStatus=agentFeatureKeyingStatus, PYSNMP_MODULE_ID=fastPathKeyingPrivate, agentFeatureKeyingDisableKey=agentFeatureKeyingDisableKey, agentFeatureKeyingName=agentFeatureKeyingName, agentFeatureKeyingEnableKey=agentFeatureKeyingEnableKey, fastPathKeyingPrivate=fastPathKeyingPrivate, agentFeatureKeyingGroup=agentFeatureKeyingGroup)
|
#coding: utf-8
#------------------------------------------------------------
# Um programa que recebe um nome e retorna com boas vindas.
#------------------------------------------------------------
# Respondendo ao usuário - Exercício #002
#------------------------------------------------------------
nome = str(input('Digite seu nome: '))
print('Bem vindo(a) {}!'.format(nome))
|
class QTimer:
def __init__(self, ticks_per_hour = 60, hours_per_day:int = 24):
self.ticks = 0
self.ticks_per_hour = ticks_per_hour
self.hours_per_day = hours_per_day
def tick(self, increment : int = 1):
self.ticks += increment
@property
def minutes(self):
return self.ticks % (self.ticks_per_hour)
@property
def hour(self):
return (self.ticks // (self.ticks_per_hour)) % self.hours_per_day
@property
def day(self):
return self.ticks // (self.ticks_per_hour * self.hours_per_day)
def __str__(self):
return f"Days {self.day:02} Hours {self.hour:02} Minutes {self.minutes:02}"
if __name__ == "__main__":
q1 = QTimer()
print(q1)
q1.tick(137)
print(q1)
q1.tick(60* 34)
print(q1)
q1.tick(60)
print(q1)
|
# Copyright (C) 2020 Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "No Default Account",
"version": "14.0.1.0.0",
"development_status": "Beta",
"author": "Open Source Integrators, Odoo Community Association (OCA)",
"maintainers": ["dreispt"],
"summary": "Remove default expense account for vendor bills journal",
"website": "https://github.com/OCA/account-financial-tools",
"license": "AGPL-3",
"depends": ["account"],
"category": "Accounting/Accounting",
"data": [
"views/account_journal_views.xml",
],
"installable": True,
}
|
def swap_even_and_odd_bits(n):
'''Swaps the even and odd bits of an unsigned, 8-bits number.
>>> swap_even_and_odd_bits(0b10101010) == 0b01010101
True
>>> swap_even_and_odd_bits(0b11100010) == 0b11010001
True
'''
assert 0 <= n <= 0xFF, 'Not an 8-bit unsigned number'
return ((n & 0b10101010) >> 1) | ((n & 0b01010101) << 1)
|
URLs = {
"ADULT_SAMPLE":[
"https://s3.amazonaws.com/fast-ai-sample/adult_sample.tgz",
968212,
"64eb9d7e23732de0b138f7372d15492f"
],
"AG_NEWS":[
"https://s3.amazonaws.com/fast-ai-nlp/ag_news_csv.tgz",
11784419,
"b86f328f4dbd072486591cb7a5644dcd"
],
"AMAZON_REVIEWS":[
"https://s3.amazonaws.com/fast-ai-nlp/amazon_review_full_csv.tgz",
643695014,
"4a1196cf0adaea22f4bc3f592cddde90"
],
"AMAZON_REVIEWS_POLARITY":[
"https://s3.amazonaws.com/fast-ai-nlp/amazon_review_polarity_csv.tgz",
688339454,
"676f7e5208ec343c8274b4bb085bc938"
],
"BIWI_HEAD_POSE":[
"https://s3.amazonaws.com/fast-ai-imagelocal/biwi_head_pose.tgz",
452316199,
"00f4ccf66e8cba184bc292fdc08fb237"
],
"BIWI_SAMPLE":[
"https://s3.amazonaws.com/fast-ai-sample/biwi_sample.tgz",
593774,
"9179f4c1435f4b291f0d5b072d60c2c9"
],
"CALTECH_101":[
"https://s3.amazonaws.com/fast-ai-imageclas/caltech_101.tgz",
131740031,
"d673425306e98ee4619fcdeef8a0e876"
],
"CAMVID":[
"https://s3.amazonaws.com/fast-ai-imagelocal/camvid.tgz",
598913237,
"648371e4f3a833682afb39b08a3ce2aa"
],
"CAMVID_TINY":[
"https://s3.amazonaws.com/fast-ai-sample/camvid_tiny.tgz",
2314212,
"2cf6daf91b7a2083ecfa3e9968e9d915"
],
"CARS":[
"https://s3.amazonaws.com/fast-ai-imageclas/stanford-cars.tgz",
1957803273,
"9045d6673c9ced0889f41816f6bf2f9f"
],
"CIFAR":[
"https://s3.amazonaws.com/fast-ai-sample/cifar10.tgz",
168168549,
"a5f8c31371b63a406b23368042812d3c"
],
"CIFAR_100":[
"https://s3.amazonaws.com/fast-ai-imageclas/cifar100.tgz",
169168619,
"e5e65dcb54b9d3913f7b8a9ad6607e62"
],
"COCO_SAMPLE":[
"https://s3.amazonaws.com/fast-ai-coco/coco_sample.tgz",
3245877008,
"006cd55d633d94b36ecaf661467830ec"
],
"COCO_TINY":[
"https://s3.amazonaws.com/fast-ai-coco/coco_tiny.tgz",
801038,
"367467451ac4fba79a647753c2c66d3a"
],
"CUB_200_2011":[
"https://s3.amazonaws.com/fast-ai-imageclas/CUB_200_2011.tgz",
1150585339,
"d2acaa99439dff0483c7bbac1bfe2a92"
],
"DBPEDIA":[
"https://s3.amazonaws.com/fast-ai-nlp/dbpedia_csv.tgz",
68341743,
"239c7837b9e79db34486f3de6a00e38e"
],
"DOGS":[
"https://s3.amazonaws.com/fast-ai-sample/dogscats.tgz",
839285364,
"3e483c8d6ef2175e9d395a6027eb92b7"
],
"FLOWERS":[
"https://s3.amazonaws.com/fast-ai-imageclas/oxford-102-flowers.tgz",
345236087,
"5666e01c1311b4c67fcf20d2b3850a88"
],
"FOOD":[
"https://s3.amazonaws.com/fast-ai-imageclas/food-101.tgz",
5686607260,
"1a540ebf1fb40b2bf3f2294234ba7907"
],
"HUMAN_NUMBERS":[
"https://s3.amazonaws.com/fast-ai-sample/human_numbers.tgz",
30252,
"8a19c3bfa2bcb08cd787e741261f3ea2"
],
"IMAGENETTE":[
"https://s3.amazonaws.com/fast-ai-imageclas/imagenette2.tgz",
1557161267,
"2c774ecb40005b35d7937d50f5d42336"
],
"IMAGENETTE_160":[
"https://s3.amazonaws.com/fast-ai-imageclas/imagenette2-160.tgz",
99003388,
"c475f8f7617a200ba35b9facc48443c3"
],
"IMAGENETTE_320":[
"https://s3.amazonaws.com/fast-ai-imageclas/imagenette2-320.tgz",
341553947,
"55496feff4562875a3246d819d094b2b"
],
"IMAGEWANG":[
"https://s3.amazonaws.com/fast-ai-imageclas/imagewang.tgz",
2900347689,
"2b7776bac0fc95db72ac8a3b091a3e30"
],
"IMAGEWANG_160":[
"https://s3.amazonaws.com/fast-ai-imageclas/imagewang-160.tgz",
191498213,
"dab9b1d97b95574ac64122a19bc74ca1"
],
"IMAGEWANG_320":[
"https://s3.amazonaws.com/fast-ai-imageclas/imagewang-320.tgz",
669826647,
"fff8ac034d60e14fcf7789845e625263"
],
"IMAGEWOOF":[
"https://s3.amazonaws.com/fast-ai-imageclas/imagewoof2.tgz",
1343715595,
"2cc1c1e36e20cb6fd24ffb978edcb487"
],
"IMAGEWOOF_160":[
"https://s3.amazonaws.com/fast-ai-imageclas/imagewoof2-160.tgz",
92612825,
"3559b194123981a540b87132dbda412f"
],
"IMAGEWOOF_320":[
"https://s3.amazonaws.com/fast-ai-imageclas/imagewoof2-320.tgz",
328387740,
"7a1fd92672a559a85de76e4810a20c21"
],
"IMDB":[
"https://s3.amazonaws.com/fast-ai-nlp/imdb.tgz",
144440600,
"90f9b1c4ff43a90d67553c9240dc0249"
],
"IMDB_SAMPLE":[
"https://s3.amazonaws.com/fast-ai-sample/imdb_sample.tgz",
571827,
"0842e61a9867caa2e6fbdb14fa703d61"
],
"LSUN_BEDROOMS":[
"https://s3.amazonaws.com/fast-ai-imageclas/bedroom.tgz",
4579163978,
"35d84f38f8a15fe47e66e460c8800d68"
],
"MACAQUES":[
"https://storage.googleapis.com/ml-animal-sounds-datasets/macaques.zip",
131604586,
"44fec3950e61d6a898f16fe30bc9c88d"
],
"ML_100k":[
"http://files.grouplens.org/datasets/movielens/ml-100k.zip",
4924029,
"39f6af2d7ea4e117f8838e4a302fec70"
],
"ML_SAMPLE":[
"https://s3.amazonaws.com/fast-ai-sample/movie_lens_sample.tgz",
51790,
"10961384dfe7c5181460390a460c1f77"
],
"MNIST":[
"https://s3.amazonaws.com/fast-ai-imageclas/mnist_png.tgz",
15683414,
"03639f83c4e3d19e0a3a53a8a997c487"
],
"MNIST_SAMPLE":[
"https://s3.amazonaws.com/fast-ai-sample/mnist_sample.tgz",
3214948,
"2dbc7ec6f9259b583af0072c55816a88"
],
"MNIST_TINY":[
"https://s3.amazonaws.com/fast-ai-sample/mnist_tiny.tgz",
342207,
"56143e8f24db90d925d82a5a74141875"
],
"MNIST_VAR_SIZE_TINY":[
"https://s3.amazonaws.com/fast-ai-imageclas/mnist_var_size_tiny.tgz",
565372,
"b71a930f4eb744a4a143a6c7ff7ed67f"
],
"MT_ENG_FRA":[
"https://s3.amazonaws.com/fast-ai-nlp/giga-fren.tgz",
2598183296,
"69573f58e2c850b90f2f954077041d8c"
],
"OPENAI_TRANSFORMER":[
"https://s3.amazonaws.com/fast-ai-modelzoo/transformer.tgz",
432848315,
"024b0d2203ebb0cd1fc64b27cf8af18e"
],
"PASCAL_2007":[
"https://s3.amazonaws.com/fast-ai-imagelocal/pascal_2007.tgz",
1637796771,
"433b4706eb7c42bd74e7f784e3fdf244"
],
"PASCAL_2012":[
"https://s3.amazonaws.com/fast-ai-imagelocal/pascal_2012.tgz",
2618908000,
"d90e29e54a4c76c0c6fba8355dcbaca5"
],
"PETS":[
"https://s3.amazonaws.com/fast-ai-imageclas/oxford-iiit-pet.tgz",
811706944,
"e4db5c768afd933bb91f5f594d7417a4"
],
"PLANET_SAMPLE":[
"https://s3.amazonaws.com/fast-ai-sample/planet_sample.tgz",
15523994,
"8bfb174b3162f07fbde09b54555bdb00"
],
"PLANET_TINY":[
"https://s3.amazonaws.com/fast-ai-sample/planet_tiny.tgz",
997569,
"490873c5683454d4b2611fb1f00a68a9"
],
"SIIM_SMALL":[
"https://s3.amazonaws.com/fast-ai-imagelocal/siim_small.tgz",
33276453,
"2f88ac350dce1d971ecbb5ec722da75f"
],
"SOGOU_NEWS":[
"https://s3.amazonaws.com/fast-ai-nlp/sogou_news_csv.tgz",
384269937,
"950f1366d33be52f5b944f8a8b680902"
],
"TCGA_SMALL":[
"https://s3.amazonaws.com/fast-ai-imagelocal/tcga_small.tgz",
14744474,
"3ceffe7cf522cb1c60e93dc555d8817f"
],
"WIKITEXT":[
"https://s3.amazonaws.com/fast-ai-nlp/wikitext-103.tgz",
190200704,
"2dd8cf8693b3d27e9c8f0a7df054b2c7"
],
"WIKITEXT_TINY":[
"https://s3.amazonaws.com/fast-ai-nlp/wikitext-2.tgz",
4070055,
"2a82d47a7b85c8b6a8e068dc4c1d37e7"
],
"WT103_BWD":[
"https://s3.amazonaws.com/fast-ai-modelzoo/wt103-bwd.tgz",
105205312,
'20b06f5830fd5a891d21044c28d3097f'
],
"WT103_FWD":[
"https://s3.amazonaws.com/fast-ai-modelzoo/wt103-fwd.tgz",
105067061,
'7d1114cd9684bf9d1ca3c9f6a54da6f9'
],
"YAHOO_ANSWERS":[
"https://s3.amazonaws.com/fast-ai-nlp/yahoo_answers_csv.tgz",
319476345,
"0632a0d236ef3a529c0fa4429b339f68"
],
"YELP_REVIEWS":[
"https://s3.amazonaws.com/fast-ai-nlp/yelp_review_full_csv.tgz",
196146755,
"1efd84215ea3e30d90e4c33764b889db"
],
"YELP_REVIEWS_POLARITY":[
"https://s3.amazonaws.com/fast-ai-nlp/yelp_review_polarity_csv.tgz",
166373201,
"48c8451c1ad30472334d856b5d294807"
],
"ZEBRA_FINCH":[
"https://storage.googleapis.com/ml-animal-sounds-datasets/zebra_finch.zip",
83886080,
"91fa9c4ebfc986b9babc2a805a10e281"
]
} |
# Construir um programa que calcule e apresente em metros por segundo o valor da velocidade de um projétil que percorre uma distância em quilômetros a um espaço de tempo em minutos. Utilize a fórmula VELOCIDADE <- (DISTÂNCIA* 1000) /(TEMPO* 60).
dist = int(input('informe a distancia: '))
tmp = int(input('informe o tempo: '))
vel = (dist * 1000)/(tmp * 60)
print('A velocidade percorrida do projetil é igual a {}m/s'.format(vel)) |
n = 6
k = 3
keys = [i for i in range(int(n))]
values = [0] * n
a = dict(zip(keys, values))
result = []
def recur(s, n, was, result):
if len(s) == k:
result.append(s)
return
for i in range(0, n):
if was[i] == 0:
was[i] = 1
recur(s + str(i + 1), n, was, result)
was[i] = 0
recur("", n, a, result)
print(result)
|
class Vertice:
def __init__(self, key, payload):
self.key = int(key)
self.right = None
self.left = None
self.pai = None
self.payload = payload
def __str__(self):
return str(self.key)+" "+str(self.payload)
class Tree:
def __init__(self):
self.raiz = None
self.count = 0
#TREE INSERT
def treeInsert(self,z):
y = None
x = self.raiz
while(x != None): #enquanto a raíz for diferente de none
y = x # none recebe a raíz
if(z.key < x.key):
x = x.left # raíz recebe a esquerda
else:
x = x.right #raiz recebe a folha da direita
z.pai = y
if(y == None): #se o pai for none,a raíz recebe o
self.raiz = z
elif(z.key < y.key):
y.left = z
else:
y.right = z
self.count += 1
#TREE SEARCH
def iterative_tree_search(self, key):
if(self.raiz == None):
return None
vertice = self.raiz
while(vertice != None and vertice.key != int(key)):
if(int(key) < vertice.key):
vertice = vertice.left
else:
vertice = vertice.right
return vertice
#TREE IN ORDER
def inorder_tree_walk(self, vertice=None):
if(self.raiz == None):
return
if(vertice == None):
vertice = self.raiz
if(vertice.left != None):
self.inorder_tree_walk(vertice = vertice.left)
print(vertice)
if(vertice.right != None):
self.inorder_tree_walk(vertice = vertice.right)
#TREE PRINT DECRESCENTE
def tree_decrescente(self, vertice=None):
if(self.raiz == None):
return
if(vertice == None):
vertice = self.raiz
if(vertice.right != None):
self.tree_decrescente(vertice = vertice.right)
print(vertice)
if(vertice.left != None):
self.tree_decrescente(vertice = vertice.left)
#TREE PRÉ ORDER
def preOrder_Tree(self,vertice = None):
if(self.raiz == None):
return
if(vertice == None):
vertice = self.raiz
print(vertice)
if(vertice.left != None):
self.preOrder_Tree(vertice = vertice.left)
if(vertice.right != None):
self.preOrder_Tree(vertice = vertice.right)
#TREE PÓS ORDER
def posOrder_Tree(self,vertice = None):
if(self.raiz == None):
return
if(vertice == None):
vertice = self.raiz
if(vertice.left != None):
self.posOrder_Tree(vertice = vertice.left)
print(vertice)
if(vertice.right != None):
self.posOrder_Tree(vertice = vertice.right)
#TREE PREDECESSOR
def tree_predecessor(self,vertice):
if(vertice.left != None):
return self.tree_maximum(vertice=vertice.left)
#TREE MINIMUM RECURSIVO
def tree_minimum_recursivo(self, vertice = None):
if(self.raiz == None):
return None
if(vertice == None):
vertice = self.raiz
while(vertice.left != None):
vertice = vertice.left
return vertice
#TREE MAXIMUM
def tree_maximum(self, vertice = None):
if(self.raiz == None): #arvore vazia
return None
if(vertice == None):
vertice = self.raiz
while(vertice.right != None):
vertice = vertice.right
return vertice
#TREE SUCESSOR
def tree_sucessor(self,vertice):
if(vertice.right != None):
return self.tree_minimum_recursivo(vertice = vertice.right)
y = vertice.pai
while(y != None and vertice == y.right):
vertice = y
y = vertice.pai
return y
#TREE TRANSPLANT
def tree_transplant(self, u, v):
if(u.pai == None):
self.raiz = v
elif(u.pai.left == u):
u.pai.left = v
else:
u.pai.right = v
if(v != None):
v.pai = u.pai
#TREE REMOVE
def tree_Remove(self,z):
if(z.left == None):
self.tree_transplant(z,z.right)
elif(z.right == None):
self.tree_transplant(z,z.left)
else:
y = self.tree_maximum(z.right)
if(y.pai != z):
self.tree_transplant(y,y.right)
y.right = z.right
y.right.pai = y
self.tree_transplant(z,y)
y.left = z.left
y.left.pai = y
#### fim da classe ####
def menu():
print("---> Aluna: Alessandra Avelino - TSI (P2) <---")
print("---------> Árvore Binária de Busca <----------")
print("Escolha a opção desejada:")
print("0 - Sair do programa")
print("1 - Insert")
print("2 - Remove")
print("3 - Search")
print("4 - In Order")
print("5 - Pre Order")
print("6 - Pos Order")
print("7 - Tree Mínimo")
print("8 - Tree Máximo")
print("9 - Decrescente")
return int(input())
def adicionaVertice(arvore):
print('Informe o par "key payload"')
texto = input()
key, payload = texto.split()
vertice = Vertice(key, payload)
arvore.treeInsert(vertice)
def removeVertice(arvore):
print("Informe a chave de busca ", end="")
chave = int(input())
vertice = arvore.iterative_tree_search(chave)
if(vertice == None):
print("Vértice de chave ", chave, "não existe")
else:
arvore.tree_Remove(vertice)
print("Vértice removida")
def buscaVertice(arvore):
print("Qual chave você deseja localizar? ", end="")
chave = int(input())
vertice = arvore.iterative_tree_search(chave)
if(vertice == None):
print("Chave não localizada!")
else:
arvore.iterative_tree_search(chave)
print("Chave", chave, "localizada!")
def main():
arvore = Tree()
opcao = menu()
while(opcao != 0):
if (opcao == 1):
adicionaVertice(arvore)
elif(opcao == 2):
removeVertice(arvore)
elif(opcao == 3):
buscaVertice(arvore)
elif(opcao == 4):
arvore.inorder_tree_walk()
elif(opcao == 5):
arvore.preOrder_Tree()
elif(opcao == 6):
arvore.posOrder_Tree()
elif(opcao == 7):
print(arvore.tree_minimum_recursivo())
elif(opcao == 8):
print(arvore.tree_maximum())
elif(opcao == 9):
arvore.tree_decrescente()
else:
print("Opção inválida!")
opcao = menu()
if(__name__== "__main__"):
main() |
"""Test utils for gourde."""
def setup(gourde, args=None):
"""Setup gourde for testing."""
args = args or []
parser = gourde.get_argparser()
# Make sure we don't use sys.argv.
args = parser.parse_args(args)
# Setup everything.
gourde.setup(args)
|
#
# PySNMP MIB module DeltaUPS-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/DeltaUPS-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 18:43:21 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)
#
OctetString, ObjectIdentifier, Integer = mibBuilder.importSymbols("ASN1", "OctetString", "ObjectIdentifier", "Integer")
NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues")
SingleValueConstraint, ValueRangeConstraint, ValueSizeConstraint, ConstraintsUnion, ConstraintsIntersection = mibBuilder.importSymbols("ASN1-REFINEMENT", "SingleValueConstraint", "ValueRangeConstraint", "ValueSizeConstraint", "ConstraintsUnion", "ConstraintsIntersection")
NotificationGroup, ModuleCompliance = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance")
Gauge32, ObjectIdentity, Unsigned32, MibIdentifier, Bits, NotificationType, iso, Counter32, NotificationType, Counter64, enterprises, ModuleIdentity, IpAddress, MibScalar, MibTable, MibTableRow, MibTableColumn, TimeTicks, Integer32 = mibBuilder.importSymbols("SNMPv2-SMI", "Gauge32", "ObjectIdentity", "Unsigned32", "MibIdentifier", "Bits", "NotificationType", "iso", "Counter32", "NotificationType", "Counter64", "enterprises", "ModuleIdentity", "IpAddress", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "TimeTicks", "Integer32")
DisplayString, TextualConvention = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "TextualConvention")
delta = MibIdentifier((1, 3, 6, 1, 4, 1, 2254))
ups = MibIdentifier((1, 3, 6, 1, 4, 1, 2254, 2))
upsv4 = MibIdentifier((1, 3, 6, 1, 4, 1, 2254, 2, 4))
dupsIdent = MibIdentifier((1, 3, 6, 1, 4, 1, 2254, 2, 4, 1))
dupsControl = MibIdentifier((1, 3, 6, 1, 4, 1, 2254, 2, 4, 2))
dupsConfig = MibIdentifier((1, 3, 6, 1, 4, 1, 2254, 2, 4, 3))
dupsInput = MibIdentifier((1, 3, 6, 1, 4, 1, 2254, 2, 4, 4))
dupsOutput = MibIdentifier((1, 3, 6, 1, 4, 1, 2254, 2, 4, 5))
dupsBypass = MibIdentifier((1, 3, 6, 1, 4, 1, 2254, 2, 4, 6))
dupsBattery = MibIdentifier((1, 3, 6, 1, 4, 1, 2254, 2, 4, 7))
dupsTest = MibIdentifier((1, 3, 6, 1, 4, 1, 2254, 2, 4, 8))
dupsAlarm = MibIdentifier((1, 3, 6, 1, 4, 1, 2254, 2, 4, 9))
dupsEnvironment = MibIdentifier((1, 3, 6, 1, 4, 1, 2254, 2, 4, 10))
dupsTraps = MibIdentifier((1, 3, 6, 1, 4, 1, 2254, 2, 4, 20))
dupsIdentManufacturer = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 1, 1), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 20))).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsIdentManufacturer.setStatus('mandatory')
dupsIdentModel = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 1, 2), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 31))).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsIdentModel.setStatus('mandatory')
dupsIdentUPSSoftwareVersion = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 1, 3), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 15))).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsIdentUPSSoftwareVersion.setStatus('mandatory')
dupsIdentAgentSoftwareVersion = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 1, 4), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 15))).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsIdentAgentSoftwareVersion.setStatus('mandatory')
dupsIdentName = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 1, 5), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 63))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: dupsIdentName.setStatus('mandatory')
dupsAttachedDevices = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 1, 6), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 63))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: dupsAttachedDevices.setStatus('mandatory')
dupsRatingOutputVA = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 1, 7), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsRatingOutputVA.setStatus('mandatory')
dupsRatingOutputVoltage = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 1, 8), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsRatingOutputVoltage.setStatus('mandatory')
dupsRatingOutputFrequency = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 1, 9), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsRatingOutputFrequency.setStatus('mandatory')
dupsRatingInputVoltage = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 1, 10), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsRatingInputVoltage.setStatus('mandatory')
dupsRatingInputFrequency = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 1, 11), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsRatingInputFrequency.setStatus('mandatory')
dupsRatingBatteryVoltage = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 1, 12), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsRatingBatteryVoltage.setStatus('mandatory')
dupsLowTransferVoltUpBound = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 1, 13), Integer32()).setUnits('Volt').setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsLowTransferVoltUpBound.setStatus('mandatory')
dupsLowTransferVoltLowBound = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 1, 14), Integer32()).setUnits('Volt').setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsLowTransferVoltLowBound.setStatus('mandatory')
dupsHighTransferVoltUpBound = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 1, 15), Integer32()).setUnits('Volt').setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsHighTransferVoltUpBound.setStatus('mandatory')
dupsHighTransferVoltLowBound = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 1, 16), Integer32()).setUnits('Volt').setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsHighTransferVoltLowBound.setStatus('mandatory')
dupsLowBattTime = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 1, 17), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsLowBattTime.setStatus('mandatory')
dupsOutletRelays = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 1, 18), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsOutletRelays.setStatus('mandatory')
dupsType = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 1, 19), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5))).clone(namedValues=NamedValues(("on-line", 1), ("off-line", 2), ("line-interactive", 3), ("3phase", 4), ("splite-phase", 5)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsType.setStatus('mandatory')
dupsShutdownType = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 2, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("output", 1), ("system", 2)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: dupsShutdownType.setStatus('mandatory')
dupsAutoReboot = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 2, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("on", 1), ("off", 2)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: dupsAutoReboot.setStatus('mandatory')
dupsShutdownAction = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 2, 3), Integer32()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: dupsShutdownAction.setStatus('mandatory')
dupsRestartAction = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 2, 4), Integer32()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: dupsRestartAction.setStatus('mandatory')
dupsSetOutletRelay = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 2, 5), Integer32()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: dupsSetOutletRelay.setStatus('mandatory')
dupsRelayOffDelay = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 2, 6), Integer32()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: dupsRelayOffDelay.setStatus('mandatory')
dupsRelayOnDelay = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 2, 7), Integer32()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: dupsRelayOnDelay.setStatus('mandatory')
dupsConfigBuzzerAlarm = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 3, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("alarm", 1), ("silence", 2)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: dupsConfigBuzzerAlarm.setStatus('mandatory')
dupsConfigBuzzerState = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 3, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enable", 1), ("disable", 2)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: dupsConfigBuzzerState.setStatus('mandatory')
dupsConfigSensitivity = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 3, 3), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1, 2))).clone(namedValues=NamedValues(("normal", 0), ("reduced", 1), ("low", 2)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: dupsConfigSensitivity.setStatus('mandatory')
dupsConfigLowVoltageTransferPoint = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 3, 4), Integer32()).setUnits('Volt').setMaxAccess("readwrite")
if mibBuilder.loadTexts: dupsConfigLowVoltageTransferPoint.setStatus('mandatory')
dupsConfigHighVoltageTransferPoint = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 3, 5), Integer32()).setUnits('Volt').setMaxAccess("readwrite")
if mibBuilder.loadTexts: dupsConfigHighVoltageTransferPoint.setStatus('mandatory')
dupsConfigShutdownOSDelay = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 3, 6), Integer32()).setUnits('Second').setMaxAccess("readwrite")
if mibBuilder.loadTexts: dupsConfigShutdownOSDelay.setStatus('mandatory')
dupsConfigUPSBootDelay = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 3, 7), Integer32()).setUnits('Second').setMaxAccess("readwrite")
if mibBuilder.loadTexts: dupsConfigUPSBootDelay.setStatus('mandatory')
dupsConfigExternalBatteryPack = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 3, 8), Integer32()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: dupsConfigExternalBatteryPack.setStatus('mandatory')
dupsInputNumLines = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 4, 1), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsInputNumLines.setStatus('mandatory')
dupsInputFrequency1 = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 4, 2), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsInputFrequency1.setStatus('mandatory')
dupsInputVoltage1 = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 4, 3), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsInputVoltage1.setStatus('mandatory')
dupsInputCurrent1 = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 4, 4), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsInputCurrent1.setStatus('mandatory')
dupsInputFrequency2 = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 4, 5), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsInputFrequency2.setStatus('mandatory')
dupsInputVoltage2 = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 4, 6), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsInputVoltage2.setStatus('mandatory')
dupsInputCurrent2 = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 4, 7), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsInputCurrent2.setStatus('mandatory')
dupsInputFrequency3 = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 4, 8), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsInputFrequency3.setStatus('mandatory')
dupsInputVoltage3 = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 4, 9), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsInputVoltage3.setStatus('mandatory')
dupsInputCurrent3 = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 4, 10), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsInputCurrent3.setStatus('mandatory')
dupsOutputSource = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 5, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1, 2, 3, 4, 5, 6, 7))).clone(namedValues=NamedValues(("normal", 0), ("battery", 1), ("bypass", 2), ("reducing", 3), ("boosting", 4), ("manualBypass", 5), ("other", 6), ("none", 7)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsOutputSource.setStatus('mandatory')
dupsOutputFrequency = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 5, 2), Integer32()).setUnits('0.1 Hertz').setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsOutputFrequency.setStatus('mandatory')
dupsOutputNumLines = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 5, 3), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsOutputNumLines.setStatus('mandatory')
dupsOutputVoltage1 = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 5, 4), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsOutputVoltage1.setStatus('mandatory')
dupsOutputCurrent1 = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 5, 5), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsOutputCurrent1.setStatus('mandatory')
dupsOutputPower1 = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 5, 6), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsOutputPower1.setStatus('mandatory')
dupsOutputLoad1 = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 5, 7), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsOutputLoad1.setStatus('mandatory')
dupsOutputVoltage2 = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 5, 8), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsOutputVoltage2.setStatus('mandatory')
dupsOutputCurrent2 = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 5, 9), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsOutputCurrent2.setStatus('mandatory')
dupsOutputPower2 = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 5, 10), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsOutputPower2.setStatus('mandatory')
dupsOutputLoad2 = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 5, 11), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsOutputLoad2.setStatus('mandatory')
dupsOutputVoltage3 = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 5, 12), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsOutputVoltage3.setStatus('mandatory')
dupsOutputCurrent3 = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 5, 13), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsOutputCurrent3.setStatus('mandatory')
dupsOutputPower3 = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 5, 14), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsOutputPower3.setStatus('mandatory')
dupsOutputLoad3 = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 5, 15), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsOutputLoad3.setStatus('mandatory')
dupsBypassFrequency = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 6, 1), Integer32()).setUnits('0.1 Hertz').setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsBypassFrequency.setStatus('mandatory')
dupsBypassNumLines = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 6, 2), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsBypassNumLines.setStatus('mandatory')
dupsBypassVoltage1 = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 6, 3), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsBypassVoltage1.setStatus('mandatory')
dupsBypassCurrent1 = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 6, 4), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsBypassCurrent1.setStatus('mandatory')
dupsBypassPower1 = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 6, 5), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsBypassPower1.setStatus('mandatory')
dupsBypassVoltage2 = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 6, 6), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsBypassVoltage2.setStatus('mandatory')
dupsBypassCurrent2 = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 6, 7), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsBypassCurrent2.setStatus('mandatory')
dupsBypassPower2 = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 6, 8), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsBypassPower2.setStatus('mandatory')
dupsBypassVoltage3 = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 6, 9), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsBypassVoltage3.setStatus('mandatory')
dupsBypassCurrent3 = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 6, 10), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsBypassCurrent3.setStatus('mandatory')
dupsBypassPower3 = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 6, 11), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsBypassPower3.setStatus('mandatory')
dupsBatteryCondiction = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 7, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1, 2))).clone(namedValues=NamedValues(("good", 0), ("weak", 1), ("replace", 2)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsBatteryCondiction.setStatus('mandatory')
dupsBatteryStatus = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 7, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1, 2))).clone(namedValues=NamedValues(("ok", 0), ("low", 1), ("depleted", 2)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsBatteryStatus.setStatus('mandatory')
dupsBatteryCharge = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 7, 3), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1, 2, 3))).clone(namedValues=NamedValues(("floating", 0), ("charging", 1), ("resting", 2), ("discharging", 3)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsBatteryCharge.setStatus('mandatory')
dupsSecondsOnBattery = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 7, 4), Integer32()).setUnits('seconds').setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsSecondsOnBattery.setStatus('mandatory')
dupsBatteryEstimatedTime = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 7, 5), Integer32()).setUnits('minutes').setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsBatteryEstimatedTime.setStatus('mandatory')
dupsBatteryVoltage = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 7, 6), Integer32()).setUnits('0.1 Volt DC').setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsBatteryVoltage.setStatus('mandatory')
dupsBatteryCurrent = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 7, 7), Integer32()).setUnits('0.1 Amp DC').setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsBatteryCurrent.setStatus('mandatory')
dupsBatteryCapacity = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 7, 8), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 100))).setUnits('percent').setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsBatteryCapacity.setStatus('mandatory')
dupsTemperature = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 7, 9), Integer32()).setUnits('degrees Centigrade').setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsTemperature.setStatus('mandatory')
dupsLastReplaceDate = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 7, 10), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 8))).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsLastReplaceDate.setStatus('mandatory')
dupsNextReplaceDate = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 7, 11), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 8))).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsNextReplaceDate.setStatus('mandatory')
dupsTestType = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 8, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1, 2, 3, 4))).clone(namedValues=NamedValues(("abort", 0), ("generalTest", 1), ("batteryTest", 2), ("testFor10sec", 3), ("testUntilBattlow", 4)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: dupsTestType.setStatus('mandatory')
dupsTestResultsSummary = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 8, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1, 2, 3, 4, 5))).clone(namedValues=NamedValues(("noTestsInitiated", 0), ("donePass", 1), ("inProgress", 2), ("generalTestFail", 3), ("batteryTestFail", 4), ("deepBatteryTestFail", 5)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsTestResultsSummary.setStatus('mandatory')
dupsTestResultsDetail = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 8, 3), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 255))).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsTestResultsDetail.setStatus('mandatory')
dupsAlarmDisconnect = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 9, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("off", 0), ("on", 1)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsAlarmDisconnect.setStatus('mandatory')
dupsAlarmPowerFail = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 9, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("off", 0), ("on", 1)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsAlarmPowerFail.setStatus('mandatory')
dupsAlarmBatteryLow = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 9, 3), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("off", 0), ("on", 1)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsAlarmBatteryLow.setStatus('mandatory')
dupsAlarmLoadWarning = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 9, 4), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("off", 0), ("on", 1)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsAlarmLoadWarning.setStatus('mandatory')
dupsAlarmLoadSeverity = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 9, 5), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("off", 0), ("on", 1)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsAlarmLoadSeverity.setStatus('mandatory')
dupsAlarmLoadOnBypass = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 9, 6), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("off", 0), ("on", 1)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsAlarmLoadOnBypass.setStatus('mandatory')
dupsAlarmUPSFault = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 9, 7), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("off", 0), ("on", 1)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsAlarmUPSFault.setStatus('mandatory')
dupsAlarmBatteryGroundFault = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 9, 8), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("off", 0), ("on", 1)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsAlarmBatteryGroundFault.setStatus('mandatory')
dupsAlarmTestInProgress = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 9, 9), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("off", 0), ("on", 1)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsAlarmTestInProgress.setStatus('mandatory')
dupsAlarmBatteryTestFail = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 9, 10), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("off", 0), ("on", 1)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsAlarmBatteryTestFail.setStatus('mandatory')
dupsAlarmFuseFailure = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 9, 11), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("off", 0), ("on", 1)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsAlarmFuseFailure.setStatus('mandatory')
dupsAlarmOutputOverload = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 9, 12), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("off", 0), ("on", 1)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsAlarmOutputOverload.setStatus('mandatory')
dupsAlarmOutputOverCurrent = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 9, 13), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("off", 0), ("on", 1)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsAlarmOutputOverCurrent.setStatus('mandatory')
dupsAlarmInverterAbnormal = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 9, 14), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("off", 0), ("on", 1)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsAlarmInverterAbnormal.setStatus('mandatory')
dupsAlarmRectifierAbnormal = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 9, 15), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("off", 0), ("on", 1)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsAlarmRectifierAbnormal.setStatus('mandatory')
dupsAlarmReserveAbnormal = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 9, 16), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("off", 0), ("on", 1)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsAlarmReserveAbnormal.setStatus('mandatory')
dupsAlarmLoadOnReserve = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 9, 17), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("off", 0), ("on", 1)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsAlarmLoadOnReserve.setStatus('mandatory')
dupsAlarmOverTemperature = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 9, 18), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("off", 0), ("on", 1)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsAlarmOverTemperature.setStatus('mandatory')
dupsAlarmOutputBad = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 9, 19), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("off", 0), ("on", 1)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsAlarmOutputBad.setStatus('mandatory')
dupsAlarmBypassBad = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 9, 20), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("off", 0), ("on", 1)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsAlarmBypassBad.setStatus('mandatory')
dupsAlarmUPSOff = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 9, 21), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("off", 0), ("on", 1)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsAlarmUPSOff.setStatus('mandatory')
dupsAlarmChargerFail = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 9, 22), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("off", 0), ("on", 1)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsAlarmChargerFail.setStatus('mandatory')
dupsAlarmFanFail = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 9, 23), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("off", 0), ("on", 1)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsAlarmFanFail.setStatus('mandatory')
dupsAlarmEconomicMode = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 9, 24), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("off", 0), ("on", 1)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsAlarmEconomicMode.setStatus('mandatory')
dupsAlarmOutputOff = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 9, 25), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("off", 0), ("on", 1)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsAlarmOutputOff.setStatus('mandatory')
dupsAlarmSmartShutdown = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 9, 26), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("off", 0), ("on", 1)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsAlarmSmartShutdown.setStatus('mandatory')
dupsAlarmEmergencyPowerOff = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 9, 27), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("off", 0), ("on", 1)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsAlarmEmergencyPowerOff.setStatus('mandatory')
dupsAlarmUPSShutdown = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 9, 28), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("off", 0), ("on", 1)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsAlarmUPSShutdown.setStatus('mandatory')
dupsEnvTemperature = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 10, 1), Integer32()).setUnits('degrees Centigrade').setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsEnvTemperature.setStatus('mandatory')
dupsEnvHumidity = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 10, 2), Integer32()).setUnits('percentage').setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsEnvHumidity.setStatus('mandatory')
dupsEnvSetTemperatureLimit = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 10, 3), Integer32()).setUnits('degrees Centigrade').setMaxAccess("readwrite")
if mibBuilder.loadTexts: dupsEnvSetTemperatureLimit.setStatus('mandatory')
dupsEnvSetHumidityLimit = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 10, 4), Integer32()).setUnits('percentage').setMaxAccess("readwrite")
if mibBuilder.loadTexts: dupsEnvSetHumidityLimit.setStatus('mandatory')
dupsEnvSetEnvRelay1 = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 10, 5), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("normalOpen", 0), ("normalClose", 1)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: dupsEnvSetEnvRelay1.setStatus('mandatory')
dupsEnvSetEnvRelay2 = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 10, 6), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("normalOpen", 0), ("normalClose", 1)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: dupsEnvSetEnvRelay2.setStatus('mandatory')
dupsEnvSetEnvRelay3 = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 10, 7), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("normalOpen", 0), ("normalClose", 1)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: dupsEnvSetEnvRelay3.setStatus('mandatory')
dupsEnvSetEnvRelay4 = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 10, 8), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("normalOpen", 0), ("normalClose", 1)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: dupsEnvSetEnvRelay4.setStatus('mandatory')
dupsAlarmOverEnvTemperature = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 10, 9), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("off", 0), ("on", 1)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsAlarmOverEnvTemperature.setStatus('mandatory')
dupsAlarmOverEnvHumidity = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 10, 10), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("off", 0), ("on", 1)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsAlarmOverEnvHumidity.setStatus('mandatory')
dupsAlarmEnvRelay1 = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 10, 11), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("off", 0), ("on", 1)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsAlarmEnvRelay1.setStatus('mandatory')
dupsAlarmEnvRelay2 = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 10, 12), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("off", 0), ("on", 1)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsAlarmEnvRelay2.setStatus('mandatory')
dupsAlarmEnvRelay3 = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 10, 13), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("off", 0), ("on", 1)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsAlarmEnvRelay3.setStatus('mandatory')
dupsAlarmEnvRelay4 = MibScalar((1, 3, 6, 1, 4, 1, 2254, 2, 4, 10, 14), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("off", 0), ("on", 1)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: dupsAlarmEnvRelay4.setStatus('mandatory')
dupsCommunicationLost = NotificationType((1, 3, 6, 1, 4, 1, 2254, 2, 4, 20) + (0,1))
dupsCommunicationEstablished = NotificationType((1, 3, 6, 1, 4, 1, 2254, 2, 4, 20) + (0,2))
dupsPowerFail = NotificationType((1, 3, 6, 1, 4, 1, 2254, 2, 4, 20) + (0,3))
dupsPowerRestored = NotificationType((1, 3, 6, 1, 4, 1, 2254, 2, 4, 20) + (0,4))
dupsLowBattery = NotificationType((1, 3, 6, 1, 4, 1, 2254, 2, 4, 20) + (0,5))
dupsReturnFromLowBattery = NotificationType((1, 3, 6, 1, 4, 1, 2254, 2, 4, 20) + (0,6))
dupsLoadWarning = NotificationType((1, 3, 6, 1, 4, 1, 2254, 2, 4, 20) + (0,7))
dupsNoLongerLoadWarning = NotificationType((1, 3, 6, 1, 4, 1, 2254, 2, 4, 20) + (0,8))
dupsLoadSeverity = NotificationType((1, 3, 6, 1, 4, 1, 2254, 2, 4, 20) + (0,9))
dupsNoLongerLoadSeverity = NotificationType((1, 3, 6, 1, 4, 1, 2254, 2, 4, 20) + (0,10))
dupsLoadOnBypass = NotificationType((1, 3, 6, 1, 4, 1, 2254, 2, 4, 20) + (0,11))
dupsNoLongerLoadOnBypass = NotificationType((1, 3, 6, 1, 4, 1, 2254, 2, 4, 20) + (0,12))
dupsUPSFault = NotificationType((1, 3, 6, 1, 4, 1, 2254, 2, 4, 20) + (0,13))
dupsReturnFromUPSFault = NotificationType((1, 3, 6, 1, 4, 1, 2254, 2, 4, 20) + (0,14))
dupsBatteryGroundFault = NotificationType((1, 3, 6, 1, 4, 1, 2254, 2, 4, 20) + (0,15))
dupsNoLongerBatteryFault = NotificationType((1, 3, 6, 1, 4, 1, 2254, 2, 4, 20) + (0,16))
dupsTestInProgress = NotificationType((1, 3, 6, 1, 4, 1, 2254, 2, 4, 20) + (0,17))
dupsBatteryTestFail = NotificationType((1, 3, 6, 1, 4, 1, 2254, 2, 4, 20) + (0,18))
dupsFuseFailure = NotificationType((1, 3, 6, 1, 4, 1, 2254, 2, 4, 20) + (0,19))
dupsFuseRecovered = NotificationType((1, 3, 6, 1, 4, 1, 2254, 2, 4, 20) + (0,20))
dupsOutputOverload = NotificationType((1, 3, 6, 1, 4, 1, 2254, 2, 4, 20) + (0,21))
dupsNoLongerOverload = NotificationType((1, 3, 6, 1, 4, 1, 2254, 2, 4, 20) + (0,22))
dupsOutputOverCurrent = NotificationType((1, 3, 6, 1, 4, 1, 2254, 2, 4, 20) + (0,23))
dupsNoLongerOutputOverCurrent = NotificationType((1, 3, 6, 1, 4, 1, 2254, 2, 4, 20) + (0,24))
dupsInverterAbnormal = NotificationType((1, 3, 6, 1, 4, 1, 2254, 2, 4, 20) + (0,25))
dupsInverterRecovered = NotificationType((1, 3, 6, 1, 4, 1, 2254, 2, 4, 20) + (0,26))
dupsRectifierAbnormal = NotificationType((1, 3, 6, 1, 4, 1, 2254, 2, 4, 20) + (0,27))
dupsRectifierRecovered = NotificationType((1, 3, 6, 1, 4, 1, 2254, 2, 4, 20) + (0,28))
dupsReserveAbnormal = NotificationType((1, 3, 6, 1, 4, 1, 2254, 2, 4, 20) + (0,29))
dupsReserveRecovered = NotificationType((1, 3, 6, 1, 4, 1, 2254, 2, 4, 20) + (0,30))
dupsLoadOnReserve = NotificationType((1, 3, 6, 1, 4, 1, 2254, 2, 4, 20) + (0,31))
dupsNoLongerLoadOnReserve = NotificationType((1, 3, 6, 1, 4, 1, 2254, 2, 4, 20) + (0,32))
dupsEnvOverTemperature = NotificationType((1, 3, 6, 1, 4, 1, 2254, 2, 4, 20) + (0,33))
dupsNoLongerEnvOverTemperature = NotificationType((1, 3, 6, 1, 4, 1, 2254, 2, 4, 20) + (0,34))
dupsEnvOverHumidity = NotificationType((1, 3, 6, 1, 4, 1, 2254, 2, 4, 20) + (0,35))
dupsNoLongerEnvOverHumidity = NotificationType((1, 3, 6, 1, 4, 1, 2254, 2, 4, 20) + (0,36))
dupsEnvRelay1Alarm = NotificationType((1, 3, 6, 1, 4, 1, 2254, 2, 4, 20) + (0,37))
dupsEnvRelay1Normal = NotificationType((1, 3, 6, 1, 4, 1, 2254, 2, 4, 20) + (0,38))
dupsEnvRelay2Alarm = NotificationType((1, 3, 6, 1, 4, 1, 2254, 2, 4, 20) + (0,39))
dupsEnvRelay2Normal = NotificationType((1, 3, 6, 1, 4, 1, 2254, 2, 4, 20) + (0,40))
dupsEnvRelay3Alarm = NotificationType((1, 3, 6, 1, 4, 1, 2254, 2, 4, 20) + (0,41))
dupsEnvRelay3Normal = NotificationType((1, 3, 6, 1, 4, 1, 2254, 2, 4, 20) + (0,42))
dupsEnvRelay4Alarm = NotificationType((1, 3, 6, 1, 4, 1, 2254, 2, 4, 20) + (0,43))
dupsEnvRelay4Normal = NotificationType((1, 3, 6, 1, 4, 1, 2254, 2, 4, 20) + (0,44))
dupsSmartShutdown = NotificationType((1, 3, 6, 1, 4, 1, 2254, 2, 4, 20) + (0,45))
dupsCancelShutdown = NotificationType((1, 3, 6, 1, 4, 1, 2254, 2, 4, 20) + (0,46))
dupsTestCompleted = NotificationType((1, 3, 6, 1, 4, 1, 2254, 2, 4, 20) + (0,47))
dupsEPOON = NotificationType((1, 3, 6, 1, 4, 1, 2254, 2, 4, 20) + (0,48))
dupsEPOOFF = NotificationType((1, 3, 6, 1, 4, 1, 2254, 2, 4, 20) + (0,49))
dupsOverTemperature = NotificationType((1, 3, 6, 1, 4, 1, 2254, 2, 4, 20) + (0,50))
dupsNormalTemperature = NotificationType((1, 3, 6, 1, 4, 1, 2254, 2, 4, 20) + (0,51))
dupsBattReplace = NotificationType((1, 3, 6, 1, 4, 1, 2254, 2, 4, 20) + (0,52))
dupsReturnFromBattReplace = NotificationType((1, 3, 6, 1, 4, 1, 2254, 2, 4, 20) + (0,53))
mibBuilder.exportSymbols("DeltaUPS-MIB", dupsRatingBatteryVoltage=dupsRatingBatteryVoltage, dupsEnvHumidity=dupsEnvHumidity, dupsAlarmSmartShutdown=dupsAlarmSmartShutdown, dupsInputFrequency2=dupsInputFrequency2, dupsNoLongerOutputOverCurrent=dupsNoLongerOutputOverCurrent, dupsSetOutletRelay=dupsSetOutletRelay, dupsBatteryCondiction=dupsBatteryCondiction, dupsLoadWarning=dupsLoadWarning, dupsNoLongerLoadSeverity=dupsNoLongerLoadSeverity, dupsNoLongerEnvOverHumidity=dupsNoLongerEnvOverHumidity, dupsBattReplace=dupsBattReplace, dupsAlarmOutputBad=dupsAlarmOutputBad, delta=delta, dupsOutputOverCurrent=dupsOutputOverCurrent, dupsRatingInputVoltage=dupsRatingInputVoltage, dupsAlarmBatteryTestFail=dupsAlarmBatteryTestFail, dupsHighTransferVoltLowBound=dupsHighTransferVoltLowBound, dupsBatteryStatus=dupsBatteryStatus, dupsRatingOutputVA=dupsRatingOutputVA, dupsShutdownType=dupsShutdownType, dupsOutputOverload=dupsOutputOverload, dupsTestCompleted=dupsTestCompleted, dupsInputVoltage1=dupsInputVoltage1, dupsOutputLoad1=dupsOutputLoad1, dupsConfigSensitivity=dupsConfigSensitivity, dupsRectifierRecovered=dupsRectifierRecovered, dupsNoLongerLoadOnReserve=dupsNoLongerLoadOnReserve, dupsInputCurrent2=dupsInputCurrent2, dupsAlarmUPSFault=dupsAlarmUPSFault, dupsAlarm=dupsAlarm, dupsType=dupsType, dupsEPOON=dupsEPOON, dupsRestartAction=dupsRestartAction, dupsNoLongerEnvOverTemperature=dupsNoLongerEnvOverTemperature, dupsOutputPower3=dupsOutputPower3, dupsReturnFromLowBattery=dupsReturnFromLowBattery, dupsAlarmEmergencyPowerOff=dupsAlarmEmergencyPowerOff, dupsLowBattery=dupsLowBattery, dupsConfigBuzzerState=dupsConfigBuzzerState, dupsPowerRestored=dupsPowerRestored, dupsSmartShutdown=dupsSmartShutdown, dupsEnvSetEnvRelay4=dupsEnvSetEnvRelay4, dupsOutputFrequency=dupsOutputFrequency, dupsEnvSetEnvRelay1=dupsEnvSetEnvRelay1, dupsReserveAbnormal=dupsReserveAbnormal, dupsEnvRelay2Normal=dupsEnvRelay2Normal, dupsBypassCurrent2=dupsBypassCurrent2, dupsAlarmOutputOverCurrent=dupsAlarmOutputOverCurrent, dupsInputNumLines=dupsInputNumLines, dupsTest=dupsTest, dupsBatteryCharge=dupsBatteryCharge, dupsRelayOffDelay=dupsRelayOffDelay, dupsNormalTemperature=dupsNormalTemperature, upsv4=upsv4, ups=ups, dupsBatteryCapacity=dupsBatteryCapacity, dupsRectifierAbnormal=dupsRectifierAbnormal, dupsInputFrequency3=dupsInputFrequency3, dupsRatingOutputVoltage=dupsRatingOutputVoltage, dupsLastReplaceDate=dupsLastReplaceDate, dupsAlarmLoadOnReserve=dupsAlarmLoadOnReserve, dupsBypassVoltage3=dupsBypassVoltage3, dupsBypassPower2=dupsBypassPower2, dupsBatteryTestFail=dupsBatteryTestFail, dupsLowBattTime=dupsLowBattTime, dupsAlarmEnvRelay2=dupsAlarmEnvRelay2, dupsAlarmPowerFail=dupsAlarmPowerFail, dupsReserveRecovered=dupsReserveRecovered, dupsReturnFromBattReplace=dupsReturnFromBattReplace, dupsAlarmFuseFailure=dupsAlarmFuseFailure, dupsLoadOnReserve=dupsLoadOnReserve, dupsBypassNumLines=dupsBypassNumLines, dupsNoLongerBatteryFault=dupsNoLongerBatteryFault, dupsConfig=dupsConfig, dupsOutputNumLines=dupsOutputNumLines, dupsSecondsOnBattery=dupsSecondsOnBattery, dupsInputVoltage3=dupsInputVoltage3, dupsConfigHighVoltageTransferPoint=dupsConfigHighVoltageTransferPoint, dupsControl=dupsControl, dupsAlarmLoadOnBypass=dupsAlarmLoadOnBypass, dupsAlarmOutputOverload=dupsAlarmOutputOverload, dupsBypassFrequency=dupsBypassFrequency, dupsOutletRelays=dupsOutletRelays, dupsAlarmUPSShutdown=dupsAlarmUPSShutdown, dupsEnvTemperature=dupsEnvTemperature, dupsTemperature=dupsTemperature, dupsOutputSource=dupsOutputSource, dupsBypassPower1=dupsBypassPower1, dupsConfigLowVoltageTransferPoint=dupsConfigLowVoltageTransferPoint, dupsTestResultsDetail=dupsTestResultsDetail, dupsEnvironment=dupsEnvironment, dupsConfigExternalBatteryPack=dupsConfigExternalBatteryPack, dupsBypassVoltage1=dupsBypassVoltage1, dupsBypass=dupsBypass, dupsEnvOverHumidity=dupsEnvOverHumidity, dupsBatteryCurrent=dupsBatteryCurrent, dupsBatteryGroundFault=dupsBatteryGroundFault, dupsBypassCurrent3=dupsBypassCurrent3, dupsAlarmOverEnvHumidity=dupsAlarmOverEnvHumidity, dupsNoLongerOverload=dupsNoLongerOverload, dupsIdent=dupsIdent, dupsFuseRecovered=dupsFuseRecovered, dupsAutoReboot=dupsAutoReboot, dupsAlarmOutputOff=dupsAlarmOutputOff, dupsOutputLoad3=dupsOutputLoad3, dupsIdentName=dupsIdentName, dupsInverterRecovered=dupsInverterRecovered, dupsOutput=dupsOutput, dupsInputCurrent3=dupsInputCurrent3, dupsEnvRelay3Normal=dupsEnvRelay3Normal, dupsAlarmOverTemperature=dupsAlarmOverTemperature, dupsOutputLoad2=dupsOutputLoad2, dupsOutputCurrent2=dupsOutputCurrent2, dupsAlarmOverEnvTemperature=dupsAlarmOverEnvTemperature, dupsInputVoltage2=dupsInputVoltage2, dupsConfigShutdownOSDelay=dupsConfigShutdownOSDelay, dupsUPSFault=dupsUPSFault, dupsReturnFromUPSFault=dupsReturnFromUPSFault, dupsEnvSetEnvRelay2=dupsEnvSetEnvRelay2, dupsHighTransferVoltUpBound=dupsHighTransferVoltUpBound, dupsCancelShutdown=dupsCancelShutdown, dupsBatteryVoltage=dupsBatteryVoltage, dupsTraps=dupsTraps, dupsConfigUPSBootDelay=dupsConfigUPSBootDelay, dupsAlarmEnvRelay1=dupsAlarmEnvRelay1, dupsAlarmTestInProgress=dupsAlarmTestInProgress, dupsIdentUPSSoftwareVersion=dupsIdentUPSSoftwareVersion, dupsOutputPower1=dupsOutputPower1, dupsNoLongerLoadWarning=dupsNoLongerLoadWarning, dupsLowTransferVoltUpBound=dupsLowTransferVoltUpBound, dupsAlarmEnvRelay3=dupsAlarmEnvRelay3, dupsInputFrequency1=dupsInputFrequency1, dupsEnvRelay1Normal=dupsEnvRelay1Normal, dupsAlarmBypassBad=dupsAlarmBypassBad, dupsCommunicationLost=dupsCommunicationLost, dupsNoLongerLoadOnBypass=dupsNoLongerLoadOnBypass, dupsAlarmInverterAbnormal=dupsAlarmInverterAbnormal, dupsEnvRelay4Normal=dupsEnvRelay4Normal, dupsAlarmEconomicMode=dupsAlarmEconomicMode, dupsBatteryEstimatedTime=dupsBatteryEstimatedTime, dupsOverTemperature=dupsOverTemperature, dupsEnvSetTemperatureLimit=dupsEnvSetTemperatureLimit, dupsTestResultsSummary=dupsTestResultsSummary, dupsAlarmChargerFail=dupsAlarmChargerFail, dupsEnvRelay4Alarm=dupsEnvRelay4Alarm, dupsAlarmEnvRelay4=dupsAlarmEnvRelay4, dupsOutputCurrent1=dupsOutputCurrent1, dupsInput=dupsInput, dupsBypassPower3=dupsBypassPower3, dupsInputCurrent1=dupsInputCurrent1, dupsTestType=dupsTestType, dupsAlarmLoadSeverity=dupsAlarmLoadSeverity, dupsAlarmReserveAbnormal=dupsAlarmReserveAbnormal, dupsEnvSetHumidityLimit=dupsEnvSetHumidityLimit, dupsEnvRelay3Alarm=dupsEnvRelay3Alarm, dupsOutputCurrent3=dupsOutputCurrent3, dupsOutputVoltage3=dupsOutputVoltage3, dupsRelayOnDelay=dupsRelayOnDelay, dupsOutputVoltage2=dupsOutputVoltage2, dupsAlarmLoadWarning=dupsAlarmLoadWarning, dupsAttachedDevices=dupsAttachedDevices, dupsConfigBuzzerAlarm=dupsConfigBuzzerAlarm, dupsOutputPower2=dupsOutputPower2, dupsAlarmDisconnect=dupsAlarmDisconnect, dupsLoadOnBypass=dupsLoadOnBypass, dupsLowTransferVoltLowBound=dupsLowTransferVoltLowBound, dupsPowerFail=dupsPowerFail, dupsEnvRelay2Alarm=dupsEnvRelay2Alarm, dupsShutdownAction=dupsShutdownAction, dupsOutputVoltage1=dupsOutputVoltage1, dupsRatingOutputFrequency=dupsRatingOutputFrequency, dupsBypassVoltage2=dupsBypassVoltage2, dupsRatingInputFrequency=dupsRatingInputFrequency, dupsEPOOFF=dupsEPOOFF, dupsEnvSetEnvRelay3=dupsEnvSetEnvRelay3, dupsEnvOverTemperature=dupsEnvOverTemperature, dupsIdentManufacturer=dupsIdentManufacturer, dupsIdentAgentSoftwareVersion=dupsIdentAgentSoftwareVersion, dupsBattery=dupsBattery, dupsBypassCurrent1=dupsBypassCurrent1, dupsNextReplaceDate=dupsNextReplaceDate, dupsEnvRelay1Alarm=dupsEnvRelay1Alarm, dupsAlarmBatteryGroundFault=dupsAlarmBatteryGroundFault, dupsIdentModel=dupsIdentModel, dupsCommunicationEstablished=dupsCommunicationEstablished, dupsAlarmFanFail=dupsAlarmFanFail, dupsLoadSeverity=dupsLoadSeverity, dupsInverterAbnormal=dupsInverterAbnormal, dupsTestInProgress=dupsTestInProgress, dupsAlarmBatteryLow=dupsAlarmBatteryLow, dupsFuseFailure=dupsFuseFailure, dupsAlarmUPSOff=dupsAlarmUPSOff, dupsAlarmRectifierAbnormal=dupsAlarmRectifierAbnormal)
|
with open('trenutek.txt',"r") as datoteka:
i = 1
dat2 = open('trenutek1.txt',"w")
for vrstica in datoteka:
dat2.write(str(i) +","+ vrstica)
i += 1
dat2.close()
|
x=[1,1]
for i in range(1000):
x=x+[x[-1]+x[-2]]
#iteration 1
#x=[1,1]+[1+1]
#x=[1,1]+[2]
#x=[1,1,2]
#iteration 2
#x=[1,1,2]+[1+2]
#x=[1,1,2]+[3]
#x=[1,1,2,3]
print(x)
print(x[-1]/x[-2]) |
class Tablet :
def __init__(self,tablet_proxy):
self._tablet = tablet_proxy
def set_background(self,color):
self._tablet.setBackgroundColor(color)
def set_image(self,url):
self._tablet.showImage(url)
def load_image(self,url):
return self._table.preLoadImage(url)
|
input = """
b(1).
a(X) :- b(X).
:- p(X).
"""
output = """
b(1).
a(X) :- b(X).
:- p(X).
"""
|
'''
lab 7
'''
#3.1
i = 0
while i <=5:
if i !=3:
print(i)
i = i+1
#3.2
i = 1
result = 1
while i <=5:
print()
i = i+1
print(result)
#3.3
i = 1
result = 0
while i <=5:
result = result +i
i = i+1
print(result)
#3.4
i = 3
result = 0
while i <=8:
result = result +i
i = i+1
print(result)
#3.5
i = 4
result = 0
while i <=8:
result = result +i
i = i+1
print(result)
#3.6
num_list = [12,32,43,35]
while num_list:
num_list.remove(num_list[0])
print(num_list)
|
lpu = "LPU"
speciality = "SPECIALLITY"
token = "TOKEN"
chat_id = "CHAT_NAME" # if u re planing to send
|
"""
Super-Automation MySQL plugin-related exceptions.
Raising one of these in a test will cause the
test-state to be logged appropriately in the DB
for tests that use the Super-Automation MySQL plugin.
"""
class BlockedTest(Exception):
""" Raise this to mark a test as Blocked in the DB. """
pass
class SkipTest(Exception):
""" Raise this to mark a test as Skipped in the DB. """
pass
class DeprecatedTest(Exception):
""" Raise this to mark a test as Deprecated in the DB. """
pass
|
class Event:
""""""
PINGED = 'ping'
PONGED = 'pong'
CONNECTED = 'connected'
"""
Called when the Websocket client has successfully connected to the server.
:param user: The twitch user that connected to the server
.. code-block:: python3
@client.event(twitch.Event.CONNECTED)
async def on_connected(user):
print(f'Bot username: {user.login}')
print(f'Bot id: {user.id}')
"""
DISCONNECT = 'disconnect'
"""
Called when the Websocket client connection to the server is closed
.. code-block:: python3
@client.event(twitch.Event.DISCONNECT)
async def on_disconnected():
print('Client disconnected')
"""
SOCKET_SEND = 'socket_send'
"""
Called when the Websocket client sends a message to the server.
:param raw_msg: The raw message sent to the server
.. code-block:: python3
@client.event(twitch.Event.SOCKET_SEND)
async def socket_send(raw_msg):
print(raw_msg)
"""
SOCKET_RECEIVE = 'socket_receive'
"""
Called when the Websocket client receives a message from the server.
:param raw_msg: The raw message received from the server
.. code-block:: python3
@client.event(twitch.Event.SOCKET_RECEIVE)
async def socket_recv(raw_msg):
print(raw_msg)
"""
MESSAGE = 'message'
"""
Called when a message is sent in any of the channels your client has joined
:param message: The message received from the server :class:`Message`
.. code-block:: python3
@client.event(twitch.Event.MESSAGE)
async def message_handler(message):
print(f'[#{message.channel.name}] '
f'{message.author.login}: '
f'{message.content}')
"""
USER_JOIN_CHANNEL = 'user_join_channel'
"""
"""
USER_LEFT_CHANNEL = 'user_leave_channel'
"""
"""
LIST_USERS = 'list_users'
"""
"""
MOD_STATUS_CHANGED = 'mod_status_updated'
"""
"""
CHAT_CLEARED = 'chat_cleared'
"""
Called when either all messages in a channel are deleted
:param channel: The channel where the messages were deleted/cleared
.. code-block:: python3
@client.event(twitch.Event.CHAT_CLEARED)
async def on_clear_chat(channel):
print(f'The messages in {channel.name}s chat we're just cleared!')
"""
MESSAGE_CLEARED = 'message_cleared'
"""
"""
USER_BANNED = 'user_banned'
"""
"""
USER_PERMANENT_BANNED = 'user_permanent_banned'
"""
"""
HOST_MODE_CHANGED = 'host_mode_updated'
"""
"""
CHANNELS_REJOINED = 'channels_rejoined'
"""
"""
CHANNEL_STATE_CHANGED = 'channel_state_update'
"""
"""
USER_NOTIFICATION = 'user_noitification'
"""
"""
USER_STATE_CHANGED = 'user_updated'
"""
"""
TAG_REQUEST_ACKED = 'tag_request_acked'
"""
Called after the client has requested the tags capability and the server
successfully acknowledges/includes the behaviour.
.. code-block:: python3
@client.event(twitch.Event.TAG_REQUEST_ACKED)
async def tags_acked(message):
print(f'We have the tags capability!')
"""
MEMBERSHIP_REQUEST_ACKED = 'membership_request_acked'
"""
Called after the client has requested the membership capability and the
server successfully acknowledges/includes the behaviour.
.. code-block:: python3
@client.event(twitch.Event.MEMBERSHIP_REQUEST_ACKED)
async def membership_acked(message):
print(f'We have the membership capability!')
"""
COMMANDS_REQUEST_ACKED = 'commands_request_acked'
"""
Called after the client has requested the commands capability and the
server successfully acknowledges/includes the behaviour.
.. code-block:: python3
@client.event(twitch.Event.COMMANDS_REQUEST_ACKED)
async def commands_acked(message):
print(f'We have the commands capability!')
"""
CHAT_ROOMS_REQUEST_ACKED = 'chat_rooms_request_acked'
"""
Called after the client has requested the chat rooms capability and the
server successfully acknowledges/includes the behaviour.
.. code-block:: python3
@client.event(twitch.Event.CHAT_ROOMS_REQUEST_ACKED)
async def chat_rooms_acked(message):
print(f'We have the chat rooms capability!')
"""
GLOBAL_USERSTATE_RECEIVED = 'global_userstate_received'
"""
"""
ROOMSTATE_RECEIVED = 'roomstate_received'
"""
"""
UNKNOWN = 'unknown'
_AUTHENTICATED = '_authenticated'
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.