Exemple #1
0
    def __init__(self, json):  # type: (Dict[str, Any]) -> None
        # attachment id get returned starting with att which can be stripped
        # this ensures ids are always of type int
        id = str(json['id'])
        if id.startswith('att'):
            id = id[3:]
        self.id = int(id)
        self.status = ContentStatus(json['status'])  # type: ContentStatus
        self.type = ContentType(json['type'])  # type: ContentType

        if 'title' in json:
            self.title = json['title']  # type: str

        if 'metadata' in json:
            self.metadata = json['metadata']  # type: Dict[str, Any]

        if 'extensions' in json:
            self.extensions = json['extensions']  # type: Dict[str, Any]

        if 'space' in json:
            self.space = Space(json['space'])

        if 'body' in json:
            self.body = ContentBody(json['body'])

        if 'history' in json:
            self.history = ContentHistory(json['history'])

        if 'version' in json:
            self.version = Version(json['version'])

        if self.type == ContentType.ATTACHMENT or '_links' in json:
            self.links = json['_links']  # type: Dict[str, Any]
Exemple #2
0
 def __init__(self, json):  # type: (Dict[str, Any]) -> None
     self.key = json['key']  # type: str
     self.value = json['value']  # type: Dict[str, Any]
     if 'version' in json:
         self.version = Version(json['version'])
     if 'content' in json:
         self.content = Content(json['content'])
 def __init__(self, json):  # type: (Dict[str, Any]) -> None
     self.key = json['key']  # type: str
     self.value = json['value']  # type: Dict[str, Any]
     if 'version' in json:
         self.version = Version(json['version'])
     if 'space' in json:
         self.space = Space(json['space'])
    def __init__(self, json):  # type: (Dict[str, Any]) -> None
        self.latest = json['latest']
        self.author = User(json['createdBy'])
        self.created_date = json['createdDate']

        # Fields only returned if the history.lastUpdated is expanded
        if 'lastUpdated' in json:
            self.last_updated = Version(json['lastUpdated'])

        if 'previousVersion' in json:
            self.previous_version = Version(json['previousVersion'])

        if 'nextVersion' in json:
            self.next_version = Version(json['nextVersion'])

        if 'contributors' in json:
            # Note: this is not properly implemented yet, we don't turn this
            # into objects with known properties.
            self.contributors = json['contributors']
def test_page_update_creation():
    cv = Version({
        'by': {
            'username': '******',
            'displayName': '2',
            'userKey': '3',
            'type': '4'
        },
        'when': '2017-02-01',
        'message': 'Hello',
        'number': 1,
        'minorEdit': False,
        'hidden': False
    })

    assert str(cv) == '1'
    def __init__(self, json):  # type: (Dict[str, Any]) -> None
        self.id = json['id']  # type: int
        self.title = json['title']  # type: str
        self.status = ContentStatus(json['status'])  # type: ContentStatus
        self.type = ContentType(json['type'])  # type: ContentType

        if 'metadata' in json:
            self.metadata = json['metadata']  # type: Dict[str, Any]

        if 'extensions' in json:
            self.extensions = json['extensions']  # type: Dict[str, Any]

        if 'space' in json:
            self.space = Space(json['space'])

        if 'body' in json:
            self.body = ContentBody(json['body'])

        if 'history' in json:
            self.history = ContentHistory(json['history'])

        if 'version' in json:
            self.version = Version(json['version'])