repo
stringlengths
7
54
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
20
28.4k
docstring
stringlengths
1
46.3k
docstring_tokens
listlengths
1
1.66k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
summary
stringlengths
4
350
obf_code
stringlengths
7.85k
764k
cloud-custodian/cloud-custodian
tools/c7n_org/c7n_org/cli.py
run
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...
python
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...
run a custodian policy across accounts
[ "run", "a", "custodian", "policy", "across", "accounts" ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_org/c7n_org/cli.py#L595-L646
train
run a custodian policy across accounts
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
c7n/log.py
CloudWatchLogHandler.emit
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...
python
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", ")", ":", "# 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", ".", ...
Send logs
[ "Send", "logs" ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/log.py#L100-L121
train
Send a message to the log.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
c7n/log.py
CloudWatchLogHandler.flush
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()
python
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", ")", ":", "if", "self", ".", "shutdown", ":", "return", "self", ".", "flush_buffers", "(", "force", "=", "True", ")", "self", ".", "queue", ".", "put", "(", "FLUSH_MARKER", ")", "self", ".", "queue", ".", "join", "(", "...
Ensure all logging output has been flushed.
[ "Ensure", "all", "logging", "output", "has", "been", "flushed", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/log.py#L123-L129
train
Ensure all logging output has been flushed.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
c7n/log.py
CloudWatchLogHandler.format_message
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}
python
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", ")", ":", "return", "{", "'timestamp'", ":", "int", "(", "msg", ".", "created", "*", "1000", ")", ",", "'message'", ":", "self", ".", "format", "(", "msg", ")", ",", "'stream'", ":", "self", ".", "l...
format message.
[ "format", "message", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/log.py#L143-L148
train
format message.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
c7n/log.py
CloudWatchLogHandler.start_transports
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 =...
python
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", ")", ":", "self", ".", "transport", "=", "Transport", "(", "self", ".", "queue", ",", "self", ".", "batch_size", ",", "self", ".", "batch_interval", ",", "self", ".", "session_factory", ")", "thread", "=", "threading...
start thread transports.
[ "start", "thread", "transports", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/log.py#L150-L158
train
start thread transports.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
c7n/resources/ami.py
ErrorHandler.extract_bad_ami
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...
python
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", ")", ":", "msg", "=", "e", ".", "response", "[", "'Error'", "]", "[", "'Message'", "]", "error", "=", "e", ".", "response", "[", "'Error'", "]", "[", "'Code'", "]", "e_ami_ids", "=", "None", "if", "error", "==", ...
Handle various client side errors when describing images
[ "Handle", "various", "client", "side", "errors", "when", "describing", "images" ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/resources/ami.py#L82-L95
train
Handle various client side errors when describing images
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
tools/sandbox/c7n_sphere11/c7n_sphere11/admin.py
format_json
def format_json(config): """format config for lambda exec """ with open(config) as fh: print(json.dumps(yaml.safe_load(fh.read()), indent=2))
python
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", ")", ":", "with", "open", "(", "config", ")", "as", "fh", ":", "print", "(", "json", ".", "dumps", "(", "yaml", ".", "safe_load", "(", "fh", ".", "read", "(", ")", ")", ",", "indent", "=", "2", ")", ")" ]
format config for lambda exec
[ "format", "config", "for", "lambda", "exec" ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/sandbox/c7n_sphere11/c7n_sphere11/admin.py#L40-L44
train
format config for lambda exec
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
tools/sandbox/c7n_sphere11/c7n_sphere11/admin.py
check
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") ...
python
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", "(", ")", ":", "t", "=", "time", ".", "time", "(", ")", "results", "=", "Client", "(", "BASE_URL", ")", ".", "version", "(", ")", "print", "(", "\"Endpoint\"", ",", "BASE_URL", ")", "print", "(", "\"Response Time %0.2f\"", "%", "(", "...
Sanity check api deployment
[ "Sanity", "check", "api", "deployment" ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/sandbox/c7n_sphere11/c7n_sphere11/admin.py#L71-L82
train
Sanity check api deployment
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
tools/sandbox/c7n_sphere11/c7n_sphere11/admin.py
metrics
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...
python
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", ")", ":", "from", "c7n", ".", "mu", "import", "LambdaManager", "manager", "=", "LambdaManager", "(", "boto3", ".", "Session", ")", "start", "=", "parse_date", "(", "start", ")", ...
lambda/api/db metrics
[ "lambda", "/", "api", "/", "db", "metrics" ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/sandbox/c7n_sphere11/c7n_sphere11/admin.py#L92-L127
train
Get metrics for a given function in a given API.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
tools/sandbox/c7n_sphere11/c7n_sphere11/admin.py
records
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...
python
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", ")", ":", "s", "=", "boto3", ".", "Session", "(", ")", "table", "=", "s", ".", "resource", "(", "'dynamodb'", ")", ".", "Table", "(", "'Sphere11.Dev.ResourceLocks'", ")", "results", "=", "table", ".", "scan", "(", "...
Fetch locks data
[ "Fetch", "locks", "data" ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/sandbox/c7n_sphere11/c7n_sphere11/admin.py#L197-L213
train
Fetch locks data
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
tools/sandbox/c7n_sphere11/c7n_sphere11/admin.py
flush_pending
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...
python
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", ")", ":", "s", "=", "boto3", ".", "Session", "(", ")", "client", "=", "s", ".", "client", "(", "'lambda'", ")", "results", "=", "client", ".", "invoke", "(", "FunctionName", "=", "function", ",", "Payload", "=",...
Attempt to acquire any pending locks.
[ "Attempt", "to", "acquire", "any", "pending", "locks", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/sandbox/c7n_sphere11/c7n_sphere11/admin.py#L218-L229
train
Attempt to acquire any pending locks.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
tools/sandbox/c7n_sphere11/c7n_sphere11/admin.py
config_status
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...
python
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", "(", ")", ":", "s", "=", "boto3", ".", "Session", "(", ")", "client", "=", "s", ".", "client", "(", "'config'", ")", "channels", "=", "client", ".", "describe_delivery_channel_status", "(", ")", "[", "'DeliveryChannelsStatus'", "]", ...
Check config status in an account.
[ "Check", "config", "status", "in", "an", "account", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/sandbox/c7n_sphere11/c7n_sphere11/admin.py#L233-L250
train
Check config status in an account.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
tools/sandbox/c7n_sphere11/c7n_sphere11/admin.py
local
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...
python
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", ")", ":", "import", "logging", "from", "bottle", "import", "run", "from", "app", "import", "controller", ",", "app", "from", "c7n", ".", "resources", "import", "load_resources", "load_resources", "(", ")", "print",...
run local app server, assumes into the account
[ "run", "local", "app", "server", "assumes", "into", "the", "account" ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/sandbox/c7n_sphere11/c7n_sphere11/admin.py#L263-L276
train
run local app server
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
c7n/commands.py
_schema_get_docstring
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)
python
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", ")", ":", "for", "cls", "in", "inspect", ".", "getmro", "(", "starting_class", ")", ":", "if", "inspect", ".", "getdoc", "(", "cls", ")", ":", "return", "inspect", ".", "getdoc", "(", "cls", ")" ]
Given a class, return its docstring. If no docstring is present for the class, search base classes in MRO for a docstring.
[ "Given", "a", "class", "return", "its", "docstring", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/commands.py#L316-L324
train
Given a class return its docstring.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
c7n/commands.py
schema_completer
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...
python
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", ")", ":", "from", "c7n", "import", "schema", "load_resources", "(", ")", "components", "=", "prefix", ".", "split", "(", "'.'", ")", "if", "components", "[", "0", "]", "in", "provider", ".", "clouds", ".", "keys"...
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.
[ "For", "tab", "-", "completion", "via", "argcomplete", "return", "completion", "options", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/commands.py#L327-L370
train
Returns a list of possible options for the given prefix.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
c7n/commands.py
schema_cmd
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....
python
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", ")", ":", "from", "c7n", "import", "schema", "if", "options", ".", "json", ":", "schema", ".", "json_dump", "(", "options", ".", "resource", ")", "return", "load_resources", "(", ")", "resource_mapping", "=", "schema", ...
Print info about the resources, actions and filters available.
[ "Print", "info", "about", "the", "resources", "actions", "and", "filters", "available", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/commands.py#L373-L502
train
Print info about the resources actions and filters available.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
c7n/commands.py
_metrics_get_endpoints
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 ...
python
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", ")", ":", "if", "bool", "(", "options", ".", "start", ")", "^", "bool", "(", "options", ".", "end", ")", ":", "log", ".", "error", "(", "'--start and --end must be specified together'", ")", "sys", ".", "exit"...
Determine the start and end dates based on user-supplied options.
[ "Determine", "the", "start", "and", "end", "dates", "based", "on", "user", "-", "supplied", "options", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/commands.py#L529-L542
train
Determine the start and end dates based on user - supplied options.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
c7n/resources/ec2.py
extract_instance_id
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...
python
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", ")", ":", "instance_id", "=", "None", "match", "=", "RE_ERROR_INSTANCE_ID", ".", "search", "(", "str", "(", "state_error", ")", ")", "if", "match", ":", "instance_id", "=", "match", ".", "groupdict", "(", ")"...
Extract an instance id from an error
[ "Extract", "an", "instance", "id", "from", "an", "error" ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/resources/ec2.py#L1011-L1019
train
Extract an instance id from an error
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
c7n/resources/ec2.py
DescribeEC2.augment
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....
python
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", ")", ":", "# 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",...
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_...
[ "EC2", "API", "and", "AWOL", "Tags" ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/resources/ec2.py#L122-L172
train
Augment the resource list with the tags from AWS EC2 API and AWOL API.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
c7n/filters/securityhub.py
SecurityHubFindingFilter.register_resources
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...
python
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", ")", ":", "for", "rtype", ",", "resource_manager", "in", "registry", ".", "items", "(", ")", ":", "if", "not", "resource_manager", ".", "has_arn", "(", ")", ":", "continue", ...
meta model subscriber on resource registration. SecurityHub Findings Filter
[ "meta", "model", "subscriber", "on", "resource", "registration", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/filters/securityhub.py#L57-L67
train
register a new findings filter
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
tools/c7n_gcp/c7n_gcp/actions/notify.py
Notify.publish_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) ...
python
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", ")", ":", "return", "client", ".", "execute_command", "(", "'publish'", ",", "{", "'topic'", ":", "self", ".", "data", "[", "'transport'", "]", "[", "'topic'", "]", ",", "'body'", ":",...
Publish message to a GCP pub/sub topic
[ "Publish", "message", "to", "a", "GCP", "pub", "/", "sub", "topic" ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_gcp/c7n_gcp/actions/notify.py#L99-L109
train
Publish a message to a GCP pub / sub topic
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
tools/c7n_mailer/c7n_mailer/email_delivery.py
EmailDelivery.set_mimetext_headers
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...
python
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", ")", ":", "message", "[", "'Subject'", "]", "=", "subject", "message", "[", "'From'", "]", "=", "from_addr", "m...
Sets headers on Mimetext message
[ "Sets", "headers", "on", "Mimetext", "message" ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_mailer/c7n_mailer/email_delivery.py#L265-L279
train
Sets headers on Mimetext message
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
c7n/filters/health.py
HealthEventFilter.register_resources
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...
python
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", ")", ":", "services", "=", "{", "'acm-certificate'", ",", "'directconnect'", ",", "'dms-instance'", ",", "'directory'", ",", "'ec2'", ",", "'dynamodb-table'", ",", "'cache-cluster'", ...
meta model subscriber on resource registration. We watch for PHD event that provides affected entities and register the health-event filter to the resources.
[ "meta", "model", "subscriber", "on", "resource", "registration", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/filters/health.py#L104-L114
train
register_resources registers a health - event filter to the resources.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
c7n/mu.py
custodian_archive
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: ...
python
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", ")", ":", "modules", "=", "{", "'c7n'", ",", "'pkg_resources'", "}", "if", "packages", ":", "modules", "=", "filter", "(", "None", ",", "modules", ".", "union", "(", "packages", ")", ")", "return"...
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...
[ "Create", "a", "lambda", "code", "archive", "for", "running", "custodian", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/mu.py#L254-L277
train
Create a lambda code archive for running custodian.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
c7n/mu.py
PythonPackageArchive.add_directory
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...
python
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", ")", ":", "for", "root", ",", "dirs", ",", "files", "in", "os", ".", "walk", "(", "path", ")", ":", "arc_prefix", "=", "os", ".", "path", ".", "relpath", "(", "root", "...
Add ``*.py`` files under the directory ``path`` to the archive.
[ "Add", "*", ".", "py", "files", "under", "the", "directory", "path", "to", "the", "archive", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/mu.py#L133-L152
train
Add all. py files under the given directory path to the archive.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
c7n/mu.py
PythonPackageArchive.add_file
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 ...
python
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", ")", ":", "dest", "=", "dest", "or", "os", ".", "path", ".", "basename", "(", "src", ")", "with", "open", "(", "src", ",", "'rb'", ")", "as", "fp", ":", "contents", "=", "fp"...
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``.
[ "Add", "the", "file", "at", "src", "to", "the", "archive", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/mu.py#L154-L166
train
Add the file at src to the archive.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
c7n/mu.py
PythonPackageArchive.add_py_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__) ...
python
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", ")", ":", "src", "=", "src", "[", ":", "-", "1", "]", "if", "src", ".", "endswith", "(", "'.pyc'", ")", "else", "src", "self", ".", "add_file", "(", "src", ",", "dest", ")...
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...
[ "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", ...
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/mu.py#L168-L182
train
This method adds a. py file to the archive.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
c7n/mu.py
PythonPackageArchive.add_contents
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....
python
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", ")", ":", "assert", "not", "self", ".", "_closed", ",", "\"Archive closed\"", "if", "not", "isinstance", "(", "dest", ",", "zipfile", ".", "ZipInfo", ")", ":", "dest", "=", "zinfo", "(", ...
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.
[ "Add", "file", "contents", "to", "the", "archive", "under", "dest", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/mu.py#L184-L199
train
Add contents to the archive under dest.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
c7n/mu.py
PythonPackageArchive.close
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...
python
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", ")", ":", "self", ".", "_closed", "=", "True", "self", ".", "_zip_file", ".", "close", "(", ")", "log", ".", "debug", "(", "\"Created custodian serverless archive size: %0.2fmb\"", ",", "(", "os", ".", "path", ".", "getsize", "...
Close the zip file. Note underlying tempfile is removed when archive is garbage collected.
[ "Close", "the", "zip", "file", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/mu.py#L201-L212
train
Close the zip file and return the object.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
c7n/mu.py
PythonPackageArchive.get_checksum
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')
python
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", ")", ":", "assert", "self", ".", "_closed", ",", "\"Archive not closed\"", "with", "open", "(", "self", ".", "_temp_archive_fil...
Return the b64 encoded sha256 checksum of the archive.
[ "Return", "the", "b64", "encoded", "sha256", "checksum", "of", "the", "archive", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/mu.py#L219-L223
train
Return the b64 encoded sha256 checksum of the archive.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
c7n/mu.py
PythonPackageArchive.get_reader
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')
python
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", ")", ":", "assert", "self", ".", "_closed", ",", "\"Archive not closed\"", "buf", "=", "io", ".", "BytesIO", "(", "self", ".", "get_bytes", "(", ")", ")", "return", "zipfile", ".", "ZipFile", "(", "buf", ",", "mode", "...
Return a read-only :py:class:`~zipfile.ZipFile`.
[ "Return", "a", "read", "-", "only", ":", "py", ":", "class", ":", "~zipfile", ".", "ZipFile", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/mu.py#L235-L239
train
Return a read - only : py : class : ~zipfile. ZipFile object.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
c7n/mu.py
LambdaManager.publish_alias
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...
python
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", ")", ":", "if", "not", "alias", ":", "return", "func_data", "[", "'FunctionArn'", "]", "func_name", "=", "func_data", "[", "'FunctionName'", "]", "func_version", "=", "func_data", "[", "'Ve...
Create or update an alias for the given function.
[ "Create", "or", "update", "an", "alias", "for", "the", "given", "function", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/mu.py#L520-L546
train
Publish an alias for the given function.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
tools/sandbox/zerodark/zerodark/utils.py
row_factory
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
python
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", ")", ":", "d", "=", "{", "}", "for", "idx", ",", "col", "in", "enumerate", "(", "cursor", ".", "description", ")", ":", "d", "[", "col", "[", "0", "]", "]", "=", "row", "[", "idx", "]", "return",...
Returns a sqlite row factory that returns a dictionary
[ "Returns", "a", "sqlite", "row", "factory", "that", "returns", "a", "dictionary" ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/sandbox/zerodark/zerodark/utils.py#L25-L30
train
Returns a sqlite row factory that returns a dictionary
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
tools/c7n_azure/c7n_azure/tags.py
TagHelper.get_tag_value
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...
python
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", ")", ":", "tags", "=", "{", "k", ".", "lower", "(", ")", ":", "v", "for", "k", ",", "v", "in", "resource", ".", "get", "(", "'tags'", ",", "{", "}", ")", ".", "i...
Get the resource's tag value.
[ "Get", "the", "resource", "s", "tag", "value", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_azure/c7n_azure/tags.py#L99-L108
train
Get the resource s tag value.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
tools/c7n_guardian/c7n_guardian/cli.py
report
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(...
python
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", ")", ":", "accounts_config", ",", "master_info", ",", "executor", "=", "guardian_init", "(", "config", ",", "debug", ",", "master", ",", "accounts", ...
report on guard duty enablement by account
[ "report", "on", "guard", "duty", "enablement", "by", "account" ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_guardian/c7n_guardian/cli.py#L52-L88
train
report on guard duty enablement by account
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
tools/c7n_guardian/c7n_guardian/cli.py
disable
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...
python
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", ")", ":", "accounts_config", ",", "master_info", ",", "executor", "...
suspend guard duty in the given accounts.
[ "suspend", "guard", "duty", "in", "the", "given", "accounts", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_guardian/c7n_guardian/cli.py#L106-L167
train
Disable guard duty in the given accounts.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
tools/c7n_guardian/c7n_guardian/cli.py
enable
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:%...
python
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", ")", ":", "accounts_config", ",", "master_info", ",", "executor", "=", "guardian_init", "(", "config", ",", "debug", ",", "master", ...
enable guard duty on a set of accounts
[ "enable", "guard", "duty", "on", "a", "set", "of", "accounts" ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_guardian/c7n_guardian/cli.py#L195-L202
train
enable guard duty on a set of accounts
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
c7n/actions/network.py
ModifyVpcSecurityGroupsAction.get_action_group_names
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'...
python
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", "self", ".", "get_group_names", "(", "list", "(", "itertools", ".", "chain", "(", "*", "[", "self", ".", "_get_array", "(", "'add'", ")", ",", "self", ".", "_get_array", "(", "'remove'", "...
Return all the security group names configured in this action.
[ "Return", "all", "the", "security", "group", "names", "configured", "in", "this", "action", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/actions/network.py#L107-L113
train
Return all the security group names configured in this action.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
c7n/actions/network.py
ModifyVpcSecurityGroupsAction.get_groups_by_names
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...
python
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", ")", ":", "if", "not", "names", ":", "return", "[", "]", "client", "=", "utils", ".", "local_session", "(", "self", ".", "manager", ".", "session_factory", ")", ".", "client", "(", "'ec2'", ")", ...
Resolve security names to security groups resources.
[ "Resolve", "security", "names", "to", "security", "groups", "resources", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/actions/network.py#L128-L150
train
Resolve security names to security groups resources.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
c7n/actions/network.py
ModifyVpcSecurityGroupsAction.resolve_group_names
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_...
python
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", ")", ":", "names", "=", "self", ".", "get_group_names", "(", "target_group_ids", ")", "if", "not", "names", ":", "return", "target_group_ids", "target_group_ids", "=", ...
Resolve any security group names to the corresponding group ids With the context of a given network attached resource.
[ "Resolve", "any", "security", "group", "names", "to", "the", "corresponding", "group", "ids" ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/actions/network.py#L152-L182
train
Resolve any security group names to the corresponding group ids with the context of a given network attached resource.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
c7n/actions/network.py
ModifyVpcSecurityGroupsAction.resolve_remove_symbols
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: ...
python
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", ")", ":", "if", "'matched'", "in", "target_group_ids", ":", "return", "r", ".", "get", "(", "'c7n:matched-security-groups'", ",", "(", ")", ")", "elif", "'network-...
Resolve the resources security groups that need be modified. Specifically handles symbolic names that match annotations from policy filters for groups being removed.
[ "Resolve", "the", "resources", "security", "groups", "that", "need", "be", "modified", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/actions/network.py#L184-L198
train
Resolve the resource security groups that need be modified.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
c7n/actions/network.py
ModifyVpcSecurityGroupsAction.get_groups
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. ...
python
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", ")", ":", "resolved_groups", "=", "self", ".", "get_groups_by_names", "(", "self", ".", "get_action_group_names", "(", ")", ")", "return_groups", "=", "[", "]", "for", "idx", ",", "r", "in", "enumerate", ...
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...
[ "Return", "lists", "of", "security", "groups", "to", "set", "on", "each", "resource" ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/actions/network.py#L200-L241
train
Returns a list of security groups that should be added to each resource.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
c7n/utils.py
type_schema
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...
python
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", ")", ":", "if", "aliases", ":", "type_names", "=", "[", "type_name", ...
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...
[ "jsonschema", "generation", "helper" ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/utils.py#L130-L174
train
generate a jsonschema for a type
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
c7n/utils.py
group_by
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...
python
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", ")", ":", "resource_map", "=", "{", "}", "parts", "=", "key", ".", "split", "(", "'.'", ")", "for", "r", "in", "resources", ":", "v", "=", "r", "for", "k", "in", "parts", ":", "v", "=", "v", ".",...
Return a mapping of key value to resources with the corresponding value. Key may be specified as dotted form for nested dictionary lookup
[ "Return", "a", "mapping", "of", "key", "value", "to", "resources", "with", "the", "corresponding", "value", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/utils.py#L185-L199
train
Return a mapping of key value to resources with the corresponding value.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
c7n/utils.py
camelResource
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(),...
python
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", ")", ":", "if", "not", "isinstance", "(", "obj", ",", "dict", ")", ":", "return", "obj", "for", "k", "in", "list", "(", "obj", ".", "keys", "(", ")", ")", ":", "v", "=", "obj", ".", "pop", "(", "k", ")", "o...
Some sources from apis return lowerCased where as describe calls always return TitleCase, this function turns the former to the later
[ "Some", "sources", "from", "apis", "return", "lowerCased", "where", "as", "describe", "calls" ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/utils.py#L214-L228
train
This function turns the former to the later
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
c7n/utils.py
query_instances
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...
python
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", ")", ":", "if", "client", "is", "None", ":", "client", "=", "session", ".", "client", "(", "'ec2'", ")", "p", "=", "client", ".", "get_paginator", "(", "'de...
Return a list of ec2 instances for the query.
[ "Return", "a", "list", "of", "ec2", "instances", "for", "the", "query", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/utils.py#L242-L251
train
Query EC2 instances for the query.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
c7n/utils.py
local_session
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...
python
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", ")", ":", "factory_region", "=", "getattr", "(", "factory", ",", "'region'", ",", "'global'", ")", "s", "=", "getattr", "(", "CONN_CACHE", ",", "factory_region", ",", "{", "}", ")", ".", "get", "(", "'session'", ")...
Cache a session thread local for up to 45m
[ "Cache", "a", "session", "thread", "local", "for", "up", "to", "45m" ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/utils.py#L257-L269
train
Cache a session thread local for up to 45m
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
c7n/utils.py
set_annotation
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)...
python
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", ")", ":", "if", "not", "isinstance", "(", "i", ",", "dict", ")", ":", "raise", "ValueError", "(", "\"Can only annotate dictionaries\"", ")", "if", "not", "isinstance", "(", "v", ",", "list", ")", "...
>>> x = {} >>> set_annotation(x, 'marker', 'a') >>> annotation(x, 'marker') ['a']
[ ">>>", "x", "=", "{}", ">>>", "set_annotation", "(", "x", "marker", "a", ")", ">>>", "annotation", "(", "x", "marker", ")", "[", "a", "]" ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/utils.py#L281-L299
train
Set the annotation of a single object.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
c7n/utils.py
generate_arn
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: ...
python
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", "=", "'/'", ")", ":", "if", "region", "and", "region"...
Generate an Amazon Resource Name. See http://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html.
[ "Generate", "an", "Amazon", "Resource", "Name", ".", "See", "http", ":", "//", "docs", ".", "aws", ".", "amazon", ".", "com", "/", "general", "/", "latest", "/", "gr", "/", "aws", "-", "arns", "-", "and", "-", "namespaces", ".", "html", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/utils.py#L325-L341
train
Generate an Amazon Resource Name.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
c7n/utils.py
snapshot_identifier
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'))
python
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", ")", ":", "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.
[ "Return", "an", "identifier", "for", "a", "snapshot", "of", "a", "database", "or", "cluster", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/utils.py#L344-L348
train
Return an identifier for a snapshot of a database or cluster.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
c7n/utils.py
get_retry
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...
python
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", ")", ":", "max_delay", "=", "max", "(", "min_delay", ",", "2", ")", "**", "max_attempts", "def", "_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 ...
[ "Decorator", "for", "retry", "boto3", "api", "call", "on", "transient", "errors", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/utils.py#L351-L387
train
Decorator for retries on transient errors.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
c7n/utils.py
backoff_delays
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
python
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", ")", ":", "cur", "=", "start", "while", "cur", "<=", "stop", ":", "if", "jitter", ":", "yield", "cur", "-", "(", "cur", "*", "random", ".", ...
Geometric backoff sequence w/ jitter
[ "Geometric", "backoff", "sequence", "w", "/", "jitter" ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/utils.py#L390-L399
train
Geometric backoff sequence w / jitter
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
c7n/utils.py
parse_cidr
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
python
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", ")", ":", "klass", "=", "IPv4Network", "if", "'/'", "not", "in", "value", ":", "klass", "=", "ipaddress", ".", "ip_address", "try", ":", "v", "=", "klass", "(", "six", ".", "text_type", "(", "value", ")", ")", "exce...
Process cidr ranges.
[ "Process", "cidr", "ranges", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/utils.py#L402-L411
train
Process cidr ranges.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
c7n/utils.py
worker
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...
python
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", ")", ":", "def", "_f", "(", "*", "args", ",", "*", "*", "kw", ")", ":", "try", ":", "return", "f", "(", "*", "args", ",", "*", "*", "kw", ")", "except", "Exception", ":", "worker_log", ".", "exception", "(", "'Error i...
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...
[ "Generic", "wrapper", "to", "log", "uncaught", "exceptions", "in", "a", "function", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/utils.py#L428-L446
train
Generic wrapper for functions that log uncaught exceptions in a function.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
c7n/utils.py
reformat_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[...
python
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", ")", ":", "if", "not", "hasattr", "(", "model", ",", "'schema'", ")", ":", "return", "\"Model '{}' does not have a schema\"", ".", "format", "(", "model", ")", "if", "'properties'", "not", "in", "model", ".", "schema", ...
Reformat schema to be in a more displayable format.
[ "Reformat", "schema", "to", "be", "in", "a", "more", "displayable", "format", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/utils.py#L449-L466
train
Reformat schema to be in a more displayable format.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
c7n/utils.py
format_string_values
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...
python
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", ")", ":", "if", "isinstance", "(", "obj", ",", "dict", ")", ":", "new", "=", "{", "}", "for", "...
Format all string values in an object. Return the updated object
[ "Format", "all", "string", "values", "in", "an", "object", ".", "Return", "the", "updated", "object" ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/utils.py#L501-L522
train
Formats all string values in an object.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
c7n/resources/dynamodb.py
DescribeDaxCluster.get_resources
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')
python
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", ")", ":", "client", "=", "local_session", "(", "self", ".", "manager", ".", "session_factory", ")", ".", "client", "(", "'dax'", ")", "return", "client", ".", "describe_clusters", ...
Retrieve dax resources for serverless policies or related resources
[ "Retrieve", "dax", "resources", "for", "serverless", "policies", "or", "related", "resources" ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/resources/dynamodb.py#L435-L439
train
Retrieve dax resources for serverless policies or related resources
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
tools/c7n_org/scripts/gcpprojects.py
main
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'] ...
python
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", ")", ":", "client", "=", "Session", "(", ")", ".", "client", "(", "'cloudresourcemanager'", ",", "'v1'", ",", "'projects'", ")", "results", "=", "[", "]", "for", "page", "in", "client", ".", "execute_paged_query", "(", "'lis...
Generate a c7n-org gcp projects config file
[ "Generate", "a", "c7n", "-", "org", "gcp", "projects", "config", "file" ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_org/scripts/gcpprojects.py#L27-L52
train
Generate a c7n - org gcp projects config file
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
tools/c7n_azure/c7n_azure/query.py
ChildResourceQuery.filter
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...
python
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", ")", ":", "m", "=", "self", ".", "resolve", "(", "resource_manager", ".", "resource_type", ")", "client", "=", "resource_manager", ".", "get_client", "(", ")", "enum_op", ",", ...
Query a set of resources.
[ "Query", "a", "set", "of", "resources", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_azure/c7n_azure/query.py#L81-L106
train
Query a set of resources.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
c7n/filters/multiattr.py
MultiAttrFilter.get_attr_filters
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 ...
python
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", ")", ":", "for", "f", "in", "self", ".", "data", ".", "keys", "(", ")", ":", "if", "f", "not", "in", "self", ".", "multi_attrs", ":", "continue", "fv", "=", "self", ".", "data", "[", "f", "]", "if", "isinst...
Return an iterator resource attribute filters configured.
[ "Return", "an", "iterator", "resource", "attribute", "filters", "configured", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/filters/multiattr.py#L48-L61
train
Return an iterator over resource attribute filters configured.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
c7n/resources/account.py
cloudtrail_policy
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'}, ...
python
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", ")", ":", "ct_actions", "=", "[", "{", "'Action'", ":", "'s3:GetBucketAcl'", ",", "'Effect'", ":", "'Allow'", ",", "'Principal'", ":", "{", "'Service'", "...
add CloudTrail permissions to an S3 policy, preserving existing
[ "add", "CloudTrail", "permissions", "to", "an", "S3", "policy", "preserving", "existing" ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/resources/account.py#L654-L690
train
add CloudTrail permissions to an S3 policy preserving existing
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
c7n/resources/rds.py
_get_available_engine_upgrades
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...
python
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", ")", ":", "results", "=", "{", "}", "engine_versions", "=", "client", ".", "describe_db_engine_versions", "(", ")", "[", "'DBEngineVersions'", "]", "for", "v", "in", "engine_vers...
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', ...
[ "Returns", "all", "extant", "rds", "engine", "upgrades", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/resources/rds.py#L224-L257
train
Returns all available rds engine upgrades.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
c7n/handler.py
get_local_output_dir
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...
python
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", "(", ")", ":", "output_dir", "=", "os", ".", "environ", ".", "get", "(", "'C7N_OUTPUT_DIR'", ",", "'/tmp/'", "+", "str", "(", "uuid", ".", "uuid4", "(", ")", ")", ")", "if", "not", "os", ".", "path", ".", "exists", "(",...
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.
[ "Create", "a", "local", "output", "directory", "per", "execution", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/handler.py#L65-L78
train
Create a local output directory per execution.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
c7n/handler.py
init_config
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. ...
python
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", ")", ":", "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...
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 ...
[ "Get", "policy", "lambda", "execution", "configuration", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/handler.py#L81-L137
train
Initialize the policy lambda execution configuration.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
tools/sandbox/c7n_index/c7n_index/metrics.py
index_metrics
def index_metrics( config, start, end, incremental=False, concurrency=5, accounts=None, period=3600, tag=None, index='policy-metrics', verbose=False): """index policy metrics""" logging.basicConfig(level=(verbose and logging.DEBUG or logging.INFO)) logging.getLogger('botocore').setLevel(logg...
python
def index_metrics( config, start, end, incremental=False, concurrency=5, accounts=None, period=3600, tag=None, index='policy-metrics', verbose=False): """index policy metrics""" logging.basicConfig(level=(verbose and logging.DEBUG or logging.INFO)) logging.getLogger('botocore').setLevel(logg...
[ "def", "index_metrics", "(", "config", ",", "start", ",", "end", ",", "incremental", "=", "False", ",", "concurrency", "=", "5", ",", "accounts", "=", "None", ",", "period", "=", "3600", ",", "tag", "=", "None", ",", "index", "=", "'policy-metrics'", "...
index policy metrics
[ "index", "policy", "metrics" ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/sandbox/c7n_index/c7n_index/metrics.py#L403-L477
train
index policy metrics in a given time range
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
c7n/filters/revisions.py
Diff.transform_revision
def transform_revision(self, revision): """make config revision look like describe output.""" config = self.manager.get_source('config') return config.load_resource(revision)
python
def transform_revision(self, revision): """make config revision look like describe output.""" config = self.manager.get_source('config') return config.load_resource(revision)
[ "def", "transform_revision", "(", "self", ",", "revision", ")", ":", "config", "=", "self", ".", "manager", ".", "get_source", "(", "'config'", ")", "return", "config", ".", "load_resource", "(", "revision", ")" ]
make config revision look like describe output.
[ "make", "config", "revision", "look", "like", "describe", "output", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/filters/revisions.py#L156-L159
train
make config revision look like describe output.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
c7n/filters/revisions.py
JsonDiff.register_resources
def register_resources(klass, registry, resource_class): """ meta model subscriber on resource registration. We watch for new resource types being registered and if they support aws config, automatically register the jsondiff filter. """ config_type = getattr(resource_class.reso...
python
def register_resources(klass, registry, resource_class): """ meta model subscriber on resource registration. We watch for new resource types being registered and if they support aws config, automatically register the jsondiff filter. """ config_type = getattr(resource_class.reso...
[ "def", "register_resources", "(", "klass", ",", "registry", ",", "resource_class", ")", ":", "config_type", "=", "getattr", "(", "resource_class", ".", "resource_type", ",", "'config_type'", ",", "None", ")", "if", "config_type", "is", "None", ":", "return", "...
meta model subscriber on resource registration. We watch for new resource types being registered and if they support aws config, automatically register the jsondiff filter.
[ "meta", "model", "subscriber", "on", "resource", "registration", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/filters/revisions.py#L186-L195
train
register the json - diff filter
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
c7n/cli.py
_default_options
def _default_options(p, blacklist=""): """ Add basic options ot the subparser. `blacklist` is a list of options to exclude from the default set. e.g.: ['region', 'log-group'] """ provider = p.add_argument_group( "provider", "AWS account information, defaults per the aws cli") if 'regio...
python
def _default_options(p, blacklist=""): """ Add basic options ot the subparser. `blacklist` is a list of options to exclude from the default set. e.g.: ['region', 'log-group'] """ provider = p.add_argument_group( "provider", "AWS account information, defaults per the aws cli") if 'regio...
[ "def", "_default_options", "(", "p", ",", "blacklist", "=", "\"\"", ")", ":", "provider", "=", "p", ".", "add_argument_group", "(", "\"provider\"", ",", "\"AWS account information, defaults per the aws cli\"", ")", "if", "'region'", "not", "in", "blacklist", ":", ...
Add basic options ot the subparser. `blacklist` is a list of options to exclude from the default set. e.g.: ['region', 'log-group']
[ "Add", "basic", "options", "ot", "the", "subparser", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/cli.py#L44-L111
train
Add basic options ot the subparser.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
c7n/cli.py
_report_options
def _report_options(p): """ Add options specific to the report subcommand. """ _default_options(p, blacklist=['cache', 'log-group', 'quiet']) p.add_argument( '--days', type=float, default=1, help="Number of days of history to consider") p.add_argument( '--raw', type=argparse.File...
python
def _report_options(p): """ Add options specific to the report subcommand. """ _default_options(p, blacklist=['cache', 'log-group', 'quiet']) p.add_argument( '--days', type=float, default=1, help="Number of days of history to consider") p.add_argument( '--raw', type=argparse.File...
[ "def", "_report_options", "(", "p", ")", ":", "_default_options", "(", "p", ",", "blacklist", "=", "[", "'cache'", ",", "'log-group'", ",", "'quiet'", "]", ")", "p", ".", "add_argument", "(", "'--days'", ",", "type", "=", "float", ",", "default", "=", ...
Add options specific to the report subcommand.
[ "Add", "options", "specific", "to", "the", "report", "subcommand", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/cli.py#L114-L135
train
Add options specific to the report subcommand.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
c7n/cli.py
_metrics_options
def _metrics_options(p): """ Add options specific to metrics subcommand. """ _default_options(p, blacklist=['log-group', 'output-dir', 'cache', 'quiet']) p.add_argument( '--start', type=date_parse, help='Start date (requires --end, overrides --days)') p.add_argument( '--end', ty...
python
def _metrics_options(p): """ Add options specific to metrics subcommand. """ _default_options(p, blacklist=['log-group', 'output-dir', 'cache', 'quiet']) p.add_argument( '--start', type=date_parse, help='Start date (requires --end, overrides --days)') p.add_argument( '--end', ty...
[ "def", "_metrics_options", "(", "p", ")", ":", "_default_options", "(", "p", ",", "blacklist", "=", "[", "'log-group'", ",", "'output-dir'", ",", "'cache'", ",", "'quiet'", "]", ")", "p", ".", "add_argument", "(", "'--start'", ",", "type", "=", "date_parse...
Add options specific to metrics subcommand.
[ "Add", "options", "specific", "to", "metrics", "subcommand", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/cli.py#L138-L150
train
Add options specific to metrics subcommand.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
c7n/cli.py
_logs_options
def _logs_options(p): """ Add options specific to logs subcommand. """ _default_options(p, blacklist=['cache', 'quiet']) # default time range is 0 to "now" (to include all log entries) p.add_argument( '--start', default='the beginning', # invalid, will result in 0 help='Start d...
python
def _logs_options(p): """ Add options specific to logs subcommand. """ _default_options(p, blacklist=['cache', 'quiet']) # default time range is 0 to "now" (to include all log entries) p.add_argument( '--start', default='the beginning', # invalid, will result in 0 help='Start d...
[ "def", "_logs_options", "(", "p", ")", ":", "_default_options", "(", "p", ",", "blacklist", "=", "[", "'cache'", ",", "'quiet'", "]", ")", "# default time range is 0 to \"now\" (to include all log entries)", "p", ".", "add_argument", "(", "'--start'", ",", "default"...
Add options specific to logs subcommand.
[ "Add", "options", "specific", "to", "logs", "subcommand", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/cli.py#L153-L167
train
Add options specific to logs subcommand.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
c7n/cli.py
_schema_options
def _schema_options(p): """ Add options specific to schema subcommand. """ p.add_argument( 'resource', metavar='selector', nargs='?', default=None).completer = _schema_tab_completer p.add_argument( '--summary', action="store_true", help="Summarize counts of available resourc...
python
def _schema_options(p): """ Add options specific to schema subcommand. """ p.add_argument( 'resource', metavar='selector', nargs='?', default=None).completer = _schema_tab_completer p.add_argument( '--summary', action="store_true", help="Summarize counts of available resourc...
[ "def", "_schema_options", "(", "p", ")", ":", "p", ".", "add_argument", "(", "'resource'", ",", "metavar", "=", "'selector'", ",", "nargs", "=", "'?'", ",", "default", "=", "None", ")", ".", "completer", "=", "_schema_tab_completer", "p", ".", "add_argumen...
Add options specific to schema subcommand.
[ "Add", "options", "specific", "to", "schema", "subcommand", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/cli.py#L178-L190
train
Add options specific to schema subcommand.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
c7n/resources/rdscluster.py
_rds_cluster_tags
def _rds_cluster_tags(model, dbs, session_factory, generator, retry): """Augment rds clusters with their respective tags.""" client = local_session(session_factory).client('rds') def process_tags(db): try: db['Tags'] = retry( client.list_tags_for_resource, ...
python
def _rds_cluster_tags(model, dbs, session_factory, generator, retry): """Augment rds clusters with their respective tags.""" client = local_session(session_factory).client('rds') def process_tags(db): try: db['Tags'] = retry( client.list_tags_for_resource, ...
[ "def", "_rds_cluster_tags", "(", "model", ",", "dbs", ",", "session_factory", ",", "generator", ",", "retry", ")", ":", "client", "=", "local_session", "(", "session_factory", ")", ".", "client", "(", "'rds'", ")", "def", "process_tags", "(", "db", ")", ":...
Augment rds clusters with their respective tags.
[ "Augment", "rds", "clusters", "with", "their", "respective", "tags", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/resources/rdscluster.py#L74-L88
train
Augment rds clusters with their respective tags.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
c7n/resources/iam.py
CredentialReport.process_user_record
def process_user_record(cls, info): """Type convert the csv record, modifies in place.""" keys = list(info.keys()) # Value conversion for k in keys: v = info[k] if v in ('N/A', 'no_information'): info[k] = None elif v == 'false': ...
python
def process_user_record(cls, info): """Type convert the csv record, modifies in place.""" keys = list(info.keys()) # Value conversion for k in keys: v = info[k] if v in ('N/A', 'no_information'): info[k] = None elif v == 'false': ...
[ "def", "process_user_record", "(", "cls", ",", "info", ")", ":", "keys", "=", "list", "(", "info", ".", "keys", "(", ")", ")", "# Value conversion", "for", "k", "in", "keys", ":", "v", "=", "info", "[", "k", "]", "if", "v", "in", "(", "'N/A'", ",...
Type convert the csv record, modifies in place.
[ "Type", "convert", "the", "csv", "record", "modifies", "in", "place", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/resources/iam.py#L1206-L1224
train
Type convert the csv record modifies in place.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
c7n/logs_support.py
normalized_log_entries
def normalized_log_entries(raw_entries): '''Mimic the format returned by LambdaManager.logs()''' entry_start = r'([0-9:, \-]+) - .* - (\w+) - (.*)$' entry = None # process start/end here - avoid parsing log entries twice for line in raw_entries: m = re.match(entry_start, line) if m: ...
python
def normalized_log_entries(raw_entries): '''Mimic the format returned by LambdaManager.logs()''' entry_start = r'([0-9:, \-]+) - .* - (\w+) - (.*)$' entry = None # process start/end here - avoid parsing log entries twice for line in raw_entries: m = re.match(entry_start, line) if m: ...
[ "def", "normalized_log_entries", "(", "raw_entries", ")", ":", "entry_start", "=", "r'([0-9:, \\-]+) - .* - (\\w+) - (.*)$'", "entry", "=", "None", "# process start/end here - avoid parsing log entries twice", "for", "line", "in", "raw_entries", ":", "m", "=", "re", ".", ...
Mimic the format returned by LambdaManager.logs()
[ "Mimic", "the", "format", "returned", "by", "LambdaManager", ".", "logs", "()" ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/logs_support.py#L47-L73
train
Mimic the format returned by LambdaManager. logs
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
c7n/logs_support.py
log_entries_in_range
def log_entries_in_range(entries, start, end): '''filter out entries before start and after end''' start = _timestamp_from_string(start) end = _timestamp_from_string(end) for entry in entries: log_timestamp = entry.get('timestamp', 0) if log_timestamp >= start and log_timestamp <= end: ...
python
def log_entries_in_range(entries, start, end): '''filter out entries before start and after end''' start = _timestamp_from_string(start) end = _timestamp_from_string(end) for entry in entries: log_timestamp = entry.get('timestamp', 0) if log_timestamp >= start and log_timestamp <= end: ...
[ "def", "log_entries_in_range", "(", "entries", ",", "start", ",", "end", ")", ":", "start", "=", "_timestamp_from_string", "(", "start", ")", "end", "=", "_timestamp_from_string", "(", "end", ")", "for", "entry", "in", "entries", ":", "log_timestamp", "=", "...
filter out entries before start and after end
[ "filter", "out", "entries", "before", "start", "and", "after", "end" ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/logs_support.py#L76-L83
train
filter out entries in a given range
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
c7n/logs_support.py
log_entries_from_group
def log_entries_from_group(session, group_name, start, end): '''Get logs for a specific log group''' logs = session.client('logs') log.info("Fetching logs from group: %s" % group_name) try: logs.describe_log_groups(logGroupNamePrefix=group_name) except ClientError as e: if e.response...
python
def log_entries_from_group(session, group_name, start, end): '''Get logs for a specific log group''' logs = session.client('logs') log.info("Fetching logs from group: %s" % group_name) try: logs.describe_log_groups(logGroupNamePrefix=group_name) except ClientError as e: if e.response...
[ "def", "log_entries_from_group", "(", "session", ",", "group_name", ",", "start", ",", "end", ")", ":", "logs", "=", "session", ".", "client", "(", "'logs'", ")", "log", ".", "info", "(", "\"Fetching logs from group: %s\"", "%", "group_name", ")", "try", ":"...
Get logs for a specific log group
[ "Get", "logs", "for", "a", "specific", "log", "group" ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/logs_support.py#L147-L178
train
Get log entries from a specific log group.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
tools/c7n_gcp/c7n_gcp/client.py
_create_service_api
def _create_service_api(credentials, service_name, version, developer_key=None, cache_discovery=False, http=None): """Builds and returns a cloud API service object. Args: credentials (OAuth2Credentials): Credentials that will be used to authenticate the API calls. ...
python
def _create_service_api(credentials, service_name, version, developer_key=None, cache_discovery=False, http=None): """Builds and returns a cloud API service object. Args: credentials (OAuth2Credentials): Credentials that will be used to authenticate the API calls. ...
[ "def", "_create_service_api", "(", "credentials", ",", "service_name", ",", "version", ",", "developer_key", "=", "None", ",", "cache_discovery", "=", "False", ",", "http", "=", "None", ")", ":", "# The default logging of the discovery obj is very noisy in recent versions...
Builds and returns a cloud API service object. Args: credentials (OAuth2Credentials): Credentials that will be used to authenticate the API calls. service_name (str): The name of the API. version (str): The version of the API to use. developer_key (str): The api key to u...
[ "Builds", "and", "returns", "a", "cloud", "API", "service", "object", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_gcp/c7n_gcp/client.py#L90-L125
train
Builds and returns a cloud API service object.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
tools/c7n_gcp/c7n_gcp/client.py
_build_http
def _build_http(http=None): """Construct an http client suitable for googleapiclient usage w/ user agent. """ if not http: http = httplib2.Http( timeout=HTTP_REQUEST_TIMEOUT, ca_certs=HTTPLIB_CA_BUNDLE) user_agent = 'Python-httplib2/{} (gzip), {}/{}'.format( httplib2.__versi...
python
def _build_http(http=None): """Construct an http client suitable for googleapiclient usage w/ user agent. """ if not http: http = httplib2.Http( timeout=HTTP_REQUEST_TIMEOUT, ca_certs=HTTPLIB_CA_BUNDLE) user_agent = 'Python-httplib2/{} (gzip), {}/{}'.format( httplib2.__versi...
[ "def", "_build_http", "(", "http", "=", "None", ")", ":", "if", "not", "http", ":", "http", "=", "httplib2", ".", "Http", "(", "timeout", "=", "HTTP_REQUEST_TIMEOUT", ",", "ca_certs", "=", "HTTPLIB_CA_BUNDLE", ")", "user_agent", "=", "'Python-httplib2/{} (gzip...
Construct an http client suitable for googleapiclient usage w/ user agent.
[ "Construct", "an", "http", "client", "suitable", "for", "googleapiclient", "usage", "w", "/", "user", "agent", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_gcp/c7n_gcp/client.py#L128-L139
train
Construct an http client suitable for googleapiclient usage w / user agent.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
tools/c7n_gcp/c7n_gcp/client.py
Session.client
def client(self, service_name, version, component, **kw): """Safely initialize a repository class to a property. Args: repository_class (class): The class to initialize. version (str): The gcp service version for the repository. Returns: object: An instance ...
python
def client(self, service_name, version, component, **kw): """Safely initialize a repository class to a property. Args: repository_class (class): The class to initialize. version (str): The gcp service version for the repository. Returns: object: An instance ...
[ "def", "client", "(", "self", ",", "service_name", ",", "version", ",", "component", ",", "*", "*", "kw", ")", ":", "service", "=", "_create_service_api", "(", "self", ".", "_credentials", ",", "service_name", ",", "version", ",", "kw", ".", "get", "(", ...
Safely initialize a repository class to a property. Args: repository_class (class): The class to initialize. version (str): The gcp service version for the repository. Returns: object: An instance of repository_class.
[ "Safely", "initialize", "a", "repository", "class", "to", "a", "property", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_gcp/c7n_gcp/client.py#L209-L233
train
Safely initialize a repository class to a property.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
tools/c7n_gcp/c7n_gcp/client.py
ServiceClient.http
def http(self): """A thread local instance of httplib2.Http. Returns: httplib2.Http: An Http instance authorized by the credentials. """ if self._use_cached_http and hasattr(self._local, 'http'): return self._local.http if self._http_replay is not None: ...
python
def http(self): """A thread local instance of httplib2.Http. Returns: httplib2.Http: An Http instance authorized by the credentials. """ if self._use_cached_http and hasattr(self._local, 'http'): return self._local.http if self._http_replay is not None: ...
[ "def", "http", "(", "self", ")", ":", "if", "self", ".", "_use_cached_http", "and", "hasattr", "(", "self", ".", "_local", ",", "'http'", ")", ":", "return", "self", ".", "_local", ".", "http", "if", "self", ".", "_http_replay", "is", "not", "None", ...
A thread local instance of httplib2.Http. Returns: httplib2.Http: An Http instance authorized by the credentials.
[ "A", "thread", "local", "instance", "of", "httplib2", ".", "Http", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_gcp/c7n_gcp/client.py#L303-L320
train
A httplib2. Http instance authorized by the credentials.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
tools/c7n_gcp/c7n_gcp/client.py
ServiceClient._build_request
def _build_request(self, verb, verb_arguments): """Builds HttpRequest object. Args: verb (str): Request verb (ex. insert, update, delete). verb_arguments (dict): Arguments to be passed with the request. Returns: httplib2.HttpRequest: HttpRequest to be sent t...
python
def _build_request(self, verb, verb_arguments): """Builds HttpRequest object. Args: verb (str): Request verb (ex. insert, update, delete). verb_arguments (dict): Arguments to be passed with the request. Returns: httplib2.HttpRequest: HttpRequest to be sent t...
[ "def", "_build_request", "(", "self", ",", "verb", ",", "verb_arguments", ")", ":", "method", "=", "getattr", "(", "self", ".", "_component", ",", "verb", ")", "# Python insists that keys in **kwargs be strings (not variables).", "# Since we initially build our kwargs as a ...
Builds HttpRequest object. Args: verb (str): Request verb (ex. insert, update, delete). verb_arguments (dict): Arguments to be passed with the request. Returns: httplib2.HttpRequest: HttpRequest to be sent to the API.
[ "Builds", "HttpRequest", "object", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_gcp/c7n_gcp/client.py#L328-L345
train
Builds a HttpRequest object.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
tools/c7n_gcp/c7n_gcp/client.py
ServiceClient._build_next_request
def _build_next_request(self, verb, prior_request, prior_response): """Builds pagination-aware request object. More details: https://developers.google.com/api-client-library/python/guide/pagination Args: verb (str): Request verb (ex. insert, update, delete). p...
python
def _build_next_request(self, verb, prior_request, prior_response): """Builds pagination-aware request object. More details: https://developers.google.com/api-client-library/python/guide/pagination Args: verb (str): Request verb (ex. insert, update, delete). p...
[ "def", "_build_next_request", "(", "self", ",", "verb", ",", "prior_request", ",", "prior_response", ")", ":", "method", "=", "getattr", "(", "self", ".", "_component", ",", "verb", "+", "'_next'", ")", "return", "method", "(", "prior_request", ",", "prior_r...
Builds pagination-aware request object. More details: https://developers.google.com/api-client-library/python/guide/pagination Args: verb (str): Request verb (ex. insert, update, delete). prior_request (httplib2.HttpRequest): Request that may trigger p...
[ "Builds", "pagination", "-", "aware", "request", "object", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_gcp/c7n_gcp/client.py#L347-L364
train
Builds the next request object.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
tools/c7n_gcp/c7n_gcp/client.py
ServiceClient.execute_command
def execute_command(self, verb, verb_arguments): """Executes command (ex. add) via a dedicated http object. Async APIs may take minutes to complete. Therefore, callers are encouraged to leverage concurrent.futures (or similar) to place long running commands on a separate threads. ...
python
def execute_command(self, verb, verb_arguments): """Executes command (ex. add) via a dedicated http object. Async APIs may take minutes to complete. Therefore, callers are encouraged to leverage concurrent.futures (or similar) to place long running commands on a separate threads. ...
[ "def", "execute_command", "(", "self", ",", "verb", ",", "verb_arguments", ")", ":", "request", "=", "self", ".", "_build_request", "(", "verb", ",", "verb_arguments", ")", "return", "self", ".", "_execute", "(", "request", ")" ]
Executes command (ex. add) via a dedicated http object. Async APIs may take minutes to complete. Therefore, callers are encouraged to leverage concurrent.futures (or similar) to place long running commands on a separate threads. Args: verb (str): Method to execute on the co...
[ "Executes", "command", "(", "ex", ".", "add", ")", "via", "a", "dedicated", "http", "object", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_gcp/c7n_gcp/client.py#L377-L392
train
Executes a command via a dedicated http object.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
tools/c7n_gcp/c7n_gcp/client.py
ServiceClient.execute_paged_query
def execute_paged_query(self, verb, verb_arguments): """Executes query (ex. list) via a dedicated http object. Args: verb (str): Method to execute on the component (ex. get, list). verb_arguments (dict): key-value pairs to be passed to _BuildRequest. Yields: ...
python
def execute_paged_query(self, verb, verb_arguments): """Executes query (ex. list) via a dedicated http object. Args: verb (str): Method to execute on the component (ex. get, list). verb_arguments (dict): key-value pairs to be passed to _BuildRequest. Yields: ...
[ "def", "execute_paged_query", "(", "self", ",", "verb", ",", "verb_arguments", ")", ":", "if", "not", "self", ".", "supports_pagination", "(", "verb", "=", "verb", ")", ":", "raise", "PaginationNotSupported", "(", "'{} does not support pagination'", ")", "request"...
Executes query (ex. list) via a dedicated http object. Args: verb (str): Method to execute on the component (ex. get, list). verb_arguments (dict): key-value pairs to be passed to _BuildRequest. Yields: dict: Service Response. Raises: Pagination...
[ "Executes", "query", "(", "ex", ".", "list", ")", "via", "a", "dedicated", "http", "object", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_gcp/c7n_gcp/client.py#L394-L418
train
Executes a paginated query via a dedicated http object.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
tools/c7n_gcp/c7n_gcp/client.py
ServiceClient.execute_search_query
def execute_search_query(self, verb, verb_arguments): """Executes query (ex. search) via a dedicated http object. Args: verb (str): Method to execute on the component (ex. search). verb_arguments (dict): key-value pairs to be passed to _BuildRequest. Yields: ...
python
def execute_search_query(self, verb, verb_arguments): """Executes query (ex. search) via a dedicated http object. Args: verb (str): Method to execute on the component (ex. search). verb_arguments (dict): key-value pairs to be passed to _BuildRequest. Yields: ...
[ "def", "execute_search_query", "(", "self", ",", "verb", ",", "verb_arguments", ")", ":", "# Implementation of search does not follow the standard API pattern.", "# Fields need to be in the body rather than sent seperately.", "next_page_token", "=", "None", "number_of_pages_processed",...
Executes query (ex. search) via a dedicated http object. Args: verb (str): Method to execute on the component (ex. search). verb_arguments (dict): key-value pairs to be passed to _BuildRequest. Yields: dict: Service Response.
[ "Executes", "query", "(", "ex", ".", "search", ")", "via", "a", "dedicated", "http", "object", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_gcp/c7n_gcp/client.py#L420-L446
train
Executes a query via a dedicated http object.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
tools/c7n_gcp/c7n_gcp/client.py
ServiceClient.execute_query
def execute_query(self, verb, verb_arguments): """Executes query (ex. get) via a dedicated http object. Args: verb (str): Method to execute on the component (ex. get, list). verb_arguments (dict): key-value pairs to be passed to _BuildRequest. Returns: dict:...
python
def execute_query(self, verb, verb_arguments): """Executes query (ex. get) via a dedicated http object. Args: verb (str): Method to execute on the component (ex. get, list). verb_arguments (dict): key-value pairs to be passed to _BuildRequest. Returns: dict:...
[ "def", "execute_query", "(", "self", ",", "verb", ",", "verb_arguments", ")", ":", "request", "=", "self", ".", "_build_request", "(", "verb", ",", "verb_arguments", ")", "return", "self", ".", "_execute", "(", "request", ")" ]
Executes query (ex. get) via a dedicated http object. Args: verb (str): Method to execute on the component (ex. get, list). verb_arguments (dict): key-value pairs to be passed to _BuildRequest. Returns: dict: Service Response.
[ "Executes", "query", "(", "ex", ".", "get", ")", "via", "a", "dedicated", "http", "object", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_gcp/c7n_gcp/client.py#L448-L459
train
Executes a query via a dedicated http object.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
tools/c7n_gcp/c7n_gcp/client.py
ServiceClient._execute
def _execute(self, request): """Run execute with retries and rate limiting. Args: request (object): The HttpRequest object to execute. Returns: dict: The response from the API. """ if self._rate_limiter: # Since the ratelimiter library only e...
python
def _execute(self, request): """Run execute with retries and rate limiting. Args: request (object): The HttpRequest object to execute. Returns: dict: The response from the API. """ if self._rate_limiter: # Since the ratelimiter library only e...
[ "def", "_execute", "(", "self", ",", "request", ")", ":", "if", "self", ".", "_rate_limiter", ":", "# Since the ratelimiter library only exposes a context manager", "# interface the code has to be duplicated to handle the case where", "# no rate limiter is defined.", "with", "self"...
Run execute with retries and rate limiting. Args: request (object): The HttpRequest object to execute. Returns: dict: The response from the API.
[ "Run", "execute", "with", "retries", "and", "rate", "limiting", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_gcp/c7n_gcp/client.py#L465-L482
train
Execute with retries and rate limiting.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
tools/sandbox/c7n_sphere11/c7n_sphere11/db.py
LockDb.info
def info(self, account_id, resource_id, parent_id): """Check if a resource is locked. If a resource has an explicit status we use that, else we defer to the parent resource lock status. """ resource = self.record(account_id, resource_id) if resource is None and not paren...
python
def info(self, account_id, resource_id, parent_id): """Check if a resource is locked. If a resource has an explicit status we use that, else we defer to the parent resource lock status. """ resource = self.record(account_id, resource_id) if resource is None and not paren...
[ "def", "info", "(", "self", ",", "account_id", ",", "resource_id", ",", "parent_id", ")", ":", "resource", "=", "self", ".", "record", "(", "account_id", ",", "resource_id", ")", "if", "resource", "is", "None", "and", "not", "parent_id", ":", "return", "...
Check if a resource is locked. If a resource has an explicit status we use that, else we defer to the parent resource lock status.
[ "Check", "if", "a", "resource", "is", "locked", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/sandbox/c7n_sphere11/c7n_sphere11/db.py#L67-L90
train
Get the resource lock status.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
tools/sandbox/zerodark/zerodark/floweni.py
process_eni_metrics
def process_eni_metrics( stream_eni, myips, stream, start, end, period, sample_size, resolver, sink_uri): """ENI flow stream processor that rollups, enhances, and indexes the stream by time period.""" stats = Counter() period_counters = flow_stream_stats(myips, stream, period)...
python
def process_eni_metrics( stream_eni, myips, stream, start, end, period, sample_size, resolver, sink_uri): """ENI flow stream processor that rollups, enhances, and indexes the stream by time period.""" stats = Counter() period_counters = flow_stream_stats(myips, stream, period)...
[ "def", "process_eni_metrics", "(", "stream_eni", ",", "myips", ",", "stream", ",", "start", ",", "end", ",", "period", ",", "sample_size", ",", "resolver", ",", "sink_uri", ")", ":", "stats", "=", "Counter", "(", ")", "period_counters", "=", "flow_stream_sta...
ENI flow stream processor that rollups, enhances, and indexes the stream by time period.
[ "ENI", "flow", "stream", "processor", "that", "rollups", "enhances", "and", "indexes", "the", "stream", "by", "time", "period", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/sandbox/zerodark/zerodark/floweni.py#L166-L211
train
ENI flow stream processor that rollups enhances and indexes the stream by time period.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
tools/sandbox/zerodark/zerodark/floweni.py
analyze_app
def analyze_app( app, env, account_id, bucket, prefix, store_dir, resources, ipdb, ipranges, start, end, tz, sink, period, sample_count, debug): """Analyze flow log records for application and generate metrics per period""" logging.basicConfig(level=logging.INFO) ...
python
def analyze_app( app, env, account_id, bucket, prefix, store_dir, resources, ipdb, ipranges, start, end, tz, sink, period, sample_count, debug): """Analyze flow log records for application and generate metrics per period""" logging.basicConfig(level=logging.INFO) ...
[ "def", "analyze_app", "(", "app", ",", "env", ",", "account_id", ",", "bucket", ",", "prefix", ",", "store_dir", ",", "resources", ",", "ipdb", ",", "ipranges", ",", "start", ",", "end", ",", "tz", ",", "sink", ",", "period", ",", "sample_count", ",", ...
Analyze flow log records for application and generate metrics per period
[ "Analyze", "flow", "log", "records", "for", "application", "and", "generate", "metrics", "per", "period" ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/sandbox/zerodark/zerodark/floweni.py#L309-L390
train
Analyze flow log records for application and generate metrics per period
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
tools/c7n_gcp/c7n_gcp/mu.py
CloudFunctionManager.list_functions
def list_functions(self, prefix=None): """List extant cloud functions.""" return self.client.execute_command( 'list', {'parent': "projects/{}/locations/{}".format( self.session.get_default_project(), self.region)} ).get('functions', [])
python
def list_functions(self, prefix=None): """List extant cloud functions.""" return self.client.execute_command( 'list', {'parent': "projects/{}/locations/{}".format( self.session.get_default_project(), self.region)} ).get('functions', [])
[ "def", "list_functions", "(", "self", ",", "prefix", "=", "None", ")", ":", "return", "self", ".", "client", ".", "execute_command", "(", "'list'", ",", "{", "'parent'", ":", "\"projects/{}/locations/{}\"", ".", "format", "(", "self", ".", "session", ".", ...
List extant cloud functions.
[ "List", "extant", "cloud", "functions", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_gcp/c7n_gcp/mu.py#L67-L74
train
List extant cloud functions.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
tools/c7n_gcp/c7n_gcp/mu.py
CloudFunctionManager.publish
def publish(self, func): """publish the given function.""" project = self.session.get_default_project() func_name = "projects/{}/locations/{}/functions/{}".format( project, self.region, func.name) func_info = self.get(func.name) source_url = None archive = fu...
python
def publish(self, func): """publish the given function.""" project = self.session.get_default_project() func_name = "projects/{}/locations/{}/functions/{}".format( project, self.region, func.name) func_info = self.get(func.name) source_url = None archive = fu...
[ "def", "publish", "(", "self", ",", "func", ")", ":", "project", "=", "self", ".", "session", ".", "get_default_project", "(", ")", "func_name", "=", "\"projects/{}/locations/{}/functions/{}\"", ".", "format", "(", "project", ",", "self", ".", "region", ",", ...
publish the given function.
[ "publish", "the", "given", "function", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_gcp/c7n_gcp/mu.py#L90-L134
train
publish the given function.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
tools/c7n_gcp/c7n_gcp/mu.py
CloudFunctionManager.get
def get(self, func_name, qualifier=None): """Get the details on a given function.""" project = self.session.get_default_project() func_name = "projects/{}/locations/{}/functions/{}".format( project, self.region, func_name) try: return self.client.execute_query('ge...
python
def get(self, func_name, qualifier=None): """Get the details on a given function.""" project = self.session.get_default_project() func_name = "projects/{}/locations/{}/functions/{}".format( project, self.region, func_name) try: return self.client.execute_query('ge...
[ "def", "get", "(", "self", ",", "func_name", ",", "qualifier", "=", "None", ")", ":", "project", "=", "self", ".", "session", ".", "get_default_project", "(", ")", "func_name", "=", "\"projects/{}/locations/{}/functions/{}\"", ".", "format", "(", "project", ",...
Get the details on a given function.
[ "Get", "the", "details", "on", "a", "given", "function", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_gcp/c7n_gcp/mu.py#L142-L151
train
Get the details on a given function.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
tools/c7n_gcp/c7n_gcp/mu.py
CloudFunctionManager._upload
def _upload(self, archive, region): """Upload function source and return source url """ # Generate source upload url url = self.client.execute_command( 'generateUploadUrl', {'parent': 'projects/{}/locations/{}'.format( self.session.get_default_proj...
python
def _upload(self, archive, region): """Upload function source and return source url """ # Generate source upload url url = self.client.execute_command( 'generateUploadUrl', {'parent': 'projects/{}/locations/{}'.format( self.session.get_default_proj...
[ "def", "_upload", "(", "self", ",", "archive", ",", "region", ")", ":", "# Generate source upload url", "url", "=", "self", ".", "client", ".", "execute_command", "(", "'generateUploadUrl'", ",", "{", "'parent'", ":", "'projects/{}/locations/{}'", ".", "format", ...
Upload function source and return source url
[ "Upload", "function", "source", "and", "return", "source", "url" ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_gcp/c7n_gcp/mu.py#L171-L194
train
Upload function source and return source url
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
tools/c7n_gcp/c7n_gcp/mu.py
PubSubSource.ensure_topic
def ensure_topic(self): """Verify the pub/sub topic exists. Returns the topic qualified name. """ client = self.session.client('pubsub', 'v1', 'projects.topics') topic = self.get_topic_param() try: client.execute_command('get', {'topic': topic}) excep...
python
def ensure_topic(self): """Verify the pub/sub topic exists. Returns the topic qualified name. """ client = self.session.client('pubsub', 'v1', 'projects.topics') topic = self.get_topic_param() try: client.execute_command('get', {'topic': topic}) excep...
[ "def", "ensure_topic", "(", "self", ")", ":", "client", "=", "self", ".", "session", ".", "client", "(", "'pubsub'", ",", "'v1'", ",", "'projects.topics'", ")", "topic", "=", "self", ".", "get_topic_param", "(", ")", "try", ":", "client", ".", "execute_c...
Verify the pub/sub topic exists. Returns the topic qualified name.
[ "Verify", "the", "pub", "/", "sub", "topic", "exists", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_gcp/c7n_gcp/mu.py#L416-L434
train
Verify the pub / sub topic exists. Returns the topic qualified name.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
tools/c7n_gcp/c7n_gcp/mu.py
PubSubSource.ensure_iam
def ensure_iam(self, publisher=None): """Ensure the given identities are in the iam role bindings for the topic. """ topic = self.get_topic_param() client = self.session.client('pubsub', 'v1', 'projects.topics') policy = client.execute_command('getIamPolicy', {'resource': topic})...
python
def ensure_iam(self, publisher=None): """Ensure the given identities are in the iam role bindings for the topic. """ topic = self.get_topic_param() client = self.session.client('pubsub', 'v1', 'projects.topics') policy = client.execute_command('getIamPolicy', {'resource': topic})...
[ "def", "ensure_iam", "(", "self", ",", "publisher", "=", "None", ")", ":", "topic", "=", "self", ".", "get_topic_param", "(", ")", "client", "=", "self", ".", "session", ".", "client", "(", "'pubsub'", ",", "'v1'", ",", "'projects.topics'", ")", "policy"...
Ensure the given identities are in the iam role bindings for the topic.
[ "Ensure", "the", "given", "identities", "are", "in", "the", "iam", "role", "bindings", "for", "the", "topic", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_gcp/c7n_gcp/mu.py#L436-L457
train
Ensure the identities are in the iam role bindings for the topic.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
tools/c7n_gcp/c7n_gcp/mu.py
LogSubscriber.get_parent
def get_parent(self, log_info): """Get the parent container for the log sink""" if self.data.get('scope', 'log') == 'log': if log_info.scope_type != 'projects': raise ValueError("Invalid log subscriber scope") parent = "%s/%s" % (log_info.scope_type, log_info.scop...
python
def get_parent(self, log_info): """Get the parent container for the log sink""" if self.data.get('scope', 'log') == 'log': if log_info.scope_type != 'projects': raise ValueError("Invalid log subscriber scope") parent = "%s/%s" % (log_info.scope_type, log_info.scop...
[ "def", "get_parent", "(", "self", ",", "log_info", ")", ":", "if", "self", ".", "data", ".", "get", "(", "'scope'", ",", "'log'", ")", "==", "'log'", ":", "if", "log_info", ".", "scope_type", "!=", "'projects'", ":", "raise", "ValueError", "(", "\"Inva...
Get the parent container for the log sink
[ "Get", "the", "parent", "container", "for", "the", "log", "sink" ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_gcp/c7n_gcp/mu.py#L612-L630
train
Get the parent container for the log sink
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
tools/c7n_gcp/c7n_gcp/mu.py
LogSubscriber.ensure_sink
def ensure_sink(self): """Ensure the log sink and its pub sub topic exist.""" topic_info = self.pubsub.ensure_topic() scope, sink_path, sink_info = self.get_sink(topic_info) client = self.session.client('logging', 'v2', '%s.sinks' % scope) try: sink = client.execute_c...
python
def ensure_sink(self): """Ensure the log sink and its pub sub topic exist.""" topic_info = self.pubsub.ensure_topic() scope, sink_path, sink_info = self.get_sink(topic_info) client = self.session.client('logging', 'v2', '%s.sinks' % scope) try: sink = client.execute_c...
[ "def", "ensure_sink", "(", "self", ")", ":", "topic_info", "=", "self", ".", "pubsub", ".", "ensure_topic", "(", ")", "scope", ",", "sink_path", ",", "sink_info", "=", "self", ".", "get_sink", "(", "topic_info", ")", "client", "=", "self", ".", "session"...
Ensure the log sink and its pub sub topic exist.
[ "Ensure", "the", "log", "sink", "and", "its", "pub", "sub", "topic", "exist", "." ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_gcp/c7n_gcp/mu.py#L658-L680
train
Ensure the log sink and its pub sub topic exist.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
cloud-custodian/cloud-custodian
tools/c7n_gcp/c7n_gcp/mu.py
LogSubscriber.remove
def remove(self, func): """Remove any provisioned log sink if auto created""" if not self.data['name'].startswith(self.prefix): return parent = self.get_parent(self.get_log()) _, sink_path, _ = self.get_sink() client = self.session.client( 'logging', 'v2',...
python
def remove(self, func): """Remove any provisioned log sink if auto created""" if not self.data['name'].startswith(self.prefix): return parent = self.get_parent(self.get_log()) _, sink_path, _ = self.get_sink() client = self.session.client( 'logging', 'v2',...
[ "def", "remove", "(", "self", ",", "func", ")", ":", "if", "not", "self", ".", "data", "[", "'name'", "]", ".", "startswith", "(", "self", ".", "prefix", ")", ":", "return", "parent", "=", "self", ".", "get_parent", "(", "self", ".", "get_log", "("...
Remove any provisioned log sink if auto created
[ "Remove", "any", "provisioned", "log", "sink", "if", "auto", "created" ]
52ef732eb3d7bc939d1579faf519314814695c08
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_gcp/c7n_gcp/mu.py#L686-L699
train
Remove any provisioned log sink if auto created
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...