How to use the awxkit.utils.random_title function in awxkit

To help you get started, we’ve selected a few awxkit examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ansible / awx / awxkit / awxkit / api / pages / notification_templates.py View on Github external
def payload(self, organization, notification_type='slack', **kwargs):
        payload = PseudoNamespace(
            name=kwargs.get('name') or 'NotificationTemplate ({0}) - {1}' .format(
                notification_type,
                random_title()),
            description=kwargs.get('description') or random_title(10),
            organization=organization.id,
            notification_type=notification_type)

        notification_configuration = kwargs.get(
            'notification_configuration', {})
        payload.notification_configuration = notification_configuration

        if payload.notification_configuration == {}:
            services = config.credentials.notification_services

            if notification_type == 'email':
                fields = (
                    'host',
                    'username',
                    'password',
                    'port',
github ansible / awx / awxkit / awxkit / api / pages / workflow_job_template_nodes.py View on Github external
def make_approval_node(
        self,
        **kwargs
    ):
        if 'name' not in kwargs:
            kwargs['name'] = 'approval node {}'.format(random_title())
        self.related.create_approval_template.post(kwargs)
        return self.get()
github ansible / awx / awxkit / awxkit / api / pages / workflow_job_templates.py View on Github external
def payload(self, **kwargs):
        payload = PseudoNamespace(name=kwargs.get('name') or 'WorkflowJobTemplate - {}'.format(random_title()),
                                  description=kwargs.get('description') or random_title(10))

        optional_fields = (
            "allow_simultaneous",
            "ask_variables_on_launch",
            "ask_inventory_on_launch",
            "ask_scm_branch_on_launch",
            "ask_limit_on_launch",
            "limit",
            "scm_branch",
            "survey_enabled",
            "webhook_service",
            "webhook_credential",
        )
        update_payload(payload, optional_fields, kwargs)
github ansible / awx / awxkit / awxkit / api / pages / workflow_job_templates.py View on Github external
def payload(self, **kwargs):
        payload = PseudoNamespace(name=kwargs.get('name') or 'WorkflowJobTemplate - {}'.format(random_title()),
                                  description=kwargs.get('description') or random_title(10))

        optional_fields = (
            "allow_simultaneous",
            "ask_variables_on_launch",
            "ask_inventory_on_launch",
            "ask_scm_branch_on_launch",
            "ask_limit_on_launch",
            "limit",
            "scm_branch",
            "survey_enabled",
            "webhook_service",
            "webhook_credential",
        )
        update_payload(payload, optional_fields, kwargs)

        extra_vars = kwargs.get('extra_vars', not_provided)
github ansible / awx / awxkit / awxkit / api / pages / credentials.py View on Github external
credential_type,
            user=None,
            team=None,
            organization=None,
            inputs=None,
            **kwargs):
        if not any((user, team, organization)):
            raise TypeError(
                '{0.__class__.__name__} requires user, team, and/or organization instances.'.format(self))

        if inputs is None:
            inputs = {}

        payload = PseudoNamespace(
            name=kwargs.get('name') or 'Credential - {}'.format(
                random_title()),
            description=kwargs.get('description') or random_title(10),
            credential_type=credential_type.id,
            inputs=inputs)
        if user:
            payload.user = user.id
        if team:
            payload.team = team.id
        if organization:
            payload.organization = organization.id

        kind, config_cred = kind_and_config_cred_from_credential_type(
            credential_type)

        for field in credential_input_fields:
            field, value = get_payload_field_and_value_from_kwargs_or_config_cred(
                field, kind, inputs or kwargs, config_cred)
github ansible / awx / awxkit / awxkit / api / pages / users.py View on Github external
def payload(self, **kwargs):
        payload = PseudoNamespace(
            username=kwargs.get('username') or 'User-{}'.format(
                random_title(
                    non_ascii=False)),
            password=kwargs.get('password') or config.credentials.default.password,
            is_superuser=kwargs.get(
                'is_superuser',
                False),
            is_system_auditor=kwargs.get(
                'is_system_auditor',
                False),
            first_name=kwargs.get(
                'first_name',
                random_title()),
            last_name=kwargs.get(
                'last_name',
                random_title()),
            email=kwargs.get(
                'email',
github ansible / awx / awxkit / awxkit / api / pages / job_templates.py View on Github external
def payload(self, job_type='run', playbook='ping.yml', **kwargs):
        name = kwargs.get('name') or 'JobTemplate - {}'.format(random_title())
        description = kwargs.get('description') or random_title(10)
        payload = PseudoNamespace(
            name=name,
            description=description,
            job_type=job_type)

        optional_fields = (
            'ask_scm_branch_on_launch',
            'ask_credential_on_launch',
            'ask_diff_mode_on_launch',
            'ask_inventory_on_launch',
            'ask_job_type_on_launch',
            'ask_limit_on_launch',
            'ask_skip_tags_on_launch',
            'ask_tags_on_launch',
            'ask_variables_on_launch',
github ansible / awx / awxkit / awxkit / api / pages / users.py View on Github external
def payload(self, **kwargs):
        payload = PseudoNamespace(
            username=kwargs.get('username') or 'User-{}'.format(
                random_title(
                    non_ascii=False)),
            password=kwargs.get('password') or config.credentials.default.password,
            is_superuser=kwargs.get(
                'is_superuser',
                False),
            is_system_auditor=kwargs.get(
                'is_system_auditor',
                False),
            first_name=kwargs.get(
                'first_name',
                random_title()),
            last_name=kwargs.get(
                'last_name',
                random_title()),
            email=kwargs.get(
                'email',
                '{}@example.com'.format(random_title(5, non_ascii=False))
            )
        )
        return payload