repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
cloud-custodian/cloud-custodian
tools/sandbox/c7n_index/c7n_index/metrics.py
index_metrics
def index_metrics( config, start, end, incremental=False, concurrency=5, accounts=None, period=3600, tag=None, index='policy-metrics', verbose=False): """index policy metrics""" logging.basicConfig(level=(verbose and logging.DEBUG or logging.INFO)) logging.getLogger('botocore').setLevel(logg...
python
def index_metrics( config, start, end, incremental=False, concurrency=5, accounts=None, period=3600, tag=None, index='policy-metrics', verbose=False): """index policy metrics""" logging.basicConfig(level=(verbose and logging.DEBUG or logging.INFO)) logging.getLogger('botocore').setLevel(logg...
[ "def", "index_metrics", "(", "config", ",", "start", ",", "end", ",", "incremental", "=", "False", ",", "concurrency", "=", "5", ",", "accounts", "=", "None", ",", "period", "=", "3600", ",", "tag", "=", "None", ",", "index", "=", "'policy-metrics'", "...
index policy metrics
[ "index", "policy", "metrics" ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/sandbox/c7n_index/c7n_index/metrics.py#L403-L477
train
cloud-custodian/cloud-custodian
c7n/filters/revisions.py
Diff.transform_revision
def transform_revision(self, revision): """make config revision look like describe output.""" config = self.manager.get_source('config') return config.load_resource(revision)
python
def transform_revision(self, revision): """make config revision look like describe output.""" config = self.manager.get_source('config') return config.load_resource(revision)
[ "def", "transform_revision", "(", "self", ",", "revision", ")", ":", "config", "=", "self", ".", "manager", ".", "get_source", "(", "'config'", ")", "return", "config", ".", "load_resource", "(", "revision", ")" ]
make config revision look like describe output.
[ "make", "config", "revision", "look", "like", "describe", "output", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/filters/revisions.py#L156-L159
train
cloud-custodian/cloud-custodian
c7n/filters/revisions.py
JsonDiff.register_resources
def register_resources(klass, registry, resource_class): """ meta model subscriber on resource registration. We watch for new resource types being registered and if they support aws config, automatically register the jsondiff filter. """ config_type = getattr(resource_class.reso...
python
def register_resources(klass, registry, resource_class): """ meta model subscriber on resource registration. We watch for new resource types being registered and if they support aws config, automatically register the jsondiff filter. """ config_type = getattr(resource_class.reso...
[ "def", "register_resources", "(", "klass", ",", "registry", ",", "resource_class", ")", ":", "config_type", "=", "getattr", "(", "resource_class", ".", "resource_type", ",", "'config_type'", ",", "None", ")", "if", "config_type", "is", "None", ":", "return", "...
meta model subscriber on resource registration. We watch for new resource types being registered and if they support aws config, automatically register the jsondiff filter.
[ "meta", "model", "subscriber", "on", "resource", "registration", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/filters/revisions.py#L186-L195
train
cloud-custodian/cloud-custodian
c7n/cli.py
_default_options
def _default_options(p, blacklist=""): """ Add basic options ot the subparser. `blacklist` is a list of options to exclude from the default set. e.g.: ['region', 'log-group'] """ provider = p.add_argument_group( "provider", "AWS account information, defaults per the aws cli") if 'regio...
python
def _default_options(p, blacklist=""): """ Add basic options ot the subparser. `blacklist` is a list of options to exclude from the default set. e.g.: ['region', 'log-group'] """ provider = p.add_argument_group( "provider", "AWS account information, defaults per the aws cli") if 'regio...
[ "def", "_default_options", "(", "p", ",", "blacklist", "=", "\"\"", ")", ":", "provider", "=", "p", ".", "add_argument_group", "(", "\"provider\"", ",", "\"AWS account information, defaults per the aws cli\"", ")", "if", "'region'", "not", "in", "blacklist", ":", ...
Add basic options ot the subparser. `blacklist` is a list of options to exclude from the default set. e.g.: ['region', 'log-group']
[ "Add", "basic", "options", "ot", "the", "subparser", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/cli.py#L44-L111
train
cloud-custodian/cloud-custodian
c7n/cli.py
_report_options
def _report_options(p): """ Add options specific to the report subcommand. """ _default_options(p, blacklist=['cache', 'log-group', 'quiet']) p.add_argument( '--days', type=float, default=1, help="Number of days of history to consider") p.add_argument( '--raw', type=argparse.File...
python
def _report_options(p): """ Add options specific to the report subcommand. """ _default_options(p, blacklist=['cache', 'log-group', 'quiet']) p.add_argument( '--days', type=float, default=1, help="Number of days of history to consider") p.add_argument( '--raw', type=argparse.File...
[ "def", "_report_options", "(", "p", ")", ":", "_default_options", "(", "p", ",", "blacklist", "=", "[", "'cache'", ",", "'log-group'", ",", "'quiet'", "]", ")", "p", ".", "add_argument", "(", "'--days'", ",", "type", "=", "float", ",", "default", "=", ...
Add options specific to the report subcommand.
[ "Add", "options", "specific", "to", "the", "report", "subcommand", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/cli.py#L114-L135
train
cloud-custodian/cloud-custodian
c7n/cli.py
_metrics_options
def _metrics_options(p): """ Add options specific to metrics subcommand. """ _default_options(p, blacklist=['log-group', 'output-dir', 'cache', 'quiet']) p.add_argument( '--start', type=date_parse, help='Start date (requires --end, overrides --days)') p.add_argument( '--end', ty...
python
def _metrics_options(p): """ Add options specific to metrics subcommand. """ _default_options(p, blacklist=['log-group', 'output-dir', 'cache', 'quiet']) p.add_argument( '--start', type=date_parse, help='Start date (requires --end, overrides --days)') p.add_argument( '--end', ty...
[ "def", "_metrics_options", "(", "p", ")", ":", "_default_options", "(", "p", ",", "blacklist", "=", "[", "'log-group'", ",", "'output-dir'", ",", "'cache'", ",", "'quiet'", "]", ")", "p", ".", "add_argument", "(", "'--start'", ",", "type", "=", "date_parse...
Add options specific to metrics subcommand.
[ "Add", "options", "specific", "to", "metrics", "subcommand", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/cli.py#L138-L150
train
cloud-custodian/cloud-custodian
c7n/cli.py
_logs_options
def _logs_options(p): """ Add options specific to logs subcommand. """ _default_options(p, blacklist=['cache', 'quiet']) # default time range is 0 to "now" (to include all log entries) p.add_argument( '--start', default='the beginning', # invalid, will result in 0 help='Start d...
python
def _logs_options(p): """ Add options specific to logs subcommand. """ _default_options(p, blacklist=['cache', 'quiet']) # default time range is 0 to "now" (to include all log entries) p.add_argument( '--start', default='the beginning', # invalid, will result in 0 help='Start d...
[ "def", "_logs_options", "(", "p", ")", ":", "_default_options", "(", "p", ",", "blacklist", "=", "[", "'cache'", ",", "'quiet'", "]", ")", "# default time range is 0 to \"now\" (to include all log entries)", "p", ".", "add_argument", "(", "'--start'", ",", "default"...
Add options specific to logs subcommand.
[ "Add", "options", "specific", "to", "logs", "subcommand", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/cli.py#L153-L167
train
cloud-custodian/cloud-custodian
c7n/cli.py
_schema_options
def _schema_options(p): """ Add options specific to schema subcommand. """ p.add_argument( 'resource', metavar='selector', nargs='?', default=None).completer = _schema_tab_completer p.add_argument( '--summary', action="store_true", help="Summarize counts of available resourc...
python
def _schema_options(p): """ Add options specific to schema subcommand. """ p.add_argument( 'resource', metavar='selector', nargs='?', default=None).completer = _schema_tab_completer p.add_argument( '--summary', action="store_true", help="Summarize counts of available resourc...
[ "def", "_schema_options", "(", "p", ")", ":", "p", ".", "add_argument", "(", "'resource'", ",", "metavar", "=", "'selector'", ",", "nargs", "=", "'?'", ",", "default", "=", "None", ")", ".", "completer", "=", "_schema_tab_completer", "p", ".", "add_argumen...
Add options specific to schema subcommand.
[ "Add", "options", "specific", "to", "schema", "subcommand", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/cli.py#L178-L190
train
cloud-custodian/cloud-custodian
c7n/resources/rdscluster.py
_rds_cluster_tags
def _rds_cluster_tags(model, dbs, session_factory, generator, retry): """Augment rds clusters with their respective tags.""" client = local_session(session_factory).client('rds') def process_tags(db): try: db['Tags'] = retry( client.list_tags_for_resource, ...
python
def _rds_cluster_tags(model, dbs, session_factory, generator, retry): """Augment rds clusters with their respective tags.""" client = local_session(session_factory).client('rds') def process_tags(db): try: db['Tags'] = retry( client.list_tags_for_resource, ...
[ "def", "_rds_cluster_tags", "(", "model", ",", "dbs", ",", "session_factory", ",", "generator", ",", "retry", ")", ":", "client", "=", "local_session", "(", "session_factory", ")", ".", "client", "(", "'rds'", ")", "def", "process_tags", "(", "db", ")", ":...
Augment rds clusters with their respective tags.
[ "Augment", "rds", "clusters", "with", "their", "respective", "tags", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/resources/rdscluster.py#L74-L88
train
cloud-custodian/cloud-custodian
c7n/resources/iam.py
CredentialReport.process_user_record
def process_user_record(cls, info): """Type convert the csv record, modifies in place.""" keys = list(info.keys()) # Value conversion for k in keys: v = info[k] if v in ('N/A', 'no_information'): info[k] = None elif v == 'false': ...
python
def process_user_record(cls, info): """Type convert the csv record, modifies in place.""" keys = list(info.keys()) # Value conversion for k in keys: v = info[k] if v in ('N/A', 'no_information'): info[k] = None elif v == 'false': ...
[ "def", "process_user_record", "(", "cls", ",", "info", ")", ":", "keys", "=", "list", "(", "info", ".", "keys", "(", ")", ")", "# Value conversion", "for", "k", "in", "keys", ":", "v", "=", "info", "[", "k", "]", "if", "v", "in", "(", "'N/A'", ",...
Type convert the csv record, modifies in place.
[ "Type", "convert", "the", "csv", "record", "modifies", "in", "place", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/resources/iam.py#L1206-L1224
train
cloud-custodian/cloud-custodian
c7n/logs_support.py
normalized_log_entries
def normalized_log_entries(raw_entries): '''Mimic the format returned by LambdaManager.logs()''' entry_start = r'([0-9:, \-]+) - .* - (\w+) - (.*)$' entry = None # process start/end here - avoid parsing log entries twice for line in raw_entries: m = re.match(entry_start, line) if m: ...
python
def normalized_log_entries(raw_entries): '''Mimic the format returned by LambdaManager.logs()''' entry_start = r'([0-9:, \-]+) - .* - (\w+) - (.*)$' entry = None # process start/end here - avoid parsing log entries twice for line in raw_entries: m = re.match(entry_start, line) if m: ...
[ "def", "normalized_log_entries", "(", "raw_entries", ")", ":", "entry_start", "=", "r'([0-9:, \\-]+) - .* - (\\w+) - (.*)$'", "entry", "=", "None", "# process start/end here - avoid parsing log entries twice", "for", "line", "in", "raw_entries", ":", "m", "=", "re", ".", ...
Mimic the format returned by LambdaManager.logs()
[ "Mimic", "the", "format", "returned", "by", "LambdaManager", ".", "logs", "()" ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/logs_support.py#L47-L73
train
cloud-custodian/cloud-custodian
c7n/logs_support.py
log_entries_in_range
def log_entries_in_range(entries, start, end): '''filter out entries before start and after end''' start = _timestamp_from_string(start) end = _timestamp_from_string(end) for entry in entries: log_timestamp = entry.get('timestamp', 0) if log_timestamp >= start and log_timestamp <= end: ...
python
def log_entries_in_range(entries, start, end): '''filter out entries before start and after end''' start = _timestamp_from_string(start) end = _timestamp_from_string(end) for entry in entries: log_timestamp = entry.get('timestamp', 0) if log_timestamp >= start and log_timestamp <= end: ...
[ "def", "log_entries_in_range", "(", "entries", ",", "start", ",", "end", ")", ":", "start", "=", "_timestamp_from_string", "(", "start", ")", "end", "=", "_timestamp_from_string", "(", "end", ")", "for", "entry", "in", "entries", ":", "log_timestamp", "=", "...
filter out entries before start and after end
[ "filter", "out", "entries", "before", "start", "and", "after", "end" ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/logs_support.py#L76-L83
train
cloud-custodian/cloud-custodian
c7n/logs_support.py
log_entries_from_group
def log_entries_from_group(session, group_name, start, end): '''Get logs for a specific log group''' logs = session.client('logs') log.info("Fetching logs from group: %s" % group_name) try: logs.describe_log_groups(logGroupNamePrefix=group_name) except ClientError as e: if e.response...
python
def log_entries_from_group(session, group_name, start, end): '''Get logs for a specific log group''' logs = session.client('logs') log.info("Fetching logs from group: %s" % group_name) try: logs.describe_log_groups(logGroupNamePrefix=group_name) except ClientError as e: if e.response...
[ "def", "log_entries_from_group", "(", "session", ",", "group_name", ",", "start", ",", "end", ")", ":", "logs", "=", "session", ".", "client", "(", "'logs'", ")", "log", ".", "info", "(", "\"Fetching logs from group: %s\"", "%", "group_name", ")", "try", ":"...
Get logs for a specific log group
[ "Get", "logs", "for", "a", "specific", "log", "group" ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/logs_support.py#L147-L178
train
cloud-custodian/cloud-custodian
tools/c7n_gcp/c7n_gcp/client.py
_create_service_api
def _create_service_api(credentials, service_name, version, developer_key=None, cache_discovery=False, http=None): """Builds and returns a cloud API service object. Args: credentials (OAuth2Credentials): Credentials that will be used to authenticate the API calls. ...
python
def _create_service_api(credentials, service_name, version, developer_key=None, cache_discovery=False, http=None): """Builds and returns a cloud API service object. Args: credentials (OAuth2Credentials): Credentials that will be used to authenticate the API calls. ...
[ "def", "_create_service_api", "(", "credentials", ",", "service_name", ",", "version", ",", "developer_key", "=", "None", ",", "cache_discovery", "=", "False", ",", "http", "=", "None", ")", ":", "# The default logging of the discovery obj is very noisy in recent versions...
Builds and returns a cloud API service object. Args: credentials (OAuth2Credentials): Credentials that will be used to authenticate the API calls. service_name (str): The name of the API. version (str): The version of the API to use. developer_key (str): The api key to u...
[ "Builds", "and", "returns", "a", "cloud", "API", "service", "object", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_gcp/c7n_gcp/client.py#L90-L125
train
cloud-custodian/cloud-custodian
tools/c7n_gcp/c7n_gcp/client.py
_build_http
def _build_http(http=None): """Construct an http client suitable for googleapiclient usage w/ user agent. """ if not http: http = httplib2.Http( timeout=HTTP_REQUEST_TIMEOUT, ca_certs=HTTPLIB_CA_BUNDLE) user_agent = 'Python-httplib2/{} (gzip), {}/{}'.format( httplib2.__versi...
python
def _build_http(http=None): """Construct an http client suitable for googleapiclient usage w/ user agent. """ if not http: http = httplib2.Http( timeout=HTTP_REQUEST_TIMEOUT, ca_certs=HTTPLIB_CA_BUNDLE) user_agent = 'Python-httplib2/{} (gzip), {}/{}'.format( httplib2.__versi...
[ "def", "_build_http", "(", "http", "=", "None", ")", ":", "if", "not", "http", ":", "http", "=", "httplib2", ".", "Http", "(", "timeout", "=", "HTTP_REQUEST_TIMEOUT", ",", "ca_certs", "=", "HTTPLIB_CA_BUNDLE", ")", "user_agent", "=", "'Python-httplib2/{} (gzip...
Construct an http client suitable for googleapiclient usage w/ user agent.
[ "Construct", "an", "http", "client", "suitable", "for", "googleapiclient", "usage", "w", "/", "user", "agent", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_gcp/c7n_gcp/client.py#L128-L139
train
cloud-custodian/cloud-custodian
tools/c7n_gcp/c7n_gcp/client.py
Session.client
def client(self, service_name, version, component, **kw): """Safely initialize a repository class to a property. Args: repository_class (class): The class to initialize. version (str): The gcp service version for the repository. Returns: object: An instance ...
python
def client(self, service_name, version, component, **kw): """Safely initialize a repository class to a property. Args: repository_class (class): The class to initialize. version (str): The gcp service version for the repository. Returns: object: An instance ...
[ "def", "client", "(", "self", ",", "service_name", ",", "version", ",", "component", ",", "*", "*", "kw", ")", ":", "service", "=", "_create_service_api", "(", "self", ".", "_credentials", ",", "service_name", ",", "version", ",", "kw", ".", "get", "(", ...
Safely initialize a repository class to a property. Args: repository_class (class): The class to initialize. version (str): The gcp service version for the repository. Returns: object: An instance of repository_class.
[ "Safely", "initialize", "a", "repository", "class", "to", "a", "property", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_gcp/c7n_gcp/client.py#L209-L233
train
cloud-custodian/cloud-custodian
tools/c7n_gcp/c7n_gcp/client.py
ServiceClient.http
def http(self): """A thread local instance of httplib2.Http. Returns: httplib2.Http: An Http instance authorized by the credentials. """ if self._use_cached_http and hasattr(self._local, 'http'): return self._local.http if self._http_replay is not None: ...
python
def http(self): """A thread local instance of httplib2.Http. Returns: httplib2.Http: An Http instance authorized by the credentials. """ if self._use_cached_http and hasattr(self._local, 'http'): return self._local.http if self._http_replay is not None: ...
[ "def", "http", "(", "self", ")", ":", "if", "self", ".", "_use_cached_http", "and", "hasattr", "(", "self", ".", "_local", ",", "'http'", ")", ":", "return", "self", ".", "_local", ".", "http", "if", "self", ".", "_http_replay", "is", "not", "None", ...
A thread local instance of httplib2.Http. Returns: httplib2.Http: An Http instance authorized by the credentials.
[ "A", "thread", "local", "instance", "of", "httplib2", ".", "Http", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_gcp/c7n_gcp/client.py#L303-L320
train
cloud-custodian/cloud-custodian
tools/c7n_gcp/c7n_gcp/client.py
ServiceClient._build_request
def _build_request(self, verb, verb_arguments): """Builds HttpRequest object. Args: verb (str): Request verb (ex. insert, update, delete). verb_arguments (dict): Arguments to be passed with the request. Returns: httplib2.HttpRequest: HttpRequest to be sent t...
python
def _build_request(self, verb, verb_arguments): """Builds HttpRequest object. Args: verb (str): Request verb (ex. insert, update, delete). verb_arguments (dict): Arguments to be passed with the request. Returns: httplib2.HttpRequest: HttpRequest to be sent t...
[ "def", "_build_request", "(", "self", ",", "verb", ",", "verb_arguments", ")", ":", "method", "=", "getattr", "(", "self", ".", "_component", ",", "verb", ")", "# Python insists that keys in **kwargs be strings (not variables).", "# Since we initially build our kwargs as a ...
Builds HttpRequest object. Args: verb (str): Request verb (ex. insert, update, delete). verb_arguments (dict): Arguments to be passed with the request. Returns: httplib2.HttpRequest: HttpRequest to be sent to the API.
[ "Builds", "HttpRequest", "object", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_gcp/c7n_gcp/client.py#L328-L345
train
cloud-custodian/cloud-custodian
tools/c7n_gcp/c7n_gcp/client.py
ServiceClient._build_next_request
def _build_next_request(self, verb, prior_request, prior_response): """Builds pagination-aware request object. More details: https://developers.google.com/api-client-library/python/guide/pagination Args: verb (str): Request verb (ex. insert, update, delete). p...
python
def _build_next_request(self, verb, prior_request, prior_response): """Builds pagination-aware request object. More details: https://developers.google.com/api-client-library/python/guide/pagination Args: verb (str): Request verb (ex. insert, update, delete). p...
[ "def", "_build_next_request", "(", "self", ",", "verb", ",", "prior_request", ",", "prior_response", ")", ":", "method", "=", "getattr", "(", "self", ".", "_component", ",", "verb", "+", "'_next'", ")", "return", "method", "(", "prior_request", ",", "prior_r...
Builds pagination-aware request object. More details: https://developers.google.com/api-client-library/python/guide/pagination Args: verb (str): Request verb (ex. insert, update, delete). prior_request (httplib2.HttpRequest): Request that may trigger p...
[ "Builds", "pagination", "-", "aware", "request", "object", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_gcp/c7n_gcp/client.py#L347-L364
train
cloud-custodian/cloud-custodian
tools/c7n_gcp/c7n_gcp/client.py
ServiceClient.execute_command
def execute_command(self, verb, verb_arguments): """Executes command (ex. add) via a dedicated http object. Async APIs may take minutes to complete. Therefore, callers are encouraged to leverage concurrent.futures (or similar) to place long running commands on a separate threads. ...
python
def execute_command(self, verb, verb_arguments): """Executes command (ex. add) via a dedicated http object. Async APIs may take minutes to complete. Therefore, callers are encouraged to leverage concurrent.futures (or similar) to place long running commands on a separate threads. ...
[ "def", "execute_command", "(", "self", ",", "verb", ",", "verb_arguments", ")", ":", "request", "=", "self", ".", "_build_request", "(", "verb", ",", "verb_arguments", ")", "return", "self", ".", "_execute", "(", "request", ")" ]
Executes command (ex. add) via a dedicated http object. Async APIs may take minutes to complete. Therefore, callers are encouraged to leverage concurrent.futures (or similar) to place long running commands on a separate threads. Args: verb (str): Method to execute on the co...
[ "Executes", "command", "(", "ex", ".", "add", ")", "via", "a", "dedicated", "http", "object", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_gcp/c7n_gcp/client.py#L377-L392
train
cloud-custodian/cloud-custodian
tools/c7n_gcp/c7n_gcp/client.py
ServiceClient.execute_paged_query
def execute_paged_query(self, verb, verb_arguments): """Executes query (ex. list) via a dedicated http object. Args: verb (str): Method to execute on the component (ex. get, list). verb_arguments (dict): key-value pairs to be passed to _BuildRequest. Yields: ...
python
def execute_paged_query(self, verb, verb_arguments): """Executes query (ex. list) via a dedicated http object. Args: verb (str): Method to execute on the component (ex. get, list). verb_arguments (dict): key-value pairs to be passed to _BuildRequest. Yields: ...
[ "def", "execute_paged_query", "(", "self", ",", "verb", ",", "verb_arguments", ")", ":", "if", "not", "self", ".", "supports_pagination", "(", "verb", "=", "verb", ")", ":", "raise", "PaginationNotSupported", "(", "'{} does not support pagination'", ")", "request"...
Executes query (ex. list) via a dedicated http object. Args: verb (str): Method to execute on the component (ex. get, list). verb_arguments (dict): key-value pairs to be passed to _BuildRequest. Yields: dict: Service Response. Raises: Pagination...
[ "Executes", "query", "(", "ex", ".", "list", ")", "via", "a", "dedicated", "http", "object", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_gcp/c7n_gcp/client.py#L394-L418
train
cloud-custodian/cloud-custodian
tools/c7n_gcp/c7n_gcp/client.py
ServiceClient.execute_search_query
def execute_search_query(self, verb, verb_arguments): """Executes query (ex. search) via a dedicated http object. Args: verb (str): Method to execute on the component (ex. search). verb_arguments (dict): key-value pairs to be passed to _BuildRequest. Yields: ...
python
def execute_search_query(self, verb, verb_arguments): """Executes query (ex. search) via a dedicated http object. Args: verb (str): Method to execute on the component (ex. search). verb_arguments (dict): key-value pairs to be passed to _BuildRequest. Yields: ...
[ "def", "execute_search_query", "(", "self", ",", "verb", ",", "verb_arguments", ")", ":", "# Implementation of search does not follow the standard API pattern.", "# Fields need to be in the body rather than sent seperately.", "next_page_token", "=", "None", "number_of_pages_processed",...
Executes query (ex. search) via a dedicated http object. Args: verb (str): Method to execute on the component (ex. search). verb_arguments (dict): key-value pairs to be passed to _BuildRequest. Yields: dict: Service Response.
[ "Executes", "query", "(", "ex", ".", "search", ")", "via", "a", "dedicated", "http", "object", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_gcp/c7n_gcp/client.py#L420-L446
train
cloud-custodian/cloud-custodian
tools/c7n_gcp/c7n_gcp/client.py
ServiceClient.execute_query
def execute_query(self, verb, verb_arguments): """Executes query (ex. get) via a dedicated http object. Args: verb (str): Method to execute on the component (ex. get, list). verb_arguments (dict): key-value pairs to be passed to _BuildRequest. Returns: dict:...
python
def execute_query(self, verb, verb_arguments): """Executes query (ex. get) via a dedicated http object. Args: verb (str): Method to execute on the component (ex. get, list). verb_arguments (dict): key-value pairs to be passed to _BuildRequest. Returns: dict:...
[ "def", "execute_query", "(", "self", ",", "verb", ",", "verb_arguments", ")", ":", "request", "=", "self", ".", "_build_request", "(", "verb", ",", "verb_arguments", ")", "return", "self", ".", "_execute", "(", "request", ")" ]
Executes query (ex. get) via a dedicated http object. Args: verb (str): Method to execute on the component (ex. get, list). verb_arguments (dict): key-value pairs to be passed to _BuildRequest. Returns: dict: Service Response.
[ "Executes", "query", "(", "ex", ".", "get", ")", "via", "a", "dedicated", "http", "object", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_gcp/c7n_gcp/client.py#L448-L459
train
cloud-custodian/cloud-custodian
tools/c7n_gcp/c7n_gcp/client.py
ServiceClient._execute
def _execute(self, request): """Run execute with retries and rate limiting. Args: request (object): The HttpRequest object to execute. Returns: dict: The response from the API. """ if self._rate_limiter: # Since the ratelimiter library only e...
python
def _execute(self, request): """Run execute with retries and rate limiting. Args: request (object): The HttpRequest object to execute. Returns: dict: The response from the API. """ if self._rate_limiter: # Since the ratelimiter library only e...
[ "def", "_execute", "(", "self", ",", "request", ")", ":", "if", "self", ".", "_rate_limiter", ":", "# Since the ratelimiter library only exposes a context manager", "# interface the code has to be duplicated to handle the case where", "# no rate limiter is defined.", "with", "self"...
Run execute with retries and rate limiting. Args: request (object): The HttpRequest object to execute. Returns: dict: The response from the API.
[ "Run", "execute", "with", "retries", "and", "rate", "limiting", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_gcp/c7n_gcp/client.py#L465-L482
train
cloud-custodian/cloud-custodian
tools/sandbox/c7n_sphere11/c7n_sphere11/db.py
LockDb.info
def info(self, account_id, resource_id, parent_id): """Check if a resource is locked. If a resource has an explicit status we use that, else we defer to the parent resource lock status. """ resource = self.record(account_id, resource_id) if resource is None and not paren...
python
def info(self, account_id, resource_id, parent_id): """Check if a resource is locked. If a resource has an explicit status we use that, else we defer to the parent resource lock status. """ resource = self.record(account_id, resource_id) if resource is None and not paren...
[ "def", "info", "(", "self", ",", "account_id", ",", "resource_id", ",", "parent_id", ")", ":", "resource", "=", "self", ".", "record", "(", "account_id", ",", "resource_id", ")", "if", "resource", "is", "None", "and", "not", "parent_id", ":", "return", "...
Check if a resource is locked. If a resource has an explicit status we use that, else we defer to the parent resource lock status.
[ "Check", "if", "a", "resource", "is", "locked", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/sandbox/c7n_sphere11/c7n_sphere11/db.py#L67-L90
train
cloud-custodian/cloud-custodian
tools/sandbox/zerodark/zerodark/floweni.py
process_eni_metrics
def process_eni_metrics( stream_eni, myips, stream, start, end, period, sample_size, resolver, sink_uri): """ENI flow stream processor that rollups, enhances, and indexes the stream by time period.""" stats = Counter() period_counters = flow_stream_stats(myips, stream, period)...
python
def process_eni_metrics( stream_eni, myips, stream, start, end, period, sample_size, resolver, sink_uri): """ENI flow stream processor that rollups, enhances, and indexes the stream by time period.""" stats = Counter() period_counters = flow_stream_stats(myips, stream, period)...
[ "def", "process_eni_metrics", "(", "stream_eni", ",", "myips", ",", "stream", ",", "start", ",", "end", ",", "period", ",", "sample_size", ",", "resolver", ",", "sink_uri", ")", ":", "stats", "=", "Counter", "(", ")", "period_counters", "=", "flow_stream_sta...
ENI flow stream processor that rollups, enhances, and indexes the stream by time period.
[ "ENI", "flow", "stream", "processor", "that", "rollups", "enhances", "and", "indexes", "the", "stream", "by", "time", "period", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/sandbox/zerodark/zerodark/floweni.py#L166-L211
train
cloud-custodian/cloud-custodian
tools/sandbox/zerodark/zerodark/floweni.py
analyze_app
def analyze_app( app, env, account_id, bucket, prefix, store_dir, resources, ipdb, ipranges, start, end, tz, sink, period, sample_count, debug): """Analyze flow log records for application and generate metrics per period""" logging.basicConfig(level=logging.INFO) ...
python
def analyze_app( app, env, account_id, bucket, prefix, store_dir, resources, ipdb, ipranges, start, end, tz, sink, period, sample_count, debug): """Analyze flow log records for application and generate metrics per period""" logging.basicConfig(level=logging.INFO) ...
[ "def", "analyze_app", "(", "app", ",", "env", ",", "account_id", ",", "bucket", ",", "prefix", ",", "store_dir", ",", "resources", ",", "ipdb", ",", "ipranges", ",", "start", ",", "end", ",", "tz", ",", "sink", ",", "period", ",", "sample_count", ",", ...
Analyze flow log records for application and generate metrics per period
[ "Analyze", "flow", "log", "records", "for", "application", "and", "generate", "metrics", "per", "period" ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/sandbox/zerodark/zerodark/floweni.py#L309-L390
train
cloud-custodian/cloud-custodian
tools/c7n_gcp/c7n_gcp/mu.py
CloudFunctionManager.list_functions
def list_functions(self, prefix=None): """List extant cloud functions.""" return self.client.execute_command( 'list', {'parent': "projects/{}/locations/{}".format( self.session.get_default_project(), self.region)} ).get('functions', [])
python
def list_functions(self, prefix=None): """List extant cloud functions.""" return self.client.execute_command( 'list', {'parent': "projects/{}/locations/{}".format( self.session.get_default_project(), self.region)} ).get('functions', [])
[ "def", "list_functions", "(", "self", ",", "prefix", "=", "None", ")", ":", "return", "self", ".", "client", ".", "execute_command", "(", "'list'", ",", "{", "'parent'", ":", "\"projects/{}/locations/{}\"", ".", "format", "(", "self", ".", "session", ".", ...
List extant cloud functions.
[ "List", "extant", "cloud", "functions", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_gcp/c7n_gcp/mu.py#L67-L74
train
cloud-custodian/cloud-custodian
tools/c7n_gcp/c7n_gcp/mu.py
CloudFunctionManager.publish
def publish(self, func): """publish the given function.""" project = self.session.get_default_project() func_name = "projects/{}/locations/{}/functions/{}".format( project, self.region, func.name) func_info = self.get(func.name) source_url = None archive = fu...
python
def publish(self, func): """publish the given function.""" project = self.session.get_default_project() func_name = "projects/{}/locations/{}/functions/{}".format( project, self.region, func.name) func_info = self.get(func.name) source_url = None archive = fu...
[ "def", "publish", "(", "self", ",", "func", ")", ":", "project", "=", "self", ".", "session", ".", "get_default_project", "(", ")", "func_name", "=", "\"projects/{}/locations/{}/functions/{}\"", ".", "format", "(", "project", ",", "self", ".", "region", ",", ...
publish the given function.
[ "publish", "the", "given", "function", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_gcp/c7n_gcp/mu.py#L90-L134
train
cloud-custodian/cloud-custodian
tools/c7n_gcp/c7n_gcp/mu.py
CloudFunctionManager.get
def get(self, func_name, qualifier=None): """Get the details on a given function.""" project = self.session.get_default_project() func_name = "projects/{}/locations/{}/functions/{}".format( project, self.region, func_name) try: return self.client.execute_query('ge...
python
def get(self, func_name, qualifier=None): """Get the details on a given function.""" project = self.session.get_default_project() func_name = "projects/{}/locations/{}/functions/{}".format( project, self.region, func_name) try: return self.client.execute_query('ge...
[ "def", "get", "(", "self", ",", "func_name", ",", "qualifier", "=", "None", ")", ":", "project", "=", "self", ".", "session", ".", "get_default_project", "(", ")", "func_name", "=", "\"projects/{}/locations/{}/functions/{}\"", ".", "format", "(", "project", ",...
Get the details on a given function.
[ "Get", "the", "details", "on", "a", "given", "function", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_gcp/c7n_gcp/mu.py#L142-L151
train
cloud-custodian/cloud-custodian
tools/c7n_gcp/c7n_gcp/mu.py
CloudFunctionManager._upload
def _upload(self, archive, region): """Upload function source and return source url """ # Generate source upload url url = self.client.execute_command( 'generateUploadUrl', {'parent': 'projects/{}/locations/{}'.format( self.session.get_default_proj...
python
def _upload(self, archive, region): """Upload function source and return source url """ # Generate source upload url url = self.client.execute_command( 'generateUploadUrl', {'parent': 'projects/{}/locations/{}'.format( self.session.get_default_proj...
[ "def", "_upload", "(", "self", ",", "archive", ",", "region", ")", ":", "# Generate source upload url", "url", "=", "self", ".", "client", ".", "execute_command", "(", "'generateUploadUrl'", ",", "{", "'parent'", ":", "'projects/{}/locations/{}'", ".", "format", ...
Upload function source and return source url
[ "Upload", "function", "source", "and", "return", "source", "url" ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_gcp/c7n_gcp/mu.py#L171-L194
train
cloud-custodian/cloud-custodian
tools/c7n_gcp/c7n_gcp/mu.py
PubSubSource.ensure_topic
def ensure_topic(self): """Verify the pub/sub topic exists. Returns the topic qualified name. """ client = self.session.client('pubsub', 'v1', 'projects.topics') topic = self.get_topic_param() try: client.execute_command('get', {'topic': topic}) excep...
python
def ensure_topic(self): """Verify the pub/sub topic exists. Returns the topic qualified name. """ client = self.session.client('pubsub', 'v1', 'projects.topics') topic = self.get_topic_param() try: client.execute_command('get', {'topic': topic}) excep...
[ "def", "ensure_topic", "(", "self", ")", ":", "client", "=", "self", ".", "session", ".", "client", "(", "'pubsub'", ",", "'v1'", ",", "'projects.topics'", ")", "topic", "=", "self", ".", "get_topic_param", "(", ")", "try", ":", "client", ".", "execute_c...
Verify the pub/sub topic exists. Returns the topic qualified name.
[ "Verify", "the", "pub", "/", "sub", "topic", "exists", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_gcp/c7n_gcp/mu.py#L416-L434
train
cloud-custodian/cloud-custodian
tools/c7n_gcp/c7n_gcp/mu.py
PubSubSource.ensure_iam
def ensure_iam(self, publisher=None): """Ensure the given identities are in the iam role bindings for the topic. """ topic = self.get_topic_param() client = self.session.client('pubsub', 'v1', 'projects.topics') policy = client.execute_command('getIamPolicy', {'resource': topic})...
python
def ensure_iam(self, publisher=None): """Ensure the given identities are in the iam role bindings for the topic. """ topic = self.get_topic_param() client = self.session.client('pubsub', 'v1', 'projects.topics') policy = client.execute_command('getIamPolicy', {'resource': topic})...
[ "def", "ensure_iam", "(", "self", ",", "publisher", "=", "None", ")", ":", "topic", "=", "self", ".", "get_topic_param", "(", ")", "client", "=", "self", ".", "session", ".", "client", "(", "'pubsub'", ",", "'v1'", ",", "'projects.topics'", ")", "policy"...
Ensure the given identities are in the iam role bindings for the topic.
[ "Ensure", "the", "given", "identities", "are", "in", "the", "iam", "role", "bindings", "for", "the", "topic", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_gcp/c7n_gcp/mu.py#L436-L457
train
cloud-custodian/cloud-custodian
tools/c7n_gcp/c7n_gcp/mu.py
LogSubscriber.get_parent
def get_parent(self, log_info): """Get the parent container for the log sink""" if self.data.get('scope', 'log') == 'log': if log_info.scope_type != 'projects': raise ValueError("Invalid log subscriber scope") parent = "%s/%s" % (log_info.scope_type, log_info.scop...
python
def get_parent(self, log_info): """Get the parent container for the log sink""" if self.data.get('scope', 'log') == 'log': if log_info.scope_type != 'projects': raise ValueError("Invalid log subscriber scope") parent = "%s/%s" % (log_info.scope_type, log_info.scop...
[ "def", "get_parent", "(", "self", ",", "log_info", ")", ":", "if", "self", ".", "data", ".", "get", "(", "'scope'", ",", "'log'", ")", "==", "'log'", ":", "if", "log_info", ".", "scope_type", "!=", "'projects'", ":", "raise", "ValueError", "(", "\"Inva...
Get the parent container for the log sink
[ "Get", "the", "parent", "container", "for", "the", "log", "sink" ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_gcp/c7n_gcp/mu.py#L612-L630
train
cloud-custodian/cloud-custodian
tools/c7n_gcp/c7n_gcp/mu.py
LogSubscriber.ensure_sink
def ensure_sink(self): """Ensure the log sink and its pub sub topic exist.""" topic_info = self.pubsub.ensure_topic() scope, sink_path, sink_info = self.get_sink(topic_info) client = self.session.client('logging', 'v2', '%s.sinks' % scope) try: sink = client.execute_c...
python
def ensure_sink(self): """Ensure the log sink and its pub sub topic exist.""" topic_info = self.pubsub.ensure_topic() scope, sink_path, sink_info = self.get_sink(topic_info) client = self.session.client('logging', 'v2', '%s.sinks' % scope) try: sink = client.execute_c...
[ "def", "ensure_sink", "(", "self", ")", ":", "topic_info", "=", "self", ".", "pubsub", ".", "ensure_topic", "(", ")", "scope", ",", "sink_path", ",", "sink_info", "=", "self", ".", "get_sink", "(", "topic_info", ")", "client", "=", "self", ".", "session"...
Ensure the log sink and its pub sub topic exist.
[ "Ensure", "the", "log", "sink", "and", "its", "pub", "sub", "topic", "exist", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_gcp/c7n_gcp/mu.py#L658-L680
train
cloud-custodian/cloud-custodian
tools/c7n_gcp/c7n_gcp/mu.py
LogSubscriber.remove
def remove(self, func): """Remove any provisioned log sink if auto created""" if not self.data['name'].startswith(self.prefix): return parent = self.get_parent(self.get_log()) _, sink_path, _ = self.get_sink() client = self.session.client( 'logging', 'v2',...
python
def remove(self, func): """Remove any provisioned log sink if auto created""" if not self.data['name'].startswith(self.prefix): return parent = self.get_parent(self.get_log()) _, sink_path, _ = self.get_sink() client = self.session.client( 'logging', 'v2',...
[ "def", "remove", "(", "self", ",", "func", ")", ":", "if", "not", "self", ".", "data", "[", "'name'", "]", ".", "startswith", "(", "self", ".", "prefix", ")", ":", "return", "parent", "=", "self", ".", "get_parent", "(", "self", ".", "get_log", "("...
Remove any provisioned log sink if auto created
[ "Remove", "any", "provisioned", "log", "sink", "if", "auto", "created" ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_gcp/c7n_gcp/mu.py#L686-L699
train
cloud-custodian/cloud-custodian
c7n/ufuncs/logsub.py
process_log_event
def process_log_event(event, context): """Format log events and relay via sns/email""" init() serialized = event['awslogs'].pop('data') data = json.loads(zlib.decompress( base64.b64decode(serialized), 16 + zlib.MAX_WBITS)) # Fetch additional logs for context (20s window) timestamps = [e...
python
def process_log_event(event, context): """Format log events and relay via sns/email""" init() serialized = event['awslogs'].pop('data') data = json.loads(zlib.decompress( base64.b64decode(serialized), 16 + zlib.MAX_WBITS)) # Fetch additional logs for context (20s window) timestamps = [e...
[ "def", "process_log_event", "(", "event", ",", "context", ")", ":", "init", "(", ")", "serialized", "=", "event", "[", "'awslogs'", "]", ".", "pop", "(", "'data'", ")", "data", "=", "json", ".", "loads", "(", "zlib", ".", "decompress", "(", "base64", ...
Format log events and relay via sns/email
[ "Format", "log", "events", "and", "relay", "via", "sns", "/", "email" ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/ufuncs/logsub.py#L46-L89
train
cloud-custodian/cloud-custodian
c7n/ufuncs/logsub.py
get_function
def get_function(session_factory, name, role, sns_topic, log_groups, subject="Lambda Error", pattern="Traceback"): """Lambda function provisioning. Self contained within the component, to allow for easier reuse. """ # Lazy import to avoid runtime dependency from c7n.mu import ( ...
python
def get_function(session_factory, name, role, sns_topic, log_groups, subject="Lambda Error", pattern="Traceback"): """Lambda function provisioning. Self contained within the component, to allow for easier reuse. """ # Lazy import to avoid runtime dependency from c7n.mu import ( ...
[ "def", "get_function", "(", "session_factory", ",", "name", ",", "role", ",", "sns_topic", ",", "log_groups", ",", "subject", "=", "\"Lambda Error\"", ",", "pattern", "=", "\"Traceback\"", ")", ":", "# Lazy import to avoid runtime dependency", "from", "c7n", ".", ...
Lambda function provisioning. Self contained within the component, to allow for easier reuse.
[ "Lambda", "function", "provisioning", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/ufuncs/logsub.py#L92-L124
train
cloud-custodian/cloud-custodian
c7n/cwe.py
CloudWatchEvents.match
def match(cls, event): """Match a given cwe event as cloudtrail with an api call That has its information filled out. """ if 'detail' not in event: return False if 'eventName' not in event['detail']: return False k = event['detail']['eventName'] ...
python
def match(cls, event): """Match a given cwe event as cloudtrail with an api call That has its information filled out. """ if 'detail' not in event: return False if 'eventName' not in event['detail']: return False k = event['detail']['eventName'] ...
[ "def", "match", "(", "cls", ",", "event", ")", ":", "if", "'detail'", "not", "in", "event", ":", "return", "False", "if", "'eventName'", "not", "in", "event", "[", "'detail'", "]", ":", "return", "False", "k", "=", "event", "[", "'detail'", "]", "[",...
Match a given cwe event as cloudtrail with an api call That has its information filled out.
[ "Match", "a", "given", "cwe", "event", "as", "cloudtrail", "with", "an", "api", "call" ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/cwe.py#L96-L117
train
cloud-custodian/cloud-custodian
c7n/cwe.py
CloudWatchEvents.get_trail_ids
def get_trail_ids(cls, event, mode): """extract resources ids from a cloud trail event.""" resource_ids = () event_name = event['detail']['eventName'] event_source = event['detail']['eventSource'] for e in mode.get('events', []): if not isinstance(e, dict): ...
python
def get_trail_ids(cls, event, mode): """extract resources ids from a cloud trail event.""" resource_ids = () event_name = event['detail']['eventName'] event_source = event['detail']['eventSource'] for e in mode.get('events', []): if not isinstance(e, dict): ...
[ "def", "get_trail_ids", "(", "cls", ",", "event", ",", "mode", ")", ":", "resource_ids", "=", "(", ")", "event_name", "=", "event", "[", "'detail'", "]", "[", "'eventName'", "]", "event_source", "=", "event", "[", "'detail'", "]", "[", "'eventSource'", "...
extract resources ids from a cloud trail event.
[ "extract", "resources", "ids", "from", "a", "cloud", "trail", "event", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/cwe.py#L120-L147
train
cloud-custodian/cloud-custodian
tools/c7n_org/scripts/orgaccounts.py
main
def main(role, ou, assume, profile, output, regions, active): """Generate a c7n-org accounts config file using AWS Organizations With c7n-org you can then run policies or arbitrary scripts across accounts. """ session = get_session(assume, 'c7n-org', profile) client = session.client('organizat...
python
def main(role, ou, assume, profile, output, regions, active): """Generate a c7n-org accounts config file using AWS Organizations With c7n-org you can then run policies or arbitrary scripts across accounts. """ session = get_session(assume, 'c7n-org', profile) client = session.client('organizat...
[ "def", "main", "(", "role", ",", "ou", ",", "assume", ",", "profile", ",", "output", ",", "regions", ",", "active", ")", ":", "session", "=", "get_session", "(", "assume", ",", "'c7n-org'", ",", "profile", ")", "client", "=", "session", ".", "client", ...
Generate a c7n-org accounts config file using AWS Organizations With c7n-org you can then run policies or arbitrary scripts across accounts.
[ "Generate", "a", "c7n", "-", "org", "accounts", "config", "file", "using", "AWS", "Organizations" ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_org/scripts/orgaccounts.py#L40-L75
train
cloud-custodian/cloud-custodian
tools/c7n_traildb/c7n_traildb/trailts.py
download
def download(config, account, day, region, output): """Download a traildb file for a given account/day/region""" with open(config) as fh: config = yaml.safe_load(fh.read()) jsonschema.validate(config, CONFIG_SCHEMA) found = None for info in config['accounts']: if info['name'] == a...
python
def download(config, account, day, region, output): """Download a traildb file for a given account/day/region""" with open(config) as fh: config = yaml.safe_load(fh.read()) jsonschema.validate(config, CONFIG_SCHEMA) found = None for info in config['accounts']: if info['name'] == a...
[ "def", "download", "(", "config", ",", "account", ",", "day", ",", "region", ",", "output", ")", ":", "with", "open", "(", "config", ")", "as", "fh", ":", "config", "=", "yaml", ".", "safe_load", "(", "fh", ".", "read", "(", ")", ")", "jsonschema",...
Download a traildb file for a given account/day/region
[ "Download", "a", "traildb", "file", "for", "a", "given", "account", "/", "day", "/", "region" ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_traildb/c7n_traildb/trailts.py#L309-L337
train
cloud-custodian/cloud-custodian
tools/c7n_traildb/c7n_traildb/trailts.py
status
def status(config): """time series lastest record time by account.""" with open(config) as fh: config = yaml.safe_load(fh.read()) jsonschema.validate(config, CONFIG_SCHEMA) last_index = get_incremental_starts(config, None) accounts = {} for (a, region), last in last_index.items(): ...
python
def status(config): """time series lastest record time by account.""" with open(config) as fh: config = yaml.safe_load(fh.read()) jsonschema.validate(config, CONFIG_SCHEMA) last_index = get_incremental_starts(config, None) accounts = {} for (a, region), last in last_index.items(): ...
[ "def", "status", "(", "config", ")", ":", "with", "open", "(", "config", ")", "as", "fh", ":", "config", "=", "yaml", ".", "safe_load", "(", "fh", ".", "read", "(", ")", ")", "jsonschema", ".", "validate", "(", "config", ",", "CONFIG_SCHEMA", ")", ...
time series lastest record time by account.
[ "time", "series", "lastest", "record", "time", "by", "account", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_traildb/c7n_traildb/trailts.py#L342-L351
train
cloud-custodian/cloud-custodian
tools/c7n_traildb/c7n_traildb/trailts.py
index
def index(config, start, end, incremental=False, concurrency=5, accounts=None, verbose=False): """index traildbs directly from s3 for multiple accounts. context: assumes a daily traildb file in s3 with key path specified by key_template in config file for each account """ with op...
python
def index(config, start, end, incremental=False, concurrency=5, accounts=None, verbose=False): """index traildbs directly from s3 for multiple accounts. context: assumes a daily traildb file in s3 with key path specified by key_template in config file for each account """ with op...
[ "def", "index", "(", "config", ",", "start", ",", "end", ",", "incremental", "=", "False", ",", "concurrency", "=", "5", ",", "accounts", "=", "None", ",", "verbose", "=", "False", ")", ":", "with", "open", "(", "config", ")", "as", "fh", ":", "con...
index traildbs directly from s3 for multiple accounts. context: assumes a daily traildb file in s3 with key path specified by key_template in config file for each account
[ "index", "traildbs", "directly", "from", "s3", "for", "multiple", "accounts", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_traildb/c7n_traildb/trailts.py#L363-L405
train
cloud-custodian/cloud-custodian
tools/c7n_traildb/c7n_traildb/trailes.py
dict_factory
def dict_factory(cursor, row): """Returns a sqlite row factory that returns a dictionary""" d = {} for idx, col in enumerate(cursor.description): d[col[0]] = row[idx] return d
python
def dict_factory(cursor, row): """Returns a sqlite row factory that returns a dictionary""" d = {} for idx, col in enumerate(cursor.description): d[col[0]] = row[idx] return d
[ "def", "dict_factory", "(", "cursor", ",", "row", ")", ":", "d", "=", "{", "}", "for", "idx", ",", "col", "in", "enumerate", "(", "cursor", ".", "description", ")", ":", "d", "[", "col", "[", "0", "]", "]", "=", "row", "[", "idx", "]", "return"...
Returns a sqlite row factory that returns a dictionary
[ "Returns", "a", "sqlite", "row", "factory", "that", "returns", "a", "dictionary" ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_traildb/c7n_traildb/trailes.py#L97-L102
train
cloud-custodian/cloud-custodian
tools/c7n_traildb/c7n_traildb/trailes.py
fetch_events
def fetch_events(cursor, config, account_name): """Generator that returns the events""" query = config['indexer'].get('query', 'select * from events where user_agent glob \'*CloudCustodian*\'') for event in cursor.execute(query): event['account'] = account_name event['_index'] = con...
python
def fetch_events(cursor, config, account_name): """Generator that returns the events""" query = config['indexer'].get('query', 'select * from events where user_agent glob \'*CloudCustodian*\'') for event in cursor.execute(query): event['account'] = account_name event['_index'] = con...
[ "def", "fetch_events", "(", "cursor", ",", "config", ",", "account_name", ")", ":", "query", "=", "config", "[", "'indexer'", "]", ".", "get", "(", "'query'", ",", "'select * from events where user_agent glob \\'*CloudCustodian*\\''", ")", "for", "event", "in", "c...
Generator that returns the events
[ "Generator", "that", "returns", "the", "events" ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_traildb/c7n_traildb/trailes.py#L105-L114
train
cloud-custodian/cloud-custodian
tools/c7n_traildb/c7n_traildb/trailes.py
valid_date
def valid_date(key, config_date): """ traildb bucket folders are not zero-padded so this validation checks that the keys returned by the paginator are *really after* the config date """ key_date = "/".join(key.split("/")[4:7]) return parse_date(key_date) > parse_date(config_date)
python
def valid_date(key, config_date): """ traildb bucket folders are not zero-padded so this validation checks that the keys returned by the paginator are *really after* the config date """ key_date = "/".join(key.split("/")[4:7]) return parse_date(key_date) > parse_date(config_date)
[ "def", "valid_date", "(", "key", ",", "config_date", ")", ":", "key_date", "=", "\"/\"", ".", "join", "(", "key", ".", "split", "(", "\"/\"", ")", "[", "4", ":", "7", "]", ")", "return", "parse_date", "(", "key_date", ")", ">", "parse_date", "(", "...
traildb bucket folders are not zero-padded so this validation checks that the keys returned by the paginator are *really after* the config date
[ "traildb", "bucket", "folders", "are", "not", "zero", "-", "padded", "so", "this", "validation", "checks", "that", "the", "keys", "returned", "by", "the", "paginator", "are", "*", "really", "after", "*", "the", "config", "date" ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_traildb/c7n_traildb/trailes.py#L132-L138
train
cloud-custodian/cloud-custodian
tools/c7n_traildb/c7n_traildb/trailes.py
index
def index( config, date=None, directory=None, concurrency=5, accounts=None, tag=None, verbose=False): """index traildbs directly from s3 for multiple accounts. context: assumes a daily traildb file in s3 with dated key path """ logging.basicConfig(level=(verbose and logging.DEBUG or lo...
python
def index( config, date=None, directory=None, concurrency=5, accounts=None, tag=None, verbose=False): """index traildbs directly from s3 for multiple accounts. context: assumes a daily traildb file in s3 with dated key path """ logging.basicConfig(level=(verbose and logging.DEBUG or lo...
[ "def", "index", "(", "config", ",", "date", "=", "None", ",", "directory", "=", "None", ",", "concurrency", "=", "5", ",", "accounts", "=", "None", ",", "tag", "=", "None", ",", "verbose", "=", "False", ")", ":", "logging", ".", "basicConfig", "(", ...
index traildbs directly from s3 for multiple accounts. context: assumes a daily traildb file in s3 with dated key path
[ "index", "traildbs", "directly", "from", "s3", "for", "multiple", "accounts", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_traildb/c7n_traildb/trailes.py#L214-L268
train
cloud-custodian/cloud-custodian
tools/c7n_azure/c7n_azure/session.py
Session._initialize_session
def _initialize_session(self): """ Creates a session using available authentication type. Auth priority: 1. Token Auth 2. Tenant Auth 3. Azure CLI Auth """ # Only run once if self.credentials is not None: return tenant_auth_...
python
def _initialize_session(self): """ Creates a session using available authentication type. Auth priority: 1. Token Auth 2. Tenant Auth 3. Azure CLI Auth """ # Only run once if self.credentials is not None: return tenant_auth_...
[ "def", "_initialize_session", "(", "self", ")", ":", "# Only run once", "if", "self", ".", "credentials", "is", "not", "None", ":", "return", "tenant_auth_variables", "=", "[", "constants", ".", "ENV_TENANT_ID", ",", "constants", ".", "ENV_SUB_ID", ",", "constan...
Creates a session using available authentication type. Auth priority: 1. Token Auth 2. Tenant Auth 3. Azure CLI Auth
[ "Creates", "a", "session", "using", "available", "authentication", "type", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_azure/c7n_azure/session.py#L58-L139
train
cloud-custodian/cloud-custodian
tools/c7n_azure/c7n_azure/session.py
Session.resource_api_version
def resource_api_version(self, resource_id): """ latest non-preview api version for resource """ namespace = ResourceIdParser.get_namespace(resource_id) resource_type = ResourceIdParser.get_resource_type(resource_id) cache_id = namespace + resource_type if cache_id in self._pr...
python
def resource_api_version(self, resource_id): """ latest non-preview api version for resource """ namespace = ResourceIdParser.get_namespace(resource_id) resource_type = ResourceIdParser.get_resource_type(resource_id) cache_id = namespace + resource_type if cache_id in self._pr...
[ "def", "resource_api_version", "(", "self", ",", "resource_id", ")", ":", "namespace", "=", "ResourceIdParser", ".", "get_namespace", "(", "resource_id", ")", "resource_type", "=", "ResourceIdParser", ".", "get_resource_type", "(", "resource_id", ")", "cache_id", "=...
latest non-preview api version for resource
[ "latest", "non", "-", "preview", "api", "version", "for", "resource" ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_azure/c7n_azure/session.py#L188-L209
train
cloud-custodian/cloud-custodian
tools/c7n_azure/c7n_azure/session.py
Session.get_functions_auth_string
def get_functions_auth_string(self, target_subscription_id): """ Build auth json string for deploying Azure Functions. Look for dedicated Functions environment variables or fall back to normal Service Principal variables. """ self._initialize_session() ...
python
def get_functions_auth_string(self, target_subscription_id): """ Build auth json string for deploying Azure Functions. Look for dedicated Functions environment variables or fall back to normal Service Principal variables. """ self._initialize_session() ...
[ "def", "get_functions_auth_string", "(", "self", ",", "target_subscription_id", ")", ":", "self", ".", "_initialize_session", "(", ")", "function_auth_variables", "=", "[", "constants", ".", "ENV_FUNCTION_TENANT_ID", ",", "constants", ".", "ENV_FUNCTION_CLIENT_ID", ",",...
Build auth json string for deploying Azure Functions. Look for dedicated Functions environment variables or fall back to normal Service Principal variables.
[ "Build", "auth", "json", "string", "for", "deploying", "Azure", "Functions", ".", "Look", "for", "dedicated", "Functions", "environment", "variables", "or", "fall", "back", "to", "normal", "Service", "Principal", "variables", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_azure/c7n_azure/session.py#L236-L282
train
cloud-custodian/cloud-custodian
c7n/query.py
ResourceQuery.filter
def filter(self, resource_manager, **params): """Query a set of resources.""" m = self.resolve(resource_manager.resource_type) client = local_session(self.session_factory).client( m.service, resource_manager.config.region) enum_op, path, extra_args = m.enum_spec if ex...
python
def filter(self, resource_manager, **params): """Query a set of resources.""" m = self.resolve(resource_manager.resource_type) client = local_session(self.session_factory).client( m.service, resource_manager.config.region) enum_op, path, extra_args = m.enum_spec if ex...
[ "def", "filter", "(", "self", ",", "resource_manager", ",", "*", "*", "params", ")", ":", "m", "=", "self", ".", "resolve", "(", "resource_manager", ".", "resource_type", ")", "client", "=", "local_session", "(", "self", ".", "session_factory", ")", ".", ...
Query a set of resources.
[ "Query", "a", "set", "of", "resources", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/query.py#L80-L90
train
cloud-custodian/cloud-custodian
c7n/query.py
ResourceQuery.get
def get(self, resource_manager, identities): """Get resources by identities """ m = self.resolve(resource_manager.resource_type) params = {} client_filter = False # Try to formulate server side query if m.filter_name: if m.filter_type == 'list': ...
python
def get(self, resource_manager, identities): """Get resources by identities """ m = self.resolve(resource_manager.resource_type) params = {} client_filter = False # Try to formulate server side query if m.filter_name: if m.filter_type == 'list': ...
[ "def", "get", "(", "self", ",", "resource_manager", ",", "identities", ")", ":", "m", "=", "self", ".", "resolve", "(", "resource_manager", ".", "resource_type", ")", "params", "=", "{", "}", "client_filter", "=", "False", "# Try to formulate server side query",...
Get resources by identities
[ "Get", "resources", "by", "identities" ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/query.py#L92-L118
train
cloud-custodian/cloud-custodian
c7n/query.py
ChildResourceQuery.filter
def filter(self, resource_manager, **params): """Query a set of resources.""" m = self.resolve(resource_manager.resource_type) client = local_session(self.session_factory).client(m.service) enum_op, path, extra_args = m.enum_spec if extra_args: params.update(extra_ar...
python
def filter(self, resource_manager, **params): """Query a set of resources.""" m = self.resolve(resource_manager.resource_type) client = local_session(self.session_factory).client(m.service) enum_op, path, extra_args = m.enum_spec if extra_args: params.update(extra_ar...
[ "def", "filter", "(", "self", ",", "resource_manager", ",", "*", "*", "params", ")", ":", "m", "=", "self", ".", "resolve", "(", "resource_manager", ".", "resource_type", ")", "client", "=", "local_session", "(", "self", ".", "session_factory", ")", ".", ...
Query a set of resources.
[ "Query", "a", "set", "of", "resources", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/query.py#L136-L171
train
cloud-custodian/cloud-custodian
tools/sandbox/c7n_sphere11/c7n_sphere11/wsgigw.py
create_gw_response
def create_gw_response(app, wsgi_env): """Create an api gw response from a wsgi app and environ. """ response = {} buf = [] result = [] def start_response(status, headers, exc_info=None): result[:] = [status, headers] return buf.append appr = app(wsgi_env, start_response) ...
python
def create_gw_response(app, wsgi_env): """Create an api gw response from a wsgi app and environ. """ response = {} buf = [] result = [] def start_response(status, headers, exc_info=None): result[:] = [status, headers] return buf.append appr = app(wsgi_env, start_response) ...
[ "def", "create_gw_response", "(", "app", ",", "wsgi_env", ")", ":", "response", "=", "{", "}", "buf", "=", "[", "]", "result", "=", "[", "]", "def", "start_response", "(", "status", ",", "headers", ",", "exc_info", "=", "None", ")", ":", "result", "[...
Create an api gw response from a wsgi app and environ.
[ "Create", "an", "api", "gw", "response", "from", "a", "wsgi", "app", "and", "environ", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/sandbox/c7n_sphere11/c7n_sphere11/wsgigw.py#L25-L53
train
cloud-custodian/cloud-custodian
tools/sandbox/c7n_sphere11/c7n_sphere11/wsgigw.py
create_wsgi_request
def create_wsgi_request(event, server_name='apigw'): """Create a wsgi environment from an apigw request. """ path = urllib.url2pathname(event['path']) script_name = ( event['headers']['Host'].endswith('.amazonaws.com') and event['requestContext']['stage'] or '').encode('utf8') query ...
python
def create_wsgi_request(event, server_name='apigw'): """Create a wsgi environment from an apigw request. """ path = urllib.url2pathname(event['path']) script_name = ( event['headers']['Host'].endswith('.amazonaws.com') and event['requestContext']['stage'] or '').encode('utf8') query ...
[ "def", "create_wsgi_request", "(", "event", ",", "server_name", "=", "'apigw'", ")", ":", "path", "=", "urllib", ".", "url2pathname", "(", "event", "[", "'path'", "]", ")", "script_name", "=", "(", "event", "[", "'headers'", "]", "[", "'Host'", "]", ".",...
Create a wsgi environment from an apigw request.
[ "Create", "a", "wsgi", "environment", "from", "an", "apigw", "request", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/sandbox/c7n_sphere11/c7n_sphere11/wsgigw.py#L56-L118
train
aws/chalice
chalice/logs.py
LogRetriever.create_from_lambda_arn
def create_from_lambda_arn(cls, client, lambda_arn): # type: (TypedAWSClient, str) -> LogRetriever """Create a LogRetriever from a client and lambda arn. :type client: botocore.client.Logs :param client: A ``logs`` client. :type lambda_arn: str :param lambda_arn: The AR...
python
def create_from_lambda_arn(cls, client, lambda_arn): # type: (TypedAWSClient, str) -> LogRetriever """Create a LogRetriever from a client and lambda arn. :type client: botocore.client.Logs :param client: A ``logs`` client. :type lambda_arn: str :param lambda_arn: The AR...
[ "def", "create_from_lambda_arn", "(", "cls", ",", "client", ",", "lambda_arn", ")", ":", "# type: (TypedAWSClient, str) -> LogRetriever", "lambda_name", "=", "lambda_arn", ".", "split", "(", "':'", ")", "[", "6", "]", "log_group_name", "=", "'/aws/lambda/%s'", "%", ...
Create a LogRetriever from a client and lambda arn. :type client: botocore.client.Logs :param client: A ``logs`` client. :type lambda_arn: str :param lambda_arn: The ARN of the lambda function. :return: An instance of ``LogRetriever``.
[ "Create", "a", "LogRetriever", "from", "a", "client", "and", "lambda", "arn", "." ]
10d7fb52e68bd1c52aae251c97e3939fc0190412
https://github.com/aws/chalice/blob/10d7fb52e68bd1c52aae251c97e3939fc0190412/chalice/logs.py#L33-L48
train
aws/chalice
chalice/logs.py
LogRetriever.retrieve_logs
def retrieve_logs(self, include_lambda_messages=True, max_entries=None): # type: (bool, Optional[int]) -> Iterator[Dict[str, Any]] """Retrieve logs from a log group. :type include_lambda_messages: boolean :param include_lambda_messages: Include logs generated by the AWS Lamb...
python
def retrieve_logs(self, include_lambda_messages=True, max_entries=None): # type: (bool, Optional[int]) -> Iterator[Dict[str, Any]] """Retrieve logs from a log group. :type include_lambda_messages: boolean :param include_lambda_messages: Include logs generated by the AWS Lamb...
[ "def", "retrieve_logs", "(", "self", ",", "include_lambda_messages", "=", "True", ",", "max_entries", "=", "None", ")", ":", "# type: (bool, Optional[int]) -> Iterator[Dict[str, Any]]", "# TODO: Add support for startTime/endTime.", "shown", "=", "0", "for", "event", "in", ...
Retrieve logs from a log group. :type include_lambda_messages: boolean :param include_lambda_messages: Include logs generated by the AWS Lambda service. If this value is False, only chalice logs will be included. :type max_entries: int :param max_entries: Maxim...
[ "Retrieve", "logs", "from", "a", "log", "group", "." ]
10d7fb52e68bd1c52aae251c97e3939fc0190412
https://github.com/aws/chalice/blob/10d7fb52e68bd1c52aae251c97e3939fc0190412/chalice/logs.py#L67-L109
train
aws/chalice
chalice/deploy/validate.py
validate_configuration
def validate_configuration(config): # type: (Config) -> None """Validate app configuration. The purpose of this method is to provide a fail fast mechanism for anything we know is going to fail deployment. We can detect common error cases and provide the user with helpful error messages. ""...
python
def validate_configuration(config): # type: (Config) -> None """Validate app configuration. The purpose of this method is to provide a fail fast mechanism for anything we know is going to fail deployment. We can detect common error cases and provide the user with helpful error messages. ""...
[ "def", "validate_configuration", "(", "config", ")", ":", "# type: (Config) -> None", "routes", "=", "config", ".", "chalice_app", ".", "routes", "validate_routes", "(", "routes", ")", "validate_route_content_types", "(", "routes", ",", "config", ".", "chalice_app", ...
Validate app configuration. The purpose of this method is to provide a fail fast mechanism for anything we know is going to fail deployment. We can detect common error cases and provide the user with helpful error messages.
[ "Validate", "app", "configuration", "." ]
10d7fb52e68bd1c52aae251c97e3939fc0190412
https://github.com/aws/chalice/blob/10d7fb52e68bd1c52aae251c97e3939fc0190412/chalice/deploy/validate.py#L28-L44
train
aws/chalice
chalice/deploy/validate.py
validate_python_version
def validate_python_version(config, actual_py_version=None): # type: (Config, Optional[str]) -> None """Validate configuration matches a specific python version. If the ``actual_py_version`` is not provided, it will default to the major/minor version of the currently running python interpreter. ...
python
def validate_python_version(config, actual_py_version=None): # type: (Config, Optional[str]) -> None """Validate configuration matches a specific python version. If the ``actual_py_version`` is not provided, it will default to the major/minor version of the currently running python interpreter. ...
[ "def", "validate_python_version", "(", "config", ",", "actual_py_version", "=", "None", ")", ":", "# type: (Config, Optional[str]) -> None", "lambda_version", "=", "config", ".", "lambda_python_version", "if", "actual_py_version", "is", "None", ":", "actual_py_version", "...
Validate configuration matches a specific python version. If the ``actual_py_version`` is not provided, it will default to the major/minor version of the currently running python interpreter. :param actual_py_version: The major/minor python version in the form "pythonX.Y", e.g "python2.7", "py...
[ "Validate", "configuration", "matches", "a", "specific", "python", "version", "." ]
10d7fb52e68bd1c52aae251c97e3939fc0190412
https://github.com/aws/chalice/blob/10d7fb52e68bd1c52aae251c97e3939fc0190412/chalice/deploy/validate.py#L74-L97
train
aws/chalice
chalice/deploy/packager.py
PipRunner._execute
def _execute(self, command, # type: str args, # type: List[str] env_vars=None, # type: EnvVars shim=None # type: OptStr ): # type: (...) -> Tuple[int, bytes, bytes] """Execute a pip command with ...
python
def _execute(self, command, # type: str args, # type: List[str] env_vars=None, # type: EnvVars shim=None # type: OptStr ): # type: (...) -> Tuple[int, bytes, bytes] """Execute a pip command with ...
[ "def", "_execute", "(", "self", ",", "command", ",", "# type: str", "args", ",", "# type: List[str]", "env_vars", "=", "None", ",", "# type: EnvVars", "shim", "=", "None", "# type: OptStr", ")", ":", "# type: (...) -> Tuple[int, bytes, bytes]", "main_args", "=", "["...
Execute a pip command with the given arguments.
[ "Execute", "a", "pip", "command", "with", "the", "given", "arguments", "." ]
10d7fb52e68bd1c52aae251c97e3939fc0190412
https://github.com/aws/chalice/blob/10d7fb52e68bd1c52aae251c97e3939fc0190412/chalice/deploy/packager.py#L696-L708
train
aws/chalice
chalice/deploy/packager.py
PipRunner.build_wheel
def build_wheel(self, wheel, directory, compile_c=True): # type: (str, str, bool) -> None """Build an sdist into a wheel file.""" arguments = ['--no-deps', '--wheel-dir', directory, wheel] env_vars = self._osutils.environ() shim = '' if not compile_c: env_vars...
python
def build_wheel(self, wheel, directory, compile_c=True): # type: (str, str, bool) -> None """Build an sdist into a wheel file.""" arguments = ['--no-deps', '--wheel-dir', directory, wheel] env_vars = self._osutils.environ() shim = '' if not compile_c: env_vars...
[ "def", "build_wheel", "(", "self", ",", "wheel", ",", "directory", ",", "compile_c", "=", "True", ")", ":", "# type: (str, str, bool) -> None", "arguments", "=", "[", "'--no-deps'", ",", "'--wheel-dir'", ",", "directory", ",", "wheel", "]", "env_vars", "=", "s...
Build an sdist into a wheel file.
[ "Build", "an", "sdist", "into", "a", "wheel", "file", "." ]
10d7fb52e68bd1c52aae251c97e3939fc0190412
https://github.com/aws/chalice/blob/10d7fb52e68bd1c52aae251c97e3939fc0190412/chalice/deploy/packager.py#L710-L723
train
aws/chalice
chalice/deploy/packager.py
PipRunner.download_all_dependencies
def download_all_dependencies(self, requirements_filename, directory): # type: (str, str) -> None """Download all dependencies as sdist or wheel.""" arguments = ['-r', requirements_filename, '--dest', directory] rc, out, err = self._execute('download', arguments) # When downloadi...
python
def download_all_dependencies(self, requirements_filename, directory): # type: (str, str) -> None """Download all dependencies as sdist or wheel.""" arguments = ['-r', requirements_filename, '--dest', directory] rc, out, err = self._execute('download', arguments) # When downloadi...
[ "def", "download_all_dependencies", "(", "self", ",", "requirements_filename", ",", "directory", ")", ":", "# type: (str, str) -> None", "arguments", "=", "[", "'-r'", ",", "requirements_filename", ",", "'--dest'", ",", "directory", "]", "rc", ",", "out", ",", "er...
Download all dependencies as sdist or wheel.
[ "Download", "all", "dependencies", "as", "sdist", "or", "wheel", "." ]
10d7fb52e68bd1c52aae251c97e3939fc0190412
https://github.com/aws/chalice/blob/10d7fb52e68bd1c52aae251c97e3939fc0190412/chalice/deploy/packager.py#L725-L758
train
aws/chalice
chalice/deploy/packager.py
PipRunner.download_manylinux_wheels
def download_manylinux_wheels(self, abi, packages, directory): # type: (str, List[str], str) -> None """Download wheel files for manylinux for all the given packages.""" # If any one of these dependencies fails pip will bail out. Since we # are only interested in all the ones we can down...
python
def download_manylinux_wheels(self, abi, packages, directory): # type: (str, List[str], str) -> None """Download wheel files for manylinux for all the given packages.""" # If any one of these dependencies fails pip will bail out. Since we # are only interested in all the ones we can down...
[ "def", "download_manylinux_wheels", "(", "self", ",", "abi", ",", "packages", ",", "directory", ")", ":", "# type: (str, List[str], str) -> None", "# If any one of these dependencies fails pip will bail out. Since we", "# are only interested in all the ones we can download, we need to fe...
Download wheel files for manylinux for all the given packages.
[ "Download", "wheel", "files", "for", "manylinux", "for", "all", "the", "given", "packages", "." ]
10d7fb52e68bd1c52aae251c97e3939fc0190412
https://github.com/aws/chalice/blob/10d7fb52e68bd1c52aae251c97e3939fc0190412/chalice/deploy/packager.py#L760-L775
train
aws/chalice
chalice/utils.py
to_cfn_resource_name
def to_cfn_resource_name(name): # type: (str) -> str """Transform a name to a valid cfn name. This will convert the provided name to a CamelCase name. It's possible that the conversion to a CFN resource name can result in name collisions. It's up to the caller to handle name collisions appropr...
python
def to_cfn_resource_name(name): # type: (str) -> str """Transform a name to a valid cfn name. This will convert the provided name to a CamelCase name. It's possible that the conversion to a CFN resource name can result in name collisions. It's up to the caller to handle name collisions appropr...
[ "def", "to_cfn_resource_name", "(", "name", ")", ":", "# type: (str) -> str", "if", "not", "name", ":", "raise", "ValueError", "(", "\"Invalid name: %r\"", "%", "name", ")", "word_separators", "=", "[", "'-'", ",", "'_'", "]", "for", "word_separator", "in", "w...
Transform a name to a valid cfn name. This will convert the provided name to a CamelCase name. It's possible that the conversion to a CFN resource name can result in name collisions. It's up to the caller to handle name collisions appropriately.
[ "Transform", "a", "name", "to", "a", "valid", "cfn", "name", "." ]
10d7fb52e68bd1c52aae251c97e3939fc0190412
https://github.com/aws/chalice/blob/10d7fb52e68bd1c52aae251c97e3939fc0190412/chalice/utils.py#L30-L46
train
aws/chalice
chalice/utils.py
remove_stage_from_deployed_values
def remove_stage_from_deployed_values(key, filename): # type: (str, str) -> None """Delete a top level key from the deployed JSON file.""" final_values = {} # type: Dict[str, Any] try: with open(filename, 'r') as f: final_values = json.load(f) except IOError: # If there ...
python
def remove_stage_from_deployed_values(key, filename): # type: (str, str) -> None """Delete a top level key from the deployed JSON file.""" final_values = {} # type: Dict[str, Any] try: with open(filename, 'r') as f: final_values = json.load(f) except IOError: # If there ...
[ "def", "remove_stage_from_deployed_values", "(", "key", ",", "filename", ")", ":", "# type: (str, str) -> None", "final_values", "=", "{", "}", "# type: Dict[str, Any]", "try", ":", "with", "open", "(", "filename", ",", "'r'", ")", "as", "f", ":", "final_values", ...
Delete a top level key from the deployed JSON file.
[ "Delete", "a", "top", "level", "key", "from", "the", "deployed", "JSON", "file", "." ]
10d7fb52e68bd1c52aae251c97e3939fc0190412
https://github.com/aws/chalice/blob/10d7fb52e68bd1c52aae251c97e3939fc0190412/chalice/utils.py#L49-L67
train
aws/chalice
chalice/utils.py
record_deployed_values
def record_deployed_values(deployed_values, filename): # type: (Dict[str, Any], str) -> None """Record deployed values to a JSON file. This allows subsequent deploys to lookup previously deployed values. """ final_values = {} # type: Dict[str, Any] if os.path.isfile(filename): with op...
python
def record_deployed_values(deployed_values, filename): # type: (Dict[str, Any], str) -> None """Record deployed values to a JSON file. This allows subsequent deploys to lookup previously deployed values. """ final_values = {} # type: Dict[str, Any] if os.path.isfile(filename): with op...
[ "def", "record_deployed_values", "(", "deployed_values", ",", "filename", ")", ":", "# type: (Dict[str, Any], str) -> None", "final_values", "=", "{", "}", "# type: Dict[str, Any]", "if", "os", ".", "path", ".", "isfile", "(", "filename", ")", ":", "with", "open", ...
Record deployed values to a JSON file. This allows subsequent deploys to lookup previously deployed values.
[ "Record", "deployed", "values", "to", "a", "JSON", "file", "." ]
10d7fb52e68bd1c52aae251c97e3939fc0190412
https://github.com/aws/chalice/blob/10d7fb52e68bd1c52aae251c97e3939fc0190412/chalice/utils.py#L70-L84
train
aws/chalice
chalice/utils.py
create_zip_file
def create_zip_file(source_dir, outfile): # type: (str, str) -> None """Create a zip file from a source input directory. This function is intended to be an equivalent to `zip -r`. You give it a source directory, `source_dir`, and it will recursively zip up the files into a zipfile specified by...
python
def create_zip_file(source_dir, outfile): # type: (str, str) -> None """Create a zip file from a source input directory. This function is intended to be an equivalent to `zip -r`. You give it a source directory, `source_dir`, and it will recursively zip up the files into a zipfile specified by...
[ "def", "create_zip_file", "(", "source_dir", ",", "outfile", ")", ":", "# type: (str, str) -> None", "with", "zipfile", ".", "ZipFile", "(", "outfile", ",", "'w'", ",", "compression", "=", "zipfile", ".", "ZIP_DEFLATED", ")", "as", "z", ":", "for", "root", "...
Create a zip file from a source input directory. This function is intended to be an equivalent to `zip -r`. You give it a source directory, `source_dir`, and it will recursively zip up the files into a zipfile specified by the `outfile` argument.
[ "Create", "a", "zip", "file", "from", "a", "source", "input", "directory", "." ]
10d7fb52e68bd1c52aae251c97e3939fc0190412
https://github.com/aws/chalice/blob/10d7fb52e68bd1c52aae251c97e3939fc0190412/chalice/utils.py#L99-L115
train
aws/chalice
chalice/awsclient.py
TypedAWSClient.update_function
def update_function(self, function_name, # type: str zip_contents, # type: str environment_variables=None, # type: StrMap runtime=None, # type: OptStr tags...
python
def update_function(self, function_name, # type: str zip_contents, # type: str environment_variables=None, # type: StrMap runtime=None, # type: OptStr tags...
[ "def", "update_function", "(", "self", ",", "function_name", ",", "# type: str", "zip_contents", ",", "# type: str", "environment_variables", "=", "None", ",", "# type: StrMap", "runtime", "=", "None", ",", "# type: OptStr", "tags", "=", "None", ",", "# type: StrMap...
Update a Lambda function's code and configuration. This method only updates the values provided to it. If a parameter is not provided, no changes will be made for that that parameter on the targeted lambda function.
[ "Update", "a", "Lambda", "function", "s", "code", "and", "configuration", "." ]
10d7fb52e68bd1c52aae251c97e3939fc0190412
https://github.com/aws/chalice/blob/10d7fb52e68bd1c52aae251c97e3939fc0190412/chalice/awsclient.py#L252-L287
train
aws/chalice
chalice/awsclient.py
TypedAWSClient.delete_role
def delete_role(self, name): # type: (str) -> None """Delete a role by first deleting all inline policies.""" client = self._client('iam') inline_policies = client.list_role_policies( RoleName=name )['PolicyNames'] for policy_name in inline_policies: ...
python
def delete_role(self, name): # type: (str) -> None """Delete a role by first deleting all inline policies.""" client = self._client('iam') inline_policies = client.list_role_policies( RoleName=name )['PolicyNames'] for policy_name in inline_policies: ...
[ "def", "delete_role", "(", "self", ",", "name", ")", ":", "# type: (str) -> None", "client", "=", "self", ".", "_client", "(", "'iam'", ")", "inline_policies", "=", "client", ".", "list_role_policies", "(", "RoleName", "=", "name", ")", "[", "'PolicyNames'", ...
Delete a role by first deleting all inline policies.
[ "Delete", "a", "role", "by", "first", "deleting", "all", "inline", "policies", "." ]
10d7fb52e68bd1c52aae251c97e3939fc0190412
https://github.com/aws/chalice/blob/10d7fb52e68bd1c52aae251c97e3939fc0190412/chalice/awsclient.py#L424-L433
train
aws/chalice
chalice/awsclient.py
TypedAWSClient.get_rest_api_id
def get_rest_api_id(self, name): # type: (str) -> Optional[str] """Get rest api id associated with an API name. :type name: str :param name: The name of the rest api. :rtype: str :return: If the rest api exists, then the restApiId is returned, otherwise None...
python
def get_rest_api_id(self, name): # type: (str) -> Optional[str] """Get rest api id associated with an API name. :type name: str :param name: The name of the rest api. :rtype: str :return: If the rest api exists, then the restApiId is returned, otherwise None...
[ "def", "get_rest_api_id", "(", "self", ",", "name", ")", ":", "# type: (str) -> Optional[str]", "rest_apis", "=", "self", ".", "_client", "(", "'apigateway'", ")", ".", "get_rest_apis", "(", ")", "[", "'items'", "]", "for", "api", "in", "rest_apis", ":", "if...
Get rest api id associated with an API name. :type name: str :param name: The name of the rest api. :rtype: str :return: If the rest api exists, then the restApiId is returned, otherwise None.
[ "Get", "rest", "api", "id", "associated", "with", "an", "API", "name", "." ]
10d7fb52e68bd1c52aae251c97e3939fc0190412
https://github.com/aws/chalice/blob/10d7fb52e68bd1c52aae251c97e3939fc0190412/chalice/awsclient.py#L435-L451
train
aws/chalice
chalice/awsclient.py
TypedAWSClient.rest_api_exists
def rest_api_exists(self, rest_api_id): # type: (str) -> bool """Check if an an API Gateway REST API exists.""" client = self._client('apigateway') try: client.get_rest_api(restApiId=rest_api_id) return True except client.exceptions.NotFoundException: ...
python
def rest_api_exists(self, rest_api_id): # type: (str) -> bool """Check if an an API Gateway REST API exists.""" client = self._client('apigateway') try: client.get_rest_api(restApiId=rest_api_id) return True except client.exceptions.NotFoundException: ...
[ "def", "rest_api_exists", "(", "self", ",", "rest_api_id", ")", ":", "# type: (str) -> bool", "client", "=", "self", ".", "_client", "(", "'apigateway'", ")", "try", ":", "client", ".", "get_rest_api", "(", "restApiId", "=", "rest_api_id", ")", "return", "True...
Check if an an API Gateway REST API exists.
[ "Check", "if", "an", "an", "API", "Gateway", "REST", "API", "exists", "." ]
10d7fb52e68bd1c52aae251c97e3939fc0190412
https://github.com/aws/chalice/blob/10d7fb52e68bd1c52aae251c97e3939fc0190412/chalice/awsclient.py#L453-L461
train
aws/chalice
chalice/awsclient.py
TypedAWSClient.add_permission_for_apigateway
def add_permission_for_apigateway(self, function_name, region_name, account_id, rest_api_id, random_id=None): # type: (str, str, str, str, Optional[str]) -> None """Authorize API gateway to invoke a lambda function is needed. ...
python
def add_permission_for_apigateway(self, function_name, region_name, account_id, rest_api_id, random_id=None): # type: (str, str, str, str, Optional[str]) -> None """Authorize API gateway to invoke a lambda function is needed. ...
[ "def", "add_permission_for_apigateway", "(", "self", ",", "function_name", ",", "region_name", ",", "account_id", ",", "rest_api_id", ",", "random_id", "=", "None", ")", ":", "# type: (str, str, str, str, Optional[str]) -> None", "source_arn", "=", "self", ".", "_build_...
Authorize API gateway to invoke a lambda function is needed. This method will first check if API gateway has permission to call the lambda function, and only if necessary will it invoke ``self.add_permission_for_apigateway(...).
[ "Authorize", "API", "gateway", "to", "invoke", "a", "lambda", "function", "is", "needed", "." ]
10d7fb52e68bd1c52aae251c97e3939fc0190412
https://github.com/aws/chalice/blob/10d7fb52e68bd1c52aae251c97e3939fc0190412/chalice/awsclient.py#L496-L513
train
aws/chalice
chalice/awsclient.py
TypedAWSClient.get_function_policy
def get_function_policy(self, function_name): # type: (str) -> Dict[str, Any] """Return the function policy for a lambda function. This function will extract the policy string as a json document and return the json.loads(...) version of the policy. """ client = self._cl...
python
def get_function_policy(self, function_name): # type: (str) -> Dict[str, Any] """Return the function policy for a lambda function. This function will extract the policy string as a json document and return the json.loads(...) version of the policy. """ client = self._cl...
[ "def", "get_function_policy", "(", "self", ",", "function_name", ")", ":", "# type: (str) -> Dict[str, Any]", "client", "=", "self", ".", "_client", "(", "'lambda'", ")", "try", ":", "policy", "=", "client", ".", "get_policy", "(", "FunctionName", "=", "function...
Return the function policy for a lambda function. This function will extract the policy string as a json document and return the json.loads(...) version of the policy.
[ "Return", "the", "function", "policy", "for", "a", "lambda", "function", "." ]
10d7fb52e68bd1c52aae251c97e3939fc0190412
https://github.com/aws/chalice/blob/10d7fb52e68bd1c52aae251c97e3939fc0190412/chalice/awsclient.py#L515-L528
train
aws/chalice
chalice/awsclient.py
TypedAWSClient.download_sdk
def download_sdk(self, rest_api_id, output_dir, api_gateway_stage=DEFAULT_STAGE_NAME, sdk_type='javascript'): # type: (str, str, str, str) -> None """Download an SDK to a directory. This will generate an SDK and download it to the provided ``out...
python
def download_sdk(self, rest_api_id, output_dir, api_gateway_stage=DEFAULT_STAGE_NAME, sdk_type='javascript'): # type: (str, str, str, str) -> None """Download an SDK to a directory. This will generate an SDK and download it to the provided ``out...
[ "def", "download_sdk", "(", "self", ",", "rest_api_id", ",", "output_dir", ",", "api_gateway_stage", "=", "DEFAULT_STAGE_NAME", ",", "sdk_type", "=", "'javascript'", ")", ":", "# type: (str, str, str, str) -> None", "zip_stream", "=", "self", ".", "get_sdk_download_stre...
Download an SDK to a directory. This will generate an SDK and download it to the provided ``output_dir``. If you're using ``get_sdk_download_stream()``, you have to handle downloading the stream and unzipping the contents yourself. This method handles that for you.
[ "Download", "an", "SDK", "to", "a", "directory", "." ]
10d7fb52e68bd1c52aae251c97e3939fc0190412
https://github.com/aws/chalice/blob/10d7fb52e68bd1c52aae251c97e3939fc0190412/chalice/awsclient.py#L530-L564
train
aws/chalice
chalice/awsclient.py
TypedAWSClient.get_sdk_download_stream
def get_sdk_download_stream(self, rest_api_id, api_gateway_stage=DEFAULT_STAGE_NAME, sdk_type='javascript'): # type: (str, str, str) -> file """Generate an SDK for a given SDK. Returns a file like object that streams a zip contents...
python
def get_sdk_download_stream(self, rest_api_id, api_gateway_stage=DEFAULT_STAGE_NAME, sdk_type='javascript'): # type: (str, str, str) -> file """Generate an SDK for a given SDK. Returns a file like object that streams a zip contents...
[ "def", "get_sdk_download_stream", "(", "self", ",", "rest_api_id", ",", "api_gateway_stage", "=", "DEFAULT_STAGE_NAME", ",", "sdk_type", "=", "'javascript'", ")", ":", "# type: (str, str, str) -> file", "response", "=", "self", ".", "_client", "(", "'apigateway'", ")"...
Generate an SDK for a given SDK. Returns a file like object that streams a zip contents for the generated SDK.
[ "Generate", "an", "SDK", "for", "a", "given", "SDK", "." ]
10d7fb52e68bd1c52aae251c97e3939fc0190412
https://github.com/aws/chalice/blob/10d7fb52e68bd1c52aae251c97e3939fc0190412/chalice/awsclient.py#L566-L579
train
aws/chalice
chalice/awsclient.py
TypedAWSClient.verify_sns_subscription_current
def verify_sns_subscription_current(self, subscription_arn, topic_name, function_arn): # type: (str, str, str) -> bool """Verify a subscription arn matches the topic and function name. Given a subscription arn, verify that the associated topic name ...
python
def verify_sns_subscription_current(self, subscription_arn, topic_name, function_arn): # type: (str, str, str) -> bool """Verify a subscription arn matches the topic and function name. Given a subscription arn, verify that the associated topic name ...
[ "def", "verify_sns_subscription_current", "(", "self", ",", "subscription_arn", ",", "topic_name", ",", "function_arn", ")", ":", "# type: (str, str, str) -> bool", "sns_client", "=", "self", ".", "_client", "(", "'sns'", ")", "try", ":", "attributes", "=", "sns_cli...
Verify a subscription arn matches the topic and function name. Given a subscription arn, verify that the associated topic name and function arn match up to the parameters passed in.
[ "Verify", "a", "subscription", "arn", "matches", "the", "topic", "and", "function", "name", "." ]
10d7fb52e68bd1c52aae251c97e3939fc0190412
https://github.com/aws/chalice/blob/10d7fb52e68bd1c52aae251c97e3939fc0190412/chalice/awsclient.py#L594-L614
train
aws/chalice
chalice/awsclient.py
TypedAWSClient.connect_s3_bucket_to_lambda
def connect_s3_bucket_to_lambda(self, bucket, function_arn, events, prefix=None, suffix=None): # type: (str, str, List[str], OptStr, OptStr) -> None """Configure S3 bucket to invoke a lambda function. The S3 bucket must already have permission to invoke the ...
python
def connect_s3_bucket_to_lambda(self, bucket, function_arn, events, prefix=None, suffix=None): # type: (str, str, List[str], OptStr, OptStr) -> None """Configure S3 bucket to invoke a lambda function. The S3 bucket must already have permission to invoke the ...
[ "def", "connect_s3_bucket_to_lambda", "(", "self", ",", "bucket", ",", "function_arn", ",", "events", ",", "prefix", "=", "None", ",", "suffix", "=", "None", ")", ":", "# type: (str, str, List[str], OptStr, OptStr) -> None", "s3", "=", "self", ".", "_client", "(",...
Configure S3 bucket to invoke a lambda function. The S3 bucket must already have permission to invoke the lambda function before you call this function, otherwise the service will return an error. You can add permissions by using the ``add_permission_for_s3_event`` below. The ...
[ "Configure", "S3", "bucket", "to", "invoke", "a", "lambda", "function", "." ]
10d7fb52e68bd1c52aae251c97e3939fc0190412
https://github.com/aws/chalice/blob/10d7fb52e68bd1c52aae251c97e3939fc0190412/chalice/awsclient.py#L741-L782
train
aws/chalice
chalice/awsclient.py
TypedAWSClient.verify_event_source_current
def verify_event_source_current(self, event_uuid, resource_name, service_name, function_arn): # type: (str, str, str, str) -> bool """Check if the uuid matches the resource and function arn provided. Given a uuid representing an event source mapping for a lam...
python
def verify_event_source_current(self, event_uuid, resource_name, service_name, function_arn): # type: (str, str, str, str) -> bool """Check if the uuid matches the resource and function arn provided. Given a uuid representing an event source mapping for a lam...
[ "def", "verify_event_source_current", "(", "self", ",", "event_uuid", ",", "resource_name", ",", "service_name", ",", "function_arn", ")", ":", "# type: (str, str, str, str) -> bool", "client", "=", "self", ".", "_client", "(", "'lambda'", ")", "try", ":", "attribut...
Check if the uuid matches the resource and function arn provided. Given a uuid representing an event source mapping for a lambda function, verify that the associated source arn and function arn match up to the parameters passed in. Instead of providing the event source arn, the resourc...
[ "Check", "if", "the", "uuid", "matches", "the", "resource", "and", "function", "arn", "provided", "." ]
10d7fb52e68bd1c52aae251c97e3939fc0190412
https://github.com/aws/chalice/blob/10d7fb52e68bd1c52aae251c97e3939fc0190412/chalice/awsclient.py#L951-L977
train
aws/chalice
chalice/cli/factory.py
CLIFactory.load_project_config
def load_project_config(self): # type: () -> Dict[str, Any] """Load the chalice config file from the project directory. :raise: OSError/IOError if unable to load the config file. """ config_file = os.path.join(self.project_dir, '.chalice', 'config.json') with open(confi...
python
def load_project_config(self): # type: () -> Dict[str, Any] """Load the chalice config file from the project directory. :raise: OSError/IOError if unable to load the config file. """ config_file = os.path.join(self.project_dir, '.chalice', 'config.json') with open(confi...
[ "def", "load_project_config", "(", "self", ")", ":", "# type: () -> Dict[str, Any]", "config_file", "=", "os", ".", "path", ".", "join", "(", "self", ".", "project_dir", ",", "'.chalice'", ",", "'config.json'", ")", "with", "open", "(", "config_file", ")", "as...
Load the chalice config file from the project directory. :raise: OSError/IOError if unable to load the config file.
[ "Load", "the", "chalice", "config", "file", "from", "the", "project", "directory", "." ]
10d7fb52e68bd1c52aae251c97e3939fc0190412
https://github.com/aws/chalice/blob/10d7fb52e68bd1c52aae251c97e3939fc0190412/chalice/cli/factory.py#L269-L278
train
aws/chalice
chalice/cli/__init__.py
invoke
def invoke(ctx, name, profile, stage): # type: (click.Context, str, str, str) -> None """Invoke the deployed lambda function NAME.""" factory = ctx.obj['factory'] # type: CLIFactory factory.profile = profile try: invoke_handler = factory.create_lambda_invoke_handler(name, stage) pa...
python
def invoke(ctx, name, profile, stage): # type: (click.Context, str, str, str) -> None """Invoke the deployed lambda function NAME.""" factory = ctx.obj['factory'] # type: CLIFactory factory.profile = profile try: invoke_handler = factory.create_lambda_invoke_handler(name, stage) pa...
[ "def", "invoke", "(", "ctx", ",", "name", ",", "profile", ",", "stage", ")", ":", "# type: (click.Context, str, str, str) -> None", "factory", "=", "ctx", ".", "obj", "[", "'factory'", "]", "# type: CLIFactory", "factory", ".", "profile", "=", "profile", "try", ...
Invoke the deployed lambda function NAME.
[ "Invoke", "the", "deployed", "lambda", "function", "NAME", "." ]
10d7fb52e68bd1c52aae251c97e3939fc0190412
https://github.com/aws/chalice/blob/10d7fb52e68bd1c52aae251c97e3939fc0190412/chalice/cli/__init__.py#L217-L247
train
aws/chalice
chalice/cli/__init__.py
generate_pipeline
def generate_pipeline(ctx, codebuild_image, source, buildspec_file, filename): # type: (click.Context, str, str, str, str) -> None """Generate a cloudformation template for a starter CD pipeline. This command will write a starter cloudformation template to the filename you provide. It contains a CodeC...
python
def generate_pipeline(ctx, codebuild_image, source, buildspec_file, filename): # type: (click.Context, str, str, str, str) -> None """Generate a cloudformation template for a starter CD pipeline. This command will write a starter cloudformation template to the filename you provide. It contains a CodeC...
[ "def", "generate_pipeline", "(", "ctx", ",", "codebuild_image", ",", "source", ",", "buildspec_file", ",", "filename", ")", ":", "# type: (click.Context, str, str, str, str) -> None", "from", "chalice", "import", "pipeline", "factory", "=", "ctx", ".", "obj", "[", "...
Generate a cloudformation template for a starter CD pipeline. This command will write a starter cloudformation template to the filename you provide. It contains a CodeCommit repo, a CodeBuild stage for packaging your chalice app, and a CodePipeline stage to deploy your application using cloudformation...
[ "Generate", "a", "cloudformation", "template", "for", "a", "starter", "CD", "pipeline", "." ]
10d7fb52e68bd1c52aae251c97e3939fc0190412
https://github.com/aws/chalice/blob/10d7fb52e68bd1c52aae251c97e3939fc0190412/chalice/cli/__init__.py#L419-L453
train
aws/chalice
chalice/config.py
Config.deployed_resources
def deployed_resources(self, chalice_stage_name): # type: (str) -> DeployedResources """Return resources associated with a given stage. If a deployment to a given stage has never happened, this method will return a value of None. """ # This is arguably the wrong level o...
python
def deployed_resources(self, chalice_stage_name): # type: (str) -> DeployedResources """Return resources associated with a given stage. If a deployment to a given stage has never happened, this method will return a value of None. """ # This is arguably the wrong level o...
[ "def", "deployed_resources", "(", "self", ",", "chalice_stage_name", ")", ":", "# type: (str) -> DeployedResources", "# This is arguably the wrong level of abstraction.", "# We might be able to move this elsewhere.", "deployed_file", "=", "os", ".", "path", ".", "join", "(", "s...
Return resources associated with a given stage. If a deployment to a given stage has never happened, this method will return a value of None.
[ "Return", "resources", "associated", "with", "a", "given", "stage", "." ]
10d7fb52e68bd1c52aae251c97e3939fc0190412
https://github.com/aws/chalice/blob/10d7fb52e68bd1c52aae251c97e3939fc0190412/chalice/config.py#L326-L346
train
aws/chalice
chalice/policy.py
AppPolicyGenerator.generate_policy
def generate_policy(self, config): # type: (Config) -> Dict[str, Any] """Auto generate policy for an application.""" # Admittedly, this is pretty bare bones logic for the time # being. All it really does it work out, given a Config instance, # which files need to analyzed and th...
python
def generate_policy(self, config): # type: (Config) -> Dict[str, Any] """Auto generate policy for an application.""" # Admittedly, this is pretty bare bones logic for the time # being. All it really does it work out, given a Config instance, # which files need to analyzed and th...
[ "def", "generate_policy", "(", "self", ",", "config", ")", ":", "# type: (Config) -> Dict[str, Any]", "# Admittedly, this is pretty bare bones logic for the time", "# being. All it really does it work out, given a Config instance,", "# which files need to analyzed and then delegates to the", ...
Auto generate policy for an application.
[ "Auto", "generate", "policy", "for", "an", "application", "." ]
10d7fb52e68bd1c52aae251c97e3939fc0190412
https://github.com/aws/chalice/blob/10d7fb52e68bd1c52aae251c97e3939fc0190412/chalice/policy.py#L81-L96
train
aws/chalice
chalice/analyzer.py
get_client_calls
def get_client_calls(source_code): # type: (str) -> APICallT """Return all clients calls made in provided source code. :returns: A dict of service_name -> set([client calls]). Example: {"s3": set(["list_objects", "create_bucket"]), "dynamodb": set(["describe_table"])} """ ...
python
def get_client_calls(source_code): # type: (str) -> APICallT """Return all clients calls made in provided source code. :returns: A dict of service_name -> set([client calls]). Example: {"s3": set(["list_objects", "create_bucket"]), "dynamodb": set(["describe_table"])} """ ...
[ "def", "get_client_calls", "(", "source_code", ")", ":", "# type: (str) -> APICallT", "parsed", "=", "parse_code", "(", "source_code", ")", "t", "=", "SymbolTableTypeInfer", "(", "parsed", ")", "binder", "=", "t", ".", "bind_types", "(", ")", "collector", "=", ...
Return all clients calls made in provided source code. :returns: A dict of service_name -> set([client calls]). Example: {"s3": set(["list_objects", "create_bucket"]), "dynamodb": set(["describe_table"])}
[ "Return", "all", "clients", "calls", "made", "in", "provided", "source", "code", "." ]
10d7fb52e68bd1c52aae251c97e3939fc0190412
https://github.com/aws/chalice/blob/10d7fb52e68bd1c52aae251c97e3939fc0190412/chalice/analyzer.py#L47-L60
train
aws/chalice
chalice/analyzer.py
get_client_calls_for_app
def get_client_calls_for_app(source_code): # type: (str) -> APICallT """Return client calls for a chalice app. This is similar to ``get_client_calls`` except it will automatically traverse into chalice views with the assumption that they will be called. """ parsed = parse_code(source_code)...
python
def get_client_calls_for_app(source_code): # type: (str) -> APICallT """Return client calls for a chalice app. This is similar to ``get_client_calls`` except it will automatically traverse into chalice views with the assumption that they will be called. """ parsed = parse_code(source_code)...
[ "def", "get_client_calls_for_app", "(", "source_code", ")", ":", "# type: (str) -> APICallT", "parsed", "=", "parse_code", "(", "source_code", ")", "parsed", ".", "parsed_ast", "=", "AppViewTransformer", "(", ")", ".", "visit", "(", "parsed", ".", "parsed_ast", ")...
Return client calls for a chalice app. This is similar to ``get_client_calls`` except it will automatically traverse into chalice views with the assumption that they will be called.
[ "Return", "client", "calls", "for", "a", "chalice", "app", "." ]
10d7fb52e68bd1c52aae251c97e3939fc0190412
https://github.com/aws/chalice/blob/10d7fb52e68bd1c52aae251c97e3939fc0190412/chalice/analyzer.py#L63-L79
train
aws/chalice
chalice/local.py
RouteMatcher.match_route
def match_route(self, url): # type: (str) -> MatchResult """Match the url against known routes. This method takes a concrete route "/foo/bar", and matches it against a set of routes. These routes can use param substitution corresponding to API gateway patterns. For exam...
python
def match_route(self, url): # type: (str) -> MatchResult """Match the url against known routes. This method takes a concrete route "/foo/bar", and matches it against a set of routes. These routes can use param substitution corresponding to API gateway patterns. For exam...
[ "def", "match_route", "(", "self", ",", "url", ")", ":", "# type: (str) -> MatchResult", "# Otherwise we need to check for param substitution", "parsed_url", "=", "urlparse", "(", "url", ")", "parsed_qs", "=", "parse_qs", "(", "parsed_url", ".", "query", ",", "keep_bl...
Match the url against known routes. This method takes a concrete route "/foo/bar", and matches it against a set of routes. These routes can use param substitution corresponding to API gateway patterns. For example:: match_route('/foo/bar') -> '/foo/{name}'
[ "Match", "the", "url", "against", "known", "routes", "." ]
10d7fb52e68bd1c52aae251c97e3939fc0190412
https://github.com/aws/chalice/blob/10d7fb52e68bd1c52aae251c97e3939fc0190412/chalice/local.py#L113-L147
train
aws/chalice
chalice/local.py
LocalGatewayAuthorizer._prepare_authorizer_event
def _prepare_authorizer_event(self, arn, lambda_event, lambda_context): # type: (str, EventType, LambdaContext) -> EventType """Translate event for an authorizer input.""" authorizer_event = lambda_event.copy() authorizer_event['type'] = 'TOKEN' try: authorizer_event[...
python
def _prepare_authorizer_event(self, arn, lambda_event, lambda_context): # type: (str, EventType, LambdaContext) -> EventType """Translate event for an authorizer input.""" authorizer_event = lambda_event.copy() authorizer_event['type'] = 'TOKEN' try: authorizer_event[...
[ "def", "_prepare_authorizer_event", "(", "self", ",", "arn", ",", "lambda_event", ",", "lambda_context", ")", ":", "# type: (str, EventType, LambdaContext) -> EventType", "authorizer_event", "=", "lambda_event", ".", "copy", "(", ")", "authorizer_event", "[", "'type'", ...
Translate event for an authorizer input.
[ "Translate", "event", "for", "an", "authorizer", "input", "." ]
10d7fb52e68bd1c52aae251c97e3939fc0190412
https://github.com/aws/chalice/blob/10d7fb52e68bd1c52aae251c97e3939fc0190412/chalice/local.py#L378-L392
train
jopohl/urh
src/urh/controller/GeneratorTabController.py
GeneratorTabController.bootstrap_modulator
def bootstrap_modulator(self, protocol: ProtocolAnalyzer): """ Set initial parameters for default modulator if it was not edited by user previously :return: """ if len(self.modulators) != 1 or len(self.table_model.protocol.messages) == 0: return modulator = s...
python
def bootstrap_modulator(self, protocol: ProtocolAnalyzer): """ Set initial parameters for default modulator if it was not edited by user previously :return: """ if len(self.modulators) != 1 or len(self.table_model.protocol.messages) == 0: return modulator = s...
[ "def", "bootstrap_modulator", "(", "self", ",", "protocol", ":", "ProtocolAnalyzer", ")", ":", "if", "len", "(", "self", ".", "modulators", ")", "!=", "1", "or", "len", "(", "self", ".", "table_model", ".", "protocol", ".", "messages", ")", "==", "0", ...
Set initial parameters for default modulator if it was not edited by user previously :return:
[ "Set", "initial", "parameters", "for", "default", "modulator", "if", "it", "was", "not", "edited", "by", "user", "previously", ":", "return", ":" ]
2eb33b125c8407964cd1092843cde5010eb88aae
https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/controller/GeneratorTabController.py#L206-L224
train
jopohl/urh
src/urh/controller/GeneratorTabController.py
GeneratorTabController.modulate_data
def modulate_data(self, buffer: np.ndarray) -> np.ndarray: """ :param buffer: Buffer in which the modulated data shall be written, initialized with zeros :return: """ self.ui.prBarGeneration.show() self.ui.prBarGeneration.setValue(0) self.ui.prBarGenerat...
python
def modulate_data(self, buffer: np.ndarray) -> np.ndarray: """ :param buffer: Buffer in which the modulated data shall be written, initialized with zeros :return: """ self.ui.prBarGeneration.show() self.ui.prBarGeneration.setValue(0) self.ui.prBarGenerat...
[ "def", "modulate_data", "(", "self", ",", "buffer", ":", "np", ".", "ndarray", ")", "->", "np", ".", "ndarray", ":", "self", ".", "ui", ".", "prBarGeneration", ".", "show", "(", ")", "self", ".", "ui", ".", "prBarGeneration", ".", "setValue", "(", "0...
:param buffer: Buffer in which the modulated data shall be written, initialized with zeros :return:
[ ":", "param", "buffer", ":", "Buffer", "in", "which", "the", "modulated", "data", "shall", "be", "written", "initialized", "with", "zeros", ":", "return", ":" ]
2eb33b125c8407964cd1092843cde5010eb88aae
https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/controller/GeneratorTabController.py#L413-L437
train
jopohl/urh
src/urh/controller/GeneratorTabController.py
GeneratorTabController.refresh_existing_encodings
def refresh_existing_encodings(self, encodings_from_file): """ Refresh existing encodings for messages, when encoding was changed by user in dialog :return: """ update = False for msg in self.table_model.protocol.messages: i = next((i for i, d in enumerate(e...
python
def refresh_existing_encodings(self, encodings_from_file): """ Refresh existing encodings for messages, when encoding was changed by user in dialog :return: """ update = False for msg in self.table_model.protocol.messages: i = next((i for i, d in enumerate(e...
[ "def", "refresh_existing_encodings", "(", "self", ",", "encodings_from_file", ")", ":", "update", "=", "False", "for", "msg", "in", "self", ".", "table_model", ".", "protocol", ".", "messages", ":", "i", "=", "next", "(", "(", "i", "for", "i", ",", "d", ...
Refresh existing encodings for messages, when encoding was changed by user in dialog :return:
[ "Refresh", "existing", "encodings", "for", "messages", "when", "encoding", "was", "changed", "by", "user", "in", "dialog" ]
2eb33b125c8407964cd1092843cde5010eb88aae
https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/controller/GeneratorTabController.py#L499-L517
train
jopohl/urh
src/urh/controller/CompareFrameController.py
CompareFrameController.protocols
def protocols(self): """ :rtype: dict[int, list of ProtocolAnalyzer] """ if self.__protocols is None: self.__protocols = self.proto_tree_model.protocols return self.__protocols
python
def protocols(self): """ :rtype: dict[int, list of ProtocolAnalyzer] """ if self.__protocols is None: self.__protocols = self.proto_tree_model.protocols return self.__protocols
[ "def", "protocols", "(", "self", ")", ":", "if", "self", ".", "__protocols", "is", "None", ":", "self", ".", "__protocols", "=", "self", ".", "proto_tree_model", ".", "protocols", "return", "self", ".", "__protocols" ]
:rtype: dict[int, list of ProtocolAnalyzer]
[ ":", "rtype", ":", "dict", "[", "int", "list", "of", "ProtocolAnalyzer", "]" ]
2eb33b125c8407964cd1092843cde5010eb88aae
https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/controller/CompareFrameController.py#L201-L207
train
jopohl/urh
src/urh/controller/CompareFrameController.py
CompareFrameController.protocol_list
def protocol_list(self): """ :return: visible protocols :rtype: list of ProtocolAnalyzer """ result = [] for group in self.groups: result.extend(group.protocols) return result
python
def protocol_list(self): """ :return: visible protocols :rtype: list of ProtocolAnalyzer """ result = [] for group in self.groups: result.extend(group.protocols) return result
[ "def", "protocol_list", "(", "self", ")", ":", "result", "=", "[", "]", "for", "group", "in", "self", ".", "groups", ":", "result", ".", "extend", "(", "group", ".", "protocols", ")", "return", "result" ]
:return: visible protocols :rtype: list of ProtocolAnalyzer
[ ":", "return", ":", "visible", "protocols", ":", "rtype", ":", "list", "of", "ProtocolAnalyzer" ]
2eb33b125c8407964cd1092843cde5010eb88aae
https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/controller/CompareFrameController.py#L210-L218
train
jopohl/urh
src/urh/controller/CompareFrameController.py
CompareFrameController.full_protocol_list
def full_protocol_list(self): """ :return: all protocols including not shown ones :rtype: list of ProtocolAnalyzer """ result = [] for group in self.groups: result.extend(group.all_protocols) return result
python
def full_protocol_list(self): """ :return: all protocols including not shown ones :rtype: list of ProtocolAnalyzer """ result = [] for group in self.groups: result.extend(group.all_protocols) return result
[ "def", "full_protocol_list", "(", "self", ")", ":", "result", "=", "[", "]", "for", "group", "in", "self", ".", "groups", ":", "result", ".", "extend", "(", "group", ".", "all_protocols", ")", "return", "result" ]
:return: all protocols including not shown ones :rtype: list of ProtocolAnalyzer
[ ":", "return", ":", "all", "protocols", "including", "not", "shown", "ones", ":", "rtype", ":", "list", "of", "ProtocolAnalyzer" ]
2eb33b125c8407964cd1092843cde5010eb88aae
https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/controller/CompareFrameController.py#L221-L229
train
jopohl/urh
src/urh/controller/CompareFrameController.py
CompareFrameController.refresh_existing_encodings
def refresh_existing_encodings(self): """ Refresh existing encodings for messages, when encoding was changed by user in dialog :return: """ update = False for msg in self.proto_analyzer.messages: i = next((i for i, d in enumerate(self.decodings) if d.name ==...
python
def refresh_existing_encodings(self): """ Refresh existing encodings for messages, when encoding was changed by user in dialog :return: """ update = False for msg in self.proto_analyzer.messages: i = next((i for i, d in enumerate(self.decodings) if d.name ==...
[ "def", "refresh_existing_encodings", "(", "self", ")", ":", "update", "=", "False", "for", "msg", "in", "self", ".", "proto_analyzer", ".", "messages", ":", "i", "=", "next", "(", "(", "i", "for", "i", ",", "d", "in", "enumerate", "(", "self", ".", "...
Refresh existing encodings for messages, when encoding was changed by user in dialog :return:
[ "Refresh", "existing", "encodings", "for", "messages", "when", "encoding", "was", "changed", "by", "user", "in", "dialog" ]
2eb33b125c8407964cd1092843cde5010eb88aae
https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/controller/CompareFrameController.py#L383-L401
train
jopohl/urh
src/urh/controller/CompareFrameController.py
CompareFrameController.set_show_only_status
def set_show_only_status(self): """ Handles the different combinations of the show only checkboxes, namely: - Show only labels - Show only Diffs """ if self.ui.chkBoxShowOnlyDiffs.isChecked() and not self.ui.cbShowDiffs.isChecked(): self.ui.cbShowDiffs.setCh...
python
def set_show_only_status(self): """ Handles the different combinations of the show only checkboxes, namely: - Show only labels - Show only Diffs """ if self.ui.chkBoxShowOnlyDiffs.isChecked() and not self.ui.cbShowDiffs.isChecked(): self.ui.cbShowDiffs.setCh...
[ "def", "set_show_only_status", "(", "self", ")", ":", "if", "self", ".", "ui", ".", "chkBoxShowOnlyDiffs", ".", "isChecked", "(", ")", "and", "not", "self", ".", "ui", ".", "cbShowDiffs", ".", "isChecked", "(", ")", ":", "self", ".", "ui", ".", "cbShow...
Handles the different combinations of the show only checkboxes, namely: - Show only labels - Show only Diffs
[ "Handles", "the", "different", "combinations", "of", "the", "show", "only", "checkboxes", "namely", ":", "-", "Show", "only", "labels", "-", "Show", "only", "Diffs" ]
2eb33b125c8407964cd1092843cde5010eb88aae
https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/controller/CompareFrameController.py#L862-L881
train
jopohl/urh
src/urh/awre/components/Component.py
Component.find_field
def find_field(self, messages): """ Wrapper method selecting the backend to assign the protocol field. Various strategies are possible e.g.: 1) Heuristics e.g. for Preamble 2) Scoring based e.g. for Length 3) Fulltext search for addresses based on participant subgroups ...
python
def find_field(self, messages): """ Wrapper method selecting the backend to assign the protocol field. Various strategies are possible e.g.: 1) Heuristics e.g. for Preamble 2) Scoring based e.g. for Length 3) Fulltext search for addresses based on participant subgroups ...
[ "def", "find_field", "(", "self", ",", "messages", ")", ":", "try", ":", "if", "self", ".", "backend", "==", "self", ".", "Backend", ".", "python", ":", "self", ".", "_py_find_field", "(", "messages", ")", "elif", "self", ".", "backend", "==", "self", ...
Wrapper method selecting the backend to assign the protocol field. Various strategies are possible e.g.: 1) Heuristics e.g. for Preamble 2) Scoring based e.g. for Length 3) Fulltext search for addresses based on participant subgroups :param messages: messages a field shall be se...
[ "Wrapper", "method", "selecting", "the", "backend", "to", "assign", "the", "protocol", "field", ".", "Various", "strategies", "are", "possible", "e", ".", "g", ".", ":", "1", ")", "Heuristics", "e", ".", "g", ".", "for", "Preamble", "2", ")", "Scoring", ...
2eb33b125c8407964cd1092843cde5010eb88aae
https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/awre/components/Component.py#L45-L66
train
jopohl/urh
src/urh/awre/components/Component.py
Component.assign_messagetypes
def assign_messagetypes(self, messages, clusters): """ Assign message types based on the clusters. Following rules: 1) Messages from different clusters will get different message types 2) Messages from same clusters will get same message type 3) The new message type will copy ove...
python
def assign_messagetypes(self, messages, clusters): """ Assign message types based on the clusters. Following rules: 1) Messages from different clusters will get different message types 2) Messages from same clusters will get same message type 3) The new message type will copy ove...
[ "def", "assign_messagetypes", "(", "self", ",", "messages", ",", "clusters", ")", ":", "for", "clustername", ",", "clustercontent", "in", "clusters", ".", "items", "(", ")", ":", "if", "clustername", "==", "\"default\"", ":", "# Do not force the default message ty...
Assign message types based on the clusters. Following rules: 1) Messages from different clusters will get different message types 2) Messages from same clusters will get same message type 3) The new message type will copy over the existing labels 4) No new message type will be set for me...
[ "Assign", "message", "types", "based", "on", "the", "clusters", ".", "Following", "rules", ":", "1", ")", "Messages", "from", "different", "clusters", "will", "get", "different", "message", "types", "2", ")", "Messages", "from", "same", "clusters", "will", "...
2eb33b125c8407964cd1092843cde5010eb88aae
https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/awre/components/Component.py#L78-L111
train
jopohl/urh
src/urh/signalprocessing/Spectrogram.py
Spectrogram.stft
def stft(self, samples: np.ndarray): """ Perform Short-time Fourier transform to get the spectrogram for the given samples :return: short-time Fourier transform of the given signal """ window = self.window_function(self.window_size) hop_size = self.hop_size if le...
python
def stft(self, samples: np.ndarray): """ Perform Short-time Fourier transform to get the spectrogram for the given samples :return: short-time Fourier transform of the given signal """ window = self.window_function(self.window_size) hop_size = self.hop_size if le...
[ "def", "stft", "(", "self", ",", "samples", ":", "np", ".", "ndarray", ")", ":", "window", "=", "self", ".", "window_function", "(", "self", ".", "window_size", ")", "hop_size", "=", "self", ".", "hop_size", "if", "len", "(", "samples", ")", "<", "se...
Perform Short-time Fourier transform to get the spectrogram for the given samples :return: short-time Fourier transform of the given signal
[ "Perform", "Short", "-", "time", "Fourier", "transform", "to", "get", "the", "spectrogram", "for", "the", "given", "samples", ":", "return", ":", "short", "-", "time", "Fourier", "transform", "of", "the", "given", "signal" ]
2eb33b125c8407964cd1092843cde5010eb88aae
https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/signalprocessing/Spectrogram.py#L78-L98
train
jopohl/urh
src/urh/signalprocessing/Spectrogram.py
Spectrogram.export_to_fta
def export_to_fta(self, sample_rate, filename: str, include_amplitude=False): """ Export to Frequency, Time, Amplitude file. Frequency is double, Time (nanosecond) is uint32, Amplitude is float32 :return: """ spectrogram = self.__calculate_spectrogram(self.samples) ...
python
def export_to_fta(self, sample_rate, filename: str, include_amplitude=False): """ Export to Frequency, Time, Amplitude file. Frequency is double, Time (nanosecond) is uint32, Amplitude is float32 :return: """ spectrogram = self.__calculate_spectrogram(self.samples) ...
[ "def", "export_to_fta", "(", "self", ",", "sample_rate", ",", "filename", ":", "str", ",", "include_amplitude", "=", "False", ")", ":", "spectrogram", "=", "self", ".", "__calculate_spectrogram", "(", "self", ".", "samples", ")", "spectrogram", "=", "np", "....
Export to Frequency, Time, Amplitude file. Frequency is double, Time (nanosecond) is uint32, Amplitude is float32 :return:
[ "Export", "to", "Frequency", "Time", "Amplitude", "file", ".", "Frequency", "is", "double", "Time", "(", "nanosecond", ")", "is", "uint32", "Amplitude", "is", "float32" ]
2eb33b125c8407964cd1092843cde5010eb88aae
https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/signalprocessing/Spectrogram.py#L100-L126
train