repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
foremast/foremast
src/foremast/elb/destroy_elb/__main__.py
main
def main(): """Destroy any ELB related Resources.""" logging.basicConfig(format=LOGGING_FORMAT) parser = argparse.ArgumentParser(description=main.__doc__) add_debug(parser) add_app(parser) add_env(parser) add_region(parser) args = parser.parse_args() logging.getLogger(__package__.s...
python
def main(): """Destroy any ELB related Resources.""" logging.basicConfig(format=LOGGING_FORMAT) parser = argparse.ArgumentParser(description=main.__doc__) add_debug(parser) add_app(parser) add_env(parser) add_region(parser) args = parser.parse_args() logging.getLogger(__package__.s...
[ "def", "main", "(", ")", ":", "logging", ".", "basicConfig", "(", "format", "=", "LOGGING_FORMAT", ")", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "main", ".", "__doc__", ")", "add_debug", "(", "parser", ")", "add_app", "(",...
Destroy any ELB related Resources.
[ "Destroy", "any", "ELB", "related", "Resources", "." ]
fb70f29b8ce532f061685a17d120486e47b215ba
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/elb/destroy_elb/__main__.py#L27-L40
train
foremast/foremast
src/foremast/utils/security_group.py
get_security_group_id
def get_security_group_id(name='', env='', region=''): """Get a security group ID. Args: name (str): Security Group name to find. env (str): Deployment environment to search. region (str): AWS Region to search. Returns: str: ID of Security Group, e.g. sg-xxxx. Raises: ...
python
def get_security_group_id(name='', env='', region=''): """Get a security group ID. Args: name (str): Security Group name to find. env (str): Deployment environment to search. region (str): AWS Region to search. Returns: str: ID of Security Group, e.g. sg-xxxx. Raises: ...
[ "def", "get_security_group_id", "(", "name", "=", "''", ",", "env", "=", "''", ",", "region", "=", "''", ")", ":", "vpc_id", "=", "get_vpc_id", "(", "env", ",", "region", ")", "LOG", ".", "info", "(", "'Find %s sg in %s [%s] in %s'", ",", "name", ",", ...
Get a security group ID. Args: name (str): Security Group name to find. env (str): Deployment environment to search. region (str): AWS Region to search. Returns: str: ID of Security Group, e.g. sg-xxxx. Raises: AssertionError: Call to Gate API was not successful. ...
[ "Get", "a", "security", "group", "ID", "." ]
fb70f29b8ce532f061685a17d120486e47b215ba
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/utils/security_group.py#L30-L63
train
foremast/foremast
src/foremast/utils/security_group.py
remove_duplicate_sg
def remove_duplicate_sg(security_groups): """Removes duplicate Security Groups that share a same name alias Args: security_groups (list): A list of security group id to compare against SECURITYGROUP_REPLACEMENTS Returns: security_groups (list): A list of security groups with duplicate alia...
python
def remove_duplicate_sg(security_groups): """Removes duplicate Security Groups that share a same name alias Args: security_groups (list): A list of security group id to compare against SECURITYGROUP_REPLACEMENTS Returns: security_groups (list): A list of security groups with duplicate alia...
[ "def", "remove_duplicate_sg", "(", "security_groups", ")", ":", "for", "each_sg", ",", "duplicate_sg_name", "in", "SECURITYGROUP_REPLACEMENTS", ".", "items", "(", ")", ":", "if", "each_sg", "in", "security_groups", "and", "duplicate_sg_name", "in", "security_groups", ...
Removes duplicate Security Groups that share a same name alias Args: security_groups (list): A list of security group id to compare against SECURITYGROUP_REPLACEMENTS Returns: security_groups (list): A list of security groups with duplicate aliases removed
[ "Removes", "duplicate", "Security", "Groups", "that", "share", "a", "same", "name", "alias" ]
fb70f29b8ce532f061685a17d120486e47b215ba
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/utils/security_group.py#L66-L80
train
foremast/foremast
src/foremast/utils/encoding.py
generate_encoded_user_data
def generate_encoded_user_data( env='dev', region='us-east-1', generated=None, group_name='', pipeline_type='', canary=False, ): r"""Generate base64 encoded User Data. Args: env (str): Deployment environment, e.g. dev, stage. region (str): AWS Reg...
python
def generate_encoded_user_data( env='dev', region='us-east-1', generated=None, group_name='', pipeline_type='', canary=False, ): r"""Generate base64 encoded User Data. Args: env (str): Deployment environment, e.g. dev, stage. region (str): AWS Reg...
[ "def", "generate_encoded_user_data", "(", "env", "=", "'dev'", ",", "region", "=", "'us-east-1'", ",", "generated", "=", "None", ",", "group_name", "=", "''", ",", "pipeline_type", "=", "''", ",", "canary", "=", "False", ",", ")", ":", "r", "if", "env", ...
r"""Generate base64 encoded User Data. Args: env (str): Deployment environment, e.g. dev, stage. region (str): AWS Region, e.g. us-east-1. generated (gogoutils.Generator): Generated naming formats. group_name (str): Application group nane, e.g. core. pipeline_type (str): Typ...
[ "r", "Generate", "base64", "encoded", "User", "Data", "." ]
fb70f29b8ce532f061685a17d120486e47b215ba
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/utils/encoding.py#L22-L74
train
foremast/foremast
src/foremast/runner.py
prepare_infrastructure
def prepare_infrastructure(): """Entry point for preparing the infrastructure in a specific env.""" runner = ForemastRunner() runner.write_configs() runner.create_app() archaius = runner.configs[runner.env]['app']['archaius_enabled'] eureka = runner.configs[runner.env]['app']['eureka_enabled']...
python
def prepare_infrastructure(): """Entry point for preparing the infrastructure in a specific env.""" runner = ForemastRunner() runner.write_configs() runner.create_app() archaius = runner.configs[runner.env]['app']['archaius_enabled'] eureka = runner.configs[runner.env]['app']['eureka_enabled']...
[ "def", "prepare_infrastructure", "(", ")", ":", "runner", "=", "ForemastRunner", "(", ")", "runner", ".", "write_configs", "(", ")", "runner", ".", "create_app", "(", ")", "archaius", "=", "runner", ".", "configs", "[", "runner", ".", "env", "]", "[", "'...
Entry point for preparing the infrastructure in a specific env.
[ "Entry", "point", "for", "preparing", "the", "infrastructure", "in", "a", "specific", "env", "." ]
fb70f29b8ce532f061685a17d120486e47b215ba
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/runner.py#L250-L283
train
foremast/foremast
src/foremast/runner.py
prepare_app_pipeline
def prepare_app_pipeline(): """Entry point for application setup and initial pipeline in Spinnaker.""" runner = ForemastRunner() runner.write_configs() runner.create_app() runner.create_pipeline() runner.cleanup()
python
def prepare_app_pipeline(): """Entry point for application setup and initial pipeline in Spinnaker.""" runner = ForemastRunner() runner.write_configs() runner.create_app() runner.create_pipeline() runner.cleanup()
[ "def", "prepare_app_pipeline", "(", ")", ":", "runner", "=", "ForemastRunner", "(", ")", "runner", ".", "write_configs", "(", ")", "runner", ".", "create_app", "(", ")", "runner", ".", "create_pipeline", "(", ")", "runner", ".", "cleanup", "(", ")" ]
Entry point for application setup and initial pipeline in Spinnaker.
[ "Entry", "point", "for", "application", "setup", "and", "initial", "pipeline", "in", "Spinnaker", "." ]
fb70f29b8ce532f061685a17d120486e47b215ba
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/runner.py#L286-L292
train
foremast/foremast
src/foremast/runner.py
prepare_onetime_pipeline
def prepare_onetime_pipeline(): """Entry point for single use pipeline setup in the defined app.""" runner = ForemastRunner() runner.write_configs() runner.create_pipeline(onetime=os.getenv('ENV')) runner.cleanup()
python
def prepare_onetime_pipeline(): """Entry point for single use pipeline setup in the defined app.""" runner = ForemastRunner() runner.write_configs() runner.create_pipeline(onetime=os.getenv('ENV')) runner.cleanup()
[ "def", "prepare_onetime_pipeline", "(", ")", ":", "runner", "=", "ForemastRunner", "(", ")", "runner", ".", "write_configs", "(", ")", "runner", ".", "create_pipeline", "(", "onetime", "=", "os", ".", "getenv", "(", "'ENV'", ")", ")", "runner", ".", "clean...
Entry point for single use pipeline setup in the defined app.
[ "Entry", "point", "for", "single", "use", "pipeline", "setup", "in", "the", "defined", "app", "." ]
fb70f29b8ce532f061685a17d120486e47b215ba
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/runner.py#L295-L300
train
foremast/foremast
src/foremast/runner.py
ForemastRunner.write_configs
def write_configs(self): """Generate the configurations needed for pipes.""" utils.banner("Generating Configs") if not self.runway_dir: app_configs = configs.process_git_configs(git_short=self.git_short) else: app_configs = configs.process_runway_configs(runway_di...
python
def write_configs(self): """Generate the configurations needed for pipes.""" utils.banner("Generating Configs") if not self.runway_dir: app_configs = configs.process_git_configs(git_short=self.git_short) else: app_configs = configs.process_runway_configs(runway_di...
[ "def", "write_configs", "(", "self", ")", ":", "utils", ".", "banner", "(", "\"Generating Configs\"", ")", "if", "not", "self", ".", "runway_dir", ":", "app_configs", "=", "configs", ".", "process_git_configs", "(", "git_short", "=", "self", ".", "git_short", ...
Generate the configurations needed for pipes.
[ "Generate", "the", "configurations", "needed", "for", "pipes", "." ]
fb70f29b8ce532f061685a17d120486e47b215ba
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/runner.py#L72-L81
train
foremast/foremast
src/foremast/runner.py
ForemastRunner.create_app
def create_app(self): """Create the spinnaker application.""" utils.banner("Creating Spinnaker App") spinnakerapp = app.SpinnakerApp(app=self.app, email=self.email, project=self.group, repo=self.repo, pipeline_config=self.configs['pipeline']) spinn...
python
def create_app(self): """Create the spinnaker application.""" utils.banner("Creating Spinnaker App") spinnakerapp = app.SpinnakerApp(app=self.app, email=self.email, project=self.group, repo=self.repo, pipeline_config=self.configs['pipeline']) spinn...
[ "def", "create_app", "(", "self", ")", ":", "utils", ".", "banner", "(", "\"Creating Spinnaker App\"", ")", "spinnakerapp", "=", "app", ".", "SpinnakerApp", "(", "app", "=", "self", ".", "app", ",", "email", "=", "self", ".", "email", ",", "project", "="...
Create the spinnaker application.
[ "Create", "the", "spinnaker", "application", "." ]
fb70f29b8ce532f061685a17d120486e47b215ba
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/runner.py#L83-L88
train
foremast/foremast
src/foremast/runner.py
ForemastRunner.create_iam
def create_iam(self): """Create IAM resources.""" utils.banner("Creating IAM") iam.create_iam_resources(env=self.env, app=self.app)
python
def create_iam(self): """Create IAM resources.""" utils.banner("Creating IAM") iam.create_iam_resources(env=self.env, app=self.app)
[ "def", "create_iam", "(", "self", ")", ":", "utils", ".", "banner", "(", "\"Creating IAM\"", ")", "iam", ".", "create_iam_resources", "(", "env", "=", "self", ".", "env", ",", "app", "=", "self", ".", "app", ")" ]
Create IAM resources.
[ "Create", "IAM", "resources", "." ]
fb70f29b8ce532f061685a17d120486e47b215ba
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/runner.py#L124-L127
train
foremast/foremast
src/foremast/runner.py
ForemastRunner.create_archaius
def create_archaius(self): """Create S3 bucket for Archaius.""" utils.banner("Creating S3") s3.init_properties(env=self.env, app=self.app)
python
def create_archaius(self): """Create S3 bucket for Archaius.""" utils.banner("Creating S3") s3.init_properties(env=self.env, app=self.app)
[ "def", "create_archaius", "(", "self", ")", ":", "utils", ".", "banner", "(", "\"Creating S3\"", ")", "s3", ".", "init_properties", "(", "env", "=", "self", ".", "env", ",", "app", "=", "self", ".", "app", ")" ]
Create S3 bucket for Archaius.
[ "Create", "S3", "bucket", "for", "Archaius", "." ]
fb70f29b8ce532f061685a17d120486e47b215ba
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/runner.py#L129-L132
train
foremast/foremast
src/foremast/runner.py
ForemastRunner.create_s3app
def create_s3app(self): """Create S3 infra for s3 applications""" utils.banner("Creating S3 App Infrastructure") primary_region = self.configs['pipeline']['primary_region'] s3obj = s3.S3Apps(app=self.app, env=self.env, region=self.regio...
python
def create_s3app(self): """Create S3 infra for s3 applications""" utils.banner("Creating S3 App Infrastructure") primary_region = self.configs['pipeline']['primary_region'] s3obj = s3.S3Apps(app=self.app, env=self.env, region=self.regio...
[ "def", "create_s3app", "(", "self", ")", ":", "utils", ".", "banner", "(", "\"Creating S3 App Infrastructure\"", ")", "primary_region", "=", "self", ".", "configs", "[", "'pipeline'", "]", "[", "'primary_region'", "]", "s3obj", "=", "s3", ".", "S3Apps", "(", ...
Create S3 infra for s3 applications
[ "Create", "S3", "infra", "for", "s3", "applications" ]
fb70f29b8ce532f061685a17d120486e47b215ba
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/runner.py#L134-L143
train
foremast/foremast
src/foremast/runner.py
ForemastRunner.deploy_s3app
def deploy_s3app(self): """Deploys artifacts contents to S3 bucket""" utils.banner("Deploying S3 App") primary_region = self.configs['pipeline']['primary_region'] s3obj = s3.S3Deployment( app=self.app, env=self.env, region=self.region, prop...
python
def deploy_s3app(self): """Deploys artifacts contents to S3 bucket""" utils.banner("Deploying S3 App") primary_region = self.configs['pipeline']['primary_region'] s3obj = s3.S3Deployment( app=self.app, env=self.env, region=self.region, prop...
[ "def", "deploy_s3app", "(", "self", ")", ":", "utils", ".", "banner", "(", "\"Deploying S3 App\"", ")", "primary_region", "=", "self", ".", "configs", "[", "'pipeline'", "]", "[", "'primary_region'", "]", "s3obj", "=", "s3", ".", "S3Deployment", "(", "app", ...
Deploys artifacts contents to S3 bucket
[ "Deploys", "artifacts", "contents", "to", "S3", "bucket" ]
fb70f29b8ce532f061685a17d120486e47b215ba
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/runner.py#L145-L157
train
foremast/foremast
src/foremast/runner.py
ForemastRunner.promote_s3app
def promote_s3app(self): """promotes S3 deployment to LATEST""" utils.banner("Promoting S3 App") primary_region = self.configs['pipeline']['primary_region'] s3obj = s3.S3Deployment( app=self.app, env=self.env, region=self.region, prop_path=...
python
def promote_s3app(self): """promotes S3 deployment to LATEST""" utils.banner("Promoting S3 App") primary_region = self.configs['pipeline']['primary_region'] s3obj = s3.S3Deployment( app=self.app, env=self.env, region=self.region, prop_path=...
[ "def", "promote_s3app", "(", "self", ")", ":", "utils", ".", "banner", "(", "\"Promoting S3 App\"", ")", "primary_region", "=", "self", ".", "configs", "[", "'pipeline'", "]", "[", "'primary_region'", "]", "s3obj", "=", "s3", ".", "S3Deployment", "(", "app",...
promotes S3 deployment to LATEST
[ "promotes", "S3", "deployment", "to", "LATEST" ]
fb70f29b8ce532f061685a17d120486e47b215ba
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/runner.py#L159-L171
train
foremast/foremast
src/foremast/runner.py
ForemastRunner.create_elb
def create_elb(self): """Create the ELB for the defined environment.""" utils.banner("Creating ELB") elbobj = elb.SpinnakerELB(app=self.app, env=self.env, region=self.region, prop_path=self.json_path) elbobj.create_elb()
python
def create_elb(self): """Create the ELB for the defined environment.""" utils.banner("Creating ELB") elbobj = elb.SpinnakerELB(app=self.app, env=self.env, region=self.region, prop_path=self.json_path) elbobj.create_elb()
[ "def", "create_elb", "(", "self", ")", ":", "utils", ".", "banner", "(", "\"Creating ELB\"", ")", "elbobj", "=", "elb", ".", "SpinnakerELB", "(", "app", "=", "self", ".", "app", ",", "env", "=", "self", ".", "env", ",", "region", "=", "self", ".", ...
Create the ELB for the defined environment.
[ "Create", "the", "ELB", "for", "the", "defined", "environment", "." ]
fb70f29b8ce532f061685a17d120486e47b215ba
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/runner.py#L191-L195
train
foremast/foremast
src/foremast/runner.py
ForemastRunner.create_dns
def create_dns(self): """Create DNS for the defined app and environment.""" utils.banner("Creating DNS") elb_subnet = self.configs[self.env]['elb']['subnet_purpose'] regions = self.configs[self.env]['regions'] failover = self.configs[self.env]['dns']['failover_dns'] prima...
python
def create_dns(self): """Create DNS for the defined app and environment.""" utils.banner("Creating DNS") elb_subnet = self.configs[self.env]['elb']['subnet_purpose'] regions = self.configs[self.env]['regions'] failover = self.configs[self.env]['dns']['failover_dns'] prima...
[ "def", "create_dns", "(", "self", ")", ":", "utils", ".", "banner", "(", "\"Creating DNS\"", ")", "elb_subnet", "=", "self", ".", "configs", "[", "self", ".", "env", "]", "[", "'elb'", "]", "[", "'subnet_purpose'", "]", "regions", "=", "self", ".", "co...
Create DNS for the defined app and environment.
[ "Create", "DNS", "for", "the", "defined", "app", "and", "environment", "." ]
fb70f29b8ce532f061685a17d120486e47b215ba
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/runner.py#L197-L217
train
foremast/foremast
src/foremast/runner.py
ForemastRunner.create_autoscaling_policy
def create_autoscaling_policy(self): """Create Scaling Policy for app in environment""" utils.banner("Creating Scaling Policy") policyobj = autoscaling_policy.AutoScalingPolicy( app=self.app, env=self.env, region=self.region, prop_path=self.json_path) policyobj.create_policy(...
python
def create_autoscaling_policy(self): """Create Scaling Policy for app in environment""" utils.banner("Creating Scaling Policy") policyobj = autoscaling_policy.AutoScalingPolicy( app=self.app, env=self.env, region=self.region, prop_path=self.json_path) policyobj.create_policy(...
[ "def", "create_autoscaling_policy", "(", "self", ")", ":", "utils", ".", "banner", "(", "\"Creating Scaling Policy\"", ")", "policyobj", "=", "autoscaling_policy", ".", "AutoScalingPolicy", "(", "app", "=", "self", ".", "app", ",", "env", "=", "self", ".", "en...
Create Scaling Policy for app in environment
[ "Create", "Scaling", "Policy", "for", "app", "in", "environment" ]
fb70f29b8ce532f061685a17d120486e47b215ba
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/runner.py#L219-L224
train
foremast/foremast
src/foremast/runner.py
ForemastRunner.create_datapipeline
def create_datapipeline(self): """Creates data pipeline and adds definition""" utils.banner("Creating Data Pipeline") dpobj = datapipeline.AWSDataPipeline(app=self.app, env=self.env, region=self.region, prop_path=self.json_path) dpobj.create_datapipeline() dpobj.set_pipeline_defi...
python
def create_datapipeline(self): """Creates data pipeline and adds definition""" utils.banner("Creating Data Pipeline") dpobj = datapipeline.AWSDataPipeline(app=self.app, env=self.env, region=self.region, prop_path=self.json_path) dpobj.create_datapipeline() dpobj.set_pipeline_defi...
[ "def", "create_datapipeline", "(", "self", ")", ":", "utils", ".", "banner", "(", "\"Creating Data Pipeline\"", ")", "dpobj", "=", "datapipeline", ".", "AWSDataPipeline", "(", "app", "=", "self", ".", "app", ",", "env", "=", "self", ".", "env", ",", "regio...
Creates data pipeline and adds definition
[ "Creates", "data", "pipeline", "and", "adds", "definition" ]
fb70f29b8ce532f061685a17d120486e47b215ba
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/runner.py#L226-L233
train
foremast/foremast
src/foremast/runner.py
ForemastRunner.slack_notify
def slack_notify(self): """Send out a slack notification.""" utils.banner("Sending slack notification") if self.env.startswith("prod"): notify = slacknotify.SlackNotification(app=self.app, env=self.env, prop_path=self.json_path) notify.post_message() else: ...
python
def slack_notify(self): """Send out a slack notification.""" utils.banner("Sending slack notification") if self.env.startswith("prod"): notify = slacknotify.SlackNotification(app=self.app, env=self.env, prop_path=self.json_path) notify.post_message() else: ...
[ "def", "slack_notify", "(", "self", ")", ":", "utils", ".", "banner", "(", "\"Sending slack notification\"", ")", "if", "self", ".", "env", ".", "startswith", "(", "\"prod\"", ")", ":", "notify", "=", "slacknotify", ".", "SlackNotification", "(", "app", "=",...
Send out a slack notification.
[ "Send", "out", "a", "slack", "notification", "." ]
fb70f29b8ce532f061685a17d120486e47b215ba
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/runner.py#L235-L243
train
foremast/foremast
src/foremast/args.py
add_debug
def add_debug(parser): """Add a `debug` flag to the _parser_.""" parser.add_argument( '-d', '--debug', action='store_const', const=logging.DEBUG, default=logging.INFO, help='Set DEBUG output')
python
def add_debug(parser): """Add a `debug` flag to the _parser_.""" parser.add_argument( '-d', '--debug', action='store_const', const=logging.DEBUG, default=logging.INFO, help='Set DEBUG output')
[ "def", "add_debug", "(", "parser", ")", ":", "parser", ".", "add_argument", "(", "'-d'", ",", "'--debug'", ",", "action", "=", "'store_const'", ",", "const", "=", "logging", ".", "DEBUG", ",", "default", "=", "logging", ".", "INFO", ",", "help", "=", "...
Add a `debug` flag to the _parser_.
[ "Add", "a", "debug", "flag", "to", "the", "_parser_", "." ]
fb70f29b8ce532f061685a17d120486e47b215ba
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/args.py#L28-L31
train
foremast/foremast
src/foremast/args.py
add_env
def add_env(parser): """Add an `env` flag to the _parser_.""" parser.add_argument( '-e', '--env', choices=ENVS, default=os.getenv('ENV', default='dev'), help='Deploy environment, overrides $ENV')
python
def add_env(parser): """Add an `env` flag to the _parser_.""" parser.add_argument( '-e', '--env', choices=ENVS, default=os.getenv('ENV', default='dev'), help='Deploy environment, overrides $ENV')
[ "def", "add_env", "(", "parser", ")", ":", "parser", ".", "add_argument", "(", "'-e'", ",", "'--env'", ",", "choices", "=", "ENVS", ",", "default", "=", "os", ".", "getenv", "(", "'ENV'", ",", "default", "=", "'dev'", ")", ",", "help", "=", "'Deploy ...
Add an `env` flag to the _parser_.
[ "Add", "an", "env", "flag", "to", "the", "_parser_", "." ]
fb70f29b8ce532f061685a17d120486e47b215ba
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/args.py#L34-L37
train
foremast/foremast
src/foremast/autoscaling_policy/__main__.py
main
def main(): """CLI entrypoint for scaling policy creation""" logging.basicConfig(format=LOGGING_FORMAT) log = logging.getLogger(__name__) parser = argparse.ArgumentParser() add_debug(parser) add_app(parser) add_properties(parser) add_env(parser) add_region(parser) args = parser....
python
def main(): """CLI entrypoint for scaling policy creation""" logging.basicConfig(format=LOGGING_FORMAT) log = logging.getLogger(__name__) parser = argparse.ArgumentParser() add_debug(parser) add_app(parser) add_properties(parser) add_env(parser) add_region(parser) args = parser....
[ "def", "main", "(", ")", ":", "logging", ".", "basicConfig", "(", "format", "=", "LOGGING_FORMAT", ")", "log", "=", "logging", ".", "getLogger", "(", "__name__", ")", "parser", "=", "argparse", ".", "ArgumentParser", "(", ")", "add_debug", "(", "parser", ...
CLI entrypoint for scaling policy creation
[ "CLI", "entrypoint", "for", "scaling", "policy", "creation" ]
fb70f29b8ce532f061685a17d120486e47b215ba
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/autoscaling_policy/__main__.py#L29-L48
train
foremast/foremast
src/foremast/awslambda/__main__.py
main
def main(): """Create Lambda events.""" logging.basicConfig(format=LOGGING_FORMAT) log = logging.getLogger(__name__) parser = argparse.ArgumentParser(description=main.__doc__) add_debug(parser) add_app(parser) add_env(parser) add_properties(parser) add_region(parser) args = pars...
python
def main(): """Create Lambda events.""" logging.basicConfig(format=LOGGING_FORMAT) log = logging.getLogger(__name__) parser = argparse.ArgumentParser(description=main.__doc__) add_debug(parser) add_app(parser) add_env(parser) add_properties(parser) add_region(parser) args = pars...
[ "def", "main", "(", ")", ":", "logging", ".", "basicConfig", "(", "format", "=", "LOGGING_FORMAT", ")", "log", "=", "logging", ".", "getLogger", "(", "__name__", ")", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "main", ".", ...
Create Lambda events.
[ "Create", "Lambda", "events", "." ]
fb70f29b8ce532f061685a17d120486e47b215ba
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/awslambda/__main__.py#L29-L51
train
foremast/foremast
src/foremast/utils/slack.py
post_slack_message
def post_slack_message(message=None, channel=None, username=None, icon_emoji=None): """Format the message and post to the appropriate slack channel. Args: message (str): Message to post to slack channel (str): Desired channel. Must start with # """ LOG.debug('Slack Channel: %s\nSlack M...
python
def post_slack_message(message=None, channel=None, username=None, icon_emoji=None): """Format the message and post to the appropriate slack channel. Args: message (str): Message to post to slack channel (str): Desired channel. Must start with # """ LOG.debug('Slack Channel: %s\nSlack M...
[ "def", "post_slack_message", "(", "message", "=", "None", ",", "channel", "=", "None", ",", "username", "=", "None", ",", "icon_emoji", "=", "None", ")", ":", "LOG", ".", "debug", "(", "'Slack Channel: %s\\nSlack Message: %s'", ",", "channel", ",", "message", ...
Format the message and post to the appropriate slack channel. Args: message (str): Message to post to slack channel (str): Desired channel. Must start with #
[ "Format", "the", "message", "and", "post", "to", "the", "appropriate", "slack", "channel", "." ]
fb70f29b8ce532f061685a17d120486e47b215ba
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/utils/slack.py#L26-L40
train
foremast/foremast
src/foremast/dns/destroy_dns/destroy_dns.py
destroy_dns
def destroy_dns(app='', env='dev', **_): """Destroy DNS records. Args: app (str): Spinnaker Application name. env (str): Deployment environment. regions (str): AWS region. Returns: bool: True upon successful completion. """ client = boto3.Session(profile_name=env).c...
python
def destroy_dns(app='', env='dev', **_): """Destroy DNS records. Args: app (str): Spinnaker Application name. env (str): Deployment environment. regions (str): AWS region. Returns: bool: True upon successful completion. """ client = boto3.Session(profile_name=env).c...
[ "def", "destroy_dns", "(", "app", "=", "''", ",", "env", "=", "'dev'", ",", "**", "_", ")", ":", "client", "=", "boto3", ".", "Session", "(", "profile_name", "=", "env", ")", ".", "client", "(", "'route53'", ")", "generated", "=", "get_details", "(",...
Destroy DNS records. Args: app (str): Spinnaker Application name. env (str): Deployment environment. regions (str): AWS region. Returns: bool: True upon successful completion.
[ "Destroy", "DNS", "records", "." ]
fb70f29b8ce532f061685a17d120486e47b215ba
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/dns/destroy_dns/destroy_dns.py#L27-L52
train
foremast/foremast
src/foremast/dns/destroy_dns/destroy_dns.py
destroy_record
def destroy_record(client=None, found_record=None, record='', zone_id=''): """Destroy an individual DNS record. Args: client (botocore.client.Route53): Route 53 boto3 client. found_record (dict): Route 53 record set:: {'Name': 'unicorn.forrest.dev.example.com.', 'Resou...
python
def destroy_record(client=None, found_record=None, record='', zone_id=''): """Destroy an individual DNS record. Args: client (botocore.client.Route53): Route 53 boto3 client. found_record (dict): Route 53 record set:: {'Name': 'unicorn.forrest.dev.example.com.', 'Resou...
[ "def", "destroy_record", "(", "client", "=", "None", ",", "found_record", "=", "None", ",", "record", "=", "''", ",", "zone_id", "=", "''", ")", ":", "LOG", ".", "debug", "(", "'Found DNS record: %s'", ",", "found_record", ")", "if", "found_record", "[", ...
Destroy an individual DNS record. Args: client (botocore.client.Route53): Route 53 boto3 client. found_record (dict): Route 53 record set:: {'Name': 'unicorn.forrest.dev.example.com.', 'ResourceRecords': [{'Value': 'internal-unicornforrest-17774...
[ "Destroy", "an", "individual", "DNS", "record", "." ]
fb70f29b8ce532f061685a17d120486e47b215ba
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/dns/destroy_dns/destroy_dns.py#L55-L88
train
foremast/foremast
src/foremast/awslambda/sns_event/sns_event.py
create_sns_event
def create_sns_event(app_name, env, region, rules): """Create SNS lambda event from rules. Args: app_name (str): name of the lambda function env (str): Environment/Account for lambda function region (str): AWS region of the lambda function rules (str): Trigger rules from the set...
python
def create_sns_event(app_name, env, region, rules): """Create SNS lambda event from rules. Args: app_name (str): name of the lambda function env (str): Environment/Account for lambda function region (str): AWS region of the lambda function rules (str): Trigger rules from the set...
[ "def", "create_sns_event", "(", "app_name", ",", "env", ",", "region", ",", "rules", ")", ":", "session", "=", "boto3", ".", "Session", "(", "profile_name", "=", "env", ",", "region_name", "=", "region", ")", "sns_client", "=", "session", ".", "client", ...
Create SNS lambda event from rules. Args: app_name (str): name of the lambda function env (str): Environment/Account for lambda function region (str): AWS region of the lambda function rules (str): Trigger rules from the settings
[ "Create", "SNS", "lambda", "event", "from", "rules", "." ]
fb70f29b8ce532f061685a17d120486e47b215ba
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/awslambda/sns_event/sns_event.py#L27-L58
train
foremast/foremast
src/foremast/awslambda/sns_event/destroy_sns_event/destroy_sns_event.py
destroy_sns_event
def destroy_sns_event(app_name, env, region): """ Destroy all Lambda SNS subscriptions. Args: app_name (str): name of the lambda function env (str): Environment/Account for lambda function region (str): AWS region of the lambda function Returns: boolean: True if subscriptio...
python
def destroy_sns_event(app_name, env, region): """ Destroy all Lambda SNS subscriptions. Args: app_name (str): name of the lambda function env (str): Environment/Account for lambda function region (str): AWS region of the lambda function Returns: boolean: True if subscriptio...
[ "def", "destroy_sns_event", "(", "app_name", ",", "env", ",", "region", ")", ":", "session", "=", "boto3", ".", "Session", "(", "profile_name", "=", "env", ",", "region_name", "=", "region", ")", "sns_client", "=", "session", ".", "client", "(", "'sns'", ...
Destroy all Lambda SNS subscriptions. Args: app_name (str): name of the lambda function env (str): Environment/Account for lambda function region (str): AWS region of the lambda function Returns: boolean: True if subscription destroyed successfully
[ "Destroy", "all", "Lambda", "SNS", "subscriptions", "." ]
fb70f29b8ce532f061685a17d120486e47b215ba
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/awslambda/sns_event/destroy_sns_event/destroy_sns_event.py#L27-L47
train
foremast/foremast
src/foremast/elb/destroy_elb/destroy_elb.py
destroy_elb
def destroy_elb(app='', env='dev', region='us-east-1', **_): """Destroy ELB Resources. Args: app (str): Spinnaker Application name. env (str): Deployment environment. region (str): AWS region. Returns: True upon successful completion. """ task_json = get_template( ...
python
def destroy_elb(app='', env='dev', region='us-east-1', **_): """Destroy ELB Resources. Args: app (str): Spinnaker Application name. env (str): Deployment environment. region (str): AWS region. Returns: True upon successful completion. """ task_json = get_template( ...
[ "def", "destroy_elb", "(", "app", "=", "''", ",", "env", "=", "'dev'", ",", "region", "=", "'us-east-1'", ",", "**", "_", ")", ":", "task_json", "=", "get_template", "(", "template_file", "=", "'destroy/destroy_elb.json.j2'", ",", "app", "=", "app", ",", ...
Destroy ELB Resources. Args: app (str): Spinnaker Application name. env (str): Deployment environment. region (str): AWS region. Returns: True upon successful completion.
[ "Destroy", "ELB", "Resources", "." ]
fb70f29b8ce532f061685a17d120486e47b215ba
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/elb/destroy_elb/destroy_elb.py#L21-L41
train
foremast/foremast
src/foremast/pipeline/clean_pipelines.py
delete_pipeline
def delete_pipeline(app='', pipeline_name=''): """Delete _pipeline_name_ from _app_.""" safe_pipeline_name = normalize_pipeline_name(name=pipeline_name) LOG.warning('Deleting Pipeline: %s', safe_pipeline_name) url = '{host}/pipelines/{app}/{pipeline}'.format(host=API_URL, app=app, pipeline=safe_pipeli...
python
def delete_pipeline(app='', pipeline_name=''): """Delete _pipeline_name_ from _app_.""" safe_pipeline_name = normalize_pipeline_name(name=pipeline_name) LOG.warning('Deleting Pipeline: %s', safe_pipeline_name) url = '{host}/pipelines/{app}/{pipeline}'.format(host=API_URL, app=app, pipeline=safe_pipeli...
[ "def", "delete_pipeline", "(", "app", "=", "''", ",", "pipeline_name", "=", "''", ")", ":", "safe_pipeline_name", "=", "normalize_pipeline_name", "(", "name", "=", "pipeline_name", ")", "LOG", ".", "warning", "(", "'Deleting Pipeline: %s'", ",", "safe_pipeline_nam...
Delete _pipeline_name_ from _app_.
[ "Delete", "_pipeline_name_", "from", "_app_", "." ]
fb70f29b8ce532f061685a17d120486e47b215ba
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/pipeline/clean_pipelines.py#L28-L47
train
foremast/foremast
src/foremast/pipeline/clean_pipelines.py
clean_pipelines
def clean_pipelines(app='', settings=None): """Delete Pipelines for regions not defined in application.json files. For Pipelines named **app_name [region]**, _region_ will need to appear in at least one application.json file. All other names are assumed unamanaged. Args: app (str): Applica...
python
def clean_pipelines(app='', settings=None): """Delete Pipelines for regions not defined in application.json files. For Pipelines named **app_name [region]**, _region_ will need to appear in at least one application.json file. All other names are assumed unamanaged. Args: app (str): Applica...
[ "def", "clean_pipelines", "(", "app", "=", "''", ",", "settings", "=", "None", ")", ":", "pipelines", "=", "get_all_pipelines", "(", "app", "=", "app", ")", "envs", "=", "settings", "[", "'pipeline'", "]", "[", "'env'", "]", "LOG", ".", "debug", "(", ...
Delete Pipelines for regions not defined in application.json files. For Pipelines named **app_name [region]**, _region_ will need to appear in at least one application.json file. All other names are assumed unamanaged. Args: app (str): Application name settings (dict): imported configu...
[ "Delete", "Pipelines", "for", "regions", "not", "defined", "in", "application", ".", "json", "files", "." ]
fb70f29b8ce532f061685a17d120486e47b215ba
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/pipeline/clean_pipelines.py#L50-L96
train
foremast/foremast
src/foremast/consts.py
extract_formats
def extract_formats(config_handle): """Get application formats. See :class:`gogoutils.Formats` for available options. Args: config_handle (configparser.ConfigParser): Instance of configurations. Returns: dict: Formats in ``{$format_type: $format_pattern}``. """ configurations...
python
def extract_formats(config_handle): """Get application formats. See :class:`gogoutils.Formats` for available options. Args: config_handle (configparser.ConfigParser): Instance of configurations. Returns: dict: Formats in ``{$format_type: $format_pattern}``. """ configurations...
[ "def", "extract_formats", "(", "config_handle", ")", ":", "configurations", "=", "dict", "(", "config_handle", ")", "formats", "=", "dict", "(", "configurations", ".", "get", "(", "'formats'", ",", "{", "}", ")", ")", "return", "formats" ]
Get application formats. See :class:`gogoutils.Formats` for available options. Args: config_handle (configparser.ConfigParser): Instance of configurations. Returns: dict: Formats in ``{$format_type: $format_pattern}``.
[ "Get", "application", "formats", "." ]
fb70f29b8ce532f061685a17d120486e47b215ba
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/consts.py#L77-L91
train
foremast/foremast
src/foremast/consts.py
load_dynamic_config
def load_dynamic_config(config_file=DEFAULT_DYNAMIC_CONFIG_FILE): """Load and parse dynamic config""" dynamic_configurations = {} # Insert config path so we can import it sys.path.insert(0, path.dirname(path.abspath(config_file))) try: config_module = __import__('config') dynamic_c...
python
def load_dynamic_config(config_file=DEFAULT_DYNAMIC_CONFIG_FILE): """Load and parse dynamic config""" dynamic_configurations = {} # Insert config path so we can import it sys.path.insert(0, path.dirname(path.abspath(config_file))) try: config_module = __import__('config') dynamic_c...
[ "def", "load_dynamic_config", "(", "config_file", "=", "DEFAULT_DYNAMIC_CONFIG_FILE", ")", ":", "dynamic_configurations", "=", "{", "}", "sys", ".", "path", ".", "insert", "(", "0", ",", "path", ".", "dirname", "(", "path", ".", "abspath", "(", "config_file", ...
Load and parse dynamic config
[ "Load", "and", "parse", "dynamic", "config" ]
fb70f29b8ce532f061685a17d120486e47b215ba
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/consts.py#L94-L108
train
foremast/foremast
src/foremast/consts.py
_remove_empty_entries
def _remove_empty_entries(entries): """Remove empty entries in a list""" valid_entries = [] for entry in set(entries): if entry: valid_entries.append(entry) return sorted(valid_entries)
python
def _remove_empty_entries(entries): """Remove empty entries in a list""" valid_entries = [] for entry in set(entries): if entry: valid_entries.append(entry) return sorted(valid_entries)
[ "def", "_remove_empty_entries", "(", "entries", ")", ":", "valid_entries", "=", "[", "]", "for", "entry", "in", "set", "(", "entries", ")", ":", "if", "entry", ":", "valid_entries", ".", "append", "(", "entry", ")", "return", "sorted", "(", "valid_entries"...
Remove empty entries in a list
[ "Remove", "empty", "entries", "in", "a", "list" ]
fb70f29b8ce532f061685a17d120486e47b215ba
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/consts.py#L144-L150
train
foremast/foremast
src/foremast/consts.py
_convert_string_to_native
def _convert_string_to_native(value): """Convert a string to its native python type""" result = None try: result = ast.literal_eval(str(value)) except (SyntaxError, ValueError): # Likely a string result = value.split(',') return result
python
def _convert_string_to_native(value): """Convert a string to its native python type""" result = None try: result = ast.literal_eval(str(value)) except (SyntaxError, ValueError): # Likely a string result = value.split(',') return result
[ "def", "_convert_string_to_native", "(", "value", ")", ":", "result", "=", "None", "try", ":", "result", "=", "ast", ".", "literal_eval", "(", "str", "(", "value", ")", ")", "except", "(", "SyntaxError", ",", "ValueError", ")", ":", "result", "=", "value...
Convert a string to its native python type
[ "Convert", "a", "string", "to", "its", "native", "python", "type" ]
fb70f29b8ce532f061685a17d120486e47b215ba
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/consts.py#L153-L162
train
foremast/foremast
src/foremast/consts.py
_generate_security_groups
def _generate_security_groups(config_key): """Read config file and generate security group dict by environment. Args: config_key (str): Configuration file key Returns: dict: of environments in {'env1': ['group1', 'group2']} format """ raw_default_groups = validate_key_values(CONFIG...
python
def _generate_security_groups(config_key): """Read config file and generate security group dict by environment. Args: config_key (str): Configuration file key Returns: dict: of environments in {'env1': ['group1', 'group2']} format """ raw_default_groups = validate_key_values(CONFIG...
[ "def", "_generate_security_groups", "(", "config_key", ")", ":", "raw_default_groups", "=", "validate_key_values", "(", "CONFIG", ",", "'base'", ",", "config_key", ",", "default", "=", "''", ")", "default_groups", "=", "_convert_string_to_native", "(", "raw_default_gr...
Read config file and generate security group dict by environment. Args: config_key (str): Configuration file key Returns: dict: of environments in {'env1': ['group1', 'group2']} format
[ "Read", "config", "file", "and", "generate", "security", "group", "dict", "by", "environment", "." ]
fb70f29b8ce532f061685a17d120486e47b215ba
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/consts.py#L165-L190
train
foremast/foremast
src/foremast/datapipeline/datapipeline.py
AWSDataPipeline.create_datapipeline
def create_datapipeline(self): """Creates the data pipeline if it does not already exist Returns: dict: the response of the Boto3 command """ tags = [{"key": "app_group", "value": self.group}, {"key": "app_name", "value": self.app_name}] response = self.client.c...
python
def create_datapipeline(self): """Creates the data pipeline if it does not already exist Returns: dict: the response of the Boto3 command """ tags = [{"key": "app_group", "value": self.group}, {"key": "app_name", "value": self.app_name}] response = self.client.c...
[ "def", "create_datapipeline", "(", "self", ")", ":", "tags", "=", "[", "{", "\"key\"", ":", "\"app_group\"", ",", "\"value\"", ":", "self", ".", "group", "}", ",", "{", "\"key\"", ":", "\"app_name\"", ",", "\"value\"", ":", "self", ".", "app_name", "}", ...
Creates the data pipeline if it does not already exist Returns: dict: the response of the Boto3 command
[ "Creates", "the", "data", "pipeline", "if", "it", "does", "not", "already", "exist" ]
fb70f29b8ce532f061685a17d120486e47b215ba
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/datapipeline/datapipeline.py#L53-L70
train
foremast/foremast
src/foremast/datapipeline/datapipeline.py
AWSDataPipeline.set_pipeline_definition
def set_pipeline_definition(self): """Translates the json definition and puts it on created pipeline Returns: dict: the response of the Boto3 command """ if not self.pipeline_id: self.get_pipeline_id() json_def = self.datapipeline_data['json_definit...
python
def set_pipeline_definition(self): """Translates the json definition and puts it on created pipeline Returns: dict: the response of the Boto3 command """ if not self.pipeline_id: self.get_pipeline_id() json_def = self.datapipeline_data['json_definit...
[ "def", "set_pipeline_definition", "(", "self", ")", ":", "if", "not", "self", ".", "pipeline_id", ":", "self", ".", "get_pipeline_id", "(", ")", "json_def", "=", "self", ".", "datapipeline_data", "[", "'json_definition'", "]", "try", ":", "pipelineobjects", "=...
Translates the json definition and puts it on created pipeline Returns: dict: the response of the Boto3 command
[ "Translates", "the", "json", "definition", "and", "puts", "it", "on", "created", "pipeline" ]
fb70f29b8ce532f061685a17d120486e47b215ba
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/datapipeline/datapipeline.py#L72-L98
train
foremast/foremast
src/foremast/datapipeline/datapipeline.py
AWSDataPipeline.get_pipeline_id
def get_pipeline_id(self): """Finds the pipeline ID for configured pipeline""" all_pipelines = [] paginiator = self.client.get_paginator('list_pipelines') for page in paginiator.paginate(): all_pipelines.extend(page['pipelineIdList']) for pipeline in all_pipelines: ...
python
def get_pipeline_id(self): """Finds the pipeline ID for configured pipeline""" all_pipelines = [] paginiator = self.client.get_paginator('list_pipelines') for page in paginiator.paginate(): all_pipelines.extend(page['pipelineIdList']) for pipeline in all_pipelines: ...
[ "def", "get_pipeline_id", "(", "self", ")", ":", "all_pipelines", "=", "[", "]", "paginiator", "=", "self", ".", "client", ".", "get_paginator", "(", "'list_pipelines'", ")", "for", "page", "in", "paginiator", ".", "paginate", "(", ")", ":", "all_pipelines",...
Finds the pipeline ID for configured pipeline
[ "Finds", "the", "pipeline", "ID", "for", "configured", "pipeline" ]
fb70f29b8ce532f061685a17d120486e47b215ba
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/datapipeline/datapipeline.py#L100-L113
train
foremast/foremast
src/foremast/datapipeline/datapipeline.py
AWSDataPipeline.activate_pipeline
def activate_pipeline(self): """Activates a deployed pipeline, useful for OnDemand pipelines""" self.client.activate_pipeline(pipelineId=self.pipeline_id) LOG.info("Activated Pipeline %s", self.pipeline_id)
python
def activate_pipeline(self): """Activates a deployed pipeline, useful for OnDemand pipelines""" self.client.activate_pipeline(pipelineId=self.pipeline_id) LOG.info("Activated Pipeline %s", self.pipeline_id)
[ "def", "activate_pipeline", "(", "self", ")", ":", "self", ".", "client", ".", "activate_pipeline", "(", "pipelineId", "=", "self", ".", "pipeline_id", ")", "LOG", ".", "info", "(", "\"Activated Pipeline %s\"", ",", "self", ".", "pipeline_id", ")" ]
Activates a deployed pipeline, useful for OnDemand pipelines
[ "Activates", "a", "deployed", "pipeline", "useful", "for", "OnDemand", "pipelines" ]
fb70f29b8ce532f061685a17d120486e47b215ba
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/datapipeline/datapipeline.py#L115-L118
train
foremast/foremast
src/foremast/utils/dns.py
get_dns_zone_ids
def get_dns_zone_ids(env='dev', facing='internal'): """Get Route 53 Hosted Zone IDs for _env_. Args: env (str): Deployment environment. facing (str): Type of ELB, external or internal. Returns: list: Hosted Zone IDs for _env_. Only *PrivateZone* when _facing_ is internal. ...
python
def get_dns_zone_ids(env='dev', facing='internal'): """Get Route 53 Hosted Zone IDs for _env_. Args: env (str): Deployment environment. facing (str): Type of ELB, external or internal. Returns: list: Hosted Zone IDs for _env_. Only *PrivateZone* when _facing_ is internal. ...
[ "def", "get_dns_zone_ids", "(", "env", "=", "'dev'", ",", "facing", "=", "'internal'", ")", ":", "client", "=", "boto3", ".", "Session", "(", "profile_name", "=", "env", ")", ".", "client", "(", "'route53'", ")", "zones", "=", "client", ".", "list_hosted...
Get Route 53 Hosted Zone IDs for _env_. Args: env (str): Deployment environment. facing (str): Type of ELB, external or internal. Returns: list: Hosted Zone IDs for _env_. Only *PrivateZone* when _facing_ is internal.
[ "Get", "Route", "53", "Hosted", "Zone", "IDs", "for", "_env_", "." ]
fb70f29b8ce532f061685a17d120486e47b215ba
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/utils/dns.py#L31-L56
train
foremast/foremast
src/foremast/utils/dns.py
update_dns_zone_record
def update_dns_zone_record(env, zone_id, **kwargs): """Create a Route53 CNAME record in _env_ zone. Args: env (str): Deployment environment. zone_id (str): Route53 zone id. Keyword Args: dns_name (str): FQDN of application's dns entry to add/update. dns_name_aws (str): FQDN...
python
def update_dns_zone_record(env, zone_id, **kwargs): """Create a Route53 CNAME record in _env_ zone. Args: env (str): Deployment environment. zone_id (str): Route53 zone id. Keyword Args: dns_name (str): FQDN of application's dns entry to add/update. dns_name_aws (str): FQDN...
[ "def", "update_dns_zone_record", "(", "env", ",", "zone_id", ",", "**", "kwargs", ")", ":", "client", "=", "boto3", ".", "Session", "(", "profile_name", "=", "env", ")", ".", "client", "(", "'route53'", ")", "response", "=", "{", "}", "hosted_zone_info", ...
Create a Route53 CNAME record in _env_ zone. Args: env (str): Deployment environment. zone_id (str): Route53 zone id. Keyword Args: dns_name (str): FQDN of application's dns entry to add/update. dns_name_aws (str): FQDN of AWS resource dns_ttl (int): DNS time-to-live (t...
[ "Create", "a", "Route53", "CNAME", "record", "in", "_env_", "zone", "." ]
fb70f29b8ce532f061685a17d120486e47b215ba
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/utils/dns.py#L59-L96
train
foremast/foremast
src/foremast/utils/dns.py
find_existing_record
def find_existing_record(env, zone_id, dns_name, check_key=None, check_value=None): """Check if a specific DNS record exists. Args: env (str): Deployment environment. zone_id (str): Route53 zone id. dns_name (str): FQDN of application's dns entry to add/update. check_key(str): K...
python
def find_existing_record(env, zone_id, dns_name, check_key=None, check_value=None): """Check if a specific DNS record exists. Args: env (str): Deployment environment. zone_id (str): Route53 zone id. dns_name (str): FQDN of application's dns entry to add/update. check_key(str): K...
[ "def", "find_existing_record", "(", "env", ",", "zone_id", ",", "dns_name", ",", "check_key", "=", "None", ",", "check_value", "=", "None", ")", ":", "client", "=", "boto3", ".", "Session", "(", "profile_name", "=", "env", ")", ".", "client", "(", "'rout...
Check if a specific DNS record exists. Args: env (str): Deployment environment. zone_id (str): Route53 zone id. dns_name (str): FQDN of application's dns entry to add/update. check_key(str): Key to look for in record. Example: "Type" check_value(str): Value to look for with ...
[ "Check", "if", "a", "specific", "DNS", "record", "exists", "." ]
fb70f29b8ce532f061685a17d120486e47b215ba
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/utils/dns.py#L99-L123
train
foremast/foremast
src/foremast/utils/dns.py
delete_existing_cname
def delete_existing_cname(env, zone_id, dns_name): """Delete an existing CNAME record. This is used when updating to multi-region for deleting old records. The record can not just be upserted since it changes types. Args: env (str): Deployment environment. zone_id (str): Route53 zone i...
python
def delete_existing_cname(env, zone_id, dns_name): """Delete an existing CNAME record. This is used when updating to multi-region for deleting old records. The record can not just be upserted since it changes types. Args: env (str): Deployment environment. zone_id (str): Route53 zone i...
[ "def", "delete_existing_cname", "(", "env", ",", "zone_id", ",", "dns_name", ")", ":", "client", "=", "boto3", ".", "Session", "(", "profile_name", "=", "env", ")", ".", "client", "(", "'route53'", ")", "startrecord", "=", "None", "newrecord_name", "=", "d...
Delete an existing CNAME record. This is used when updating to multi-region for deleting old records. The record can not just be upserted since it changes types. Args: env (str): Deployment environment. zone_id (str): Route53 zone id. dns_name (str): FQDN of application's dns entry...
[ "Delete", "an", "existing", "CNAME", "record", "." ]
fb70f29b8ce532f061685a17d120486e47b215ba
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/utils/dns.py#L126-L148
train
foremast/foremast
src/foremast/utils/dns.py
update_failover_dns_record
def update_failover_dns_record(env, zone_id, **kwargs): """Create a Failover Route53 alias record in _env_ zone. Args: env (str): Deployment environment. zone_id (str): Route53 zone id. Keyword Args: dns_name (str): FQDN of application's dns entry to add/update. dns_ttl (in...
python
def update_failover_dns_record(env, zone_id, **kwargs): """Create a Failover Route53 alias record in _env_ zone. Args: env (str): Deployment environment. zone_id (str): Route53 zone id. Keyword Args: dns_name (str): FQDN of application's dns entry to add/update. dns_ttl (in...
[ "def", "update_failover_dns_record", "(", "env", ",", "zone_id", ",", "**", "kwargs", ")", ":", "client", "=", "boto3", ".", "Session", "(", "profile_name", "=", "env", ")", ".", "client", "(", "'route53'", ")", "response", "=", "{", "}", "hosted_zone_info...
Create a Failover Route53 alias record in _env_ zone. Args: env (str): Deployment environment. zone_id (str): Route53 zone id. Keyword Args: dns_name (str): FQDN of application's dns entry to add/update. dns_ttl (int): DNS time-to-live (ttl) elb_aws_dns (str): DNS A Rec...
[ "Create", "a", "Failover", "Route53", "alias", "record", "in", "_env_", "zone", "." ]
fb70f29b8ce532f061685a17d120486e47b215ba
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/utils/dns.py#L151-L198
train
foremast/foremast
src/foremast/awslambda/cloudwatch_log_event/cloudwatch_log_event.py
create_cloudwatch_log_event
def create_cloudwatch_log_event(app_name, env, region, rules): """Create cloudwatch log event for lambda from rules. Args: app_name (str): name of the lambda function env (str): Environment/Account for lambda function region (str): AWS region of the lambda function rules (str): ...
python
def create_cloudwatch_log_event(app_name, env, region, rules): """Create cloudwatch log event for lambda from rules. Args: app_name (str): name of the lambda function env (str): Environment/Account for lambda function region (str): AWS region of the lambda function rules (str): ...
[ "def", "create_cloudwatch_log_event", "(", "app_name", ",", "env", ",", "region", ",", "rules", ")", ":", "session", "=", "boto3", ".", "Session", "(", "profile_name", "=", "env", ",", "region_name", "=", "region", ")", "cloudwatch_client", "=", "session", "...
Create cloudwatch log event for lambda from rules. Args: app_name (str): name of the lambda function env (str): Environment/Account for lambda function region (str): AWS region of the lambda function rules (str): Trigger rules from the settings
[ "Create", "cloudwatch", "log", "event", "for", "lambda", "from", "rules", "." ]
fb70f29b8ce532f061685a17d120486e47b215ba
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/awslambda/cloudwatch_log_event/cloudwatch_log_event.py#L28-L75
train
foremast/foremast
src/foremast/autoscaling_policy/create_policy.py
AutoScalingPolicy.prepare_policy_template
def prepare_policy_template(self, scaling_type, period_sec, server_group): """Renders scaling policy templates based on configs and variables. After rendering, POSTs the json to Spinnaker for creation. Args: scaling_type (str): ``scale_up`` or ``scaling_down``. Type of policy ...
python
def prepare_policy_template(self, scaling_type, period_sec, server_group): """Renders scaling policy templates based on configs and variables. After rendering, POSTs the json to Spinnaker for creation. Args: scaling_type (str): ``scale_up`` or ``scaling_down``. Type of policy ...
[ "def", "prepare_policy_template", "(", "self", ",", "scaling_type", ",", "period_sec", ",", "server_group", ")", ":", "template_kwargs", "=", "{", "'app'", ":", "self", ".", "app", ",", "'env'", ":", "self", ".", "env", ",", "'region'", ":", "self", ".", ...
Renders scaling policy templates based on configs and variables. After rendering, POSTs the json to Spinnaker for creation. Args: scaling_type (str): ``scale_up`` or ``scaling_down``. Type of policy period_sec (int): Period of time to look at metrics for determining scale ...
[ "Renders", "scaling", "policy", "templates", "based", "on", "configs", "and", "variables", ".", "After", "rendering", "POSTs", "the", "json", "to", "Spinnaker", "for", "creation", "." ]
fb70f29b8ce532f061685a17d120486e47b215ba
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/autoscaling_policy/create_policy.py#L56-L88
train
foremast/foremast
src/foremast/autoscaling_policy/create_policy.py
AutoScalingPolicy.create_policy
def create_policy(self): """Wrapper function. Gets the server group, sets sane defaults, deletes existing policies, and then runs self.prepare_policy_template for scaling up and scaling down policies. This function acts as the main driver for the scaling policy creationprocess ""...
python
def create_policy(self): """Wrapper function. Gets the server group, sets sane defaults, deletes existing policies, and then runs self.prepare_policy_template for scaling up and scaling down policies. This function acts as the main driver for the scaling policy creationprocess ""...
[ "def", "create_policy", "(", "self", ")", ":", "if", "not", "self", ".", "settings", "[", "'asg'", "]", "[", "'scaling_policy'", "]", ":", "self", ".", "log", ".", "info", "(", "\"No scaling policy found, skipping...\"", ")", "return", "server_group", "=", "...
Wrapper function. Gets the server group, sets sane defaults, deletes existing policies, and then runs self.prepare_policy_template for scaling up and scaling down policies. This function acts as the main driver for the scaling policy creationprocess
[ "Wrapper", "function", ".", "Gets", "the", "server", "group", "sets", "sane", "defaults", "deletes", "existing", "policies", "and", "then", "runs", "self", ".", "prepare_policy_template", "for", "scaling", "up", "and", "scaling", "down", "policies", ".", "This",...
fb70f29b8ce532f061685a17d120486e47b215ba
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/autoscaling_policy/create_policy.py#L90-L115
train
foremast/foremast
src/foremast/autoscaling_policy/create_policy.py
AutoScalingPolicy.get_server_group
def get_server_group(self): """Finds the most recently deployed server group for the application. This is the server group that the scaling policy will be applied to. Returns: server_group (str): Name of the newest server group """ api_url = "{0}/applications/{1}".fo...
python
def get_server_group(self): """Finds the most recently deployed server group for the application. This is the server group that the scaling policy will be applied to. Returns: server_group (str): Name of the newest server group """ api_url = "{0}/applications/{1}".fo...
[ "def", "get_server_group", "(", "self", ")", ":", "api_url", "=", "\"{0}/applications/{1}\"", ".", "format", "(", "API_URL", ",", "self", ".", "app", ")", "response", "=", "requests", ".", "get", "(", "api_url", ",", "verify", "=", "GATE_CA_BUNDLE", ",", "...
Finds the most recently deployed server group for the application. This is the server group that the scaling policy will be applied to. Returns: server_group (str): Name of the newest server group
[ "Finds", "the", "most", "recently", "deployed", "server", "group", "for", "the", "application", ".", "This", "is", "the", "server", "group", "that", "the", "scaling", "policy", "will", "be", "applied", "to", "." ]
fb70f29b8ce532f061685a17d120486e47b215ba
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/autoscaling_policy/create_policy.py#L117-L127
train
foremast/foremast
src/foremast/autoscaling_policy/create_policy.py
AutoScalingPolicy.delete_existing_policy
def delete_existing_policy(self, scaling_policy, server_group): """Given a scaling_policy and server_group, deletes the existing scaling_policy. Scaling policies need to be deleted instead of upserted for consistency. Args: scaling_policy (json): the scaling_policy json from Spinnak...
python
def delete_existing_policy(self, scaling_policy, server_group): """Given a scaling_policy and server_group, deletes the existing scaling_policy. Scaling policies need to be deleted instead of upserted for consistency. Args: scaling_policy (json): the scaling_policy json from Spinnak...
[ "def", "delete_existing_policy", "(", "self", ",", "scaling_policy", ",", "server_group", ")", ":", "self", ".", "log", ".", "info", "(", "\"Deleting policy %s on %s\"", ",", "scaling_policy", "[", "'policyName'", "]", ",", "server_group", ")", "delete_dict", "=",...
Given a scaling_policy and server_group, deletes the existing scaling_policy. Scaling policies need to be deleted instead of upserted for consistency. Args: scaling_policy (json): the scaling_policy json from Spinnaker that should be deleted server_group (str): the affected serv...
[ "Given", "a", "scaling_policy", "and", "server_group", "deletes", "the", "existing", "scaling_policy", ".", "Scaling", "policies", "need", "to", "be", "deleted", "instead", "of", "upserted", "for", "consistency", "." ]
fb70f29b8ce532f061685a17d120486e47b215ba
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/autoscaling_policy/create_policy.py#L129-L153
train
foremast/foremast
src/foremast/autoscaling_policy/create_policy.py
AutoScalingPolicy.get_all_existing
def get_all_existing(self, server_group): """Finds all existing scaling policies for an application Returns: scalingpolicies (list): List of all existing scaling policies for the application """ self.log.info("Checking for existing scaling policy") url = "{0}/applica...
python
def get_all_existing(self, server_group): """Finds all existing scaling policies for an application Returns: scalingpolicies (list): List of all existing scaling policies for the application """ self.log.info("Checking for existing scaling policy") url = "{0}/applica...
[ "def", "get_all_existing", "(", "self", ",", "server_group", ")", ":", "self", ".", "log", ".", "info", "(", "\"Checking for existing scaling policy\"", ")", "url", "=", "\"{0}/applications/{1}/clusters/{2}/{1}/serverGroups\"", ".", "format", "(", "API_URL", ",", "sel...
Finds all existing scaling policies for an application Returns: scalingpolicies (list): List of all existing scaling policies for the application
[ "Finds", "all", "existing", "scaling", "policies", "for", "an", "application" ]
fb70f29b8ce532f061685a17d120486e47b215ba
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/autoscaling_policy/create_policy.py#L155-L172
train
foremast/foremast
src/foremast/awslambda/cloudwatch_event/destroy_cloudwatch_event/destroy_cloudwatch_event.py
destroy_cloudwatch_event
def destroy_cloudwatch_event(app='', env='dev', region=''): """Destroy Cloudwatch event subscription. Args: app (str): Spinnaker Application name. env (str): Deployment environment. region (str): AWS region. Returns: bool: True upon successful completion. """ sessio...
python
def destroy_cloudwatch_event(app='', env='dev', region=''): """Destroy Cloudwatch event subscription. Args: app (str): Spinnaker Application name. env (str): Deployment environment. region (str): AWS region. Returns: bool: True upon successful completion. """ sessio...
[ "def", "destroy_cloudwatch_event", "(", "app", "=", "''", ",", "env", "=", "'dev'", ",", "region", "=", "''", ")", ":", "session", "=", "boto3", ".", "Session", "(", "profile_name", "=", "env", ",", "region_name", "=", "region", ")", "cloudwatch_client", ...
Destroy Cloudwatch event subscription. Args: app (str): Spinnaker Application name. env (str): Deployment environment. region (str): AWS region. Returns: bool: True upon successful completion.
[ "Destroy", "Cloudwatch", "event", "subscription", "." ]
fb70f29b8ce532f061685a17d120486e47b215ba
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/awslambda/cloudwatch_event/destroy_cloudwatch_event/destroy_cloudwatch_event.py#L26-L45
train
foremast/foremast
src/foremast/s3/s3apps.py
S3Apps.create_bucket
def create_bucket(self): """Create or update bucket based on app name.""" bucket_exists = self._bucket_exists() if self.s3props.get('shared_bucket_target'): if bucket_exists: LOG.info('App uses shared bucket - %s ', self.bucket) else: LOG.e...
python
def create_bucket(self): """Create or update bucket based on app name.""" bucket_exists = self._bucket_exists() if self.s3props.get('shared_bucket_target'): if bucket_exists: LOG.info('App uses shared bucket - %s ', self.bucket) else: LOG.e...
[ "def", "create_bucket", "(", "self", ")", ":", "bucket_exists", "=", "self", ".", "_bucket_exists", "(", ")", "if", "self", ".", "s3props", ".", "get", "(", "'shared_bucket_target'", ")", ":", "if", "bucket_exists", ":", "LOG", ".", "info", "(", "'App uses...
Create or update bucket based on app name.
[ "Create", "or", "update", "bucket", "based", "on", "app", "name", "." ]
fb70f29b8ce532f061685a17d120486e47b215ba
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/s3/s3apps.py#L65-L92
train
foremast/foremast
src/foremast/s3/s3apps.py
S3Apps._bucket_exists
def _bucket_exists(self): """Check if the bucket exists.""" try: self.s3client.get_bucket_location(Bucket=self.bucket) return True except ClientError as error: LOG.error(error) return False
python
def _bucket_exists(self): """Check if the bucket exists.""" try: self.s3client.get_bucket_location(Bucket=self.bucket) return True except ClientError as error: LOG.error(error) return False
[ "def", "_bucket_exists", "(", "self", ")", ":", "try", ":", "self", ".", "s3client", ".", "get_bucket_location", "(", "Bucket", "=", "self", ".", "bucket", ")", "return", "True", "except", "ClientError", "as", "error", ":", "LOG", ".", "error", "(", "err...
Check if the bucket exists.
[ "Check", "if", "the", "bucket", "exists", "." ]
fb70f29b8ce532f061685a17d120486e47b215ba
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/s3/s3apps.py#L94-L101
train
foremast/foremast
src/foremast/s3/s3apps.py
S3Apps._put_bucket_policy
def _put_bucket_policy(self): """Attach a bucket policy to app bucket.""" if self.s3props['bucket_policy']: policy_str = json.dumps(self.s3props['bucket_policy']) _response = self.s3client.put_bucket_policy(Bucket=self.bucket, Policy=policy_str) else: _respons...
python
def _put_bucket_policy(self): """Attach a bucket policy to app bucket.""" if self.s3props['bucket_policy']: policy_str = json.dumps(self.s3props['bucket_policy']) _response = self.s3client.put_bucket_policy(Bucket=self.bucket, Policy=policy_str) else: _respons...
[ "def", "_put_bucket_policy", "(", "self", ")", ":", "if", "self", ".", "s3props", "[", "'bucket_policy'", "]", ":", "policy_str", "=", "json", ".", "dumps", "(", "self", ".", "s3props", "[", "'bucket_policy'", "]", ")", "_response", "=", "self", ".", "s3...
Attach a bucket policy to app bucket.
[ "Attach", "a", "bucket", "policy", "to", "app", "bucket", "." ]
fb70f29b8ce532f061685a17d120486e47b215ba
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/s3/s3apps.py#L103-L111
train
foremast/foremast
src/foremast/s3/s3apps.py
S3Apps._put_bucket_website
def _put_bucket_website(self): """Configure static website on S3 bucket.""" if self.s3props['website']['enabled']: website_config = { 'ErrorDocument': { 'Key': self.s3props['website']['error_document'] }, 'IndexDocument': { ...
python
def _put_bucket_website(self): """Configure static website on S3 bucket.""" if self.s3props['website']['enabled']: website_config = { 'ErrorDocument': { 'Key': self.s3props['website']['error_document'] }, 'IndexDocument': { ...
[ "def", "_put_bucket_website", "(", "self", ")", ":", "if", "self", ".", "s3props", "[", "'website'", "]", "[", "'enabled'", "]", ":", "website_config", "=", "{", "'ErrorDocument'", ":", "{", "'Key'", ":", "self", ".", "s3props", "[", "'website'", "]", "[...
Configure static website on S3 bucket.
[ "Configure", "static", "website", "on", "S3", "bucket", "." ]
fb70f29b8ce532f061685a17d120486e47b215ba
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/s3/s3apps.py#L113-L131
train
foremast/foremast
src/foremast/s3/s3apps.py
S3Apps._set_bucket_dns
def _set_bucket_dns(self): """Create CNAME for S3 endpoint.""" # Different regions have different s3 endpoint formats dotformat_regions = ["eu-west-2", "eu-central-1", "ap-northeast-2", "ap-south-1", "ca-central-1", "us-east-2"] if self.region in dotformat_regions: s3_endpoin...
python
def _set_bucket_dns(self): """Create CNAME for S3 endpoint.""" # Different regions have different s3 endpoint formats dotformat_regions = ["eu-west-2", "eu-central-1", "ap-northeast-2", "ap-south-1", "ca-central-1", "us-east-2"] if self.region in dotformat_regions: s3_endpoin...
[ "def", "_set_bucket_dns", "(", "self", ")", ":", "dotformat_regions", "=", "[", "\"eu-west-2\"", ",", "\"eu-central-1\"", ",", "\"ap-northeast-2\"", ",", "\"ap-south-1\"", ",", "\"ca-central-1\"", ",", "\"us-east-2\"", "]", "if", "self", ".", "region", "in", "dotf...
Create CNAME for S3 endpoint.
[ "Create", "CNAME", "for", "S3", "endpoint", "." ]
fb70f29b8ce532f061685a17d120486e47b215ba
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/s3/s3apps.py#L133-L152
train
foremast/foremast
src/foremast/s3/s3apps.py
S3Apps._put_bucket_cors
def _put_bucket_cors(self): """Adds bucket cors configuration.""" if self.s3props['cors']['enabled'] and self.s3props['website']['enabled']: cors_config = {} cors_rules = [] for each_rule in self.s3props['cors']['cors_rules']: cors_rules.append({ ...
python
def _put_bucket_cors(self): """Adds bucket cors configuration.""" if self.s3props['cors']['enabled'] and self.s3props['website']['enabled']: cors_config = {} cors_rules = [] for each_rule in self.s3props['cors']['cors_rules']: cors_rules.append({ ...
[ "def", "_put_bucket_cors", "(", "self", ")", ":", "if", "self", ".", "s3props", "[", "'cors'", "]", "[", "'enabled'", "]", "and", "self", ".", "s3props", "[", "'website'", "]", "[", "'enabled'", "]", ":", "cors_config", "=", "{", "}", "cors_rules", "="...
Adds bucket cors configuration.
[ "Adds", "bucket", "cors", "configuration", "." ]
fb70f29b8ce532f061685a17d120486e47b215ba
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/s3/s3apps.py#L154-L175
train
foremast/foremast
src/foremast/s3/s3apps.py
S3Apps._put_bucket_encryption
def _put_bucket_encryption(self): """Adds bucket encryption configuration.""" if self.s3props['encryption']['enabled']: encryption_config = {'Rules': [{}]} encryption_config = { 'Rules': self.s3props['encryption']['encryption_rules'] } LOG....
python
def _put_bucket_encryption(self): """Adds bucket encryption configuration.""" if self.s3props['encryption']['enabled']: encryption_config = {'Rules': [{}]} encryption_config = { 'Rules': self.s3props['encryption']['encryption_rules'] } LOG....
[ "def", "_put_bucket_encryption", "(", "self", ")", ":", "if", "self", ".", "s3props", "[", "'encryption'", "]", "[", "'enabled'", "]", ":", "encryption_config", "=", "{", "'Rules'", ":", "[", "{", "}", "]", "}", "encryption_config", "=", "{", "'Rules'", ...
Adds bucket encryption configuration.
[ "Adds", "bucket", "encryption", "configuration", "." ]
fb70f29b8ce532f061685a17d120486e47b215ba
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/s3/s3apps.py#L177-L190
train
foremast/foremast
src/foremast/s3/s3apps.py
S3Apps._put_bucket_lifecycle
def _put_bucket_lifecycle(self): """Adds bucket lifecycle configuration.""" status = 'deleted' if self.s3props['lifecycle']['enabled']: lifecycle_config = { 'Rules': self.s3props['lifecycle']['lifecycle_rules'] } LOG.debug('Lifecycle Config: %s...
python
def _put_bucket_lifecycle(self): """Adds bucket lifecycle configuration.""" status = 'deleted' if self.s3props['lifecycle']['enabled']: lifecycle_config = { 'Rules': self.s3props['lifecycle']['lifecycle_rules'] } LOG.debug('Lifecycle Config: %s...
[ "def", "_put_bucket_lifecycle", "(", "self", ")", ":", "status", "=", "'deleted'", "if", "self", ".", "s3props", "[", "'lifecycle'", "]", "[", "'enabled'", "]", ":", "lifecycle_config", "=", "{", "'Rules'", ":", "self", ".", "s3props", "[", "'lifecycle'", ...
Adds bucket lifecycle configuration.
[ "Adds", "bucket", "lifecycle", "configuration", "." ]
fb70f29b8ce532f061685a17d120486e47b215ba
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/s3/s3apps.py#L192-L206
train
foremast/foremast
src/foremast/s3/s3apps.py
S3Apps._put_bucket_logging
def _put_bucket_logging(self): """Adds bucket logging policy to bucket for s3 access requests""" logging_config = {} if self.s3props['logging']['enabled']: logging_config = { 'LoggingEnabled': { 'TargetBucket': self.s3props['logging']['logging_buck...
python
def _put_bucket_logging(self): """Adds bucket logging policy to bucket for s3 access requests""" logging_config = {} if self.s3props['logging']['enabled']: logging_config = { 'LoggingEnabled': { 'TargetBucket': self.s3props['logging']['logging_buck...
[ "def", "_put_bucket_logging", "(", "self", ")", ":", "logging_config", "=", "{", "}", "if", "self", ".", "s3props", "[", "'logging'", "]", "[", "'enabled'", "]", ":", "logging_config", "=", "{", "'LoggingEnabled'", ":", "{", "'TargetBucket'", ":", "self", ...
Adds bucket logging policy to bucket for s3 access requests
[ "Adds", "bucket", "logging", "policy", "to", "bucket", "for", "s3", "access", "requests" ]
fb70f29b8ce532f061685a17d120486e47b215ba
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/s3/s3apps.py#L208-L221
train
foremast/foremast
src/foremast/s3/s3apps.py
S3Apps._put_bucket_tagging
def _put_bucket_tagging(self): """Add bucket tags to bucket.""" all_tags = self.s3props['tagging']['tags'] all_tags.update({'app_group': self.group, 'app_name': self.app_name}) tag_set = generate_s3_tags.generated_tag_data(all_tags) tagging_config = {'TagSet': tag_set} ...
python
def _put_bucket_tagging(self): """Add bucket tags to bucket.""" all_tags = self.s3props['tagging']['tags'] all_tags.update({'app_group': self.group, 'app_name': self.app_name}) tag_set = generate_s3_tags.generated_tag_data(all_tags) tagging_config = {'TagSet': tag_set} ...
[ "def", "_put_bucket_tagging", "(", "self", ")", ":", "all_tags", "=", "self", ".", "s3props", "[", "'tagging'", "]", "[", "'tags'", "]", "all_tags", ".", "update", "(", "{", "'app_group'", ":", "self", ".", "group", ",", "'app_name'", ":", "self", ".", ...
Add bucket tags to bucket.
[ "Add", "bucket", "tags", "to", "bucket", "." ]
fb70f29b8ce532f061685a17d120486e47b215ba
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/s3/s3apps.py#L223-L232
train
foremast/foremast
src/foremast/s3/s3apps.py
S3Apps._put_bucket_versioning
def _put_bucket_versioning(self): """Adds bucket versioning policy to bucket""" status = 'Suspended' if self.s3props['versioning']['enabled']: status = 'Enabled' versioning_config = { 'MFADelete': self.s3props['versioning']['mfa_delete'], 'Status': st...
python
def _put_bucket_versioning(self): """Adds bucket versioning policy to bucket""" status = 'Suspended' if self.s3props['versioning']['enabled']: status = 'Enabled' versioning_config = { 'MFADelete': self.s3props['versioning']['mfa_delete'], 'Status': st...
[ "def", "_put_bucket_versioning", "(", "self", ")", ":", "status", "=", "'Suspended'", "if", "self", ".", "s3props", "[", "'versioning'", "]", "[", "'enabled'", "]", ":", "status", "=", "'Enabled'", "versioning_config", "=", "{", "'MFADelete'", ":", "self", "...
Adds bucket versioning policy to bucket
[ "Adds", "bucket", "versioning", "policy", "to", "bucket" ]
fb70f29b8ce532f061685a17d120486e47b215ba
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/s3/s3apps.py#L234-L247
train
foremast/foremast
src/foremast/configs/prepare_configs.py
process_git_configs
def process_git_configs(git_short=''): """Retrieve _application.json_ files from GitLab. Args: git_short (str): Short Git representation of repository, e.g. forrest/core. Returns: collections.defaultdict: Configurations stored for each environment found. """ LOG...
python
def process_git_configs(git_short=''): """Retrieve _application.json_ files from GitLab. Args: git_short (str): Short Git representation of repository, e.g. forrest/core. Returns: collections.defaultdict: Configurations stored for each environment found. """ LOG...
[ "def", "process_git_configs", "(", "git_short", "=", "''", ")", ":", "LOG", ".", "info", "(", "'Processing application.json files from GitLab \"%s\".'", ",", "git_short", ")", "file_lookup", "=", "FileLookup", "(", "git_short", "=", "git_short", ")", "app_configs", ...
Retrieve _application.json_ files from GitLab. Args: git_short (str): Short Git representation of repository, e.g. forrest/core. Returns: collections.defaultdict: Configurations stored for each environment found.
[ "Retrieve", "_application", ".", "json_", "files", "from", "GitLab", "." ]
fb70f29b8ce532f061685a17d120486e47b215ba
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/configs/prepare_configs.py#L26-L46
train
foremast/foremast
src/foremast/configs/prepare_configs.py
process_runway_configs
def process_runway_configs(runway_dir=''): """Read the _application.json_ files. Args: runway_dir (str): Name of runway directory with app.json files. Returns: collections.defaultdict: Configurations stored for each environment found. """ LOG.info('Processing application.js...
python
def process_runway_configs(runway_dir=''): """Read the _application.json_ files. Args: runway_dir (str): Name of runway directory with app.json files. Returns: collections.defaultdict: Configurations stored for each environment found. """ LOG.info('Processing application.js...
[ "def", "process_runway_configs", "(", "runway_dir", "=", "''", ")", ":", "LOG", ".", "info", "(", "'Processing application.json files from local directory \"%s\".'", ",", "runway_dir", ")", "file_lookup", "=", "FileLookup", "(", "runway_dir", "=", "runway_dir", ")", "...
Read the _application.json_ files. Args: runway_dir (str): Name of runway directory with app.json files. Returns: collections.defaultdict: Configurations stored for each environment found.
[ "Read", "the", "_application", ".", "json_", "files", "." ]
fb70f29b8ce532f061685a17d120486e47b215ba
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/configs/prepare_configs.py#L49-L62
train
foremast/foremast
src/foremast/configs/prepare_configs.py
process_configs
def process_configs(file_lookup, app_config_format, pipeline_config): """Processes the configs from lookup sources. Args: file_lookup (FileLookup): Source to look for file/config app_config_format (str): The format for application config files. pipeline_config (str): Name/path of the pi...
python
def process_configs(file_lookup, app_config_format, pipeline_config): """Processes the configs from lookup sources. Args: file_lookup (FileLookup): Source to look for file/config app_config_format (str): The format for application config files. pipeline_config (str): Name/path of the pi...
[ "def", "process_configs", "(", "file_lookup", ",", "app_config_format", ",", "pipeline_config", ")", ":", "app_configs", "=", "collections", ".", "defaultdict", "(", "dict", ")", "for", "env", "in", "ENVS", ":", "file_json", "=", "app_config_format", ".", "forma...
Processes the configs from lookup sources. Args: file_lookup (FileLookup): Source to look for file/config app_config_format (str): The format for application config files. pipeline_config (str): Name/path of the pipeline config Returns: dict: Retreived application config
[ "Processes", "the", "configs", "from", "lookup", "sources", "." ]
fb70f29b8ce532f061685a17d120486e47b215ba
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/configs/prepare_configs.py#L65-L93
train
foremast/foremast
src/foremast/configs/prepare_configs.py
apply_region_configs
def apply_region_configs(env_config): """Override default env configs with region specific configs and nest all values under a region Args: env_config (dict): The environment specific config. Return: dict: Newly updated dictionary with region overrides applied. """ new_config =...
python
def apply_region_configs(env_config): """Override default env configs with region specific configs and nest all values under a region Args: env_config (dict): The environment specific config. Return: dict: Newly updated dictionary with region overrides applied. """ new_config =...
[ "def", "apply_region_configs", "(", "env_config", ")", ":", "new_config", "=", "env_config", ".", "copy", "(", ")", "for", "region", "in", "env_config", ".", "get", "(", "'regions'", ",", "REGIONS", ")", ":", "if", "isinstance", "(", "env_config", ".", "ge...
Override default env configs with region specific configs and nest all values under a region Args: env_config (dict): The environment specific config. Return: dict: Newly updated dictionary with region overrides applied.
[ "Override", "default", "env", "configs", "with", "region", "specific", "configs", "and", "nest", "all", "values", "under", "a", "region" ]
fb70f29b8ce532f061685a17d120486e47b215ba
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/configs/prepare_configs.py#L96-L114
train
foremast/foremast
src/foremast/iam/create_iam.py
create_iam_resources
def create_iam_resources(env='dev', app='', **_): """Create the IAM Resources for the application. Args: env (str): Deployment environment/account, i.e. dev, stage, prod. app (str): Spinnaker Application name. Returns: True upon successful completion. """ session = boto3.se...
python
def create_iam_resources(env='dev', app='', **_): """Create the IAM Resources for the application. Args: env (str): Deployment environment/account, i.e. dev, stage, prod. app (str): Spinnaker Application name. Returns: True upon successful completion. """ session = boto3.se...
[ "def", "create_iam_resources", "(", "env", "=", "'dev'", ",", "app", "=", "''", ",", "**", "_", ")", ":", "session", "=", "boto3", ".", "session", ".", "Session", "(", "profile_name", "=", "env", ")", "client", "=", "session", ".", "client", "(", "'i...
Create the IAM Resources for the application. Args: env (str): Deployment environment/account, i.e. dev, stage, prod. app (str): Spinnaker Application name. Returns: True upon successful completion.
[ "Create", "the", "IAM", "Resources", "for", "the", "application", "." ]
fb70f29b8ce532f061685a17d120486e47b215ba
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/iam/create_iam.py#L29-L87
train
foremast/foremast
src/foremast/iam/create_iam.py
attach_profile_to_role
def attach_profile_to_role(client, role_name='forrest_unicorn_role', profile_name='forrest_unicorn_profile'): """Attach an IAM Instance Profile _profile_name_ to Role _role_name_. Args: role_name (str): Name of Role. profile_name (str): Name of Instance Profile. Returns: True upon ...
python
def attach_profile_to_role(client, role_name='forrest_unicorn_role', profile_name='forrest_unicorn_profile'): """Attach an IAM Instance Profile _profile_name_ to Role _role_name_. Args: role_name (str): Name of Role. profile_name (str): Name of Instance Profile. Returns: True upon ...
[ "def", "attach_profile_to_role", "(", "client", ",", "role_name", "=", "'forrest_unicorn_role'", ",", "profile_name", "=", "'forrest_unicorn_profile'", ")", ":", "current_instance_profiles", "=", "resource_action", "(", "client", ",", "action", "=", "'list_instance_profil...
Attach an IAM Instance Profile _profile_name_ to Role _role_name_. Args: role_name (str): Name of Role. profile_name (str): Name of Instance Profile. Returns: True upon successful completion.
[ "Attach", "an", "IAM", "Instance", "Profile", "_profile_name_", "to", "Role", "_role_name_", "." ]
fb70f29b8ce532f061685a17d120486e47b215ba
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/iam/create_iam.py#L90-L128
train
foremast/foremast
src/foremast/utils/elb.py
find_elb
def find_elb(name='', env='', region=''): """Get an application's AWS elb dns name. Args: name (str): ELB name env (str): Environment/account of ELB region (str): AWS Region Returns: str: elb DNS record """ LOG.info('Find %s ELB in %s [%s].', name, env, region) ...
python
def find_elb(name='', env='', region=''): """Get an application's AWS elb dns name. Args: name (str): ELB name env (str): Environment/account of ELB region (str): AWS Region Returns: str: elb DNS record """ LOG.info('Find %s ELB in %s [%s].', name, env, region) ...
[ "def", "find_elb", "(", "name", "=", "''", ",", "env", "=", "''", ",", "region", "=", "''", ")", ":", "LOG", ".", "info", "(", "'Find %s ELB in %s [%s].'", ",", "name", ",", "env", ",", "region", ")", "url", "=", "'{0}/applications/{1}/loadBalancers'", "...
Get an application's AWS elb dns name. Args: name (str): ELB name env (str): Environment/account of ELB region (str): AWS Region Returns: str: elb DNS record
[ "Get", "an", "application", "s", "AWS", "elb", "dns", "name", "." ]
fb70f29b8ce532f061685a17d120486e47b215ba
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/utils/elb.py#L30-L58
train
foremast/foremast
src/foremast/utils/elb.py
find_elb_dns_zone_id
def find_elb_dns_zone_id(name='', env='dev', region='us-east-1'): """Get an application's AWS elb dns zone id. Args: name (str): ELB name env (str): Environment/account of ELB region (str): AWS Region Returns: str: elb DNS zone ID """ LOG.info('Find %s ELB DNS Zone...
python
def find_elb_dns_zone_id(name='', env='dev', region='us-east-1'): """Get an application's AWS elb dns zone id. Args: name (str): ELB name env (str): Environment/account of ELB region (str): AWS Region Returns: str: elb DNS zone ID """ LOG.info('Find %s ELB DNS Zone...
[ "def", "find_elb_dns_zone_id", "(", "name", "=", "''", ",", "env", "=", "'dev'", ",", "region", "=", "'us-east-1'", ")", ":", "LOG", ".", "info", "(", "'Find %s ELB DNS Zone ID in %s [%s].'", ",", "name", ",", "env", ",", "region", ")", "client", "=", "bot...
Get an application's AWS elb dns zone id. Args: name (str): ELB name env (str): Environment/account of ELB region (str): AWS Region Returns: str: elb DNS zone ID
[ "Get", "an", "application", "s", "AWS", "elb", "dns", "zone", "id", "." ]
fb70f29b8ce532f061685a17d120486e47b215ba
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/utils/elb.py#L61-L76
train
foremast/foremast
src/foremast/version.py
get_version
def get_version(): """Retrieve package version.""" version = 'Not installed.' try: version = pkg_resources.get_distribution(__package__).version except pkg_resources.DistributionNotFound: pass return version
python
def get_version(): """Retrieve package version.""" version = 'Not installed.' try: version = pkg_resources.get_distribution(__package__).version except pkg_resources.DistributionNotFound: pass return version
[ "def", "get_version", "(", ")", ":", "version", "=", "'Not installed.'", "try", ":", "version", "=", "pkg_resources", ".", "get_distribution", "(", "__package__", ")", ".", "version", "except", "pkg_resources", ".", "DistributionNotFound", ":", "pass", "return", ...
Retrieve package version.
[ "Retrieve", "package", "version", "." ]
fb70f29b8ce532f061685a17d120486e47b215ba
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/version.py#L5-L14
train
szastupov/aiotg
aiotg/bot.py
Bot.loop
async def loop(self): """ Return bot's main loop as coroutine. Use with asyncio. :Example: >>> loop = asyncio.get_event_loop() >>> loop.run_until_complete(bot.loop()) or >>> loop = asyncio.get_event_loop() >>> loop.create_task(bot.loop()) """ ...
python
async def loop(self): """ Return bot's main loop as coroutine. Use with asyncio. :Example: >>> loop = asyncio.get_event_loop() >>> loop.run_until_complete(bot.loop()) or >>> loop = asyncio.get_event_loop() >>> loop.create_task(bot.loop()) """ ...
[ "async", "def", "loop", "(", "self", ")", ":", "self", ".", "_running", "=", "True", "while", "self", ".", "_running", ":", "updates", "=", "await", "self", ".", "api_call", "(", "\"getUpdates\"", ",", "offset", "=", "self", ".", "_offset", "+", "1", ...
Return bot's main loop as coroutine. Use with asyncio. :Example: >>> loop = asyncio.get_event_loop() >>> loop.run_until_complete(bot.loop()) or >>> loop = asyncio.get_event_loop() >>> loop.create_task(bot.loop())
[ "Return", "bot", "s", "main", "loop", "as", "coroutine", ".", "Use", "with", "asyncio", "." ]
eed81a6a728c02120f1d730a6e8b8fe50263c010
https://github.com/szastupov/aiotg/blob/eed81a6a728c02120f1d730a6e8b8fe50263c010/aiotg/bot.py#L134-L153
train
szastupov/aiotg
aiotg/bot.py
Bot.run
def run(self, debug=False, reload=None): """ Convenience method for running bots in getUpdates mode :param bool debug: Enable debug logging and automatic reloading :param bool reload: Automatically reload bot on code change :Example: >>> if __name__ == '__main__': ...
python
def run(self, debug=False, reload=None): """ Convenience method for running bots in getUpdates mode :param bool debug: Enable debug logging and automatic reloading :param bool reload: Automatically reload bot on code change :Example: >>> if __name__ == '__main__': ...
[ "def", "run", "(", "self", ",", "debug", "=", "False", ",", "reload", "=", "None", ")", ":", "loop", "=", "asyncio", ".", "get_event_loop", "(", ")", "logging", ".", "basicConfig", "(", "level", "=", "logging", ".", "DEBUG", "if", "debug", "else", "l...
Convenience method for running bots in getUpdates mode :param bool debug: Enable debug logging and automatic reloading :param bool reload: Automatically reload bot on code change :Example: >>> if __name__ == '__main__': >>> bot.run()
[ "Convenience", "method", "for", "running", "bots", "in", "getUpdates", "mode" ]
eed81a6a728c02120f1d730a6e8b8fe50263c010
https://github.com/szastupov/aiotg/blob/eed81a6a728c02120f1d730a6e8b8fe50263c010/aiotg/bot.py#L155-L196
train
szastupov/aiotg
aiotg/bot.py
Bot.run_webhook
def run_webhook(self, webhook_url, **options): """ Convenience method for running bots in webhook mode :Example: >>> if __name__ == '__main__': >>> bot.run_webhook(webhook_url="https://yourserver.com/webhooktoken") Additional documentation on https://core.telegram....
python
def run_webhook(self, webhook_url, **options): """ Convenience method for running bots in webhook mode :Example: >>> if __name__ == '__main__': >>> bot.run_webhook(webhook_url="https://yourserver.com/webhooktoken") Additional documentation on https://core.telegram....
[ "def", "run_webhook", "(", "self", ",", "webhook_url", ",", "**", "options", ")", ":", "loop", "=", "asyncio", ".", "get_event_loop", "(", ")", "loop", ".", "run_until_complete", "(", "self", ".", "set_webhook", "(", "webhook_url", ",", "**", "options", ")...
Convenience method for running bots in webhook mode :Example: >>> if __name__ == '__main__': >>> bot.run_webhook(webhook_url="https://yourserver.com/webhooktoken") Additional documentation on https://core.telegram.org/bots/api#setwebhook
[ "Convenience", "method", "for", "running", "bots", "in", "webhook", "mode" ]
eed81a6a728c02120f1d730a6e8b8fe50263c010
https://github.com/szastupov/aiotg/blob/eed81a6a728c02120f1d730a6e8b8fe50263c010/aiotg/bot.py#L198-L222
train
szastupov/aiotg
aiotg/bot.py
Bot.command
def command(self, regexp): """ Register a new command :param str regexp: Regular expression matching the command to register :Example: >>> @bot.command(r"/echo (.+)") >>> def echo(chat, match): >>> return chat.reply(match.group(1)) """ def ...
python
def command(self, regexp): """ Register a new command :param str regexp: Regular expression matching the command to register :Example: >>> @bot.command(r"/echo (.+)") >>> def echo(chat, match): >>> return chat.reply(match.group(1)) """ def ...
[ "def", "command", "(", "self", ",", "regexp", ")", ":", "def", "decorator", "(", "fn", ")", ":", "self", ".", "add_command", "(", "regexp", ",", "fn", ")", "return", "fn", "return", "decorator" ]
Register a new command :param str regexp: Regular expression matching the command to register :Example: >>> @bot.command(r"/echo (.+)") >>> def echo(chat, match): >>> return chat.reply(match.group(1))
[ "Register", "a", "new", "command" ]
eed81a6a728c02120f1d730a6e8b8fe50263c010
https://github.com/szastupov/aiotg/blob/eed81a6a728c02120f1d730a6e8b8fe50263c010/aiotg/bot.py#L236-L253
train
szastupov/aiotg
aiotg/bot.py
Bot.inline
def inline(self, callback): """ Set callback for inline queries :Example: >>> @bot.inline >>> def echo(iq): >>> return iq.answer([ >>> {"type": "text", "title": "test", "id": "0"} >>> ]) >>> @bot.inline(r"myinline-(.+)") ...
python
def inline(self, callback): """ Set callback for inline queries :Example: >>> @bot.inline >>> def echo(iq): >>> return iq.answer([ >>> {"type": "text", "title": "test", "id": "0"} >>> ]) >>> @bot.inline(r"myinline-(.+)") ...
[ "def", "inline", "(", "self", ",", "callback", ")", ":", "if", "callable", "(", "callback", ")", ":", "self", ".", "_default_inline", "=", "callback", "return", "callback", "elif", "isinstance", "(", "callback", ",", "str", ")", ":", "def", "decorator", ...
Set callback for inline queries :Example: >>> @bot.inline >>> def echo(iq): >>> return iq.answer([ >>> {"type": "text", "title": "test", "id": "0"} >>> ]) >>> @bot.inline(r"myinline-(.+)") >>> def echo(chat, iq, match): >>> r...
[ "Set", "callback", "for", "inline", "queries" ]
eed81a6a728c02120f1d730a6e8b8fe50263c010
https://github.com/szastupov/aiotg/blob/eed81a6a728c02120f1d730a6e8b8fe50263c010/aiotg/bot.py#L276-L305
train
szastupov/aiotg
aiotg/bot.py
Bot.callback
def callback(self, callback): """ Set callback for callback queries :Example: >>> @bot.callback >>> def echo(chat, cq): >>> return cq.answer() >>> @bot.callback(r"buttonclick-(.+)") >>> def echo(chat, cq, match): >>> return chat.reply(ma...
python
def callback(self, callback): """ Set callback for callback queries :Example: >>> @bot.callback >>> def echo(chat, cq): >>> return cq.answer() >>> @bot.callback(r"buttonclick-(.+)") >>> def echo(chat, cq, match): >>> return chat.reply(ma...
[ "def", "callback", "(", "self", ",", "callback", ")", ":", "if", "callable", "(", "callback", ")", ":", "self", ".", "_default_callback", "=", "callback", "return", "callback", "elif", "isinstance", "(", "callback", ",", "str", ")", ":", "def", "decorator"...
Set callback for callback queries :Example: >>> @bot.callback >>> def echo(chat, cq): >>> return cq.answer() >>> @bot.callback(r"buttonclick-(.+)") >>> def echo(chat, cq, match): >>> return chat.reply(match.group(1))
[ "Set", "callback", "for", "callback", "queries" ]
eed81a6a728c02120f1d730a6e8b8fe50263c010
https://github.com/szastupov/aiotg/blob/eed81a6a728c02120f1d730a6e8b8fe50263c010/aiotg/bot.py#L313-L338
train
szastupov/aiotg
aiotg/bot.py
Bot.handle
def handle(self, msg_type): """ Set handler for specific message type :Example: >>> @bot.handle("audio") >>> def handle(chat, audio): >>> pass """ def wrap(callback): self._handlers[msg_type] = callback return callback ...
python
def handle(self, msg_type): """ Set handler for specific message type :Example: >>> @bot.handle("audio") >>> def handle(chat, audio): >>> pass """ def wrap(callback): self._handlers[msg_type] = callback return callback ...
[ "def", "handle", "(", "self", ",", "msg_type", ")", ":", "def", "wrap", "(", "callback", ")", ":", "self", ".", "_handlers", "[", "msg_type", "]", "=", "callback", "return", "callback", "return", "wrap" ]
Set handler for specific message type :Example: >>> @bot.handle("audio") >>> def handle(chat, audio): >>> pass
[ "Set", "handler", "for", "specific", "message", "type" ]
eed81a6a728c02120f1d730a6e8b8fe50263c010
https://github.com/szastupov/aiotg/blob/eed81a6a728c02120f1d730a6e8b8fe50263c010/aiotg/bot.py#L359-L374
train
szastupov/aiotg
aiotg/bot.py
Bot.api_call
def api_call(self, method, **params): """ Call Telegram API. See https://core.telegram.org/bots/api for reference. :param str method: Telegram API method :param params: Arguments for the method call """ coro = self._api_call(method, **params) # Explicitl...
python
def api_call(self, method, **params): """ Call Telegram API. See https://core.telegram.org/bots/api for reference. :param str method: Telegram API method :param params: Arguments for the method call """ coro = self._api_call(method, **params) # Explicitl...
[ "def", "api_call", "(", "self", ",", "method", ",", "**", "params", ")", ":", "coro", "=", "self", ".", "_api_call", "(", "method", ",", "**", "params", ")", "return", "asyncio", ".", "ensure_future", "(", "coro", ")" ]
Call Telegram API. See https://core.telegram.org/bots/api for reference. :param str method: Telegram API method :param params: Arguments for the method call
[ "Call", "Telegram", "API", "." ]
eed81a6a728c02120f1d730a6e8b8fe50263c010
https://github.com/szastupov/aiotg/blob/eed81a6a728c02120f1d730a6e8b8fe50263c010/aiotg/bot.py#L400-L411
train
szastupov/aiotg
aiotg/bot.py
Bot.send_message
def send_message(self, chat_id, text, **options): """ Send a text message to chat :param int chat_id: ID of the chat to send the message to :param str text: Text to send :param options: Additional sendMessage options (see https://core.telegram.org/bots/api#sendmessag...
python
def send_message(self, chat_id, text, **options): """ Send a text message to chat :param int chat_id: ID of the chat to send the message to :param str text: Text to send :param options: Additional sendMessage options (see https://core.telegram.org/bots/api#sendmessag...
[ "def", "send_message", "(", "self", ",", "chat_id", ",", "text", ",", "**", "options", ")", ":", "return", "self", ".", "api_call", "(", "\"sendMessage\"", ",", "chat_id", "=", "chat_id", ",", "text", "=", "text", ",", "**", "options", ")" ]
Send a text message to chat :param int chat_id: ID of the chat to send the message to :param str text: Text to send :param options: Additional sendMessage options (see https://core.telegram.org/bots/api#sendmessage)
[ "Send", "a", "text", "message", "to", "chat" ]
eed81a6a728c02120f1d730a6e8b8fe50263c010
https://github.com/szastupov/aiotg/blob/eed81a6a728c02120f1d730a6e8b8fe50263c010/aiotg/bot.py#L461-L470
train
szastupov/aiotg
aiotg/bot.py
Bot.edit_message_text
def edit_message_text(self, chat_id, message_id, text, **options): """ Edit a text message in a chat :param int chat_id: ID of the chat the message to edit is in :param int message_id: ID of the message to edit :param str text: Text to edit the message to :param options:...
python
def edit_message_text(self, chat_id, message_id, text, **options): """ Edit a text message in a chat :param int chat_id: ID of the chat the message to edit is in :param int message_id: ID of the message to edit :param str text: Text to edit the message to :param options:...
[ "def", "edit_message_text", "(", "self", ",", "chat_id", ",", "message_id", ",", "text", ",", "**", "options", ")", ":", "return", "self", ".", "api_call", "(", "\"editMessageText\"", ",", "chat_id", "=", "chat_id", ",", "message_id", "=", "message_id", ",",...
Edit a text message in a chat :param int chat_id: ID of the chat the message to edit is in :param int message_id: ID of the message to edit :param str text: Text to edit the message to :param options: Additional API options
[ "Edit", "a", "text", "message", "in", "a", "chat" ]
eed81a6a728c02120f1d730a6e8b8fe50263c010
https://github.com/szastupov/aiotg/blob/eed81a6a728c02120f1d730a6e8b8fe50263c010/aiotg/bot.py#L472-L487
train
szastupov/aiotg
aiotg/bot.py
Bot.edit_message_reply_markup
def edit_message_reply_markup(self, chat_id, message_id, reply_markup, **options): """ Edit a reply markup of message in a chat :param int chat_id: ID of the chat the message to edit is in :param int message_id: ID of the message to edit :param str reply_markup: New inline keybo...
python
def edit_message_reply_markup(self, chat_id, message_id, reply_markup, **options): """ Edit a reply markup of message in a chat :param int chat_id: ID of the chat the message to edit is in :param int message_id: ID of the message to edit :param str reply_markup: New inline keybo...
[ "def", "edit_message_reply_markup", "(", "self", ",", "chat_id", ",", "message_id", ",", "reply_markup", ",", "**", "options", ")", ":", "return", "self", ".", "api_call", "(", "\"editMessageReplyMarkup\"", ",", "chat_id", "=", "chat_id", ",", "message_id", "=",...
Edit a reply markup of message in a chat :param int chat_id: ID of the chat the message to edit is in :param int message_id: ID of the message to edit :param str reply_markup: New inline keyboard markup for the message :param options: Additional API options
[ "Edit", "a", "reply", "markup", "of", "message", "in", "a", "chat" ]
eed81a6a728c02120f1d730a6e8b8fe50263c010
https://github.com/szastupov/aiotg/blob/eed81a6a728c02120f1d730a6e8b8fe50263c010/aiotg/bot.py#L489-L504
train
szastupov/aiotg
aiotg/bot.py
Bot.download_file
def download_file(self, file_path, range=None): """ Download a file from Telegram servers """ headers = {"range": range} if range else None url = "{0}/file/bot{1}/{2}".format(API_URL, self.api_token, file_path) return self.session.get( url, headers=headers, pr...
python
def download_file(self, file_path, range=None): """ Download a file from Telegram servers """ headers = {"range": range} if range else None url = "{0}/file/bot{1}/{2}".format(API_URL, self.api_token, file_path) return self.session.get( url, headers=headers, pr...
[ "def", "download_file", "(", "self", ",", "file_path", ",", "range", "=", "None", ")", ":", "headers", "=", "{", "\"range\"", ":", "range", "}", "if", "range", "else", "None", "url", "=", "\"{0}/file/bot{1}/{2}\"", ".", "format", "(", "API_URL", ",", "se...
Download a file from Telegram servers
[ "Download", "a", "file", "from", "Telegram", "servers" ]
eed81a6a728c02120f1d730a6e8b8fe50263c010
https://github.com/szastupov/aiotg/blob/eed81a6a728c02120f1d730a6e8b8fe50263c010/aiotg/bot.py#L516-L524
train
szastupov/aiotg
aiotg/bot.py
Bot.get_user_profile_photos
def get_user_profile_photos(self, user_id, **options): """ Get a list of profile pictures for a user :param int user_id: Unique identifier of the target user :param options: Additional getUserProfilePhotos options (see https://core.telegram.org/bots/api#getuserprofilephotos)...
python
def get_user_profile_photos(self, user_id, **options): """ Get a list of profile pictures for a user :param int user_id: Unique identifier of the target user :param options: Additional getUserProfilePhotos options (see https://core.telegram.org/bots/api#getuserprofilephotos)...
[ "def", "get_user_profile_photos", "(", "self", ",", "user_id", ",", "**", "options", ")", ":", "return", "self", ".", "api_call", "(", "\"getUserProfilePhotos\"", ",", "user_id", "=", "str", "(", "user_id", ")", ",", "**", "options", ")" ]
Get a list of profile pictures for a user :param int user_id: Unique identifier of the target user :param options: Additional getUserProfilePhotos options (see https://core.telegram.org/bots/api#getuserprofilephotos)
[ "Get", "a", "list", "of", "profile", "pictures", "for", "a", "user" ]
eed81a6a728c02120f1d730a6e8b8fe50263c010
https://github.com/szastupov/aiotg/blob/eed81a6a728c02120f1d730a6e8b8fe50263c010/aiotg/bot.py#L526-L534
train
szastupov/aiotg
aiotg/bot.py
Bot.webhook_handle
async def webhook_handle(self, request): """ aiohttp.web handle for processing web hooks :Example: >>> from aiohttp import web >>> app = web.Application() >>> app.router.add_route('/webhook') """ update = await request.json(loads=self.json_deserialize) ...
python
async def webhook_handle(self, request): """ aiohttp.web handle for processing web hooks :Example: >>> from aiohttp import web >>> app = web.Application() >>> app.router.add_route('/webhook') """ update = await request.json(loads=self.json_deserialize) ...
[ "async", "def", "webhook_handle", "(", "self", ",", "request", ")", ":", "update", "=", "await", "request", ".", "json", "(", "loads", "=", "self", ".", "json_deserialize", ")", "self", ".", "_process_update", "(", "update", ")", "return", "web", ".", "R...
aiohttp.web handle for processing web hooks :Example: >>> from aiohttp import web >>> app = web.Application() >>> app.router.add_route('/webhook')
[ "aiohttp", ".", "web", "handle", "for", "processing", "web", "hooks" ]
eed81a6a728c02120f1d730a6e8b8fe50263c010
https://github.com/szastupov/aiotg/blob/eed81a6a728c02120f1d730a6e8b8fe50263c010/aiotg/bot.py#L547-L559
train
szastupov/aiotg
aiotg/bot.py
Bot.create_webhook_app
def create_webhook_app(self, path, loop=None): """ Shorthand for creating aiohttp.web.Application with registered webhook hanlde """ app = web.Application(loop=loop) app.router.add_route("POST", path, self.webhook_handle) return app
python
def create_webhook_app(self, path, loop=None): """ Shorthand for creating aiohttp.web.Application with registered webhook hanlde """ app = web.Application(loop=loop) app.router.add_route("POST", path, self.webhook_handle) return app
[ "def", "create_webhook_app", "(", "self", ",", "path", ",", "loop", "=", "None", ")", ":", "app", "=", "web", ".", "Application", "(", "loop", "=", "loop", ")", "app", ".", "router", ".", "add_route", "(", "\"POST\"", ",", "path", ",", "self", ".", ...
Shorthand for creating aiohttp.web.Application with registered webhook hanlde
[ "Shorthand", "for", "creating", "aiohttp", ".", "web", ".", "Application", "with", "registered", "webhook", "hanlde" ]
eed81a6a728c02120f1d730a6e8b8fe50263c010
https://github.com/szastupov/aiotg/blob/eed81a6a728c02120f1d730a6e8b8fe50263c010/aiotg/bot.py#L561-L567
train
szastupov/aiotg
aiotg/chat.py
Chat.send_text
def send_text(self, text, **options): """ Send a text message to the chat. :param str text: Text of the message to send :param options: Additional sendMessage options (see https://core.telegram.org/bots/api#sendmessage """ return self.bot.send_message(self.id...
python
def send_text(self, text, **options): """ Send a text message to the chat. :param str text: Text of the message to send :param options: Additional sendMessage options (see https://core.telegram.org/bots/api#sendmessage """ return self.bot.send_message(self.id...
[ "def", "send_text", "(", "self", ",", "text", ",", "**", "options", ")", ":", "return", "self", ".", "bot", ".", "send_message", "(", "self", ".", "id", ",", "text", ",", "**", "options", ")" ]
Send a text message to the chat. :param str text: Text of the message to send :param options: Additional sendMessage options (see https://core.telegram.org/bots/api#sendmessage
[ "Send", "a", "text", "message", "to", "the", "chat", "." ]
eed81a6a728c02120f1d730a6e8b8fe50263c010
https://github.com/szastupov/aiotg/blob/eed81a6a728c02120f1d730a6e8b8fe50263c010/aiotg/chat.py#L11-L19
train
szastupov/aiotg
aiotg/chat.py
Chat.reply
def reply(self, text, markup=None, parse_mode=None): """ Reply to the message this `Chat` object is based on. :param str text: Text of the message to send :param dict markup: Markup options :param str parse_mode: Text parsing mode (``"Markdown"``, ``"HTML"`` or ``Non...
python
def reply(self, text, markup=None, parse_mode=None): """ Reply to the message this `Chat` object is based on. :param str text: Text of the message to send :param dict markup: Markup options :param str parse_mode: Text parsing mode (``"Markdown"``, ``"HTML"`` or ``Non...
[ "def", "reply", "(", "self", ",", "text", ",", "markup", "=", "None", ",", "parse_mode", "=", "None", ")", ":", "if", "markup", "is", "None", ":", "markup", "=", "{", "}", "return", "self", ".", "send_text", "(", "text", ",", "reply_to_message_id", "...
Reply to the message this `Chat` object is based on. :param str text: Text of the message to send :param dict markup: Markup options :param str parse_mode: Text parsing mode (``"Markdown"``, ``"HTML"`` or ``None``)
[ "Reply", "to", "the", "message", "this", "Chat", "object", "is", "based", "on", "." ]
eed81a6a728c02120f1d730a6e8b8fe50263c010
https://github.com/szastupov/aiotg/blob/eed81a6a728c02120f1d730a6e8b8fe50263c010/aiotg/chat.py#L21-L39
train
szastupov/aiotg
aiotg/chat.py
Chat.edit_text
def edit_text(self, message_id, text, markup=None, parse_mode=None): """ Edit the message in this chat. :param int message_id: ID of the message to edit :param str text: Text to edit the message to :param dict markup: Markup options :param str parse_mode: Text parsing mo...
python
def edit_text(self, message_id, text, markup=None, parse_mode=None): """ Edit the message in this chat. :param int message_id: ID of the message to edit :param str text: Text to edit the message to :param dict markup: Markup options :param str parse_mode: Text parsing mo...
[ "def", "edit_text", "(", "self", ",", "message_id", ",", "text", ",", "markup", "=", "None", ",", "parse_mode", "=", "None", ")", ":", "if", "markup", "is", "None", ":", "markup", "=", "{", "}", "return", "self", ".", "bot", ".", "edit_message_text", ...
Edit the message in this chat. :param int message_id: ID of the message to edit :param str text: Text to edit the message to :param dict markup: Markup options :param str parse_mode: Text parsing mode (``"Markdown"``, ``"HTML"`` or ``None``)
[ "Edit", "the", "message", "in", "this", "chat", "." ]
eed81a6a728c02120f1d730a6e8b8fe50263c010
https://github.com/szastupov/aiotg/blob/eed81a6a728c02120f1d730a6e8b8fe50263c010/aiotg/chat.py#L41-L60
train
szastupov/aiotg
aiotg/chat.py
Chat.edit_reply_markup
def edit_reply_markup(self, message_id, markup): """ Edit only reply markup of the message in this chat. :param int message_id: ID of the message to edit :param dict markup: Markup options """ return self.bot.edit_message_reply_markup( self.id, message_id, re...
python
def edit_reply_markup(self, message_id, markup): """ Edit only reply markup of the message in this chat. :param int message_id: ID of the message to edit :param dict markup: Markup options """ return self.bot.edit_message_reply_markup( self.id, message_id, re...
[ "def", "edit_reply_markup", "(", "self", ",", "message_id", ",", "markup", ")", ":", "return", "self", ".", "bot", ".", "edit_message_reply_markup", "(", "self", ".", "id", ",", "message_id", ",", "reply_markup", "=", "self", ".", "bot", ".", "json_serialize...
Edit only reply markup of the message in this chat. :param int message_id: ID of the message to edit :param dict markup: Markup options
[ "Edit", "only", "reply", "markup", "of", "the", "message", "in", "this", "chat", "." ]
eed81a6a728c02120f1d730a6e8b8fe50263c010
https://github.com/szastupov/aiotg/blob/eed81a6a728c02120f1d730a6e8b8fe50263c010/aiotg/chat.py#L62-L71
train
szastupov/aiotg
aiotg/chat.py
Chat.get_chat_member
def get_chat_member(self, user_id): """ Get information about a member of a chat. :param int user_id: Unique identifier of the target user """ return self.bot.api_call( "getChatMember", chat_id=str(self.id), user_id=str(user_id) )
python
def get_chat_member(self, user_id): """ Get information about a member of a chat. :param int user_id: Unique identifier of the target user """ return self.bot.api_call( "getChatMember", chat_id=str(self.id), user_id=str(user_id) )
[ "def", "get_chat_member", "(", "self", ",", "user_id", ")", ":", "return", "self", ".", "bot", ".", "api_call", "(", "\"getChatMember\"", ",", "chat_id", "=", "str", "(", "self", ".", "id", ")", ",", "user_id", "=", "str", "(", "user_id", ")", ")" ]
Get information about a member of a chat. :param int user_id: Unique identifier of the target user
[ "Get", "information", "about", "a", "member", "of", "a", "chat", "." ]
eed81a6a728c02120f1d730a6e8b8fe50263c010
https://github.com/szastupov/aiotg/blob/eed81a6a728c02120f1d730a6e8b8fe50263c010/aiotg/chat.py#L91-L99
train
szastupov/aiotg
aiotg/chat.py
Chat.send_sticker
def send_sticker(self, sticker, **options): """ Send a sticker to the chat. :param sticker: Sticker to send (file or string) :param options: Additional sendSticker options (see https://core.telegram.org/bots/api#sendsticker) """ return self.bot.api_call( ...
python
def send_sticker(self, sticker, **options): """ Send a sticker to the chat. :param sticker: Sticker to send (file or string) :param options: Additional sendSticker options (see https://core.telegram.org/bots/api#sendsticker) """ return self.bot.api_call( ...
[ "def", "send_sticker", "(", "self", ",", "sticker", ",", "**", "options", ")", ":", "return", "self", ".", "bot", ".", "api_call", "(", "\"sendSticker\"", ",", "chat_id", "=", "str", "(", "self", ".", "id", ")", ",", "sticker", "=", "sticker", ",", "...
Send a sticker to the chat. :param sticker: Sticker to send (file or string) :param options: Additional sendSticker options (see https://core.telegram.org/bots/api#sendsticker)
[ "Send", "a", "sticker", "to", "the", "chat", "." ]
eed81a6a728c02120f1d730a6e8b8fe50263c010
https://github.com/szastupov/aiotg/blob/eed81a6a728c02120f1d730a6e8b8fe50263c010/aiotg/chat.py#L101-L111
train
szastupov/aiotg
aiotg/chat.py
Chat.send_audio
def send_audio(self, audio, **options): """ Send an mp3 audio file to the chat. :param audio: Object containing the audio data :param options: Additional sendAudio options (see https://core.telegram.org/bots/api#sendaudio) :Example: >>> with open("foo.mp3",...
python
def send_audio(self, audio, **options): """ Send an mp3 audio file to the chat. :param audio: Object containing the audio data :param options: Additional sendAudio options (see https://core.telegram.org/bots/api#sendaudio) :Example: >>> with open("foo.mp3",...
[ "def", "send_audio", "(", "self", ",", "audio", ",", "**", "options", ")", ":", "return", "self", ".", "bot", ".", "api_call", "(", "\"sendAudio\"", ",", "chat_id", "=", "str", "(", "self", ".", "id", ")", ",", "audio", "=", "audio", ",", "**", "op...
Send an mp3 audio file to the chat. :param audio: Object containing the audio data :param options: Additional sendAudio options (see https://core.telegram.org/bots/api#sendaudio) :Example: >>> with open("foo.mp3", "rb") as f: >>> await chat.send_audio(f, perfor...
[ "Send", "an", "mp3", "audio", "file", "to", "the", "chat", "." ]
eed81a6a728c02120f1d730a6e8b8fe50263c010
https://github.com/szastupov/aiotg/blob/eed81a6a728c02120f1d730a6e8b8fe50263c010/aiotg/chat.py#L113-L128
train
szastupov/aiotg
aiotg/chat.py
Chat.send_photo
def send_photo(self, photo, caption="", **options): """ Send a photo to the chat. :param photo: Object containing the photo data :param str caption: Photo caption (optional) :param options: Additional sendPhoto options (see https://core.telegram.org/bots/api#sendphot...
python
def send_photo(self, photo, caption="", **options): """ Send a photo to the chat. :param photo: Object containing the photo data :param str caption: Photo caption (optional) :param options: Additional sendPhoto options (see https://core.telegram.org/bots/api#sendphot...
[ "def", "send_photo", "(", "self", ",", "photo", ",", "caption", "=", "\"\"", ",", "**", "options", ")", ":", "return", "self", ".", "bot", ".", "api_call", "(", "\"sendPhoto\"", ",", "chat_id", "=", "str", "(", "self", ".", "id", ")", ",", "photo", ...
Send a photo to the chat. :param photo: Object containing the photo data :param str caption: Photo caption (optional) :param options: Additional sendPhoto options (see https://core.telegram.org/bots/api#sendphoto) :Example: >>> with open("foo.png", "rb") as f: ...
[ "Send", "a", "photo", "to", "the", "chat", "." ]
eed81a6a728c02120f1d730a6e8b8fe50263c010
https://github.com/szastupov/aiotg/blob/eed81a6a728c02120f1d730a6e8b8fe50263c010/aiotg/chat.py#L130-L146
train
szastupov/aiotg
aiotg/chat.py
Chat.send_video
def send_video(self, video, caption="", **options): """ Send an mp4 video file to the chat. :param video: Object containing the video data :param str caption: Video caption (optional) :param options: Additional sendVideo options (see https://core.telegram.org/bots/ap...
python
def send_video(self, video, caption="", **options): """ Send an mp4 video file to the chat. :param video: Object containing the video data :param str caption: Video caption (optional) :param options: Additional sendVideo options (see https://core.telegram.org/bots/ap...
[ "def", "send_video", "(", "self", ",", "video", ",", "caption", "=", "\"\"", ",", "**", "options", ")", ":", "return", "self", ".", "bot", ".", "api_call", "(", "\"sendVideo\"", ",", "chat_id", "=", "str", "(", "self", ".", "id", ")", ",", "video", ...
Send an mp4 video file to the chat. :param video: Object containing the video data :param str caption: Video caption (optional) :param options: Additional sendVideo options (see https://core.telegram.org/bots/api#sendvideo) :Example: >>> with open("foo.mp4", "rb") ...
[ "Send", "an", "mp4", "video", "file", "to", "the", "chat", "." ]
eed81a6a728c02120f1d730a6e8b8fe50263c010
https://github.com/szastupov/aiotg/blob/eed81a6a728c02120f1d730a6e8b8fe50263c010/aiotg/chat.py#L148-L164
train
szastupov/aiotg
aiotg/chat.py
Chat.send_document
def send_document(self, document, caption="", **options): """ Send a general file. :param document: Object containing the document data :param str caption: Document caption (optional) :param options: Additional sendDocument options (see https://core.telegram.org/bots...
python
def send_document(self, document, caption="", **options): """ Send a general file. :param document: Object containing the document data :param str caption: Document caption (optional) :param options: Additional sendDocument options (see https://core.telegram.org/bots...
[ "def", "send_document", "(", "self", ",", "document", ",", "caption", "=", "\"\"", ",", "**", "options", ")", ":", "return", "self", ".", "bot", ".", "api_call", "(", "\"sendDocument\"", ",", "chat_id", "=", "str", "(", "self", ".", "id", ")", ",", "...
Send a general file. :param document: Object containing the document data :param str caption: Document caption (optional) :param options: Additional sendDocument options (see https://core.telegram.org/bots/api#senddocument) :Example: >>> with open("file.doc", "rb")...
[ "Send", "a", "general", "file", "." ]
eed81a6a728c02120f1d730a6e8b8fe50263c010
https://github.com/szastupov/aiotg/blob/eed81a6a728c02120f1d730a6e8b8fe50263c010/aiotg/chat.py#L166-L186
train
szastupov/aiotg
aiotg/chat.py
Chat.send_voice
def send_voice(self, voice, **options): """ Send an OPUS-encoded .ogg audio file. :param voice: Object containing the audio data :param options: Additional sendVoice options (see https://core.telegram.org/bots/api#sendvoice) :Example: >>> with open("voice.o...
python
def send_voice(self, voice, **options): """ Send an OPUS-encoded .ogg audio file. :param voice: Object containing the audio data :param options: Additional sendVoice options (see https://core.telegram.org/bots/api#sendvoice) :Example: >>> with open("voice.o...
[ "def", "send_voice", "(", "self", ",", "voice", ",", "**", "options", ")", ":", "return", "self", ".", "bot", ".", "api_call", "(", "\"sendVoice\"", ",", "chat_id", "=", "str", "(", "self", ".", "id", ")", ",", "voice", "=", "voice", ",", "**", "op...
Send an OPUS-encoded .ogg audio file. :param voice: Object containing the audio data :param options: Additional sendVoice options (see https://core.telegram.org/bots/api#sendvoice) :Example: >>> with open("voice.ogg", "rb") as f: >>> await chat.send_voice(f)
[ "Send", "an", "OPUS", "-", "encoded", ".", "ogg", "audio", "file", "." ]
eed81a6a728c02120f1d730a6e8b8fe50263c010
https://github.com/szastupov/aiotg/blob/eed81a6a728c02120f1d730a6e8b8fe50263c010/aiotg/chat.py#L188-L203
train
szastupov/aiotg
aiotg/chat.py
Chat.send_location
def send_location(self, latitude, longitude, **options): """ Send a point on the map. :param float latitude: Latitude of the location :param float longitude: Longitude of the location :param options: Additional sendLocation options (see https://core.telegram.org/bots...
python
def send_location(self, latitude, longitude, **options): """ Send a point on the map. :param float latitude: Latitude of the location :param float longitude: Longitude of the location :param options: Additional sendLocation options (see https://core.telegram.org/bots...
[ "def", "send_location", "(", "self", ",", "latitude", ",", "longitude", ",", "**", "options", ")", ":", "return", "self", ".", "bot", ".", "api_call", "(", "\"sendLocation\"", ",", "chat_id", "=", "self", ".", "id", ",", "latitude", "=", "latitude", ",",...
Send a point on the map. :param float latitude: Latitude of the location :param float longitude: Longitude of the location :param options: Additional sendLocation options (see https://core.telegram.org/bots/api#sendlocation)
[ "Send", "a", "point", "on", "the", "map", "." ]
eed81a6a728c02120f1d730a6e8b8fe50263c010
https://github.com/szastupov/aiotg/blob/eed81a6a728c02120f1d730a6e8b8fe50263c010/aiotg/chat.py#L205-L220
train
szastupov/aiotg
aiotg/chat.py
Chat.send_venue
def send_venue(self, latitude, longitude, title, address, **options): """ Send information about a venue. :param float latitude: Latitude of the location :param float longitude: Longitude of the location :param str title: Name of the venue :param str address: Address of ...
python
def send_venue(self, latitude, longitude, title, address, **options): """ Send information about a venue. :param float latitude: Latitude of the location :param float longitude: Longitude of the location :param str title: Name of the venue :param str address: Address of ...
[ "def", "send_venue", "(", "self", ",", "latitude", ",", "longitude", ",", "title", ",", "address", ",", "**", "options", ")", ":", "return", "self", ".", "bot", ".", "api_call", "(", "\"sendVenue\"", ",", "chat_id", "=", "self", ".", "id", ",", "latitu...
Send information about a venue. :param float latitude: Latitude of the location :param float longitude: Longitude of the location :param str title: Name of the venue :param str address: Address of the venue :param options: Additional sendVenue options (see https://co...
[ "Send", "information", "about", "a", "venue", "." ]
eed81a6a728c02120f1d730a6e8b8fe50263c010
https://github.com/szastupov/aiotg/blob/eed81a6a728c02120f1d730a6e8b8fe50263c010/aiotg/chat.py#L222-L241
train