Exemplo n.º 1
0
def create_group(base_url,
                 digest_login,
                 name,
                 description="",
                 roles="",
                 users=""):
    """
    Create group.

    :param base_url: The URL for the request
    :type base_url: str
    :param digest_login: The login credentials for digest authentication
    :type digest_login: DigestLogin
    :param name: The name of the group
    :type name: str
    :param description: The description of the group
    :type description: str
    :param roles: The roles of the group
    :type roles: str
    :param users: The users of the group
    :type users: str
    :raise RequestError:
    """
    url = '{}/admin-ng/groups'.format(base_url)
    data = {
        'name': name,
        'description': description,
        'roles': roles,
        'users': users
    }
    post_request(url,
                 digest_login,
                 element_description="/admin-ng/groups",
                 data=data)
Exemplo n.º 2
0
def start_task(base_url, digest_login, workflow_definition, event_id):
    """
        Start a workflow on a media package.

    :param base_url: The URL for the request
    :type base_url: str
    :param digest_login: The login credentials for digest authentication
    :type digest_login: DigestLogin
    :param workflow_definition: The workflow definition
    :type workflow_definition: str
    :param event_id: the event id
    :type event_id: str
    :return: The workflow instance
    :rtype: str
    :raise RequestError:
    """

    url = '{}/admin-ng/tasks/new'.format(base_url)
    # hardcode workflow definition and ingest start date since I don't think it's actually relevant
    metadata = {
        'workflow': workflow_definition,
        'configuration': {
            '{}'.format(event_id): {
                "workflowDefinitionId": "fast",
                "ingest_start_date": "20210607T020914Z"
            }
        }
    }
    data = {'metadata': json.dumps(metadata)}

    post_request(url,
                 digest_login,
                 element_description="/admin-ng/tasks/new",
                 data=data)
Exemplo n.º 3
0
def add_catalog(base_url, digest_login, mp, catalog):
    """
    Add a catalog to a new media package.

    :param base_url: Base URL for request.
    :type base_url: str
    :param digest_login: User and password for digest authentication.
    :type digest_login: DigestLogin
    :param mp: New media package.
    :type mp: str
    :param catalog: The catalog to be added.
    :type catalog: Element
    :return: Augmented media package.
    :rtype: str
    """

    url = '{}/ingest/addCatalog'.format(base_url)

    data = {'flavor': catalog.flavor, 'mediaPackage': mp}
    files = {'BODY': open(catalog.path, 'rb')}

    response = post_request(url,
                            digest_login,
                            "/ingest/addCatalog",
                            data=data,
                            files=files)

    return response.content
Exemplo n.º 4
0
def ingest(base_url, digest_login, mp, workflow_id):
    """
    Ingest media package and start a workflow.

    :param base_url: Base URL for request.
    :type base_url: str
    :param digest_login: User and password for digest authentication.
    :type digest_login: DigestLogin
    :param mp: New media package.
    :type mp: str
    :param workflow_id: The workflow to be run on ingest.
    :type workflow_id: str
    :return: Information about the started workflow.
    :rtype: Workflow
    """

    if workflow_id:

        url = '{}/ingest/ingest/{}'.format(base_url, workflow_id)
    else:
        url = '{}/ingest/ingest/'.format(base_url)

    data = {'mediaPackage': mp}

    response = post_request(url, digest_login, "/ingest/ingest", data=data)
    return __parse_ingest_response(response)
def add_attachment_with_url(base_url, digest_login, mp, attachment):
    """
    Add an attachment to a new media package via URL.

    :param base_url: Base URL for request.
    :type base_url: str
    :param digest_login: User and password for digest authentication.
    :type digest_login: DigestLogin
    :param mp: New media package.
    :type mp: str
    :param attachment: The attachment to be added.
    :type attachment: Asset
    :return: Augmented media package.
    :rtype: str
    :raise RequestError:
    """

    url = '{}/ingest/addAttachment'.format(base_url)
    data = {
        'flavor': attachment.flavor,
        'mediaPackage': mp,
        'url': attachment.url
    }

    response = post_request(url,
                            digest_login,
                            "/ingest/addAttachment",
                            data=data)
    return response.content
Exemplo n.º 6
0
def create_series(base_url, digest_login, series_dc, series_acl=None):
    """
    Create a new series with a Dublin Core catalog (required) and an ACL (optional).

    :param base_url: Base URL for request.
    :type base_url: str
    :param digest_login: User and password for digest authentication.
    :type digest_login: DigestLogin
    :param series_dc: Series Dublin Core catalog
    :type series_dc: ste
    :param series_acl: Series ACL
    :type series_acl: str
    :raise RequestError: If series could not be created
    """

    url = '{}/series/'.format(base_url)

    data = {'series': series_dc, 'acl': series_acl}

    post_request(url, digest_login, "/series/", data=data)
Exemplo n.º 7
0
def start_workflow(base_url, digest_login, workflow_definition, media_package):
    """
    Starts a workflow on a media package.

    :param base_url: The URL for the request
    :type base_url: str
    :param digest_login: The login credentials for digest authentication
    :type digest_login: DigestLogin
    :param workflow_definition: The workflow definition
    :type workflow_definition: str
    :param media_package: The media package
    :type media_package: str
    :return: The workflow instance
    :rtype: str
    """

    url = '{}/workflow/start'.format(base_url)
    data = {'definition': workflow_definition, 'mediapackage': media_package}

    post_request(url, digest_login, element_description="/workflow/start", data=data)