Exemple #1
0
def _serialize_folder(folder: CREFolder):
    uri = constructors.object_href('folder_config', folder.id())
    return constructors.domain_object(
        domain_type='folder_config',
        identifier=folder.id(),
        title=folder.title(),
        members={
            'move': constructors.object_action(
                name='move',
                base=uri,
                parameters=dict([
                    constructors.action_parameter(
                        action='move',
                        parameter='destination',
                        friendly_name='The destination folder of this move action',
                        optional=False,
                        pattern="[0-9a-fA-F]{32}|root",
                    ),
                ]),
            ),
        },
        extensions={
            'attributes': folder.attributes().copy(),
        },
    )
Exemple #2
0
def _serialize_folder(folder):
    # type: (CREFolder) -> DomainObject
    uri = '/objects/folder/%s' % (folder.id(), )
    return constructors.domain_object(
        domain_type='folder',
        identifier=folder.id(),
        title=folder.title(),
        members={
            'hosts':
            constructors.object_collection(
                name='hosts',
                entries=[
                    constructors.link_rel(
                        rel='.../value;collection="items"',
                        href=constructors.object_href('host', host),
                    ) for host in folder.hosts().values()
                ],
                base=uri,
            ),
            'move':
            constructors.object_action(
                name='move',
                base=uri,
                parameters=dict([
                    constructors.action_parameter(
                        action='move',
                        parameter='destination',
                        friendly_name=
                        'The destination folder of this move action',
                        optional=False,
                        pattern="[0-9a-fA-F]{32}|root",
                    ),
                ]),
            ),
            'title':
            constructors.object_property(
                name='title',
                value=folder.title(),
                prop_format='string',
                base=uri,
            ),
        },
        extensions={
            'attributes': folder.attributes(),
        },
    )
Exemple #3
0
def _serialize_folder(folder: CREFolder) -> DomainObject:
    uri = constructors.object_href('folder_config', folder.id())
    return constructors.domain_object(
        domain_type='folder_config',
        identifier=folder.id(),
        title=folder.title(),
        members={
            'hosts':
            constructors.object_collection(
                name='hosts',
                domain_type='host_config',
                entries=[
                    constructors.link_rel(
                        rel='.../value',
                        parameters={'collection': "items"},
                        href=constructors.object_href('host_config', host),
                    ) for host in folder.hosts().values()
                ],
                base=uri,
            ),
            'move':
            constructors.object_action(
                name='move',
                base=uri,
                parameters=dict([
                    constructors.action_parameter(
                        action='move',
                        parameter='destination',
                        friendly_name=
                        'The destination folder of this move action',
                        optional=False,
                        pattern="[0-9a-fA-F]{32}|root",
                    ),
                ]),
            ),
        },
        extensions={
            'attributes': folder.attributes(),
        },
    )