Ejemplo n.º 1
0
    def create(cls, name, description=None, billing_group=None,
               secret_settings=None, api=None):
        """
        Create a automation template.
        :param name:  Automation name.
        :param billing_group: Automation billing group.
        :param description:  Automation description.
        :param secret_settings: Automation settings.
        :param api: Api instance.
        :return:
        """
        api = api if api else cls._API

        if name is None:
            raise SbgError('Automation name is required!')

        data = {
            'name': name,
        }

        if billing_group:
            data['billing_group'] = Transform.to_billing_group(billing_group)

        if description:
            data['description'] = description
        if secret_settings:
            data['secret_settings'] = secret_settings

        extra = {
            'resource': cls.__name__,
            'query': data
        }
        logger.info('Creating automation template', extra=extra)
        automation_data = api.post(url=cls._URL['query'], data=data).json()
        return Automation(api=api, **automation_data)
Ejemplo n.º 2
0
    def create(cls, name, billing_group, description=None, tags=None,
               api=None):
        """
        Create a project.
        :param name:  Project name.
        :param billing_group: Project billing group.
        :param description:  Project description.
        :param tags: Project tags.
        :param api: Api instance.
        :return:
        """
        api = api if api else cls._API

        billing_group = Transform.to_billing_group(billing_group)
        if name is None:
            raise SbgError('Project name is required!')

        data = {
            'name': name,
            'billing_group': billing_group,
        }
        if description:
            data['description'] = description
        if tags:
            data['tags'] = tags

        project_data = api.post(url=cls._URL['query'],
                                data=data).json()
        return Project(api=api, **project_data)
Ejemplo n.º 3
0
    def create(cls, name, billing_group, description=None, tags=None,
               api=None):
        """
        Create a project.
        :param name:  Project name.
        :param billing_group: Project billing group.
        :param description:  Project description.
        :param tags: Project tags.
        :param api: Api instance.
        :return:
        """
        api = api if api else cls._API

        billing_group = Transform.to_billing_group(billing_group)
        if name is None:
            raise SbgError('Project name is required!')

        data = {
            'name': name,
            'billing_group': billing_group,
        }
        if description:
            data['description'] = description
        if tags:
            data['tags'] = tags

        project_data = api.post(url=cls._URL['query'],
                                data=data).json()
        return Project(api=api, **project_data)
Ejemplo n.º 4
0
    def create(cls,
               name,
               billing_group=None,
               description=None,
               tags=None,
               settings=None,
               api=None):
        """
        Create a project.
        :param name:  Project name.
        :param billing_group: Project billing group.
        :param description:  Project description.
        :param tags: Project tags.
        :param settings: Project settings.
        :param api: Api instance.
        :return:
        """
        api = api if api else cls._API

        if name is None:
            raise SbgError('Project name is required!')

        data = {
            'name': name,
        }

        if billing_group:
            data['billing_group'] = Transform.to_billing_group(billing_group)

        if description:
            data['description'] = description
        if tags:
            data['tags'] = tags

        if settings:
            data['settings'] = settings

        extra = {'resource': cls.__name__, 'query': data}
        logger.info('Creating project', extra=extra)
        project_data = api.post(url=cls._URL['create'], data=data).json()
        return Project(api=api, **project_data)
Ejemplo n.º 5
0
    def create(cls, name, billing_group=None, description=None, tags=None,
               settings=None, api=None):
        """
        Create a project.
        :param name:  Project name.
        :param billing_group: Project billing group.
        :param description:  Project description.
        :param tags: Project tags.
        :param settings: Project settings.
        :param api: Api instance.
        :return:
        """
        api = api if api else cls._API

        if name is None:
            raise SbgError('Project name is required!')

        data = {
            'name': name,
        }

        if billing_group:
            data['billing_group'] = Transform.to_billing_group(billing_group)

        if description:
            data['description'] = description
        if tags:
            data['tags'] = tags

        if settings:
            data['settings'] = settings

        extra = {
            'resource': cls.__name__,
            'query': data
        }
        logger.info('Creating project', extra=extra)
        project_data = api.post(url=cls._URL['create'], data=data).json()
        return Project(api=api, **project_data)
def test_transform_billing_group_invalid_values(group):
    with pytest.raises(SbgError):
        Transform.to_billing_group(group)
def test_transform_billing_group(group):
    Transform.to_billing_group(group)
Ejemplo n.º 8
0
def test_transform_billing_group_invalid_values(group):
    with pytest.raises(SbgError):
        Transform.to_billing_group(group)
Ejemplo n.º 9
0
def test_transform_billing_group(group):
    Transform.to_billing_group(group)