docstring
stringlengths
52
499
function
stringlengths
67
35.2k
__index_level_0__
int64
52.6k
1.16M
Set the value of field in a hash stored at key. Args: key (str): key (name) of the hash field (str): Field within the hash to set value: Value to set pipeline (bool): True, start a transaction block. Default false.
def set_hash_value(self, key, field, value, pipeline=False): # FIXME(BMo): new name for this function -> save_dict_value ? if pipeline: self._pipeline.hset(key, field, str(value)) else: self._db.hset(key, field, str(value))
652,133
Add new element to the start of the list stored at key. Args: key (str): Key where the list is stored value: Value to add to the list pipeline (bool): True, start a transaction block. Default false.
def prepend_to_list(self, key, *value, pipeline=False): if pipeline: self._pipeline.lpush(key, *value) else: self._db.lpush(key, *value)
652,134
Add new element to the end of the list stored at key. Args: key (str): Key where the list is stored value: Value to add to the list pipeline (bool): True, start a transaction block. Default false.
def append_to_list(self, key, *value, pipeline=False): if pipeline: self._pipeline.rpush(key, *value) else: self._db.rpush(key, *value)
652,135
Get all the value in the list stored at key. Args: key (str): Key where the list is stored. pipeline (bool): True, start a transaction block. Default false. Returns: list: values in the list ordered by list index
def get_list(self, key, pipeline=False): if pipeline: return self._pipeline.lrange(key, 0, -1) return self._db.lrange(key, 0, -1)
652,136
Delete one or more keys specified by names. Args: names (str): Names of keys to delete pipeline (bool): True, start a transaction block. Default false.
def delete(self, *names: str, pipeline=False): if pipeline: self._pipeline.delete(*names) else: self._db.delete(*names)
652,137
Get an event from the database. Gets an event from the named event list removing the event and adding it to the event history. Args: event_name (str): Event list key. event_history (str, optional): Event history list. Returns: str: string representa...
def get_event(self, event_name, event_history=None): if event_history is None: event_history = event_name + '_history' return self._db.rpoplpush(event_name, event_history)
652,138
Remove specified value(s) from the list stored at key. Args: key (str): Key where the list is stored. value: value to remove count (int): Number of entries to remove, default 0 == all pipeline(bool): If True, start a transaction block. Default False.
def remove_from_list(self, key: str, value, count: int = 0, pipeline: bool = False): if pipeline: if redis.__version__ == '2.10.6': self._pipeline.lrem(name=key, value=value, num=count) else: self._pipeline.lrem(key, count...
652,139
Watch the given key. Marks the given key to be watch for conditional execution of a transaction. Args: key (str): Key that needs to be watched pipeline (bool): True, start a transaction block. Default false.
def watch(self, key, pipeline=False): if pipeline: self._pipeline.watch(key) else: self._db.watch(key)
652,140
Post a message to a given channel. Args: channel (str): Channel where the message will be published message (str): Message to publish pipeline (bool): True, start a transaction block. Default false.
def publish(self, channel, message, pipeline=False): if pipeline: self._pipeline.publish(channel, message) else: self._db.publish(channel, message)
652,141
Get the health of a service using service_id. Args: service_id Returns: str, health status
def get_service_health(service_id: str) -> str: # Check if the current and actual replica levels are the same if DC.get_replicas(service_id) != DC.get_actual_replica(service_id): health_status = "Unhealthy" else: health_status = "Healthy" return health_s...
652,144
Constructor. The supplied configuration dictionary must contain all parameters needed to define new user See pulsar_receiver_config.json for an example. Args: config (dict): Dictionary containing JSON configuration file. log: Logger.
def __init__(self, config, log): # Initialise class variables. self._config = config self._log = log log.info('Pulsar Search Interface Initialisation')
652,153
Create a SBI object. Args: sbi_id (str): SBI Identifier Raises: KeyError, if the specified SBI does not exist.
def __init__(self, sbi_id: str): SchedulingObject.__init__(self, SBI_KEY, sbi_id) self._check_object_exists()
652,162
Create an SBI object from the specified configuration dict. NOTE(BM) This should really be done as a single atomic db transaction. Args: config_dict(dict): SBI configuration dictionary schema_path(str, optional): Path to the SBI config schema.
def from_config(cls, config_dict: dict, schema_path: str = None): # Validate the SBI config schema if schema_path is None: schema_path = join(dirname(__file__), 'schema', 'configure_sbi.json') with open(schema_path, 'r') as file: sc...
652,163
Get a SBI Identifier. Args: date (str or datetime.datetime, optional): UTC date of the SBI project (str, optional ): Project Name instance_id (int, optional): SBI instance identifier Returns: str, Scheduling Block Instance (SBI) ID.
def get_id(date=None, project: str = 'sip', instance_id: int = None) -> str: if date is None: date = datetime.datetime.utcnow() if isinstance(date, datetime.datetime): date = date.strftime('%Y%m%d') if instance_id is None: instance_id...
652,166
Update the PB configuration workflow definition. Args: pb_config (dict): PB configuration dictionary Raises: RunTimeError, if the workflow definition (id, version) specified in the sbi_config is not known.
def _update_workflow_definition(pb_config: dict): known_workflows = get_workflows() workflow_id = pb_config['workflow']['id'] workflow_version = pb_config['workflow']['version'] if workflow_id not in known_workflows or \ workflow_version not in known_workflows[workflo...
652,168
Initialise the logging object. Args: level (int): Logging level. Returns: Logger: Python logging object.
def _init_log(level=logging.DEBUG): log = logging.getLogger(__file__) log.setLevel(level) handler = logging.StreamHandler(sys.stdout) handler.setLevel(level) formatter = logging.Formatter('%(asctime)s: %(message)s', '%Y/%m/%d-%H:%M:%S') handler.setFormatter...
652,185
Attempts to send a message to the specified destination in IRC Extends Legobot.Lego.handle() Args: message (Legobot.Message): message w/ metadata to send.
def handle(self, message): logger.debug(message) if Utilities.isNotEmpty(message['metadata']['opts']): target = message['metadata']['opts']['target'] for split_line in Utilities.tokenize(message['text']): for truncated_line in Utilities.truncate(split_l...
652,216
Splits the message into a list of strings of of length `length` Args: text (str): The text to be divided length (int, optional): The length of the chunks of text. \ Defaults to 255. Returns: list: Text divided into chunks of length `length`
def truncate(text, length=255): lines = [] i = 0 while i < len(text) - 1: try: lines.append(text[i:i+length]) i += length except IndexError as e: lines.append(text[i:]) return lines
652,613
Initializes RtmBot Args: baseplate (Legobot.Lego): The parent Pykka actor. Typically passed in fromLegobot.Connectors.Slack.Slack token (string): Slack API token actor_urn (string): URN of Pykka actor launching RtmBot *args: Variable length argume...
def __init__(self, baseplate, token, actor_urn, reconnect=True, *args, **kwargs): self.baseplate = baseplate self.token = token self.last_ping = 0 self.actor_urn = actor_urn self.reconnect = reconnect self.auto_reconnect = True # 'event':...
652,715
Runs when a message event is received Args: event: RTM API event. Returns: Legobot.messge
def on_message(self, event): metadata = self._parse_metadata(event) message = Message(text=metadata['text'], metadata=metadata).__dict__ if message.get('text'): message['text'] = self.find_and_replace_userids(message['text']) message['t...
652,717
Finds occurrences of Slack userids and attempts to replace them with display names. Args: text (string): The message text Returns: string: The message text with userids replaced.
def find_and_replace_userids(self, text): match = True pattern = re.compile('<@([A-Z0-9]{9})>') while match: match = pattern.search(text) if match: name = self.get_user_display_name(match.group(1)) text = re.sub(re.compile(match.g...
652,719
Find occurrences of Slack channel referenfces and attempts to replace them with just channel names. Args: text (string): The message text Returns: string: The message text with channel references replaced.
def find_and_replace_channel_refs(self, text): match = True pattern = re.compile('<#([A-Z0-9]{9})\|([A-Za-z0-9-]+)>') while match: match = pattern.search(text) if match: text = text.replace(match.group(0), '#' + match.group(2)) return te...
652,720
Grabs all channels in the slack team Args: condensed (bool): if true triggers list condensing functionality Returns: dic: Dict of channels in Slack team. See also: https://api.slack.com/methods/channels.list
def get_channels(self, condensed=False): channel_list = self.slack_client.api_call('channels.list') if not channel_list.get('ok'): return None if condensed: channels = [{'id': item.get('id'), 'name': item.get('name')} for item in channel...
652,723
Grabs all users in the slack team This should should only be used for getting list of all users. Do not use it for searching users. Use get_user_info instead. Args: condensed (bool): if true triggers list condensing functionality Returns: dict: Dict of users in...
def get_users(self, condensed=False): user_list = self.slack_client.api_call('users.list') if not user_list.get('ok'): return None if condensed: users = [{'id': item.get('id'), 'name': item.get('name'), 'display_name': item.get('profile').ge...
652,724
Given a Slack userid, grabs user display_name from api. Args: userid (string): the user id of the user being queried Returns: dict: a dictionary of the api response
def get_user_display_name(self, userid): user_info = self.slack_client.api_call('users.info', user=userid) if user_info.get('ok'): user = user_info.get('user') if user.get('profile'): return user.get('profile').get('display_name') else: ...
652,725
Perform a lookup of users to resolve a userid to a DM channel Args: userid (string): Slack userid to lookup. Returns: string: DM channel ID of user
def get_dm_channel(self, userid): dm_open = self.slack_client.api_call('im.open', user=userid) return dm_open['channel']['id']
652,726
Perform a lookup of users to resolve a userid to a username Args: userid (string): Slack userid to lookup. Returns: string: Human-friendly name of the user
def get_username(self, userid): username = self.user_map.get(userid) if not username: users = self.get_users() if users: members = { m['id']: m['name'] for m in users.get('members', [{}]) if m.g...
652,727
Perform a lookup of bots.info to resolve a botid to a userid Args: botid (string): Slack botid to lookup. Returns: string: userid value
def get_userid_from_botid(self, botid): botinfo = self.slack_client.api_call('bots.info', bot=botid) if botinfo['ok'] is True: return botinfo['bot'].get('user_id') else: return botid
652,728
Parse incoming messages to build metadata dict Lots of 'if' statements. It sucks, I know. Args: message (dict): JSON dump of message sent from Slack Returns: Legobot.Metadata
def _parse_metadata(self, message): # Try to handle all the fields of events we care about. metadata = Metadata(source=self.actor_urn).__dict__ metadata['thread_ts'] = message.get('thread_ts') if 'presence' in message: metadata['presence'] = message['presence'] ...
652,729
Builds a slack attachment. Args: message (Legobot.Message): message w/ metadata to send. Returns: attachment (dict): attachment data.
def build_attachment(self, text, target, attachment, thread): attachment = { 'as_user': True, 'text': text, 'channel': target, 'attachments': [ { 'fallback': text, 'image_url': attachment ...
652,730
Attempts to send a message to the specified destination in Slack. Extends Legobot.Lego.handle() Args: message (Legobot.Message): message w/ metadata to send.
def handle(self, message): logger.debug(message) if Utilities.isNotEmpty(message['metadata']['opts']): target = message['metadata']['opts']['target'] thread = message['metadata']['opts'].get('thread') # pattern = re.compile('@([a-zA-Z0-9._-]+)') ...
652,731
Initialize DiscoBot Args: baseplate (Legobot.Lego): The parent Pykka actor. Typically passed in from Legobot.Connectors.Discord.Discord token (string): Discord bot token actor_urn (string): URN of Pykka actor launching DiscoBot *args: Variable len...
def __init__(self, baseplate, token, actor_urn, *args, **kwargs): self.baseplate = baseplate self.rest_baseurl = 'https://discordapp.com/api/v6' self.token = token self.headers = {"Authorization": "Bot {}".format(token), "User-Agent": "Legobot", ...
652,753
Sends a message to a Discord channel or user via REST API Args: channel_id (string): ID of destingation Discord channel text (string): Content of message
def create_message(self, channel_id, text): baseurl = self.rest_baseurl + \ '/channels/{}/messages'.format(channel_id) requests.post(baseurl, headers=self.headers, data=json.dumps({'content': text}))
652,754
Identifies to the websocket endpoint Args: token (string): Discord bot token
def identify(self, token): payload = { 'op': 2, 'd': { 'token': self.token, 'properties': { '$os': sys.platform, '$browser': 'legobot', '$device': 'legobot' }, ...
652,755
Runs on a hello event from websocket connection Args: message (dict): Full message from Discord websocket connection"
def on_hello(self, message): logger.info("Got a hello") self.identify(self.token) self.heartbeat_thread = Heartbeat(self.ws, message['d']['heartbeat_interval']) self.heartbeat_thread.start() return
652,756
Runs on a heartbeat event from websocket connection Args: message (dict): Full message from Discord websocket connection"
def on_heartbeat(self, message): logger.info("Got a heartbeat") logger.info("Heartbeat message: {}".format(message)) self.heartbeat_thread.update_sequence(message['d']) return
652,757
Runs on a create_message event from websocket connection Args: message (dict): Full message from Discord websocket connection"
def on_message(self, message): if 'content' in message['d']: metadata = self._parse_metadata(message) message = Message(text=message['d']['content'], metadata=metadata).__dict__ logger.debug(message) self.baseplate.tell(mess...
652,758
Sets metadata in Legobot message Args: message (dict): Full message from Discord websocket connection" Returns: Legobot.Metadata
def _parse_metadata(self, message): metadata = Metadata(source=self.actor_urn).__dict__ if 'author' in message['d']: metadata['source_user'] = message['d']['author']['username'] else: metadata['source_user'] = None if 'channel_id' in message['d']: ...
652,759
Dispatches messages to appropriate handler based on opcode Args: message (dict): Full message from Discord websocket connection
def handle(self, message): opcode = message['op'] if opcode == 10: self.on_hello(message) elif opcode == 11: self.on_heartbeat(message) elif opcode == 0: self.on_message(message) else: logger.debug("Not a message we handle...
652,760
Attempts to send a message to the specified destination in Discord. Extends Legobot.Lego.handle() Args: message (Legobot.Message): message w/ metadata to send.
def handle(self, message): logger.debug(message) if Utilities.isNotEmpty(message['metadata']['opts']): target = message['metadata']['opts']['target'] self.botThread.create_message(target, message['text'])
652,763
Initialization function. Args: path (str): absolute path to the ns-3 installation this Runner should lock on. script (str): ns-3 script that will be used by this Runner. optimized (bool): whether this Runner should build ns-3 with the optimize...
def __init__(self, path, script, optimized=True): # Save member variables self.path = path self.script = script if optimized: # For old ns-3 installations, the library is in build, while for # recent ns-3 installations it's in build/lib. Both paths are ...
653,142
Configure and build the ns-3 code. Args: show_progress (bool): whether or not to display a progress bar during compilation. optimized (bool): whether to use an optimized build. If False, use a standard ./waf configure. skip_configuration (bool...
def configure_and_build(self, show_progress=True, optimized=True, skip_configuration=False): # Only configure if necessary if not skip_configuration: configuration_command = ['python', 'waf', 'configure', '--enable-examples', ...
653,143
Parse the output of the ns-3 build process to extract the information that is needed to draw the progress bar. Args: process: the subprocess instance to listen to.
def get_build_output(self, process): while True: output = process.stdout.readline() if output == b'' and process.poll() is not None: if process.returncode > 0: raise Exception("Compilation ended with an error" ...
653,144
Run several simulations using a certain combination of parameters. Yields results as simulations are completed. Args: parameter_list (list): list of parameter combinations to simulate. data_folder (str): folder in which to save subfolders containing simulation o...
def run_simulations(self, parameter_list, data_folder): for idx, parameter in enumerate(parameter_list): current_result = { 'params': {}, 'meta': {} } current_result['params'].update(parameter) command = [self.script...
653,146
Return the command that is needed to obtain a certain result. Args: params (dict): Dictionary containing parameter: value pairs. debug (bool): Whether the command should include the debugging template.
def get_command_from_result(script, result, debug=False): if not debug: command = "python waf --run \"" + script + " " + " ".join( ['--%s=%s' % (param, value) for param, value in result['params'].items()]) + "\"" else: command = "python waf --run " + script + " --co...
653,272
Initialize the Simulation Execution Manager, using the provided CampaignManager and SimulationRunner instances. This method should never be used on its own, but only as a constructor from the new and load @classmethods. Args: campaign_db (DatabaseManager): the DatabaseManag...
def __init__(self, campaign_db, campaign_runner, check_repo=True): self.db = campaign_db self.runner = campaign_runner self.check_repo = check_repo # Check that the current repo commit corresponds to the one specified # in the campaign if self.check_repo: ...
653,288
Return a list of the simulations among the required ones that are not available in the database. Args: param_list (list): a list of dictionaries containing all the parameters combinations. runs (int): an integer representing how many repetitions are wanted ...
def get_missing_simulations(self, param_list, runs=None): params_to_simulate = [] if runs is not None: # Get next available runs from the database next_runs = self.db.get_next_rngruns() available_params = [r['params'] for r in self.db.get_results()] for pa...
653,293
Deduce [parameter, default] pairs from simulations available in the db. Args: param_list (list): List of parameters to query for. db (DatabaseManager): Database where to query for defaults.
def get_params_and_defaults(param_list, db): return [[p, d] for p, d in db.get_all_values_of_all_params().items()]
653,311
Asks the user for parameters. If available, proposes some defaults. Args: param_list (list): List of parameters to ask the user for values. defaults (list): A list of proposed defaults. It must be a list of the same length as param_list. A value of None in one element of the ...
def query_parameters(param_list, defaults=None): script_params = collections.OrderedDict([k, []] for k in param_list) for param, default in zip(list(script_params.keys()), defaults): user_input = click.prompt("%s" % param, default=default) script_params[param] = ast.literal_eval(user_inpu...
653,312
This function runs multiple simulations in parallel. Args: parameter_list (list): list of parameter combinations to simulate. data_folder (str): folder in which to create output folders.
def run_simulations(self, parameter_list, data_folder): self.data_folder = data_folder with Pool(processes=MAX_PARALLEL_PROCESSES) as pool: for result in pool.imap_unordered(self.launch_simulation, parameter_list): yield ...
653,410
Launch a single simulation, using SimulationRunner's facilities. This function is used by ParallelRunner's run_simulations to map simulation running over the parameter list. Args: parameter (dict): the parameter combination to simulate.
def launch_simulation(self, parameter): return next(SimulationRunner.run_simulations(self, [parameter], self.data_folder))
653,411
Initialize from an existing database. It is assumed that the database json file has the same name as its containing folder. Args: campaign_dir (str): The path to the campaign directory.
def load(cls, campaign_dir): # We only accept absolute paths if not Path(campaign_dir).is_absolute(): raise ValueError("Path is not absolute") # Verify file exists if not Path(campaign_dir).exists(): raise ValueError("Directory does not exist") ...
653,433
Delete CDN assets Arguments: service_id: The ID of the service to delete from. url: The URL at which to delete assets all: When True, delete all assets associated with the service_id. You cannot specifiy both url and all.
def delete_assets(self, service_id, url=None, all=False): self._services_manager.delete_assets(service_id, url, all)
654,544
Delete given group. Args: name (string): Name of group. url_prefix (string): Protocol + host such as https://api.theboss.io auth (string): Token to send in the request header. session (requests.Session): HTTP session to use for request. send_opts (dic...
def delete_group(self, name, url_prefix, auth, session, send_opts): req = self.get_group_request( 'DELETE', 'application/json', url_prefix, auth, name) prep = session.prepare_request(req) resp = session.send(prep, **send_opts) if resp.status_code == 204: ...
655,505
Deletes the entity described by the given resource. Args: resource (intern.resource.boss.BossResource) url_prefix (string): Protocol + host such as https://api.theboss.io auth (string): Token to send in the request header. session (requests.Session): HTTP session...
def delete(self, resource, url_prefix, auth, session, send_opts): req = self.get_request( resource, 'DELETE', 'application/json', url_prefix, auth) prep = session.prepare_request(req) resp = session.send(prep, **send_opts) if resp.status_code == 204: retu...
655,514
Extracts list of resources from the HTTP response. Args: rsrc_dict (dict): HTTP response encoded in a dictionary. Returns: (list[string]): List of a type of resource (collections, experiments, etc). Raises: (RuntimeError): If rsrc_dict does not contain any ...
def _get_resource_list(self, rsrc_dict): if 'collections' in rsrc_dict: return rsrc_dict['collections'] if 'experiments' in rsrc_dict: return rsrc_dict['experiments'] if 'channels' in rsrc_dict: return rsrc_dict['channels'] if 'coords' in rsrc...
655,524
Decorator that ensures a valid channel passed in. Args: fcn (function): Function that has a ChannelResource as its second argument. Returns: (function): Wraps given function with one that checks for a valid channel.
def check_channel(fcn): def wrapper(*args, **kwargs): if not isinstance(args[1], ChannelResource): raise RuntimeError('resource must be an instance of intern.resource.boss.ChannelResource.') if not args[1].cutout_ready: raise PartialChannelResourceError( ...
655,526
Reserve a block of unique, sequential ids for annotations. Args: resource (intern.resource.Resource): Resource should be an annotation channel. num_ids (int): Number of ids to reserve. Returns: (int): First id reserved.
def reserve_ids(self, resource, num_ids): return self.service.reserve_ids( resource, num_ids, self.url_prefix, self.auth, self.session, self.session_send_opts)
655,528
Constructor. Args: name (string): Name of resource. description (string): Description of resource. creator (optional[string]): Resource creator. raw (optional[dictionary]): Holds JSON data returned by the Boss API on a POST (create) or GET operation.
def __init__(self, name, description, creator='', raw={}): self.name = name self.description = description self.creator = creator self.raw = raw
655,598
Constructor. Args: name (string): Collection name. description (optional[string]): Collection description. Defaults to empty. creator (optional[string]): Resource creator. raw (optional[dictionary]): Holds JSON data returned by the Boss API on a POST (create) or...
def __init__( self, name, description='', creator='', raw={}): BossResource.__init__(self, name, description, creator, raw)
655,599
List metadata keys associated with the given resource. Args: resource (intern.resource.boss.BossResource): List keys associated with this resource. Returns: (list): List of key names. Raises: requests.HTTPError on failure.
def list(self, resource): return self.service.list( resource, self.url_prefix, self.auth, self.session, self.session_send_opts)
655,622
Get the groups the logged in user is a member of. Optionally filter by 'member' or 'maintainer'. Args: filtr (optional[string|None]): ['member'|'maintainer'] or defaults to None. Returns: (list[string]): List of group names. Raises: requests.HTTPErr...
def list_groups(self, filtr=None): return self.service.list_groups( filtr, self.url_prefix, self.auth, self.session, self.session_send_opts)
655,623
Get owner of group and the resources it's attached to. Args: name (string): Name of group to query. user_name (optional[string]): Supply None if not interested in determining if user is a member of the given group. Returns: (dict): Keys include 'owner', 'name', 'res...
def get_group(self, name, user_name=None): return self.service.get_group( name, user_name, self.url_prefix, self.auth, self.session, self.session_send_opts)
655,624
Create a new group. Args: name (string): Name of the group to create. Raises: requests.HTTPError on failure.
def create_group(self, name): self.service.create_group( name, self.url_prefix, self.auth, self.session, self.session_send_opts)
655,625
Delete given group. Args: name (string): Name of group. Raises: requests.HTTPError on failure.
def delete_group(self, name): self.service.delete_group( name, self.url_prefix, self.auth, self.session, self.session_send_opts)
655,626
Get the members of a group (does not include maintainers). Args: name (string): Name of group to query. Returns: (list[string]): List of member names. Raises: requests.HTTPError on failure.
def list_group_members(self, name): return self.service.list_group_members( name, self.url_prefix, self.auth, self.session, self.session_send_opts)
655,627
Get the maintainers of a group. Args: name (string): Name of group to query. Returns: (list[string]): List of maintainer names.
def list_group_maintainers(self, name): return self.service.list_group_maintainers( name, self.url_prefix, self.auth, self.session, self.session_send_opts)
655,628
Add the given user to the named group. Both group and user must already exist for this to succeed. Args: name (string): Name of group. user (string): User to add to group. version (optional[string]): Version of the Boss API to use. Defaults to the latest supported ...
def add_group_maintainer(self, name, user): self.service.add_group_maintainer( name, user, self.url_prefix, self.auth, self.session, self.session_send_opts)
655,629
Delete the given user to the named group. Both group and user must already exist for this to succeed. Args: name (string): Name of group. user (string): User to add to group. Raises: requests.HTTPError on failure.
def delete_group_maintainer(self, grp_name, user): self.service.delete_group_maintainer( grp_name, user, self.url_prefix, self.auth, self.session, self.session_send_opts)
655,630
List permission sets associated filtering by group and/or resource. Args: group_name (string): Name of group. resource (intern.resource.boss.Resource): Identifies which data model object to operate on. Returns: (list): List of permissions. Raises: ...
def list_permissions(self, group_name=None, resource=None): return self.service.list_permissions(group_name, resource, self.url_prefix, self.auth, self.session, self.session_send_opts)
655,631
Add additional permissions for the group associated with the given resource. Args: grp_name (string): Name of group. resource (intern.resource.boss.BossResource): Identifies which data model object to operate on. permissions (list): List of permissions to add to the given re...
def add_permissions(self, grp_name, resource, permissions): self.service.add_permissions( grp_name, resource, permissions, self.url_prefix, self.auth, self.session, self.session_send_opts)
655,632
Removes permissions from the group for the given resource. Args: grp_name (string): Name of group. resource (intern.resource.boss.BossResource): Identifies which data model object to operate on. Raises: requests.HTTPError on failure.
def delete_permissions(self, grp_name, resource): self.service.delete_permissions( grp_name, resource, self.url_prefix, self.auth, self.session, self.session_send_opts)
655,633
Add role to given user. Args: user (string): User name. role (string): Role to assign. Raises: requests.HTTPError on failure.
def add_user_role(self, user, role): self.service.add_user_role( user, role, self.url_prefix, self.auth, self.session, self.session_send_opts)
655,634
Get roles associated with the given user. Args: user (string): User name. Returns: (list): List of roles that user has. Raises: requests.HTTPError on failure.
def get_user_roles(self, user): return self.service.get_user_roles( user, self.url_prefix, self.auth, self.session, self.session_send_opts)
655,635
Add a new user. Args: user (string): User name. first_name (optional[string]): User's first name. Defaults to None. last_name (optional[string]): User's last name. Defaults to None. email: (optional[string]): User's email address. Defaults to None. ...
def add_user( self, user, first_name=None, last_name=None, email=None, password=None): self.service.add_user( user, first_name, last_name, email, password, self.url_prefix, self.auth, self.session, self.session_send_opts)
655,636
Get user's data (first and last name, email, etc). Args: user (string): User name. Returns: (dictionary): User's data encoded in a dictionary. Raises: requests.HTTPError on failure.
def get_user(self, user): return self.service.get_user( user, self.url_prefix, self.auth, self.session, self.session_send_opts)
655,637
Delete the given user. Args: user (string): User name. Raises: requests.HTTPError on failure.
def delete_user(self, user): self.service.delete_user( user, self.url_prefix, self.auth, self.session, self.session_send_opts)
655,638
Create the given resource. Args: resource (intern.resource.boss.BossResource): Create a data model object with attributes matching those of the resource. Returns: (intern.resource.boss.BossResource): Returns resource of type requested on success. Raises: re...
def create(self, resource): return self.service.create( resource, self.url_prefix, self.auth, self.session, self.session_send_opts)
655,639
Get attributes of the data model object named by the given resource. Args: resource (intern.resource.boss.BossResource): resource.name as well as any parents must be identified to succeed. Returns: (intern.resource.boss.BossResource): Returns resource of type requested on succe...
def get(self, resource): return self.service.get( resource, self.url_prefix, self.auth, self.session, self.session_send_opts)
655,640
Method to initialize the Project Service from the config data Args: version (string): Version of Boss API to use. Returns: None Raises: (KeyError): if given invalid version.
def _init_project_service(self, version): project_cfg = self._load_config_section(CONFIG_PROJECT_SECTION) self._token_project = project_cfg[CONFIG_TOKEN] proto = project_cfg[CONFIG_PROTOCOL] host = project_cfg[CONFIG_HOST] self._project = ProjectService(host, version) ...
655,644
Method to initialize the Metadata Service from the config data Args: version (string): Version of Boss API to use. Returns: None Raises: (KeyError): if given invalid version.
def _init_metadata_service(self, version): metadata_cfg = self._load_config_section(CONFIG_METADATA_SECTION) self._token_metadata = metadata_cfg[CONFIG_TOKEN] proto = metadata_cfg[CONFIG_PROTOCOL] host = metadata_cfg[CONFIG_HOST] self._metadata = MetadataService(host, v...
655,645
Method to initialize the Volume Service from the config data Args: version (string): Version of Boss API to use. Returns: None Raises: (KeyError): if given invalid version.
def _init_volume_service(self, version): volume_cfg = self._load_config_section(CONFIG_VOLUME_SECTION) self._token_volume = volume_cfg[CONFIG_TOKEN] proto = volume_cfg[CONFIG_PROTOCOL] host = volume_cfg[CONFIG_HOST] self._volume = VolumeService(host, version) se...
655,646
Method to load the specific Service section from the config file if it exists, or fall back to the default Args: section_name (str): The desired service section name Returns: (dict): the section parameters
def _load_config_section(self, section_name): if self._config.has_section(section_name): # Load specific section section = dict(self._config.items(section_name)) elif self._config.has_section("Default"): # Load Default section section = dict(self....
655,647
Get the groups the logged in user is a member of. Optionally filter by 'member' or 'maintainer'. Args: filtr (optional[string|None]): ['member'|'maintainer'] Returns: (list[string]): List of group names. Raises: requests.HTTPError on failure.
def list_groups(self, filtr=None): self.project_service.set_auth(self._token_project) return self.project_service.list_groups(filtr)
655,651
Get information on the given group or whether or not a user is a member of the group. Args: name (string): Name of group to query. user_name (optional[string]): Supply None if not interested in determining if user is a member of the given group. Returns: ...
def get_group(self, name, user_name=None): self.project_service.set_auth(self._token_project) return self.project_service.get_group(name, user_name)
655,652
Create a new group. Args: name (string): Name of the group to create. Returns: (bool): True on success. Raises: requests.HTTPError on failure.
def create_group(self, name): self.project_service.set_auth(self._token_project) return self.project_service.create_group(name)
655,653
Delete given group. Args: name (string): Name of group. Returns: (bool): True on success. Raises: requests.HTTPError on failure.
def delete_group(self, name): self.project_service.set_auth(self._token_project) return self.project_service.delete_group(name)
655,654
Get the members of a group. Args: name (string): Name of group to query. Returns: (list[string]): List of member names. Raises: requests.HTTPError on failure.
def list_group_members(self, name): self.project_service.set_auth(self._token_project) return self.project_service.list_group_members(name)
655,655
Add the given user to the named group. Both group and user must already exist for this to succeed. Args: name (string): Name of group. user_name (string): User to add to group. Raises: requests.HTTPError on failure.
def add_group_member(self, grp_name, user): self.project_service.set_auth(self._token_project) self.project_service.add_group_member(grp_name, user)
655,656
Delete the given user to the named group. Both group and user must already exist for this to succeed. Args: name (string): Name of group. user_name (string): User to delete from the group. Raises: requests.HTTPError on failure.
def delete_group_member(self, grp_name, user): self.project_service.set_auth(self._token_project) self.project_service.delete_group_member(grp_name, user)
655,657
Check if the given user is a member of the named group. Note that a group maintainer is not considered a member unless the user is also explicitly added as a member. Args: name (string): Name of group. user_name (string): User of interest. Returns: ...
def get_is_group_member(self, grp_name, user): self.project_service.set_auth(self._token_project) return self.project_service.get_is_group_member(grp_name, user)
655,658
Get the maintainers of a group. Args: name (string): Name of group to query. Returns: (list[string]): List of maintainer names. Raises: requests.HTTPError on failure.
def list_group_maintainers(self, name): self.project_service.set_auth(self._token_project) return self.project_service.list_group_maintainers(name)
655,659
Add the given user to the named group. Both group and user must already exist for this to succeed. Args: name (string): Name of group. user (string): User to add to group. Raises: requests.HTTPError on failure.
def add_group_maintainer(self, name, user): self.project_service.set_auth(self._token_project) self.project_service.add_group_maintainer(name, user)
655,660
Delete the given user to the named group. Both group and user must already exist for this to succeed. Args: name (string): Name of group. user (string): User to add to group. Raises: requests.HTTPError on failure.
def delete_group_maintainer(self, grp_name, user): self.project_service.set_auth(self._token_project) self.project_service.delete_group_maintainer(grp_name, user)
655,661
Check if the given user is a member of the named group. Args: name (string): Name of group. user (string): User of interest. Returns: (bool): False if user not a member.
def get_is_group_maintainer(self, grp_name, user): self.project_service.set_auth(self._token_project) return self.project_service.get_is_group_maintainer(grp_name, user)
655,662
List permission sets associated filtering by group and/or resource. Args: group_name (string): Name of group. resource (intern.resource.boss.Resource): Identifies which data model object to operate on. Returns: (list): List of permissions. R...
def list_permissions(self, group_name=None, resource=None): self.project_service.set_auth(self._token_project) return self.project_service.list_permissions(group_name, resource)
655,663
Get permissions associated the group has with the given resource. Args: grp_name (string): Name of group. resource (intern.resource.boss.Resource): Identifies which data model object to operate on. Returns: (list): List of permissions. Raise...
def get_permissions(self, grp_name, resource): self.project_service.set_auth(self._token_project) return self.project_service.get_permissions(grp_name, resource)
655,664
Add additional permissions for the group associated with the resource. Args: grp_name (string): Name of group. resource (intern.resource.boss.Resource): Identifies which data model object to operate on. permissions (list): List of permissions to add to the gi...
def add_permissions(self, grp_name, resource, permissions): self.project_service.set_auth(self._token_project) self.project_service.add_permissions(grp_name, resource, permissions)
655,665
Update permissions for the group associated with the given resource. Args: grp_name (string): Name of group. resource (intern.resource.boss.Resource): Identifies which data model object to operate on permissions (list): List of permissions to add to the given...
def update_permissions(self, grp_name, resource, permissions): self.project_service.set_auth(self._token_project) self.project_service.update_permissions(grp_name, resource, permissions)
655,666
Removes permissions from the group for the given resource. Args: grp_name (string): Name of group. resource (intern.resource.boss.Resource): Identifies which data model object to operate on. Raises: requests.HTTPError on failure.
def delete_permissions(self, grp_name, resource): self.project_service.set_auth(self._token_project) self.project_service.delete_permissions(grp_name, resource)
655,667