Esempio n. 1
0
    def _make_credentials_path(self, user, credential_type, name):
        if not is_valid_identifier(user):
            raise ValueError('invalid user "%s"' % (user,))
        if not is_valid_identifier(credential_type):
            raise ValueError('invalid credential type "%s"' % (credential_type,))

        path = self.USER_PATH + "/" + user + self.CREDENTIALS_PATH + "/" + credential_type
        self.retry(self.kazoo.ensure_path, path)
        if name:
            path = path + "/" + name
        return path
Esempio n. 2
0
def validate_credentials(credentials_type, name, credentials):
    if credentials_type not in CredentialType.VALID_CREDENTIAL_TYPES:
        raise BadRequestError("Invalid credentials type '%s'" % (credentials_type,))

    if not is_valid_identifier(name):
        raise BadRequestError("Invalid credentials name '%s'" % (name,))

    if not (credentials and isinstance(credentials, dict)):
        raise BadRequestError("Invalid credentials block")
Esempio n. 3
0
def validate_definition_id(definition_id):
    if not is_valid_identifier(definition_id):
        raise BadRequestError("invalid definition_id")
Esempio n. 4
0
def validate_owner_upid(owner, upid):
    # so far we don't enforce owner since it isn't used for anything
    if not is_valid_identifier(upid):
        raise BadRequestError("invalid upid")