def _get_settings_data(self, setting_type): setting_types = ['all', 'authentication', 'azuread-oauth2', 'changed', 'github', 'github-org', 'github-team', 'google-oauth2', 'jobs', 'ldap', 'logging', 'named-url', 'radius', 'saml', 'system', 'tacacsplus', 'ui'] if not setting_type.lower() in setting_types: raise InvalidValue(('{value} is invalid. The following setting types are allowed:' '{setting_types}').format(value=setting_type, setting_types=setting_types)) url = '{api}/settings/{type_}/'.format(api=self._tower.api, type_=setting_type) response = self._tower.session.get(url) if not response.ok: LOGGER.error('Error getting setting type "%s", response was: "%s"', setting_type, response.text) return response.json() if response.ok else {}
def name(self, value): """Update the name of the template.""" max_characters = 512 conditions = [validate_max_length(value, max_characters)] if all(conditions): self._update_values('name', value) else: raise InvalidValue( f'{value} is invalid. Condition max_characters must be less than or equal to ' f'{max_characters}')
def injectors(self, value): """Update the injectors of the credential type. Returns: None: """ if isinstance(value, dict): self._update_values('injectors', value) else: raise InvalidValue('Value is not valid dictionary received: {value}'.format(value=value))
def variables(self, value): """Update the variables of the team. Returns: None: """ if validate_json(value): self._update_values('variables', value) else: raise InvalidValue(f'Value is not valid json received: {value}')
def inputs(self, value): """Update the inputs of the credential. Returns: None: """ if isinstance(value, dict): self._update_values('inputs', value) else: raise InvalidValue(f'Value is not valid json received: {value}')
def variables(self, value): """Update the variables on the host. Returns: None: """ conditions = [validate_json(value)] if all(conditions): self._update_values('variables', value) else: raise InvalidValue(f'{value} is not valid json.')
def variables(self, value): """Update the variables of the group. Returns: None: """ conditions = [validate_json(value)] if all(conditions): self._update_values('variables', value) else: raise InvalidValue( '{value} is not valid json.'.format(value=value))
def last_name(self, value): """Update the last name of the user. Returns: None: """ max_characters = 30 conditions = [validate_max_length(value, max_characters)] if all(conditions): self._update_values('last_name', value) else: raise InvalidValue(value)
def name(self, value): """Update the name of the credential type. Returns: None: """ max_characters = 512 conditions = [validate_max_length(value, max_characters)] if all(conditions): self._update_values('name', value) else: raise InvalidValue('{value} is invalid. Condition max_characters must be less or equal ' '{max_characters}'.format(value=value, max_characters=max_characters))
def instance_id(self, value): """Update the instance_id of the host. Returns: None: """ max_characters = 1024 conditions = [validate_max_length(value, max_characters)] if all(conditions): self._update_values('instance_id', value) else: raise InvalidValue('{value} is invalid. Condition max_characters must be less than or equal to ' '{max_characters}'.format(value=value, max_characters=max_characters))
def custom_virtualenv(self, value): """Update the custom_virtualenv of the group. Returns: None: """ max_characters = 100 conditions = [validate_max_length(value, max_characters)] if all(conditions): self._update_values('custom_virtualenv', value) else: raise InvalidValue(f'{value} is invalid. Condition max_characters must be less than or equal to ' f'{max_characters}')
def scm_branch(self, value): """Update the scm_branch project. Returns: None: """ max_characters = 256 conditions = [validate_max_length(value, max_characters)] if all(conditions): self._update_values('scm_branch', value) else: raise InvalidValue('{value} is invalid. Condition max_characters must be less than or equal to ' '{max_characters}'.format(value=value, max_characters=max_characters))
def script(self, value): """Update the script of the inventory script. Returns: None: """ pattern = '(#!/(usr|bin)/(sh|bash|bin)(/)?(make|env)?)' conditions = re.match(pattern, value) if conditions: self._update_values('script', value) else: raise InvalidValue( 'Script content is invalid, it should start with a shebang.')
def name(self, value): """Update the name of the inventory script. Returns: None: """ max_characters = 512 conditions = [validate_max_length(value, max_characters)] if all(conditions): self._update_values('name', value) else: raise InvalidValue( f'{value} is invalid. Condition max_characters must be less or equal to ' f'{max_characters}')
def first_name(self, value): """Update the first name of the user. Returns: None: """ max_characters = 30 conditions = [validate_max_length(value, max_characters)] if all(conditions): self._update_values('first_name', value) else: raise InvalidValue( f'{value} is invalid. Condition max_characters must be less or equal to ' f'{max_characters}')
def scm_update_cache_timeout(self, value): """Update the scm_update_cache_timeout of the project. Returns: None: """ minimum = 0 maximum = 2147483647 conditions = [validate_range(value, minimum, maximum)] if all(conditions): self._update_values('scm_update_cache_timeout', value) else: raise InvalidValue( f'{value} is invalid, must be between {minimum} and {maximum}')
def scm_url(self, value): """Update the scm_url project. Returns: None: """ max_characters = 1024 conditions = [validate_max_length(value, max_characters)] if all(conditions): self._update_values('scm_url', value) else: raise InvalidValue( f'{value} is invalid. Condition max_characters must be less than or equal to ' f'{max_characters}')
def email(self, value): """Update the email address of the user. Returns: None: """ max_characters = 254 conditions = [validate_max_length(value, max_characters)] if all(conditions): self._update_values('email', value) else: raise InvalidValue( f'{value} is invalid. Condition max_characters must be less or equal to ' f'{max_characters}')
def timeout(self, value): """Update the timeout of the project. Returns: None: """ minimum = -2147483648 maximum = 2147483647 conditions = [validate_range(value, minimum, maximum)] if all(conditions): self._update_values('timeout', value) else: raise InvalidValue('{value} is invalid, must be between {minimum} and {maximum}'.format(value=value, minimum=minimum, maximum=maximum))
def username(self, value): """Update the username of the user. Returns: None: """ max_characters = 150 valid_metacharacters = '@.+-_' conditions = [ validate_max_length(value, max_characters), validate_characters(value, extra_chars=valid_metacharacters) ] if all(conditions): self._update_values('username', value) else: raise InvalidValue( f'{value} is invalid. Condition max_characters must be less or equal to ' f'{max_characters} and valid character are only alphanums and {valid_metacharacters}' )