partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
PostFinding.get_name
Given an arbitrary resource attempt to resolve back to a qualified name.
tools/c7n_gcp/c7n_gcp/actions/cscc.py
def get_name(self, r): """Given an arbitrary resource attempt to resolve back to a qualified name.""" namer = ResourceNameAdapters[self.manager.resource_type.service] return namer(r)
def get_name(self, r): """Given an arbitrary resource attempt to resolve back to a qualified name.""" namer = ResourceNameAdapters[self.manager.resource_type.service] return namer(r)
[ "Given", "an", "arbitrary", "resource", "attempt", "to", "resolve", "back", "to", "a", "qualified", "name", "." ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_gcp/c7n_gcp/actions/cscc.py#L137-L140
[ "def", "get_name", "(", "self", ",", "r", ")", ":", "namer", "=", "ResourceNameAdapters", "[", "self", ".", "manager", ".", "resource_type", ".", "service", "]", "return", "namer", "(", "r", ")" ]
52ef732eb3d7bc939d1579faf519314814695c08
train
update_headers
Main.
tools/dev/license-headers.py
def update_headers(src_tree): """Main.""" print("src tree", src_tree) for root, dirs, files in os.walk(src_tree): py_files = fnmatch.filter(files, "*.py") for f in py_files: print("checking", f) p = os.path.join(root, f) with open(p) as fh: ...
def update_headers(src_tree): """Main.""" print("src tree", src_tree) for root, dirs, files in os.walk(src_tree): py_files = fnmatch.filter(files, "*.py") for f in py_files: print("checking", f) p = os.path.join(root, f) with open(p) as fh: ...
[ "Main", "." ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/dev/license-headers.py#L45-L60
[ "def", "update_headers", "(", "src_tree", ")", ":", "print", "(", "\"src tree\"", ",", "src_tree", ")", "for", "root", ",", "dirs", ",", "files", "in", "os", ".", "walk", "(", "src_tree", ")", ":", "py_files", "=", "fnmatch", ".", "filter", "(", "files...
52ef732eb3d7bc939d1579faf519314814695c08
train
list_locks
Show extant locks and unlocks.
tools/sandbox/c7n_sphere11/c7n_sphere11/cli.py
def list_locks(account_id, resource_type=None, resource_id=None): """Show extant locks and unlocks. """ locks = Client(BASE_URL, account_id).list_locks().json() for r in locks: if 'LockDate' in r: r['LockDate'] = datetime.fromtimestamp(r['LockDate']) if 'RevisionDate' in r: ...
def list_locks(account_id, resource_type=None, resource_id=None): """Show extant locks and unlocks. """ locks = Client(BASE_URL, account_id).list_locks().json() for r in locks: if 'LockDate' in r: r['LockDate'] = datetime.fromtimestamp(r['LockDate']) if 'RevisionDate' in r: ...
[ "Show", "extant", "locks", "and", "unlocks", "." ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/sandbox/c7n_sphere11/c7n_sphere11/cli.py#L38-L52
[ "def", "list_locks", "(", "account_id", ",", "resource_type", "=", "None", ",", "resource_id", "=", "None", ")", ":", "locks", "=", "Client", "(", "BASE_URL", ",", "account_id", ")", ".", "list_locks", "(", ")", ".", "json", "(", ")", "for", "r", "in",...
52ef732eb3d7bc939d1579faf519314814695c08
train
lock_status
Show extant locks' status
tools/sandbox/c7n_sphere11/c7n_sphere11/cli.py
def lock_status(account_id, resource_id, parent_id): """Show extant locks' status """ return output( Client(BASE_URL, account_id).lock_status(resource_id, parent_id))
def lock_status(account_id, resource_id, parent_id): """Show extant locks' status """ return output( Client(BASE_URL, account_id).lock_status(resource_id, parent_id))
[ "Show", "extant", "locks", "status" ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/sandbox/c7n_sphere11/c7n_sphere11/cli.py#L67-L71
[ "def", "lock_status", "(", "account_id", ",", "resource_id", ",", "parent_id", ")", ":", "return", "output", "(", "Client", "(", "BASE_URL", ",", "account_id", ")", ".", "lock_status", "(", "resource_id", ",", "parent_id", ")", ")" ]
52ef732eb3d7bc939d1579faf519314814695c08
train
lock
Lock a resource
tools/sandbox/c7n_sphere11/c7n_sphere11/cli.py
def lock(account_id, resource_id, region): """Lock a resource """ return output( Client(BASE_URL, account_id).lock(resource_id, region))
def lock(account_id, resource_id, region): """Lock a resource """ return output( Client(BASE_URL, account_id).lock(resource_id, region))
[ "Lock", "a", "resource" ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/sandbox/c7n_sphere11/c7n_sphere11/cli.py#L78-L82
[ "def", "lock", "(", "account_id", ",", "resource_id", ",", "region", ")", ":", "return", "output", "(", "Client", "(", "BASE_URL", ",", "account_id", ")", ".", "lock", "(", "resource_id", ",", "region", ")", ")" ]
52ef732eb3d7bc939d1579faf519314814695c08
train
Client.list_locks
Get extant locks for the given account.
tools/sandbox/c7n_sphere11/c7n_sphere11/client.py
def list_locks(self, account_id=None): """Get extant locks for the given account. """ account_id = self.get_account_id(account_id) return self.http.get( "%s/%s/locks" % (self.endpoint, account_id), auth=self.get_api_auth())
def list_locks(self, account_id=None): """Get extant locks for the given account. """ account_id = self.get_account_id(account_id) return self.http.get( "%s/%s/locks" % (self.endpoint, account_id), auth=self.get_api_auth())
[ "Get", "extant", "locks", "for", "the", "given", "account", "." ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/sandbox/c7n_sphere11/c7n_sphere11/client.py#L41-L47
[ "def", "list_locks", "(", "self", ",", "account_id", "=", "None", ")", ":", "account_id", "=", "self", ".", "get_account_id", "(", "account_id", ")", "return", "self", ".", "http", ".", "get", "(", "\"%s/%s/locks\"", "%", "(", "self", ".", "endpoint", ",...
52ef732eb3d7bc939d1579faf519314814695c08
train
Client.lock_status
Get the lock status for a given resource. for security groups, parent id is their vpc.
tools/sandbox/c7n_sphere11/c7n_sphere11/client.py
def lock_status(self, resource_id, parent_id=None, account_id=None): """Get the lock status for a given resource. for security groups, parent id is their vpc. """ account_id = self.get_account_id(account_id) params = parent_id and {'parent_id': parent_id} or None return ...
def lock_status(self, resource_id, parent_id=None, account_id=None): """Get the lock status for a given resource. for security groups, parent id is their vpc. """ account_id = self.get_account_id(account_id) params = parent_id and {'parent_id': parent_id} or None return ...
[ "Get", "the", "lock", "status", "for", "a", "given", "resource", "." ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/sandbox/c7n_sphere11/c7n_sphere11/client.py#L49-L58
[ "def", "lock_status", "(", "self", ",", "resource_id", ",", "parent_id", "=", "None", ",", "account_id", "=", "None", ")", ":", "account_id", "=", "self", ".", "get_account_id", "(", "account_id", ")", "params", "=", "parent_id", "and", "{", "'parent_id'", ...
52ef732eb3d7bc939d1579faf519314814695c08
train
Client.lock
Lock a given resource
tools/sandbox/c7n_sphere11/c7n_sphere11/client.py
def lock(self, resource_id, region, account_id=None): """Lock a given resource """ account_id = self.get_account_id(account_id) return self.http.post( "%s/%s/locks/%s/lock" % (self.endpoint, account_id, resource_id), json={'region': region}, auth=self....
def lock(self, resource_id, region, account_id=None): """Lock a given resource """ account_id = self.get_account_id(account_id) return self.http.post( "%s/%s/locks/%s/lock" % (self.endpoint, account_id, resource_id), json={'region': region}, auth=self....
[ "Lock", "a", "given", "resource" ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/sandbox/c7n_sphere11/c7n_sphere11/client.py#L60-L67
[ "def", "lock", "(", "self", ",", "resource_id", ",", "region", ",", "account_id", "=", "None", ")", ":", "account_id", "=", "self", ".", "get_account_id", "(", "account_id", ")", "return", "self", ".", "http", ".", "post", "(", "\"%s/%s/locks/%s/lock\"", "...
52ef732eb3d7bc939d1579faf519314814695c08
train
report
report on a cross account policy execution.
tools/c7n_org/c7n_org/cli.py
def report(config, output, use, output_dir, accounts, field, no_default_fields, tags, region, debug, verbose, policy, policy_tags, format, resource, cache_path): """report on a cross account policy execution.""" accounts_config, custodian_config, executor = init( config, use, debug...
def report(config, output, use, output_dir, accounts, field, no_default_fields, tags, region, debug, verbose, policy, policy_tags, format, resource, cache_path): """report on a cross account policy execution.""" accounts_config, custodian_config, executor = init( config, use, debug...
[ "report", "on", "a", "cross", "account", "policy", "execution", "." ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_org/c7n_org/cli.py#L322-L386
[ "def", "report", "(", "config", ",", "output", ",", "use", ",", "output_dir", ",", "accounts", ",", "field", ",", "no_default_fields", ",", "tags", ",", "region", ",", "debug", ",", "verbose", ",", "policy", ",", "policy_tags", ",", "format", ",", "resou...
52ef732eb3d7bc939d1579faf519314814695c08
train
run_script
run an aws script across accounts
tools/c7n_org/c7n_org/cli.py
def run_script(config, output_dir, accounts, tags, region, echo, serial, script_args): """run an aws script across accounts""" # TODO count up on success / error / error list by account accounts_config, custodian_config, executor = init( config, None, serial, True, accounts, tags, (), ()) if ec...
def run_script(config, output_dir, accounts, tags, region, echo, serial, script_args): """run an aws script across accounts""" # TODO count up on success / error / error list by account accounts_config, custodian_config, executor = init( config, None, serial, True, accounts, tags, (), ()) if ec...
[ "run", "an", "aws", "script", "across", "accounts" ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_org/c7n_org/cli.py#L434-L472
[ "def", "run_script", "(", "config", ",", "output_dir", ",", "accounts", ",", "tags", ",", "region", ",", "echo", ",", "serial", ",", "script_args", ")", ":", "# TODO count up on success / error / error list by account", "accounts_config", ",", "custodian_config", ",",...
52ef732eb3d7bc939d1579faf519314814695c08
train
run_account
Execute a set of policies on an account.
tools/c7n_org/c7n_org/cli.py
def run_account(account, region, policies_config, output_path, cache_period, cache_path, metrics, dryrun, debug): """Execute a set of policies on an account. """ logging.getLogger('custodian.output').setLevel(logging.ERROR + 1) CONN_CACHE.session = None CONN_CACHE.time = None # ...
def run_account(account, region, policies_config, output_path, cache_period, cache_path, metrics, dryrun, debug): """Execute a set of policies on an account. """ logging.getLogger('custodian.output').setLevel(logging.ERROR + 1) CONN_CACHE.session = None CONN_CACHE.time = None # ...
[ "Execute", "a", "set", "of", "policies", "on", "an", "account", "." ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_org/c7n_org/cli.py#L492-L570
[ "def", "run_account", "(", "account", ",", "region", ",", "policies_config", ",", "output_path", ",", "cache_period", ",", "cache_path", ",", "metrics", ",", "dryrun", ",", "debug", ")", ":", "logging", ".", "getLogger", "(", "'custodian.output'", ")", ".", ...
52ef732eb3d7bc939d1579faf519314814695c08
train
run
run a custodian policy across accounts
tools/c7n_org/c7n_org/cli.py
def run(config, use, output_dir, accounts, tags, region, policy, policy_tags, cache_period, cache_path, metrics, dryrun, debug, verbose, metrics_uri): """run a custodian policy across accounts""" accounts_config, custodian_config, executor = init( config, use, debug, verbose, accounts, t...
def run(config, use, output_dir, accounts, tags, region, policy, policy_tags, cache_period, cache_path, metrics, dryrun, debug, verbose, metrics_uri): """run a custodian policy across accounts""" accounts_config, custodian_config, executor = init( config, use, debug, verbose, accounts, t...
[ "run", "a", "custodian", "policy", "across", "accounts" ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_org/c7n_org/cli.py#L595-L646
[ "def", "run", "(", "config", ",", "use", ",", "output_dir", ",", "accounts", ",", "tags", ",", "region", ",", "policy", ",", "policy_tags", ",", "cache_period", ",", "cache_path", ",", "metrics", ",", "dryrun", ",", "debug", ",", "verbose", ",", "metrics...
52ef732eb3d7bc939d1579faf519314814695c08
train
CloudWatchLogHandler.emit
Send logs
c7n/log.py
def emit(self, message): """Send logs""" # We're sending messages asynchronously, bubble to caller when # we've detected an error on the message. This isn't great, # but options once we've gone async without a deferred/promise # aren't great. if self.transport and self.tr...
def emit(self, message): """Send logs""" # We're sending messages asynchronously, bubble to caller when # we've detected an error on the message. This isn't great, # but options once we've gone async without a deferred/promise # aren't great. if self.transport and self.tr...
[ "Send", "logs" ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/log.py#L100-L121
[ "def", "emit", "(", "self", ",", "message", ")", ":", "# We're sending messages asynchronously, bubble to caller when", "# we've detected an error on the message. This isn't great,", "# but options once we've gone async without a deferred/promise", "# aren't great.", "if", "self", ".", ...
52ef732eb3d7bc939d1579faf519314814695c08
train
CloudWatchLogHandler.flush
Ensure all logging output has been flushed.
c7n/log.py
def flush(self): """Ensure all logging output has been flushed.""" if self.shutdown: return self.flush_buffers(force=True) self.queue.put(FLUSH_MARKER) self.queue.join()
def flush(self): """Ensure all logging output has been flushed.""" if self.shutdown: return self.flush_buffers(force=True) self.queue.put(FLUSH_MARKER) self.queue.join()
[ "Ensure", "all", "logging", "output", "has", "been", "flushed", "." ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/log.py#L123-L129
[ "def", "flush", "(", "self", ")", ":", "if", "self", ".", "shutdown", ":", "return", "self", ".", "flush_buffers", "(", "force", "=", "True", ")", "self", ".", "queue", ".", "put", "(", "FLUSH_MARKER", ")", "self", ".", "queue", ".", "join", "(", "...
52ef732eb3d7bc939d1579faf519314814695c08
train
CloudWatchLogHandler.format_message
format message.
c7n/log.py
def format_message(self, msg): """format message.""" return {'timestamp': int(msg.created * 1000), 'message': self.format(msg), 'stream': self.log_stream or msg.name, 'group': self.log_group}
def format_message(self, msg): """format message.""" return {'timestamp': int(msg.created * 1000), 'message': self.format(msg), 'stream': self.log_stream or msg.name, 'group': self.log_group}
[ "format", "message", "." ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/log.py#L143-L148
[ "def", "format_message", "(", "self", ",", "msg", ")", ":", "return", "{", "'timestamp'", ":", "int", "(", "msg", ".", "created", "*", "1000", ")", ",", "'message'", ":", "self", ".", "format", "(", "msg", ")", ",", "'stream'", ":", "self", ".", "l...
52ef732eb3d7bc939d1579faf519314814695c08
train
CloudWatchLogHandler.start_transports
start thread transports.
c7n/log.py
def start_transports(self): """start thread transports.""" self.transport = Transport( self.queue, self.batch_size, self.batch_interval, self.session_factory) thread = threading.Thread(target=self.transport.loop) self.threads.append(thread) thread.daemon =...
def start_transports(self): """start thread transports.""" self.transport = Transport( self.queue, self.batch_size, self.batch_interval, self.session_factory) thread = threading.Thread(target=self.transport.loop) self.threads.append(thread) thread.daemon =...
[ "start", "thread", "transports", "." ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/log.py#L150-L158
[ "def", "start_transports", "(", "self", ")", ":", "self", ".", "transport", "=", "Transport", "(", "self", ".", "queue", ",", "self", ".", "batch_size", ",", "self", ".", "batch_interval", ",", "self", ".", "session_factory", ")", "thread", "=", "threading...
52ef732eb3d7bc939d1579faf519314814695c08
train
ErrorHandler.extract_bad_ami
Handle various client side errors when describing images
c7n/resources/ami.py
def extract_bad_ami(e): """Handle various client side errors when describing images""" msg = e.response['Error']['Message'] error = e.response['Error']['Code'] e_ami_ids = None if error == 'InvalidAMIID.NotFound': e_ami_ids = [ e_ami_id.strip() for e_a...
def extract_bad_ami(e): """Handle various client side errors when describing images""" msg = e.response['Error']['Message'] error = e.response['Error']['Code'] e_ami_ids = None if error == 'InvalidAMIID.NotFound': e_ami_ids = [ e_ami_id.strip() for e_a...
[ "Handle", "various", "client", "side", "errors", "when", "describing", "images" ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/resources/ami.py#L82-L95
[ "def", "extract_bad_ami", "(", "e", ")", ":", "msg", "=", "e", ".", "response", "[", "'Error'", "]", "[", "'Message'", "]", "error", "=", "e", ".", "response", "[", "'Error'", "]", "[", "'Code'", "]", "e_ami_ids", "=", "None", "if", "error", "==", ...
52ef732eb3d7bc939d1579faf519314814695c08
train
format_json
format config for lambda exec
tools/sandbox/c7n_sphere11/c7n_sphere11/admin.py
def format_json(config): """format config for lambda exec """ with open(config) as fh: print(json.dumps(yaml.safe_load(fh.read()), indent=2))
def format_json(config): """format config for lambda exec """ with open(config) as fh: print(json.dumps(yaml.safe_load(fh.read()), indent=2))
[ "format", "config", "for", "lambda", "exec" ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/sandbox/c7n_sphere11/c7n_sphere11/admin.py#L40-L44
[ "def", "format_json", "(", "config", ")", ":", "with", "open", "(", "config", ")", "as", "fh", ":", "print", "(", "json", ".", "dumps", "(", "yaml", ".", "safe_load", "(", "fh", ".", "read", "(", ")", ")", ",", "indent", "=", "2", ")", ")" ]
52ef732eb3d7bc939d1579faf519314814695c08
train
check
Sanity check api deployment
tools/sandbox/c7n_sphere11/c7n_sphere11/admin.py
def check(): """Sanity check api deployment """ t = time.time() results = Client(BASE_URL).version() print("Endpoint", BASE_URL) print("Response Time %0.2f" % (time.time() - t)) print("Headers") for k, v in results.headers.items(): print(" %s: %s" % (k, v)) print("Body") ...
def check(): """Sanity check api deployment """ t = time.time() results = Client(BASE_URL).version() print("Endpoint", BASE_URL) print("Response Time %0.2f" % (time.time() - t)) print("Headers") for k, v in results.headers.items(): print(" %s: %s" % (k, v)) print("Body") ...
[ "Sanity", "check", "api", "deployment" ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/sandbox/c7n_sphere11/c7n_sphere11/admin.py#L71-L82
[ "def", "check", "(", ")", ":", "t", "=", "time", ".", "time", "(", ")", "results", "=", "Client", "(", "BASE_URL", ")", ".", "version", "(", ")", "print", "(", "\"Endpoint\"", ",", "BASE_URL", ")", "print", "(", "\"Response Time %0.2f\"", "%", "(", "...
52ef732eb3d7bc939d1579faf519314814695c08
train
metrics
lambda/api/db metrics
tools/sandbox/c7n_sphere11/c7n_sphere11/admin.py
def metrics(function, api, start, period): """lambda/api/db metrics""" from c7n.mu import LambdaManager manager = LambdaManager(boto3.Session) start = parse_date(start) period = int(abs(parse_timedelta(period).total_seconds())) print("Lambda Metrics") metrics = manager.metrics( [{'F...
def metrics(function, api, start, period): """lambda/api/db metrics""" from c7n.mu import LambdaManager manager = LambdaManager(boto3.Session) start = parse_date(start) period = int(abs(parse_timedelta(period).total_seconds())) print("Lambda Metrics") metrics = manager.metrics( [{'F...
[ "lambda", "/", "api", "/", "db", "metrics" ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/sandbox/c7n_sphere11/c7n_sphere11/admin.py#L92-L127
[ "def", "metrics", "(", "function", ",", "api", ",", "start", ",", "period", ")", ":", "from", "c7n", ".", "mu", "import", "LambdaManager", "manager", "=", "LambdaManager", "(", "boto3", ".", "Session", ")", "start", "=", "parse_date", "(", "start", ")", ...
52ef732eb3d7bc939d1579faf519314814695c08
train
records
Fetch locks data
tools/sandbox/c7n_sphere11/c7n_sphere11/admin.py
def records(account_id): """Fetch locks data """ s = boto3.Session() table = s.resource('dynamodb').Table('Sphere11.Dev.ResourceLocks') results = table.scan() for r in results['Items']: if 'LockDate' in r: r['LockDate'] = datetime.fromtimestamp(r['LockDate']) if 'Rev...
def records(account_id): """Fetch locks data """ s = boto3.Session() table = s.resource('dynamodb').Table('Sphere11.Dev.ResourceLocks') results = table.scan() for r in results['Items']: if 'LockDate' in r: r['LockDate'] = datetime.fromtimestamp(r['LockDate']) if 'Rev...
[ "Fetch", "locks", "data" ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/sandbox/c7n_sphere11/c7n_sphere11/admin.py#L197-L213
[ "def", "records", "(", "account_id", ")", ":", "s", "=", "boto3", ".", "Session", "(", ")", "table", "=", "s", ".", "resource", "(", "'dynamodb'", ")", ".", "Table", "(", "'Sphere11.Dev.ResourceLocks'", ")", "results", "=", "table", ".", "scan", "(", "...
52ef732eb3d7bc939d1579faf519314814695c08
train
flush_pending
Attempt to acquire any pending locks.
tools/sandbox/c7n_sphere11/c7n_sphere11/admin.py
def flush_pending(function): """Attempt to acquire any pending locks. """ s = boto3.Session() client = s.client('lambda') results = client.invoke( FunctionName=function, Payload=json.dumps({'detail-type': 'Scheduled Event'}) ) content = results.pop('Payload').read() pprin...
def flush_pending(function): """Attempt to acquire any pending locks. """ s = boto3.Session() client = s.client('lambda') results = client.invoke( FunctionName=function, Payload=json.dumps({'detail-type': 'Scheduled Event'}) ) content = results.pop('Payload').read() pprin...
[ "Attempt", "to", "acquire", "any", "pending", "locks", "." ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/sandbox/c7n_sphere11/c7n_sphere11/admin.py#L218-L229
[ "def", "flush_pending", "(", "function", ")", ":", "s", "=", "boto3", ".", "Session", "(", ")", "client", "=", "s", ".", "client", "(", "'lambda'", ")", "results", "=", "client", ".", "invoke", "(", "FunctionName", "=", "function", ",", "Payload", "=",...
52ef732eb3d7bc939d1579faf519314814695c08
train
config_status
Check config status in an account.
tools/sandbox/c7n_sphere11/c7n_sphere11/admin.py
def config_status(): """ Check config status in an account. """ s = boto3.Session() client = s.client('config') channels = client.describe_delivery_channel_status()[ 'DeliveryChannelsStatus'] for c in channels: print(yaml.safe_dump({ c['name']: dict( s...
def config_status(): """ Check config status in an account. """ s = boto3.Session() client = s.client('config') channels = client.describe_delivery_channel_status()[ 'DeliveryChannelsStatus'] for c in channels: print(yaml.safe_dump({ c['name']: dict( s...
[ "Check", "config", "status", "in", "an", "account", "." ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/sandbox/c7n_sphere11/c7n_sphere11/admin.py#L233-L250
[ "def", "config_status", "(", ")", ":", "s", "=", "boto3", ".", "Session", "(", ")", "client", "=", "s", ".", "client", "(", "'config'", ")", "channels", "=", "client", ".", "describe_delivery_channel_status", "(", ")", "[", "'DeliveryChannelsStatus'", "]", ...
52ef732eb3d7bc939d1579faf519314814695c08
train
local
run local app server, assumes into the account
tools/sandbox/c7n_sphere11/c7n_sphere11/admin.py
def local(reload, port): """run local app server, assumes into the account """ import logging from bottle import run from app import controller, app from c7n.resources import load_resources load_resources() print("Loaded resources definitions") logging.basicConfig(level=logging.DEBUG...
def local(reload, port): """run local app server, assumes into the account """ import logging from bottle import run from app import controller, app from c7n.resources import load_resources load_resources() print("Loaded resources definitions") logging.basicConfig(level=logging.DEBUG...
[ "run", "local", "app", "server", "assumes", "into", "the", "account" ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/sandbox/c7n_sphere11/c7n_sphere11/admin.py#L263-L276
[ "def", "local", "(", "reload", ",", "port", ")", ":", "import", "logging", "from", "bottle", "import", "run", "from", "app", "import", "controller", ",", "app", "from", "c7n", ".", "resources", "import", "load_resources", "load_resources", "(", ")", "print",...
52ef732eb3d7bc939d1579faf519314814695c08
train
_schema_get_docstring
Given a class, return its docstring. If no docstring is present for the class, search base classes in MRO for a docstring.
c7n/commands.py
def _schema_get_docstring(starting_class): """ Given a class, return its docstring. If no docstring is present for the class, search base classes in MRO for a docstring. """ for cls in inspect.getmro(starting_class): if inspect.getdoc(cls): return inspect.getdoc(cls)
def _schema_get_docstring(starting_class): """ Given a class, return its docstring. If no docstring is present for the class, search base classes in MRO for a docstring. """ for cls in inspect.getmro(starting_class): if inspect.getdoc(cls): return inspect.getdoc(cls)
[ "Given", "a", "class", "return", "its", "docstring", "." ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/commands.py#L316-L324
[ "def", "_schema_get_docstring", "(", "starting_class", ")", ":", "for", "cls", "in", "inspect", ".", "getmro", "(", "starting_class", ")", ":", "if", "inspect", ".", "getdoc", "(", "cls", ")", ":", "return", "inspect", ".", "getdoc", "(", "cls", ")" ]
52ef732eb3d7bc939d1579faf519314814695c08
train
schema_completer
For tab-completion via argcomplete, return completion options. For the given prefix so far, return the possible options. Note that filtering via startswith happens after this list is returned.
c7n/commands.py
def schema_completer(prefix): """ For tab-completion via argcomplete, return completion options. For the given prefix so far, return the possible options. Note that filtering via startswith happens after this list is returned. """ from c7n import schema load_resources() components = prefix...
def schema_completer(prefix): """ For tab-completion via argcomplete, return completion options. For the given prefix so far, return the possible options. Note that filtering via startswith happens after this list is returned. """ from c7n import schema load_resources() components = prefix...
[ "For", "tab", "-", "completion", "via", "argcomplete", "return", "completion", "options", "." ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/commands.py#L327-L370
[ "def", "schema_completer", "(", "prefix", ")", ":", "from", "c7n", "import", "schema", "load_resources", "(", ")", "components", "=", "prefix", ".", "split", "(", "'.'", ")", "if", "components", "[", "0", "]", "in", "provider", ".", "clouds", ".", "keys"...
52ef732eb3d7bc939d1579faf519314814695c08
train
schema_cmd
Print info about the resources, actions and filters available.
c7n/commands.py
def schema_cmd(options): """ Print info about the resources, actions and filters available. """ from c7n import schema if options.json: schema.json_dump(options.resource) return load_resources() resource_mapping = schema.resource_vocabulary() if options.summary: schema....
def schema_cmd(options): """ Print info about the resources, actions and filters available. """ from c7n import schema if options.json: schema.json_dump(options.resource) return load_resources() resource_mapping = schema.resource_vocabulary() if options.summary: schema....
[ "Print", "info", "about", "the", "resources", "actions", "and", "filters", "available", "." ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/commands.py#L373-L502
[ "def", "schema_cmd", "(", "options", ")", ":", "from", "c7n", "import", "schema", "if", "options", ".", "json", ":", "schema", ".", "json_dump", "(", "options", ".", "resource", ")", "return", "load_resources", "(", ")", "resource_mapping", "=", "schema", ...
52ef732eb3d7bc939d1579faf519314814695c08
train
_metrics_get_endpoints
Determine the start and end dates based on user-supplied options.
c7n/commands.py
def _metrics_get_endpoints(options): """ Determine the start and end dates based on user-supplied options. """ if bool(options.start) ^ bool(options.end): log.error('--start and --end must be specified together') sys.exit(1) if options.start and options.end: start = options.start ...
def _metrics_get_endpoints(options): """ Determine the start and end dates based on user-supplied options. """ if bool(options.start) ^ bool(options.end): log.error('--start and --end must be specified together') sys.exit(1) if options.start and options.end: start = options.start ...
[ "Determine", "the", "start", "and", "end", "dates", "based", "on", "user", "-", "supplied", "options", "." ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/commands.py#L529-L542
[ "def", "_metrics_get_endpoints", "(", "options", ")", ":", "if", "bool", "(", "options", ".", "start", ")", "^", "bool", "(", "options", ".", "end", ")", ":", "log", ".", "error", "(", "'--start and --end must be specified together'", ")", "sys", ".", "exit"...
52ef732eb3d7bc939d1579faf519314814695c08
train
extract_instance_id
Extract an instance id from an error
c7n/resources/ec2.py
def extract_instance_id(state_error): "Extract an instance id from an error" instance_id = None match = RE_ERROR_INSTANCE_ID.search(str(state_error)) if match: instance_id = match.groupdict().get('instance_id') if match is None or instance_id is None: raise ValueError("Could not extr...
def extract_instance_id(state_error): "Extract an instance id from an error" instance_id = None match = RE_ERROR_INSTANCE_ID.search(str(state_error)) if match: instance_id = match.groupdict().get('instance_id') if match is None or instance_id is None: raise ValueError("Could not extr...
[ "Extract", "an", "instance", "id", "from", "an", "error" ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/resources/ec2.py#L1011-L1019
[ "def", "extract_instance_id", "(", "state_error", ")", ":", "instance_id", "=", "None", "match", "=", "RE_ERROR_INSTANCE_ID", ".", "search", "(", "str", "(", "state_error", ")", ")", "if", "match", ":", "instance_id", "=", "match", ".", "groupdict", "(", ")"...
52ef732eb3d7bc939d1579faf519314814695c08
train
DescribeEC2.augment
EC2 API and AWOL Tags While ec2 api generally returns tags when doing describe_x on for various resources, it may also silently fail to do so unless a tag is used as a filter. See footnote on for official documentation. https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_...
c7n/resources/ec2.py
def augment(self, resources): """EC2 API and AWOL Tags While ec2 api generally returns tags when doing describe_x on for various resources, it may also silently fail to do so unless a tag is used as a filter. See footnote on for official documentation. https://docs.aws....
def augment(self, resources): """EC2 API and AWOL Tags While ec2 api generally returns tags when doing describe_x on for various resources, it may also silently fail to do so unless a tag is used as a filter. See footnote on for official documentation. https://docs.aws....
[ "EC2", "API", "and", "AWOL", "Tags" ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/resources/ec2.py#L122-L172
[ "def", "augment", "(", "self", ",", "resources", ")", ":", "# First if we're in event based lambda go ahead and skip this,", "# tags can't be trusted in ec2 instances immediately post creation.", "if", "not", "resources", "or", "self", ".", "manager", ".", "data", ".", "get",...
52ef732eb3d7bc939d1579faf519314814695c08
train
SecurityHubFindingFilter.register_resources
meta model subscriber on resource registration. SecurityHub Findings Filter
c7n/filters/securityhub.py
def register_resources(klass, registry, resource_class): """ meta model subscriber on resource registration. SecurityHub Findings Filter """ for rtype, resource_manager in registry.items(): if not resource_manager.has_arn(): continue if 'post-find...
def register_resources(klass, registry, resource_class): """ meta model subscriber on resource registration. SecurityHub Findings Filter """ for rtype, resource_manager in registry.items(): if not resource_manager.has_arn(): continue if 'post-find...
[ "meta", "model", "subscriber", "on", "resource", "registration", "." ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/filters/securityhub.py#L57-L67
[ "def", "register_resources", "(", "klass", ",", "registry", ",", "resource_class", ")", ":", "for", "rtype", ",", "resource_manager", "in", "registry", ".", "items", "(", ")", ":", "if", "not", "resource_manager", ".", "has_arn", "(", ")", ":", "continue", ...
52ef732eb3d7bc939d1579faf519314814695c08
train
Notify.publish_message
Publish message to a GCP pub/sub topic
tools/c7n_gcp/c7n_gcp/actions/notify.py
def publish_message(self, message, client): """Publish message to a GCP pub/sub topic """ return client.execute_command('publish', { 'topic': self.data['transport']['topic'], 'body': { 'messages': { 'data': self.pack(message) ...
def publish_message(self, message, client): """Publish message to a GCP pub/sub topic """ return client.execute_command('publish', { 'topic': self.data['transport']['topic'], 'body': { 'messages': { 'data': self.pack(message) ...
[ "Publish", "message", "to", "a", "GCP", "pub", "/", "sub", "topic" ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_gcp/c7n_gcp/actions/notify.py#L99-L109
[ "def", "publish_message", "(", "self", ",", "message", ",", "client", ")", ":", "return", "client", ".", "execute_command", "(", "'publish'", ",", "{", "'topic'", ":", "self", ".", "data", "[", "'transport'", "]", "[", "'topic'", "]", ",", "'body'", ":",...
52ef732eb3d7bc939d1579faf519314814695c08
train
EmailDelivery.set_mimetext_headers
Sets headers on Mimetext message
tools/c7n_mailer/c7n_mailer/email_delivery.py
def set_mimetext_headers(self, message, subject, from_addr, to_addrs, cc_addrs, priority): """Sets headers on Mimetext message""" message['Subject'] = subject message['From'] = from_addr message['To'] = ', '.join(to_addrs) if cc_addrs: message['Cc'] = ', '.join(cc_ad...
def set_mimetext_headers(self, message, subject, from_addr, to_addrs, cc_addrs, priority): """Sets headers on Mimetext message""" message['Subject'] = subject message['From'] = from_addr message['To'] = ', '.join(to_addrs) if cc_addrs: message['Cc'] = ', '.join(cc_ad...
[ "Sets", "headers", "on", "Mimetext", "message" ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_mailer/c7n_mailer/email_delivery.py#L265-L279
[ "def", "set_mimetext_headers", "(", "self", ",", "message", ",", "subject", ",", "from_addr", ",", "to_addrs", ",", "cc_addrs", ",", "priority", ")", ":", "message", "[", "'Subject'", "]", "=", "subject", "message", "[", "'From'", "]", "=", "from_addr", "m...
52ef732eb3d7bc939d1579faf519314814695c08
train
HealthEventFilter.register_resources
meta model subscriber on resource registration. We watch for PHD event that provides affected entities and register the health-event filter to the resources.
c7n/filters/health.py
def register_resources(klass, registry, resource_class): """ meta model subscriber on resource registration. We watch for PHD event that provides affected entities and register the health-event filter to the resources. """ services = {'acm-certificate', 'directconnect', 'dms-ins...
def register_resources(klass, registry, resource_class): """ meta model subscriber on resource registration. We watch for PHD event that provides affected entities and register the health-event filter to the resources. """ services = {'acm-certificate', 'directconnect', 'dms-ins...
[ "meta", "model", "subscriber", "on", "resource", "registration", "." ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/filters/health.py#L104-L114
[ "def", "register_resources", "(", "klass", ",", "registry", ",", "resource_class", ")", ":", "services", "=", "{", "'acm-certificate'", ",", "'directconnect'", ",", "'dms-instance'", ",", "'directory'", ",", "'ec2'", ",", "'dynamodb-table'", ",", "'cache-cluster'", ...
52ef732eb3d7bc939d1579faf519314814695c08
train
custodian_archive
Create a lambda code archive for running custodian. Lambda archive currently always includes `c7n` and `pkg_resources`. Add additional packages in the mode block. Example policy that includes additional packages .. code-block:: yaml policy: name: lambda-archive-example re...
c7n/mu.py
def custodian_archive(packages=None): """Create a lambda code archive for running custodian. Lambda archive currently always includes `c7n` and `pkg_resources`. Add additional packages in the mode block. Example policy that includes additional packages .. code-block:: yaml policy: ...
def custodian_archive(packages=None): """Create a lambda code archive for running custodian. Lambda archive currently always includes `c7n` and `pkg_resources`. Add additional packages in the mode block. Example policy that includes additional packages .. code-block:: yaml policy: ...
[ "Create", "a", "lambda", "code", "archive", "for", "running", "custodian", "." ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/mu.py#L254-L277
[ "def", "custodian_archive", "(", "packages", "=", "None", ")", ":", "modules", "=", "{", "'c7n'", ",", "'pkg_resources'", "}", "if", "packages", ":", "modules", "=", "filter", "(", "None", ",", "modules", ".", "union", "(", "packages", ")", ")", "return"...
52ef732eb3d7bc939d1579faf519314814695c08
train
PythonPackageArchive.add_modules
Add the named Python modules to the archive. For consistency's sake we only add ``*.py`` files, not ``*.pyc``. We also don't add other files, including compiled modules. You'll have to add such files manually using :py:meth:`add_file`.
c7n/mu.py
def add_modules(self, ignore, *modules): """Add the named Python modules to the archive. For consistency's sake we only add ``*.py`` files, not ``*.pyc``. We also don't add other files, including compiled modules. You'll have to add such files manually using :py:meth:`add_file`. ...
def add_modules(self, ignore, *modules): """Add the named Python modules to the archive. For consistency's sake we only add ``*.py`` files, not ``*.pyc``. We also don't add other files, including compiled modules. You'll have to add such files manually using :py:meth:`add_file`. ...
[ "Add", "the", "named", "Python", "modules", "to", "the", "archive", ".", "For", "consistency", "s", "sake", "we", "only", "add", "*", ".", "py", "files", "not", "*", ".", "pyc", ".", "We", "also", "don", "t", "add", "other", "files", "including", "co...
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/mu.py#L91-L131
[ "def", "add_modules", "(", "self", ",", "ignore", ",", "*", "modules", ")", ":", "for", "module_name", "in", "modules", ":", "module", "=", "importlib", ".", "import_module", "(", "module_name", ")", "if", "hasattr", "(", "module", ",", "'__path__'", ")", ...
52ef732eb3d7bc939d1579faf519314814695c08
train
PythonPackageArchive.add_directory
Add ``*.py`` files under the directory ``path`` to the archive.
c7n/mu.py
def add_directory(self, path, ignore=None): """Add ``*.py`` files under the directory ``path`` to the archive. """ for root, dirs, files in os.walk(path): arc_prefix = os.path.relpath(root, os.path.dirname(path)) # py3 remove pyc cache dirs. if '__pycache__' i...
def add_directory(self, path, ignore=None): """Add ``*.py`` files under the directory ``path`` to the archive. """ for root, dirs, files in os.walk(path): arc_prefix = os.path.relpath(root, os.path.dirname(path)) # py3 remove pyc cache dirs. if '__pycache__' i...
[ "Add", "*", ".", "py", "files", "under", "the", "directory", "path", "to", "the", "archive", "." ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/mu.py#L133-L152
[ "def", "add_directory", "(", "self", ",", "path", ",", "ignore", "=", "None", ")", ":", "for", "root", ",", "dirs", ",", "files", "in", "os", ".", "walk", "(", "path", ")", ":", "arc_prefix", "=", "os", ".", "path", ".", "relpath", "(", "root", "...
52ef732eb3d7bc939d1579faf519314814695c08
train
PythonPackageArchive.add_file
Add the file at ``src`` to the archive. If ``dest`` is ``None`` then it is added under just the original filename. So ``add_file('foo/bar.txt')`` ends up at ``bar.txt`` in the archive, while ``add_file('bar.txt', 'foo/bar.txt')`` ends up at ``foo/bar.txt``.
c7n/mu.py
def add_file(self, src, dest=None): """Add the file at ``src`` to the archive. If ``dest`` is ``None`` then it is added under just the original filename. So ``add_file('foo/bar.txt')`` ends up at ``bar.txt`` in the archive, while ``add_file('bar.txt', 'foo/bar.txt')`` ends up at ...
def add_file(self, src, dest=None): """Add the file at ``src`` to the archive. If ``dest`` is ``None`` then it is added under just the original filename. So ``add_file('foo/bar.txt')`` ends up at ``bar.txt`` in the archive, while ``add_file('bar.txt', 'foo/bar.txt')`` ends up at ...
[ "Add", "the", "file", "at", "src", "to", "the", "archive", "." ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/mu.py#L154-L166
[ "def", "add_file", "(", "self", ",", "src", ",", "dest", "=", "None", ")", ":", "dest", "=", "dest", "or", "os", ".", "path", ".", "basename", "(", "src", ")", "with", "open", "(", "src", ",", "'rb'", ")", "as", "fp", ":", "contents", "=", "fp"...
52ef732eb3d7bc939d1579faf519314814695c08
train
PythonPackageArchive.add_py_file
This is a special case of :py:meth:`add_file` that helps for adding a ``py`` when a ``pyc`` may be present as well. So for example, if ``__file__`` is ``foo.pyc`` and you do: .. code-block:: python archive.add_py_file(__file__) then this method will add ``foo.py`` instead if...
c7n/mu.py
def add_py_file(self, src, dest=None): """This is a special case of :py:meth:`add_file` that helps for adding a ``py`` when a ``pyc`` may be present as well. So for example, if ``__file__`` is ``foo.pyc`` and you do: .. code-block:: python archive.add_py_file(__file__) ...
def add_py_file(self, src, dest=None): """This is a special case of :py:meth:`add_file` that helps for adding a ``py`` when a ``pyc`` may be present as well. So for example, if ``__file__`` is ``foo.pyc`` and you do: .. code-block:: python archive.add_py_file(__file__) ...
[ "This", "is", "a", "special", "case", "of", ":", "py", ":", "meth", ":", "add_file", "that", "helps", "for", "adding", "a", "py", "when", "a", "pyc", "may", "be", "present", "as", "well", ".", "So", "for", "example", "if", "__file__", "is", "foo", ...
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/mu.py#L168-L182
[ "def", "add_py_file", "(", "self", ",", "src", ",", "dest", "=", "None", ")", ":", "src", "=", "src", "[", ":", "-", "1", "]", "if", "src", ".", "endswith", "(", "'.pyc'", ")", "else", "src", "self", ".", "add_file", "(", "src", ",", "dest", ")...
52ef732eb3d7bc939d1579faf519314814695c08
train
PythonPackageArchive.add_contents
Add file contents to the archive under ``dest``. If ``dest`` is a path, it will be added compressed and world-readable (user-writeable). You may also pass a :py:class:`~zipfile.ZipInfo` for custom behavior.
c7n/mu.py
def add_contents(self, dest, contents): """Add file contents to the archive under ``dest``. If ``dest`` is a path, it will be added compressed and world-readable (user-writeable). You may also pass a :py:class:`~zipfile.ZipInfo` for custom behavior. """ assert not self....
def add_contents(self, dest, contents): """Add file contents to the archive under ``dest``. If ``dest`` is a path, it will be added compressed and world-readable (user-writeable). You may also pass a :py:class:`~zipfile.ZipInfo` for custom behavior. """ assert not self....
[ "Add", "file", "contents", "to", "the", "archive", "under", "dest", "." ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/mu.py#L184-L199
[ "def", "add_contents", "(", "self", ",", "dest", ",", "contents", ")", ":", "assert", "not", "self", ".", "_closed", ",", "\"Archive closed\"", "if", "not", "isinstance", "(", "dest", ",", "zipfile", ".", "ZipInfo", ")", ":", "dest", "=", "zinfo", "(", ...
52ef732eb3d7bc939d1579faf519314814695c08
train
PythonPackageArchive.close
Close the zip file. Note underlying tempfile is removed when archive is garbage collected.
c7n/mu.py
def close(self): """Close the zip file. Note underlying tempfile is removed when archive is garbage collected. """ self._closed = True self._zip_file.close() log.debug( "Created custodian serverless archive size: %0.2fmb", (os.path.getsize(self._t...
def close(self): """Close the zip file. Note underlying tempfile is removed when archive is garbage collected. """ self._closed = True self._zip_file.close() log.debug( "Created custodian serverless archive size: %0.2fmb", (os.path.getsize(self._t...
[ "Close", "the", "zip", "file", "." ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/mu.py#L201-L212
[ "def", "close", "(", "self", ")", ":", "self", ".", "_closed", "=", "True", "self", ".", "_zip_file", ".", "close", "(", ")", "log", ".", "debug", "(", "\"Created custodian serverless archive size: %0.2fmb\"", ",", "(", "os", ".", "path", ".", "getsize", "...
52ef732eb3d7bc939d1579faf519314814695c08
train
PythonPackageArchive.get_checksum
Return the b64 encoded sha256 checksum of the archive.
c7n/mu.py
def get_checksum(self, encoder=base64.b64encode, hasher=hashlib.sha256): """Return the b64 encoded sha256 checksum of the archive.""" assert self._closed, "Archive not closed" with open(self._temp_archive_file.name, 'rb') as fh: return encoder(checksum(fh, hasher())).decode('ascii')
def get_checksum(self, encoder=base64.b64encode, hasher=hashlib.sha256): """Return the b64 encoded sha256 checksum of the archive.""" assert self._closed, "Archive not closed" with open(self._temp_archive_file.name, 'rb') as fh: return encoder(checksum(fh, hasher())).decode('ascii')
[ "Return", "the", "b64", "encoded", "sha256", "checksum", "of", "the", "archive", "." ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/mu.py#L219-L223
[ "def", "get_checksum", "(", "self", ",", "encoder", "=", "base64", ".", "b64encode", ",", "hasher", "=", "hashlib", ".", "sha256", ")", ":", "assert", "self", ".", "_closed", ",", "\"Archive not closed\"", "with", "open", "(", "self", ".", "_temp_archive_fil...
52ef732eb3d7bc939d1579faf519314814695c08
train
PythonPackageArchive.get_reader
Return a read-only :py:class:`~zipfile.ZipFile`.
c7n/mu.py
def get_reader(self): """Return a read-only :py:class:`~zipfile.ZipFile`.""" assert self._closed, "Archive not closed" buf = io.BytesIO(self.get_bytes()) return zipfile.ZipFile(buf, mode='r')
def get_reader(self): """Return a read-only :py:class:`~zipfile.ZipFile`.""" assert self._closed, "Archive not closed" buf = io.BytesIO(self.get_bytes()) return zipfile.ZipFile(buf, mode='r')
[ "Return", "a", "read", "-", "only", ":", "py", ":", "class", ":", "~zipfile", ".", "ZipFile", "." ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/mu.py#L235-L239
[ "def", "get_reader", "(", "self", ")", ":", "assert", "self", ".", "_closed", ",", "\"Archive not closed\"", "buf", "=", "io", ".", "BytesIO", "(", "self", ".", "get_bytes", "(", ")", ")", "return", "zipfile", ".", "ZipFile", "(", "buf", ",", "mode", "...
52ef732eb3d7bc939d1579faf519314814695c08
train
LambdaManager.publish_alias
Create or update an alias for the given function.
c7n/mu.py
def publish_alias(self, func_data, alias): """Create or update an alias for the given function. """ if not alias: return func_data['FunctionArn'] func_name = func_data['FunctionName'] func_version = func_data['Version'] exists = resource_exists( s...
def publish_alias(self, func_data, alias): """Create or update an alias for the given function. """ if not alias: return func_data['FunctionArn'] func_name = func_data['FunctionName'] func_version = func_data['Version'] exists = resource_exists( s...
[ "Create", "or", "update", "an", "alias", "for", "the", "given", "function", "." ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/mu.py#L520-L546
[ "def", "publish_alias", "(", "self", ",", "func_data", ",", "alias", ")", ":", "if", "not", "alias", ":", "return", "func_data", "[", "'FunctionArn'", "]", "func_name", "=", "func_data", "[", "'FunctionName'", "]", "func_version", "=", "func_data", "[", "'Ve...
52ef732eb3d7bc939d1579faf519314814695c08
train
row_factory
Returns a sqlite row factory that returns a dictionary
tools/sandbox/zerodark/zerodark/utils.py
def row_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 row_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
[ "Returns", "a", "sqlite", "row", "factory", "that", "returns", "a", "dictionary" ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/sandbox/zerodark/zerodark/utils.py#L25-L30
[ "def", "row_factory", "(", "cursor", ",", "row", ")", ":", "d", "=", "{", "}", "for", "idx", ",", "col", "in", "enumerate", "(", "cursor", ".", "description", ")", ":", "d", "[", "col", "[", "0", "]", "]", "=", "row", "[", "idx", "]", "return",...
52ef732eb3d7bc939d1579faf519314814695c08
train
TagHelper.get_tag_value
Get the resource's tag value.
tools/c7n_azure/c7n_azure/tags.py
def get_tag_value(resource, tag, utf_8=False): """Get the resource's tag value.""" tags = {k.lower(): v for k, v in resource.get('tags', {}).items()} value = tags.get(tag, False) if value is not False: if utf_8: value = value.encode('utf8').decode('u...
def get_tag_value(resource, tag, utf_8=False): """Get the resource's tag value.""" tags = {k.lower(): v for k, v in resource.get('tags', {}).items()} value = tags.get(tag, False) if value is not False: if utf_8: value = value.encode('utf8').decode('u...
[ "Get", "the", "resource", "s", "tag", "value", "." ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_azure/c7n_azure/tags.py#L99-L108
[ "def", "get_tag_value", "(", "resource", ",", "tag", ",", "utf_8", "=", "False", ")", ":", "tags", "=", "{", "k", ".", "lower", "(", ")", ":", "v", "for", "k", ",", "v", "in", "resource", ".", "get", "(", "'tags'", ",", "{", "}", ")", ".", "i...
52ef732eb3d7bc939d1579faf519314814695c08
train
report
report on guard duty enablement by account
tools/c7n_guardian/c7n_guardian/cli.py
def report(config, tags, accounts, master, debug, region): """report on guard duty enablement by account""" accounts_config, master_info, executor = guardian_init( config, debug, master, accounts, tags) session = get_session( master_info.get('role'), 'c7n-guardian', master_info.get(...
def report(config, tags, accounts, master, debug, region): """report on guard duty enablement by account""" accounts_config, master_info, executor = guardian_init( config, debug, master, accounts, tags) session = get_session( master_info.get('role'), 'c7n-guardian', master_info.get(...
[ "report", "on", "guard", "duty", "enablement", "by", "account" ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_guardian/c7n_guardian/cli.py#L52-L88
[ "def", "report", "(", "config", ",", "tags", ",", "accounts", ",", "master", ",", "debug", ",", "region", ")", ":", "accounts_config", ",", "master_info", ",", "executor", "=", "guardian_init", "(", "config", ",", "debug", ",", "master", ",", "accounts", ...
52ef732eb3d7bc939d1579faf519314814695c08
train
disable
suspend guard duty in the given accounts.
tools/c7n_guardian/c7n_guardian/cli.py
def disable(config, tags, accounts, master, debug, suspend, disable_detector, delete_detector, dissociate, region): """suspend guard duty in the given accounts.""" accounts_config, master_info, executor = guardian_init( config, debug, master, accounts, tags) if sum(map(int, (suspend, di...
def disable(config, tags, accounts, master, debug, suspend, disable_detector, delete_detector, dissociate, region): """suspend guard duty in the given accounts.""" accounts_config, master_info, executor = guardian_init( config, debug, master, accounts, tags) if sum(map(int, (suspend, di...
[ "suspend", "guard", "duty", "in", "the", "given", "accounts", "." ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_guardian/c7n_guardian/cli.py#L106-L167
[ "def", "disable", "(", "config", ",", "tags", ",", "accounts", ",", "master", ",", "debug", ",", "suspend", ",", "disable_detector", ",", "delete_detector", ",", "dissociate", ",", "region", ")", ":", "accounts_config", ",", "master_info", ",", "executor", "...
52ef732eb3d7bc939d1579faf519314814695c08
train
enable
enable guard duty on a set of accounts
tools/c7n_guardian/c7n_guardian/cli.py
def enable(config, master, tags, accounts, debug, message, region): """enable guard duty on a set of accounts""" accounts_config, master_info, executor = guardian_init( config, debug, master, accounts, tags) regions = expand_regions(region) for r in regions: log.info("Processing Region:%...
def enable(config, master, tags, accounts, debug, message, region): """enable guard duty on a set of accounts""" accounts_config, master_info, executor = guardian_init( config, debug, master, accounts, tags) regions = expand_regions(region) for r in regions: log.info("Processing Region:%...
[ "enable", "guard", "duty", "on", "a", "set", "of", "accounts" ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_guardian/c7n_guardian/cli.py#L195-L202
[ "def", "enable", "(", "config", ",", "master", ",", "tags", ",", "accounts", ",", "debug", ",", "message", ",", "region", ")", ":", "accounts_config", ",", "master_info", ",", "executor", "=", "guardian_init", "(", "config", ",", "debug", ",", "master", ...
52ef732eb3d7bc939d1579faf519314814695c08
train
ModifyVpcSecurityGroupsAction.get_action_group_names
Return all the security group names configured in this action.
c7n/actions/network.py
def get_action_group_names(self): """Return all the security group names configured in this action.""" return self.get_group_names( list(itertools.chain( *[self._get_array('add'), self._get_array('remove'), self._get_array('isolation-group'...
def get_action_group_names(self): """Return all the security group names configured in this action.""" return self.get_group_names( list(itertools.chain( *[self._get_array('add'), self._get_array('remove'), self._get_array('isolation-group'...
[ "Return", "all", "the", "security", "group", "names", "configured", "in", "this", "action", "." ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/actions/network.py#L107-L113
[ "def", "get_action_group_names", "(", "self", ")", ":", "return", "self", ".", "get_group_names", "(", "list", "(", "itertools", ".", "chain", "(", "*", "[", "self", ".", "_get_array", "(", "'add'", ")", ",", "self", ".", "_get_array", "(", "'remove'", "...
52ef732eb3d7bc939d1579faf519314814695c08
train
ModifyVpcSecurityGroupsAction.get_groups_by_names
Resolve security names to security groups resources.
c7n/actions/network.py
def get_groups_by_names(self, names): """Resolve security names to security groups resources.""" if not names: return [] client = utils.local_session( self.manager.session_factory).client('ec2') sgs = self.manager.retry( client.describe_security_groups...
def get_groups_by_names(self, names): """Resolve security names to security groups resources.""" if not names: return [] client = utils.local_session( self.manager.session_factory).client('ec2') sgs = self.manager.retry( client.describe_security_groups...
[ "Resolve", "security", "names", "to", "security", "groups", "resources", "." ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/actions/network.py#L128-L150
[ "def", "get_groups_by_names", "(", "self", ",", "names", ")", ":", "if", "not", "names", ":", "return", "[", "]", "client", "=", "utils", ".", "local_session", "(", "self", ".", "manager", ".", "session_factory", ")", ".", "client", "(", "'ec2'", ")", ...
52ef732eb3d7bc939d1579faf519314814695c08
train
ModifyVpcSecurityGroupsAction.resolve_group_names
Resolve any security group names to the corresponding group ids With the context of a given network attached resource.
c7n/actions/network.py
def resolve_group_names(self, r, target_group_ids, groups): """Resolve any security group names to the corresponding group ids With the context of a given network attached resource. """ names = self.get_group_names(target_group_ids) if not names: return target_group_...
def resolve_group_names(self, r, target_group_ids, groups): """Resolve any security group names to the corresponding group ids With the context of a given network attached resource. """ names = self.get_group_names(target_group_ids) if not names: return target_group_...
[ "Resolve", "any", "security", "group", "names", "to", "the", "corresponding", "group", "ids" ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/actions/network.py#L152-L182
[ "def", "resolve_group_names", "(", "self", ",", "r", ",", "target_group_ids", ",", "groups", ")", ":", "names", "=", "self", ".", "get_group_names", "(", "target_group_ids", ")", "if", "not", "names", ":", "return", "target_group_ids", "target_group_ids", "=", ...
52ef732eb3d7bc939d1579faf519314814695c08
train
ModifyVpcSecurityGroupsAction.resolve_remove_symbols
Resolve the resources security groups that need be modified. Specifically handles symbolic names that match annotations from policy filters for groups being removed.
c7n/actions/network.py
def resolve_remove_symbols(self, r, target_group_ids, rgroups): """Resolve the resources security groups that need be modified. Specifically handles symbolic names that match annotations from policy filters for groups being removed. """ if 'matched' in target_group_ids: ...
def resolve_remove_symbols(self, r, target_group_ids, rgroups): """Resolve the resources security groups that need be modified. Specifically handles symbolic names that match annotations from policy filters for groups being removed. """ if 'matched' in target_group_ids: ...
[ "Resolve", "the", "resources", "security", "groups", "that", "need", "be", "modified", "." ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/actions/network.py#L184-L198
[ "def", "resolve_remove_symbols", "(", "self", ",", "r", ",", "target_group_ids", ",", "rgroups", ")", ":", "if", "'matched'", "in", "target_group_ids", ":", "return", "r", ".", "get", "(", "'c7n:matched-security-groups'", ",", "(", ")", ")", "elif", "'network-...
52ef732eb3d7bc939d1579faf519314814695c08
train
ModifyVpcSecurityGroupsAction.get_groups
Return lists of security groups to set on each resource For each input resource, parse the various add/remove/isolation- group policies for 'modify-security-groups' to find the resulting set of VPC security groups to attach to that resource. Returns a list of lists containing the resul...
c7n/actions/network.py
def get_groups(self, resources): """Return lists of security groups to set on each resource For each input resource, parse the various add/remove/isolation- group policies for 'modify-security-groups' to find the resulting set of VPC security groups to attach to that resource. ...
def get_groups(self, resources): """Return lists of security groups to set on each resource For each input resource, parse the various add/remove/isolation- group policies for 'modify-security-groups' to find the resulting set of VPC security groups to attach to that resource. ...
[ "Return", "lists", "of", "security", "groups", "to", "set", "on", "each", "resource" ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/actions/network.py#L200-L241
[ "def", "get_groups", "(", "self", ",", "resources", ")", ":", "resolved_groups", "=", "self", ".", "get_groups_by_names", "(", "self", ".", "get_action_group_names", "(", ")", ")", "return_groups", "=", "[", "]", "for", "idx", ",", "r", "in", "enumerate", ...
52ef732eb3d7bc939d1579faf519314814695c08
train
type_schema
jsonschema generation helper params: - type_name: name of the type - inherits: list of document fragments that are required via anyOf[$ref] - rinherit: use another schema as a base for this, basically work around inherits issues with additionalProperties and type enums. - alias...
c7n/utils.py
def type_schema( type_name, inherits=None, rinherit=None, aliases=None, required=None, **props): """jsonschema generation helper params: - type_name: name of the type - inherits: list of document fragments that are required via anyOf[$ref] - rinherit: use another schema as a base...
def type_schema( type_name, inherits=None, rinherit=None, aliases=None, required=None, **props): """jsonschema generation helper params: - type_name: name of the type - inherits: list of document fragments that are required via anyOf[$ref] - rinherit: use another schema as a base...
[ "jsonschema", "generation", "helper" ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/utils.py#L130-L174
[ "def", "type_schema", "(", "type_name", ",", "inherits", "=", "None", ",", "rinherit", "=", "None", ",", "aliases", "=", "None", ",", "required", "=", "None", ",", "*", "*", "props", ")", ":", "if", "aliases", ":", "type_names", "=", "[", "type_name", ...
52ef732eb3d7bc939d1579faf519314814695c08
train
group_by
Return a mapping of key value to resources with the corresponding value. Key may be specified as dotted form for nested dictionary lookup
c7n/utils.py
def group_by(resources, key): """Return a mapping of key value to resources with the corresponding value. Key may be specified as dotted form for nested dictionary lookup """ resource_map = {} parts = key.split('.') for r in resources: v = r for k in parts: v = v.get...
def group_by(resources, key): """Return a mapping of key value to resources with the corresponding value. Key may be specified as dotted form for nested dictionary lookup """ resource_map = {} parts = key.split('.') for r in resources: v = r for k in parts: v = v.get...
[ "Return", "a", "mapping", "of", "key", "value", "to", "resources", "with", "the", "corresponding", "value", "." ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/utils.py#L185-L199
[ "def", "group_by", "(", "resources", ",", "key", ")", ":", "resource_map", "=", "{", "}", "parts", "=", "key", ".", "split", "(", "'.'", ")", "for", "r", "in", "resources", ":", "v", "=", "r", "for", "k", "in", "parts", ":", "v", "=", "v", ".",...
52ef732eb3d7bc939d1579faf519314814695c08
train
camelResource
Some sources from apis return lowerCased where as describe calls always return TitleCase, this function turns the former to the later
c7n/utils.py
def camelResource(obj): """Some sources from apis return lowerCased where as describe calls always return TitleCase, this function turns the former to the later """ if not isinstance(obj, dict): return obj for k in list(obj.keys()): v = obj.pop(k) obj["%s%s" % (k[0].upper(),...
def camelResource(obj): """Some sources from apis return lowerCased where as describe calls always return TitleCase, this function turns the former to the later """ if not isinstance(obj, dict): return obj for k in list(obj.keys()): v = obj.pop(k) obj["%s%s" % (k[0].upper(),...
[ "Some", "sources", "from", "apis", "return", "lowerCased", "where", "as", "describe", "calls" ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/utils.py#L214-L228
[ "def", "camelResource", "(", "obj", ")", ":", "if", "not", "isinstance", "(", "obj", ",", "dict", ")", ":", "return", "obj", "for", "k", "in", "list", "(", "obj", ".", "keys", "(", ")", ")", ":", "v", "=", "obj", ".", "pop", "(", "k", ")", "o...
52ef732eb3d7bc939d1579faf519314814695c08
train
query_instances
Return a list of ec2 instances for the query.
c7n/utils.py
def query_instances(session, client=None, **query): """Return a list of ec2 instances for the query. """ if client is None: client = session.client('ec2') p = client.get_paginator('describe_instances') results = p.paginate(**query) return list(itertools.chain( *[r["Instances"] fo...
def query_instances(session, client=None, **query): """Return a list of ec2 instances for the query. """ if client is None: client = session.client('ec2') p = client.get_paginator('describe_instances') results = p.paginate(**query) return list(itertools.chain( *[r["Instances"] fo...
[ "Return", "a", "list", "of", "ec2", "instances", "for", "the", "query", "." ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/utils.py#L242-L251
[ "def", "query_instances", "(", "session", ",", "client", "=", "None", ",", "*", "*", "query", ")", ":", "if", "client", "is", "None", ":", "client", "=", "session", ".", "client", "(", "'ec2'", ")", "p", "=", "client", ".", "get_paginator", "(", "'de...
52ef732eb3d7bc939d1579faf519314814695c08
train
local_session
Cache a session thread local for up to 45m
c7n/utils.py
def local_session(factory): """Cache a session thread local for up to 45m""" factory_region = getattr(factory, 'region', 'global') s = getattr(CONN_CACHE, factory_region, {}).get('session') t = getattr(CONN_CACHE, factory_region, {}).get('time') n = time.time() if s is not None and t + (60 * 45...
def local_session(factory): """Cache a session thread local for up to 45m""" factory_region = getattr(factory, 'region', 'global') s = getattr(CONN_CACHE, factory_region, {}).get('session') t = getattr(CONN_CACHE, factory_region, {}).get('time') n = time.time() if s is not None and t + (60 * 45...
[ "Cache", "a", "session", "thread", "local", "for", "up", "to", "45m" ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/utils.py#L257-L269
[ "def", "local_session", "(", "factory", ")", ":", "factory_region", "=", "getattr", "(", "factory", ",", "'region'", ",", "'global'", ")", "s", "=", "getattr", "(", "CONN_CACHE", ",", "factory_region", ",", "{", "}", ")", ".", "get", "(", "'session'", ")...
52ef732eb3d7bc939d1579faf519314814695c08
train
set_annotation
>>> x = {} >>> set_annotation(x, 'marker', 'a') >>> annotation(x, 'marker') ['a']
c7n/utils.py
def set_annotation(i, k, v): """ >>> x = {} >>> set_annotation(x, 'marker', 'a') >>> annotation(x, 'marker') ['a'] """ if not isinstance(i, dict): raise ValueError("Can only annotate dictionaries") if not isinstance(v, list): v = [v] if k in i: ev = i.get(k)...
def set_annotation(i, k, v): """ >>> x = {} >>> set_annotation(x, 'marker', 'a') >>> annotation(x, 'marker') ['a'] """ if not isinstance(i, dict): raise ValueError("Can only annotate dictionaries") if not isinstance(v, list): v = [v] if k in i: ev = i.get(k)...
[ ">>>", "x", "=", "{}", ">>>", "set_annotation", "(", "x", "marker", "a", ")", ">>>", "annotation", "(", "x", "marker", ")", "[", "a", "]" ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/utils.py#L281-L299
[ "def", "set_annotation", "(", "i", ",", "k", ",", "v", ")", ":", "if", "not", "isinstance", "(", "i", ",", "dict", ")", ":", "raise", "ValueError", "(", "\"Can only annotate dictionaries\"", ")", "if", "not", "isinstance", "(", "v", ",", "list", ")", "...
52ef732eb3d7bc939d1579faf519314814695c08
train
generate_arn
Generate an Amazon Resource Name. See http://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html.
c7n/utils.py
def generate_arn( service, resource, partition='aws', region=None, account_id=None, resource_type=None, separator='/'): """Generate an Amazon Resource Name. See http://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html. """ if region and region in REGION_PARTITION_MAP: ...
def generate_arn( service, resource, partition='aws', region=None, account_id=None, resource_type=None, separator='/'): """Generate an Amazon Resource Name. See http://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html. """ if region and region in REGION_PARTITION_MAP: ...
[ "Generate", "an", "Amazon", "Resource", "Name", ".", "See", "http", ":", "//", "docs", ".", "aws", ".", "amazon", ".", "com", "/", "general", "/", "latest", "/", "gr", "/", "aws", "-", "arns", "-", "and", "-", "namespaces", ".", "html", "." ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/utils.py#L325-L341
[ "def", "generate_arn", "(", "service", ",", "resource", ",", "partition", "=", "'aws'", ",", "region", "=", "None", ",", "account_id", "=", "None", ",", "resource_type", "=", "None", ",", "separator", "=", "'/'", ")", ":", "if", "region", "and", "region"...
52ef732eb3d7bc939d1579faf519314814695c08
train
snapshot_identifier
Return an identifier for a snapshot of a database or cluster.
c7n/utils.py
def snapshot_identifier(prefix, db_identifier): """Return an identifier for a snapshot of a database or cluster. """ now = datetime.now() return '%s-%s-%s' % (prefix, db_identifier, now.strftime('%Y-%m-%d-%H-%M'))
def snapshot_identifier(prefix, db_identifier): """Return an identifier for a snapshot of a database or cluster. """ now = datetime.now() return '%s-%s-%s' % (prefix, db_identifier, now.strftime('%Y-%m-%d-%H-%M'))
[ "Return", "an", "identifier", "for", "a", "snapshot", "of", "a", "database", "or", "cluster", "." ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/utils.py#L344-L348
[ "def", "snapshot_identifier", "(", "prefix", ",", "db_identifier", ")", ":", "now", "=", "datetime", ".", "now", "(", ")", "return", "'%s-%s-%s'", "%", "(", "prefix", ",", "db_identifier", ",", "now", ".", "strftime", "(", "'%Y-%m-%d-%H-%M'", ")", ")" ]
52ef732eb3d7bc939d1579faf519314814695c08
train
get_retry
Decorator for retry boto3 api call on transient errors. https://www.awsarchitectureblog.com/2015/03/backoff.html https://en.wikipedia.org/wiki/Exponential_backoff :param codes: A sequence of retryable error codes. :param max_attempts: The max number of retries, by default the delay time is ...
c7n/utils.py
def get_retry(codes=(), max_attempts=8, min_delay=1, log_retries=False): """Decorator for retry boto3 api call on transient errors. https://www.awsarchitectureblog.com/2015/03/backoff.html https://en.wikipedia.org/wiki/Exponential_backoff :param codes: A sequence of retryable error codes. :param m...
def get_retry(codes=(), max_attempts=8, min_delay=1, log_retries=False): """Decorator for retry boto3 api call on transient errors. https://www.awsarchitectureblog.com/2015/03/backoff.html https://en.wikipedia.org/wiki/Exponential_backoff :param codes: A sequence of retryable error codes. :param m...
[ "Decorator", "for", "retry", "boto3", "api", "call", "on", "transient", "errors", "." ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/utils.py#L351-L387
[ "def", "get_retry", "(", "codes", "=", "(", ")", ",", "max_attempts", "=", "8", ",", "min_delay", "=", "1", ",", "log_retries", "=", "False", ")", ":", "max_delay", "=", "max", "(", "min_delay", ",", "2", ")", "**", "max_attempts", "def", "_retry", "...
52ef732eb3d7bc939d1579faf519314814695c08
train
backoff_delays
Geometric backoff sequence w/ jitter
c7n/utils.py
def backoff_delays(start, stop, factor=2.0, jitter=False): """Geometric backoff sequence w/ jitter """ cur = start while cur <= stop: if jitter: yield cur - (cur * random.random()) else: yield cur cur = cur * factor
def backoff_delays(start, stop, factor=2.0, jitter=False): """Geometric backoff sequence w/ jitter """ cur = start while cur <= stop: if jitter: yield cur - (cur * random.random()) else: yield cur cur = cur * factor
[ "Geometric", "backoff", "sequence", "w", "/", "jitter" ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/utils.py#L390-L399
[ "def", "backoff_delays", "(", "start", ",", "stop", ",", "factor", "=", "2.0", ",", "jitter", "=", "False", ")", ":", "cur", "=", "start", "while", "cur", "<=", "stop", ":", "if", "jitter", ":", "yield", "cur", "-", "(", "cur", "*", "random", ".", ...
52ef732eb3d7bc939d1579faf519314814695c08
train
parse_cidr
Process cidr ranges.
c7n/utils.py
def parse_cidr(value): """Process cidr ranges.""" klass = IPv4Network if '/' not in value: klass = ipaddress.ip_address try: v = klass(six.text_type(value)) except (ipaddress.AddressValueError, ValueError): v = None return v
def parse_cidr(value): """Process cidr ranges.""" klass = IPv4Network if '/' not in value: klass = ipaddress.ip_address try: v = klass(six.text_type(value)) except (ipaddress.AddressValueError, ValueError): v = None return v
[ "Process", "cidr", "ranges", "." ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/utils.py#L402-L411
[ "def", "parse_cidr", "(", "value", ")", ":", "klass", "=", "IPv4Network", "if", "'/'", "not", "in", "value", ":", "klass", "=", "ipaddress", ".", "ip_address", "try", ":", "v", "=", "klass", "(", "six", ".", "text_type", "(", "value", ")", ")", "exce...
52ef732eb3d7bc939d1579faf519314814695c08
train
worker
Generic wrapper to log uncaught exceptions in a function. When we cross concurrent.futures executor boundaries we lose our traceback information, and when doing bulk operations we may tolerate transient failures on a partial subset. However we still want to have full accounting of the error in the logs...
c7n/utils.py
def worker(f): """Generic wrapper to log uncaught exceptions in a function. When we cross concurrent.futures executor boundaries we lose our traceback information, and when doing bulk operations we may tolerate transient failures on a partial subset. However we still want to have full accounting of...
def worker(f): """Generic wrapper to log uncaught exceptions in a function. When we cross concurrent.futures executor boundaries we lose our traceback information, and when doing bulk operations we may tolerate transient failures on a partial subset. However we still want to have full accounting of...
[ "Generic", "wrapper", "to", "log", "uncaught", "exceptions", "in", "a", "function", "." ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/utils.py#L428-L446
[ "def", "worker", "(", "f", ")", ":", "def", "_f", "(", "*", "args", ",", "*", "*", "kw", ")", ":", "try", ":", "return", "f", "(", "*", "args", ",", "*", "*", "kw", ")", "except", "Exception", ":", "worker_log", ".", "exception", "(", "'Error i...
52ef732eb3d7bc939d1579faf519314814695c08
train
reformat_schema
Reformat schema to be in a more displayable format.
c7n/utils.py
def reformat_schema(model): """ Reformat schema to be in a more displayable format. """ if not hasattr(model, 'schema'): return "Model '{}' does not have a schema".format(model) if 'properties' not in model.schema: return "Schema in unexpected format." ret = copy.deepcopy(model.schema[...
def reformat_schema(model): """ Reformat schema to be in a more displayable format. """ if not hasattr(model, 'schema'): return "Model '{}' does not have a schema".format(model) if 'properties' not in model.schema: return "Schema in unexpected format." ret = copy.deepcopy(model.schema[...
[ "Reformat", "schema", "to", "be", "in", "a", "more", "displayable", "format", "." ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/utils.py#L449-L466
[ "def", "reformat_schema", "(", "model", ")", ":", "if", "not", "hasattr", "(", "model", ",", "'schema'", ")", ":", "return", "\"Model '{}' does not have a schema\"", ".", "format", "(", "model", ")", "if", "'properties'", "not", "in", "model", ".", "schema", ...
52ef732eb3d7bc939d1579faf519314814695c08
train
format_string_values
Format all string values in an object. Return the updated object
c7n/utils.py
def format_string_values(obj, err_fallback=(IndexError, KeyError), *args, **kwargs): """ Format all string values in an object. Return the updated object """ if isinstance(obj, dict): new = {} for key in obj.keys(): new[key] = format_string_values(obj[key], *args, **kwarg...
def format_string_values(obj, err_fallback=(IndexError, KeyError), *args, **kwargs): """ Format all string values in an object. Return the updated object """ if isinstance(obj, dict): new = {} for key in obj.keys(): new[key] = format_string_values(obj[key], *args, **kwarg...
[ "Format", "all", "string", "values", "in", "an", "object", ".", "Return", "the", "updated", "object" ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/utils.py#L501-L522
[ "def", "format_string_values", "(", "obj", ",", "err_fallback", "=", "(", "IndexError", ",", "KeyError", ")", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "isinstance", "(", "obj", ",", "dict", ")", ":", "new", "=", "{", "}", "for", "...
52ef732eb3d7bc939d1579faf519314814695c08
train
DescribeDaxCluster.get_resources
Retrieve dax resources for serverless policies or related resources
c7n/resources/dynamodb.py
def get_resources(self, ids, cache=True): """Retrieve dax resources for serverless policies or related resources """ client = local_session(self.manager.session_factory).client('dax') return client.describe_clusters(ClusterNames=ids).get('Clusters')
def get_resources(self, ids, cache=True): """Retrieve dax resources for serverless policies or related resources """ client = local_session(self.manager.session_factory).client('dax') return client.describe_clusters(ClusterNames=ids).get('Clusters')
[ "Retrieve", "dax", "resources", "for", "serverless", "policies", "or", "related", "resources" ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/resources/dynamodb.py#L435-L439
[ "def", "get_resources", "(", "self", ",", "ids", ",", "cache", "=", "True", ")", ":", "client", "=", "local_session", "(", "self", ".", "manager", ".", "session_factory", ")", ".", "client", "(", "'dax'", ")", "return", "client", ".", "describe_clusters", ...
52ef732eb3d7bc939d1579faf519314814695c08
train
main
Generate a c7n-org gcp projects config file
tools/c7n_org/scripts/gcpprojects.py
def main(output): """ Generate a c7n-org gcp projects config file """ client = Session().client('cloudresourcemanager', 'v1', 'projects') results = [] for page in client.execute_paged_query('list', {}): for project in page.get('projects', []): if project['lifecycleState'] ...
def main(output): """ Generate a c7n-org gcp projects config file """ client = Session().client('cloudresourcemanager', 'v1', 'projects') results = [] for page in client.execute_paged_query('list', {}): for project in page.get('projects', []): if project['lifecycleState'] ...
[ "Generate", "a", "c7n", "-", "org", "gcp", "projects", "config", "file" ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_org/scripts/gcpprojects.py#L27-L52
[ "def", "main", "(", "output", ")", ":", "client", "=", "Session", "(", ")", ".", "client", "(", "'cloudresourcemanager'", ",", "'v1'", ",", "'projects'", ")", "results", "=", "[", "]", "for", "page", "in", "client", ".", "execute_paged_query", "(", "'lis...
52ef732eb3d7bc939d1579faf519314814695c08
train
ChildResourceQuery.filter
Query a set of resources.
tools/c7n_azure/c7n_azure/query.py
def filter(self, resource_manager, **params): """Query a set of resources.""" m = self.resolve(resource_manager.resource_type) client = resource_manager.get_client() enum_op, list_op, extra_args = m.enum_spec parent_type, annotate_parent = m.parent_spec parents = self.m...
def filter(self, resource_manager, **params): """Query a set of resources.""" m = self.resolve(resource_manager.resource_type) client = resource_manager.get_client() enum_op, list_op, extra_args = m.enum_spec parent_type, annotate_parent = m.parent_spec parents = self.m...
[ "Query", "a", "set", "of", "resources", "." ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_azure/c7n_azure/query.py#L81-L106
[ "def", "filter", "(", "self", ",", "resource_manager", ",", "*", "*", "params", ")", ":", "m", "=", "self", ".", "resolve", "(", "resource_manager", ".", "resource_type", ")", "client", "=", "resource_manager", ".", "get_client", "(", ")", "enum_op", ",", ...
52ef732eb3d7bc939d1579faf519314814695c08
train
MultiAttrFilter.get_attr_filters
Return an iterator resource attribute filters configured.
c7n/filters/multiattr.py
def get_attr_filters(self): """Return an iterator resource attribute filters configured. """ for f in self.data.keys(): if f not in self.multi_attrs: continue fv = self.data[f] if isinstance(fv, dict): fv['key'] = f ...
def get_attr_filters(self): """Return an iterator resource attribute filters configured. """ for f in self.data.keys(): if f not in self.multi_attrs: continue fv = self.data[f] if isinstance(fv, dict): fv['key'] = f ...
[ "Return", "an", "iterator", "resource", "attribute", "filters", "configured", "." ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/filters/multiattr.py#L48-L61
[ "def", "get_attr_filters", "(", "self", ")", ":", "for", "f", "in", "self", ".", "data", ".", "keys", "(", ")", ":", "if", "f", "not", "in", "self", ".", "multi_attrs", ":", "continue", "fv", "=", "self", ".", "data", "[", "f", "]", "if", "isinst...
52ef732eb3d7bc939d1579faf519314814695c08
train
cloudtrail_policy
add CloudTrail permissions to an S3 policy, preserving existing
c7n/resources/account.py
def cloudtrail_policy(original, bucket_name, account_id, bucket_region): '''add CloudTrail permissions to an S3 policy, preserving existing''' ct_actions = [ { 'Action': 's3:GetBucketAcl', 'Effect': 'Allow', 'Principal': {'Service': 'cloudtrail.amazonaws.com'}, ...
def cloudtrail_policy(original, bucket_name, account_id, bucket_region): '''add CloudTrail permissions to an S3 policy, preserving existing''' ct_actions = [ { 'Action': 's3:GetBucketAcl', 'Effect': 'Allow', 'Principal': {'Service': 'cloudtrail.amazonaws.com'}, ...
[ "add", "CloudTrail", "permissions", "to", "an", "S3", "policy", "preserving", "existing" ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/resources/account.py#L654-L690
[ "def", "cloudtrail_policy", "(", "original", ",", "bucket_name", ",", "account_id", ",", "bucket_region", ")", ":", "ct_actions", "=", "[", "{", "'Action'", ":", "'s3:GetBucketAcl'", ",", "'Effect'", ":", "'Allow'", ",", "'Principal'", ":", "{", "'Service'", "...
52ef732eb3d7bc939d1579faf519314814695c08
train
_get_available_engine_upgrades
Returns all extant rds engine upgrades. As a nested mapping of engine type to known versions and their upgrades. Defaults to minor upgrades, but configurable to major. Example:: >>> _get_engine_upgrades(client) { 'oracle-se2': {'12.1.0.2.v2': '12.1.0.2.v5', ...
c7n/resources/rds.py
def _get_available_engine_upgrades(client, major=False): """Returns all extant rds engine upgrades. As a nested mapping of engine type to known versions and their upgrades. Defaults to minor upgrades, but configurable to major. Example:: >>> _get_engine_upgrades(client) { 'o...
def _get_available_engine_upgrades(client, major=False): """Returns all extant rds engine upgrades. As a nested mapping of engine type to known versions and their upgrades. Defaults to minor upgrades, but configurable to major. Example:: >>> _get_engine_upgrades(client) { 'o...
[ "Returns", "all", "extant", "rds", "engine", "upgrades", "." ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/resources/rds.py#L224-L257
[ "def", "_get_available_engine_upgrades", "(", "client", ",", "major", "=", "False", ")", ":", "results", "=", "{", "}", "engine_versions", "=", "client", ".", "describe_db_engine_versions", "(", ")", "[", "'DBEngineVersions'", "]", "for", "v", "in", "engine_vers...
52ef732eb3d7bc939d1579faf519314814695c08
train
get_local_output_dir
Create a local output directory per execution. We've seen occassional (1/100000) perm issues with lambda on temp directory and changing unix execution users (2015-2018), so use a per execution temp space. With firecracker lambdas this may be outdated.
c7n/handler.py
def get_local_output_dir(): """Create a local output directory per execution. We've seen occassional (1/100000) perm issues with lambda on temp directory and changing unix execution users (2015-2018), so use a per execution temp space. With firecracker lambdas this may be outdated. """ output_d...
def get_local_output_dir(): """Create a local output directory per execution. We've seen occassional (1/100000) perm issues with lambda on temp directory and changing unix execution users (2015-2018), so use a per execution temp space. With firecracker lambdas this may be outdated. """ output_d...
[ "Create", "a", "local", "output", "directory", "per", "execution", "." ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/handler.py#L65-L78
[ "def", "get_local_output_dir", "(", ")", ":", "output_dir", "=", "os", ".", "environ", ".", "get", "(", "'C7N_OUTPUT_DIR'", ",", "'/tmp/'", "+", "str", "(", "uuid", ".", "uuid4", "(", ")", ")", ")", "if", "not", "os", ".", "path", ".", "exists", "(",...
52ef732eb3d7bc939d1579faf519314814695c08
train
init_config
Get policy lambda execution configuration. cli parameters are serialized into the policy lambda config, we merge those with any policy specific execution options. --assume role and -s output directory get special handling, as to disambiguate any cli context. account id is sourced from the config ...
c7n/handler.py
def init_config(policy_config): """Get policy lambda execution configuration. cli parameters are serialized into the policy lambda config, we merge those with any policy specific execution options. --assume role and -s output directory get special handling, as to disambiguate any cli context. ...
def init_config(policy_config): """Get policy lambda execution configuration. cli parameters are serialized into the policy lambda config, we merge those with any policy specific execution options. --assume role and -s output directory get special handling, as to disambiguate any cli context. ...
[ "Get", "policy", "lambda", "execution", "configuration", "." ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/handler.py#L81-L137
[ "def", "init_config", "(", "policy_config", ")", ":", "global", "account_id", "exec_options", "=", "policy_config", ".", "get", "(", "'execution-options'", ",", "{", "}", ")", "# Remove some configuration options that don't make sense to translate from", "# cli to lambda auto...
52ef732eb3d7bc939d1579faf519314814695c08
train
index_metrics
index policy metrics
tools/sandbox/c7n_index/c7n_index/metrics.py
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', verbose=False): """index policy metrics""" logging.basicConfig(level=(verbose and logging.DEBUG or logging.INFO)) logging.getLogger('botocore').setLevel(logg...
[ "index", "policy", "metrics" ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/sandbox/c7n_index/c7n_index/metrics.py#L403-L477
[ "def", "index_metrics", "(", "config", ",", "start", ",", "end", ",", "incremental", "=", "False", ",", "concurrency", "=", "5", ",", "accounts", "=", "None", ",", "period", "=", "3600", ",", "tag", "=", "None", ",", "index", "=", "'policy-metrics'", "...
52ef732eb3d7bc939d1579faf519314814695c08
train
Diff.transform_revision
make config revision look like describe output.
c7n/filters/revisions.py
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): """make config revision look like describe output.""" config = self.manager.get_source('config') return config.load_resource(revision)
[ "make", "config", "revision", "look", "like", "describe", "output", "." ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/filters/revisions.py#L156-L159
[ "def", "transform_revision", "(", "self", ",", "revision", ")", ":", "config", "=", "self", ".", "manager", ".", "get_source", "(", "'config'", ")", "return", "config", ".", "load_resource", "(", "revision", ")" ]
52ef732eb3d7bc939d1579faf519314814695c08
train
JsonDiff.register_resources
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.
c7n/filters/revisions.py
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): """ 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...
[ "meta", "model", "subscriber", "on", "resource", "registration", "." ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/filters/revisions.py#L186-L195
[ "def", "register_resources", "(", "klass", ",", "registry", ",", "resource_class", ")", ":", "config_type", "=", "getattr", "(", "resource_class", ".", "resource_type", ",", "'config_type'", ",", "None", ")", "if", "config_type", "is", "None", ":", "return", "...
52ef732eb3d7bc939d1579faf519314814695c08
train
_default_options
Add basic options ot the subparser. `blacklist` is a list of options to exclude from the default set. e.g.: ['region', 'log-group']
c7n/cli.py
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=""): """ 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...
[ "Add", "basic", "options", "ot", "the", "subparser", "." ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/cli.py#L44-L111
[ "def", "_default_options", "(", "p", ",", "blacklist", "=", "\"\"", ")", ":", "provider", "=", "p", ".", "add_argument_group", "(", "\"provider\"", ",", "\"AWS account information, defaults per the aws cli\"", ")", "if", "'region'", "not", "in", "blacklist", ":", ...
52ef732eb3d7bc939d1579faf519314814695c08
train
_report_options
Add options specific to the report subcommand.
c7n/cli.py
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): """ 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...
[ "Add", "options", "specific", "to", "the", "report", "subcommand", "." ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/cli.py#L114-L135
[ "def", "_report_options", "(", "p", ")", ":", "_default_options", "(", "p", ",", "blacklist", "=", "[", "'cache'", ",", "'log-group'", ",", "'quiet'", "]", ")", "p", ".", "add_argument", "(", "'--days'", ",", "type", "=", "float", ",", "default", "=", ...
52ef732eb3d7bc939d1579faf519314814695c08
train
_metrics_options
Add options specific to metrics subcommand.
c7n/cli.py
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): """ 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...
[ "Add", "options", "specific", "to", "metrics", "subcommand", "." ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/cli.py#L138-L150
[ "def", "_metrics_options", "(", "p", ")", ":", "_default_options", "(", "p", ",", "blacklist", "=", "[", "'log-group'", ",", "'output-dir'", ",", "'cache'", ",", "'quiet'", "]", ")", "p", ".", "add_argument", "(", "'--start'", ",", "type", "=", "date_parse...
52ef732eb3d7bc939d1579faf519314814695c08
train
_logs_options
Add options specific to logs subcommand.
c7n/cli.py
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): """ 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...
[ "Add", "options", "specific", "to", "logs", "subcommand", "." ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/cli.py#L153-L167
[ "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"...
52ef732eb3d7bc939d1579faf519314814695c08
train
_schema_options
Add options specific to schema subcommand.
c7n/cli.py
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): """ 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...
[ "Add", "options", "specific", "to", "schema", "subcommand", "." ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/cli.py#L178-L190
[ "def", "_schema_options", "(", "p", ")", ":", "p", ".", "add_argument", "(", "'resource'", ",", "metavar", "=", "'selector'", ",", "nargs", "=", "'?'", ",", "default", "=", "None", ")", ".", "completer", "=", "_schema_tab_completer", "p", ".", "add_argumen...
52ef732eb3d7bc939d1579faf519314814695c08
train
_rds_cluster_tags
Augment rds clusters with their respective tags.
c7n/resources/rdscluster.py
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): """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, ...
[ "Augment", "rds", "clusters", "with", "their", "respective", "tags", "." ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/resources/rdscluster.py#L74-L88
[ "def", "_rds_cluster_tags", "(", "model", ",", "dbs", ",", "session_factory", ",", "generator", ",", "retry", ")", ":", "client", "=", "local_session", "(", "session_factory", ")", ".", "client", "(", "'rds'", ")", "def", "process_tags", "(", "db", ")", ":...
52ef732eb3d7bc939d1579faf519314814695c08
train
CredentialReport.process_user_record
Type convert the csv record, modifies in place.
c7n/resources/iam.py
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): """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': ...
[ "Type", "convert", "the", "csv", "record", "modifies", "in", "place", "." ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/resources/iam.py#L1206-L1224
[ "def", "process_user_record", "(", "cls", ",", "info", ")", ":", "keys", "=", "list", "(", "info", ".", "keys", "(", ")", ")", "# Value conversion", "for", "k", "in", "keys", ":", "v", "=", "info", "[", "k", "]", "if", "v", "in", "(", "'N/A'", ",...
52ef732eb3d7bc939d1579faf519314814695c08
train
normalized_log_entries
Mimic the format returned by LambdaManager.logs()
c7n/logs_support.py
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): '''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: ...
[ "Mimic", "the", "format", "returned", "by", "LambdaManager", ".", "logs", "()" ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/logs_support.py#L47-L73
[ "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", ".", ...
52ef732eb3d7bc939d1579faf519314814695c08
train
log_entries_in_range
filter out entries before start and after end
c7n/logs_support.py
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): '''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: ...
[ "filter", "out", "entries", "before", "start", "and", "after", "end" ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/logs_support.py#L76-L83
[ "def", "log_entries_in_range", "(", "entries", ",", "start", ",", "end", ")", ":", "start", "=", "_timestamp_from_string", "(", "start", ")", "end", "=", "_timestamp_from_string", "(", "end", ")", "for", "entry", "in", "entries", ":", "log_timestamp", "=", "...
52ef732eb3d7bc939d1579faf519314814695c08
train
log_entries_from_group
Get logs for a specific log group
c7n/logs_support.py
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): '''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...
[ "Get", "logs", "for", "a", "specific", "log", "group" ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/logs_support.py#L147-L178
[ "def", "log_entries_from_group", "(", "session", ",", "group_name", ",", "start", ",", "end", ")", ":", "logs", "=", "session", ".", "client", "(", "'logs'", ")", "log", ".", "info", "(", "\"Fetching logs from group: %s\"", "%", "group_name", ")", "try", ":"...
52ef732eb3d7bc939d1579faf519314814695c08
train
_create_service_api
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...
tools/c7n_gcp/c7n_gcp/client.py
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): """Builds and returns a cloud API service object. Args: credentials (OAuth2Credentials): Credentials that will be used to authenticate the API calls. ...
[ "Builds", "and", "returns", "a", "cloud", "API", "service", "object", "." ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_gcp/c7n_gcp/client.py#L90-L125
[ "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...
52ef732eb3d7bc939d1579faf519314814695c08
train
_build_http
Construct an http client suitable for googleapiclient usage w/ user agent.
tools/c7n_gcp/c7n_gcp/client.py
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): """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...
[ "Construct", "an", "http", "client", "suitable", "for", "googleapiclient", "usage", "w", "/", "user", "agent", "." ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_gcp/c7n_gcp/client.py#L128-L139
[ "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...
52ef732eb3d7bc939d1579faf519314814695c08
train
Session.client
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.
tools/c7n_gcp/c7n_gcp/client.py
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): """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 ...
[ "Safely", "initialize", "a", "repository", "class", "to", "a", "property", "." ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_gcp/c7n_gcp/client.py#L209-L233
[ "def", "client", "(", "self", ",", "service_name", ",", "version", ",", "component", ",", "*", "*", "kw", ")", ":", "service", "=", "_create_service_api", "(", "self", ".", "_credentials", ",", "service_name", ",", "version", ",", "kw", ".", "get", "(", ...
52ef732eb3d7bc939d1579faf519314814695c08
train
ServiceClient.http
A thread local instance of httplib2.Http. Returns: httplib2.Http: An Http instance authorized by the credentials.
tools/c7n_gcp/c7n_gcp/client.py
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): """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: ...
[ "A", "thread", "local", "instance", "of", "httplib2", ".", "Http", "." ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_gcp/c7n_gcp/client.py#L303-L320
[ "def", "http", "(", "self", ")", ":", "if", "self", ".", "_use_cached_http", "and", "hasattr", "(", "self", ".", "_local", ",", "'http'", ")", ":", "return", "self", ".", "_local", ".", "http", "if", "self", ".", "_http_replay", "is", "not", "None", ...
52ef732eb3d7bc939d1579faf519314814695c08
train
ServiceClient._build_request
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.
tools/c7n_gcp/c7n_gcp/client.py
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): """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...
[ "Builds", "HttpRequest", "object", "." ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_gcp/c7n_gcp/client.py#L328-L345
[ "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 ...
52ef732eb3d7bc939d1579faf519314814695c08
train
ServiceClient._build_next_request
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...
tools/c7n_gcp/c7n_gcp/client.py
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): """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...
[ "Builds", "pagination", "-", "aware", "request", "object", "." ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_gcp/c7n_gcp/client.py#L347-L364
[ "def", "_build_next_request", "(", "self", ",", "verb", ",", "prior_request", ",", "prior_response", ")", ":", "method", "=", "getattr", "(", "self", ".", "_component", ",", "verb", "+", "'_next'", ")", "return", "method", "(", "prior_request", ",", "prior_r...
52ef732eb3d7bc939d1579faf519314814695c08
train
ServiceClient.execute_command
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...
tools/c7n_gcp/c7n_gcp/client.py
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): """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. ...
[ "Executes", "command", "(", "ex", ".", "add", ")", "via", "a", "dedicated", "http", "object", "." ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_gcp/c7n_gcp/client.py#L377-L392
[ "def", "execute_command", "(", "self", ",", "verb", ",", "verb_arguments", ")", ":", "request", "=", "self", ".", "_build_request", "(", "verb", ",", "verb_arguments", ")", "return", "self", ".", "_execute", "(", "request", ")" ]
52ef732eb3d7bc939d1579faf519314814695c08
train
ServiceClient.execute_paged_query
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...
tools/c7n_gcp/c7n_gcp/client.py
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): """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: ...
[ "Executes", "query", "(", "ex", ".", "list", ")", "via", "a", "dedicated", "http", "object", "." ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_gcp/c7n_gcp/client.py#L394-L418
[ "def", "execute_paged_query", "(", "self", ",", "verb", ",", "verb_arguments", ")", ":", "if", "not", "self", ".", "supports_pagination", "(", "verb", "=", "verb", ")", ":", "raise", "PaginationNotSupported", "(", "'{} does not support pagination'", ")", "request"...
52ef732eb3d7bc939d1579faf519314814695c08
train
ServiceClient.execute_search_query
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.
tools/c7n_gcp/c7n_gcp/client.py
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): """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: ...
[ "Executes", "query", "(", "ex", ".", "search", ")", "via", "a", "dedicated", "http", "object", "." ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_gcp/c7n_gcp/client.py#L420-L446
[ "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",...
52ef732eb3d7bc939d1579faf519314814695c08
train
ServiceClient.execute_query
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.
tools/c7n_gcp/c7n_gcp/client.py
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): """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:...
[ "Executes", "query", "(", "ex", ".", "get", ")", "via", "a", "dedicated", "http", "object", "." ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_gcp/c7n_gcp/client.py#L448-L459
[ "def", "execute_query", "(", "self", ",", "verb", ",", "verb_arguments", ")", ":", "request", "=", "self", ".", "_build_request", "(", "verb", ",", "verb_arguments", ")", "return", "self", ".", "_execute", "(", "request", ")" ]
52ef732eb3d7bc939d1579faf519314814695c08
train
ServiceClient._execute
Run execute with retries and rate limiting. Args: request (object): The HttpRequest object to execute. Returns: dict: The response from the API.
tools/c7n_gcp/c7n_gcp/client.py
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): """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...
[ "Run", "execute", "with", "retries", "and", "rate", "limiting", "." ]
cloud-custodian/cloud-custodian
python
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_gcp/c7n_gcp/client.py#L465-L482
[ "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"...
52ef732eb3d7bc939d1579faf519314814695c08