Module libnova.common.api.JobMessage

Expand source code
#!/usr/bin/env python
# coding: utf-8

import datetime
from enum import Enum
from libnova.common import api

# Define Enum structs
from libnova.common.api.Serializable import Serializable


class JobMessageType(Enum):
    """Job Message Type
    """
    DEBUG      = 1
    INFO       = 2
    WARNING    = 3
    ERROR      = 4
    FILE_ASSET = 5
    SUMMARY    = 6


class JobMessage(Serializable):
    """Job Message

    The main methods allows the interaction with the main structures related to job messages hosted in the platform
    """

    id:              int       = 0
    job_id:          int
    file_id:         int
    creator_id:      int
    date_created:    datetime.datetime
    message_type:    JobMessageType = JobMessageType.INFO
    message:         str


def add(job_id, message, message_type = JobMessageType.INFO, file_id = None):
    """Add a message to an existing `Job`

    Args:
        job_id (int): The `Job` id
        message (str): The message
        message_type (JobMessageType): The level of the message
        file_id (int): If set, the message will also be related to a `File` based on the give `file_id`

    Returns:
        dict: An API result (see documentation)
    """

    query = {
        "message":      message,
        "message_type": str(message_type.name),
        "file_id":      file_id
    }

    api_driver = api.Driver.get_instance()
    return api_driver.post_json(
        url_segment='job/' + job_id + '/message',
        data=query
    )


if __name__ == "__main__":
    print('This file cannot be executed directly!')

Functions

def add(job_id, message, message_type=JobMessageType.INFO, file_id=None)

Add a message to an existing Job

Args

job_id : int
The Job id
message : str
The message
message_type : JobMessageType
The level of the message
file_id : int
If set, the message will also be related to a File based on the give file_id

Returns

dict
An API result (see documentation)
Expand source code
def add(job_id, message, message_type = JobMessageType.INFO, file_id = None):
    """Add a message to an existing `Job`

    Args:
        job_id (int): The `Job` id
        message (str): The message
        message_type (JobMessageType): The level of the message
        file_id (int): If set, the message will also be related to a `File` based on the give `file_id`

    Returns:
        dict: An API result (see documentation)
    """

    query = {
        "message":      message,
        "message_type": str(message_type.name),
        "file_id":      file_id
    }

    api_driver = api.Driver.get_instance()
    return api_driver.post_json(
        url_segment='job/' + job_id + '/message',
        data=query
    )

Classes

class JobMessage (**entries: dict)

Job Message

The main methods allows the interaction with the main structures related to job messages hosted in the platform

Expand source code
class JobMessage(Serializable):
    """Job Message

    The main methods allows the interaction with the main structures related to job messages hosted in the platform
    """

    id:              int       = 0
    job_id:          int
    file_id:         int
    creator_id:      int
    date_created:    datetime.datetime
    message_type:    JobMessageType = JobMessageType.INFO
    message:         str

Ancestors

Class variables

var creator_id : int
var date_created : datetime.datetime
var file_id : int
var id : int
var job_id : int
var message : str
var message_typeJobMessageType
class JobMessageType (value, names=None, *, module=None, qualname=None, type=None, start=1)

Job Message Type

Expand source code
class JobMessageType(Enum):
    """Job Message Type
    """
    DEBUG      = 1
    INFO       = 2
    WARNING    = 3
    ERROR      = 4
    FILE_ASSET = 5
    SUMMARY    = 6

Ancestors

  • enum.Enum

Class variables

var DEBUG
var ERROR
var FILE_ASSET
var INFO
var SUMMARY
var WARNING