コード例 #1
0
def get_capabilities():
    """This function enables an Open Geospatial Consortium Web Service-like GetCapabilities function which describes
    this service (PROMS as a whole) in a standardised way. See http://ogcnetwork.net/node/180 for the OGC's WFS
    GetCapabilities function description.

    This function is only called via the index page ('/')."""

    # TODO: add all API endpoints
    em = ElementMaker(
        namespace="http://fake.com/ldapi",
        nsmap={
            'ldapi': "http://fake.com/ldapi"
        }
    )
    onl = ElementMaker(
        namespace="http://fake.com/ldapi",
        nsmap={
            'xlink': "http://www.w3.org/1999/xlink",
        }
    )
    doc = em.LDAPI_Capabilities(
        em.Service(
            em.Name('PROMS Server'),
            em.Title('PRovenance Management System (PROMS) Server'),
            em.KeywordList(
                em.Keyword('provenance'),
                em.Keyword('RDF'),
                em.Keyword('Linked Data')
            ),
            # TODO: parameterised namespaces not working yet
            onl.OnlineResource(type="simple", href=conf.BASE_URI),
            em.ContactInformation(
                em.ContactPersonPrimary(
                    em.contactPerson('Nicholas Car'),
                    em.ContactOrganization('Geoscience Australia')
                ),
                em.ContactAddress(
                    em.AddressType('Postal'),
                    em.Address('GPO Box 378'),
                    em.City('Canberra'),
                    em.StateOrProvince('ACT'),
                    em.PostCode('2601'),
                    em.Country('Australia'),
                    em.ContactVoiceTelephone('+61 2 6249 9111'),
                    em.ContactFacsimileTelephone(),
                    em.ContactElectronicMailAddress('*****@*****.**')
                )
            ),
            em.Fees('none'),
            em.AccessConstraints(
                '(c) Commonwealth of Australia (Geoscience Australia) 2016. This product is released under the ' +
                'Creative Commons Attribution 4.0 International Licence. ' +
                'http://creativecommons.org/licenses/by/4.0/legalcode'
            )
        ),
        em.Capability(
            em.Request(
                em.GetCapabilities(
                    em.Format('application/xml'),
                    em.DCPType(
                        em.HTTP(
                            em.Get(
                                onl.OnlineResource(
                                    type="simple",
                                    href=conf.BASE_URI +
                                         "?_view=getcapabilities&_format=application/xml"
                                ),
                            )
                        )
                    )
                ),
                em.Sample(
                    em.Format('text/html'),
                    em.Format('text/turtle'),
                    em.Format('application/rdf+xml'),
                    em.Format('application/rdf+json'),
                    em.DCPType(
                        em.HTTP(
                            em.Get(
                                onl.OnlineResource(
                                    type="simple",
                                    href=conf.BASE_URI + "object/{OBJECT_URI}"
                                ),
                            )
                        )
                    )
                )
            )
        )
    )
    return etree.tostring(
        doc,
        pretty_print=True,
        xml_declaration=True,
        encoding='UTF-8'
    )
コード例 #2
0
ファイル: winrm.py プロジェクト: ckabalan/losteyelid
    def get_soap_header(resource_uri, action, message_id):
        """Generates a basic SOAP header to be modified later.

        :param resource_uri: The resource we're working with.
        :param action: The action we're taking.
        :param message_id: The UUID of the related message.
        :returns: An LXML object representing the soap header."""
        env = ElementMaker(
            namespace="http://www.w3.org/2003/05/soap-envelope",
            nsmap={
                "env": "http://www.w3.org/2003/05/soap-envelope",
                "a": "http://schemas.xmlsoap.org/ws/2004/08/addressing",
                "p": "http://schemas.microsoft.com/wbem/wsman/1/wsman.xsd",
                "rsp":
                "http://schemas.microsoft.com/wbem/wsman/1/windows/shell",
                "w": "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd",
                "xml": "http://www.w3.org/XML/1998/namespace/"
            })
        ns_a = ElementMaker(
            namespace="http://schemas.xmlsoap.org/ws/2004/08/addressing")
        ns_p = ElementMaker(
            namespace="http://schemas.microsoft.com/wbem/wsman/1/wsman.xsd")
        ns_w = ElementMaker(
            namespace="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd")
        request = env.Envelope(
            env.Header(
                ns_a.To("http://windows-host:5985/wsman"),
                ns_a.ReplyTo(
                    ns_a.Address(
                        "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous",
                        **{
                            "{http://www.w3.org/2003/05/soap-envelope}mustUnderstand":
                            "true"
                        })),
                ns_w.MaxEnvelopeSize(
                    "153600", **{
                        "{http://www.w3.org/2003/05/soap-envelope}mustUnderstand":
                        "true"
                    }),
                ns_a.MessageID(message_id),
                ns_w.Locale(
                    **{
                        "{http://www.w3.org/2003/05/soap-envelope}mustUnderstand":
                        "false",
                        "{http://www.w3.org/XML/1998/namespace/}lang": "en-US"
                    }),
                ns_p.DataLocale(
                    **{
                        "{http://www.w3.org/2003/05/soap-envelope}mustUnderstand":
                        "false",
                        "{http://www.w3.org/XML/1998/namespace/}lang": "en-US"
                    }),
                ns_w.OperationTimeout("PT60.000S"),
                ns_w.ResourceURI(
                    resource_uri, **{
                        "{http://www.w3.org/2003/05/soap-envelope}mustUnderstand":
                        "true"
                    }),
                ns_a.Action(
                    action, **{
                        "{http://www.w3.org/2003/05/soap-envelope}mustUnderstand":
                        "true"
                    }),
            ), )
        return request