示例#1
0
文件: service.py 项目: uberVU/libsaas
def add_docstrings():
    for method_name in Mailchimp.list_methods():
        function = port.method_func(Mailchimp, method_name)
        # set the docstring
        function.__doc__ = """
Call Mailchimp's {0} method.

Upstream documentation: http://apidocs.mailchimp.com/api/rtfm/{1}.func.php
""".format(method_name, method_name.lower())
示例#2
0
文件: service.py 项目: 80vs90/libsaas
def add_docstrings():
    for method_name in Mailchimp.list_methods():
        function = port.method_func(Mailchimp, method_name)
        # set the docstring
        function.__doc__ = """
Call Mailchimp's {0} method.

Upstream documentation: http://apidocs.mailchimp.com/api/rtfm/{1}.func.php
""".format(method_name, method_name.lower())
示例#3
0
文件: service.py 项目: nZac/libsaas
def add_docstrings():
    # the upstream URLs follow a fixed pattern, so add them programatically

    def extra_doc(resource_name, method_name):
        base = "https://mixpanel.com/docs/api-documentation/data-export-api"
        method_name = "default" if method_name == "get" else method_name
        doc_name = "event-properties" if resource_name == "properties" else resource_name

        tmpl = "\nUpstream documentation: {0}#{1}-{2}"
        return tmpl.format(base, doc_name, method_name)

    # walk the list of resources
    for resource_name in Mixpanel.list_resources():
        # get the resource class
        resource = getattr(Mixpanel, resource_name).produces[0]
        # walks its list of methods
        for method_name in resource.list_methods():
            # update the method's docstring
            function = port.method_func(resource, method_name)
            extra = extra_doc(resource_name, method_name)
            function.__doc__ += extra
示例#4
0
def add_docstrings():
    # the upstream URLs follow a fixed pattern, so add them programatically

    def extra_doc(resource_name, method_name):
        base = 'https://mixpanel.com/docs/api-documentation/data-export-api'
        method_name = 'default' if method_name == 'get' else method_name
        doc_name = ('event-properties'
                    if resource_name == 'properties' else resource_name)

        tmpl = '\nUpstream documentation: {0}#{1}-{2}'
        return tmpl.format(base, doc_name, method_name)

    # walk the list of resources
    for resource_name in Mixpanel.list_resources():
        # get the resource class
        resource = getattr(Mixpanel, resource_name).produces[0]
        # walks its list of methods
        for method_name in resource.list_methods():
            # update the method's docstring
            function = port.method_func(resource, method_name)
            extra = extra_doc(resource_name, method_name)
            function.__doc__ += extra
示例#5
0
文件: results.py 项目: nZac/libsaas
    path = "results"

    @base.apimethod
    def get(
        self,
        from_=None,
        to=None,
        limit=None,
        offset=None,
        probes=None,
        status=None,
        includeanalysis=None,
        maxresponse=None,
        minresponse=None,
    ):
        params = base.get_params(None, locals(), translate_param=resource.translate_param)

        return http.Request("GET", self.get_url(), params), parsers.parse_json


port.method_func(
    Results, "get"
).__doc__ = """
Return a list of raw test results for a specified check

Upstream documentation: {0}
""".format(
    "https://www.pingdom.com/services/api-documentation-rest/" "#ResourceResults"
)
示例#6
0
文件: probes.py 项目: 80vs90/libsaas
from libsaas import http, parsers, port
from libsaas.services import base
from . import resource


class Probes(resource.PingdomGETResource):

    path = 'probes'

    @base.apimethod
    def get(self, limit=None, offset=None, onlyactive=None,
            includedeleted=None):
        params = base.get_params(None, locals(),
                                 translate_param=resource.translate_param)

        return http.Request('GET', self.get_url(), params), parsers.parse_json


port.method_func(Probes, 'get').__doc__ = """
Returns a list of all Pingdom probe servers.

Upstream documentation: {0}
""".format('https://www.pingdom.com/services/api-documentation-rest/'
           '#ResourceProbes')
示例#7
0
文件: checks.py 项目: 80vs90/libsaas
    # redefine methods to set docstring later

    @base.mark_apimethod
    def create(self, obj):
        return super(Checks, self).create(obj)

    @base.mark_apimethod
    def update(self, obj):
        return super(Checks, self).update(obj)

    @base.mark_apimethod
    def delete(self):
        return super(Checks, self).delete()


port.method_func(Checks, 'create').__doc__ = """
Creates a new check with settings specified by provided parameters.

Upstream documentation: {0}
""".format('https://www.pingdom.com/services/api-documentation-rest/'
           '#MethodCreate+New+Check')


port.method_func(Checks, 'update').__doc__ = """
Pause or change resolution for multiple checks in one bulk call.

Upstream documentation: {0}
""".format('https://www.pingdom.com/services/api-documentation-rest/'
           '#MethodModify+Multiple+Checks')

port.method_func(Checks, 'delete').__doc__ = """
示例#8
0
文件: single.py 项目: 80vs90/libsaas
from libsaas import http, parsers, port
from libsaas.services import base
from . import resource


class Single(resource.PingdomGETResource):

    path = 'single'

    @base.apimethod
    def get(self, **params):
        params = base.get_params(None, params,
                                 translate_param=resource.translate_param)

        return http.Request('GET', self.get_url(), params), parsers.parse_json


port.method_func(Single, 'get').__doc__ = """
Performs a single test using a specified Pingdom probe against a specified
target. Please note that this method is meant to be used sparingly, not to
set up your own monitoring solution.

Upstream documentation: {0}
""".format('https://www.pingdom.com/services/api-documentation-rest/'
           '#ResourceSingle')
示例#9
0
文件: lists.py 项目: scsi110/libsaas
        return Actions(self)

    @base.resource(Board)
    def board(self):
        """
        Returns a single board
        """
        return Board(self)

    @base.resource(Cards)
    def cards(self):
        """
        Returns all cards
        """
        return Cards(self)


class Lists(TrelloCollection):
    path = 'lists'

    def get(self, *args, **kwargs):
        raise base.MethodNotSupported()


port.method_func(List, 'get').__doc__ = """
Fetch a single object.

Upstream documentation:
https://trello.com/docs/api/list/index.html#get-1-lists-idlist
"""
示例#10
0
    def get(self, limit=None, offset=None):
        """
        Returns a list of all contacts.

        Upstream documentation: {0}
        """

        params = base.get_params(None, locals())

        return http.Request("GET", self.get_url(), params), parsers.parse_json

    get.__doc__ = get.__doc__.format("https://www.pingdom.com/services/api-documentation-rest/" "#ResourceContacts")


port.method_func(
    Contacts, "create"
).__doc__ = """
Creates a new contact with settings specified by provided parameters.

Upstream documentation: {0}
""".format(
    "https://www.pingdom.com/services/api-documentation-rest/" "#MethodCreate+Contact"
)

port.method_func(
    Contacts, "update"
).__doc__ = """
Modifies a list of contacts.

Upstream documentation: {0}
""".format(
示例#11
0
    # redefine methods to set docstring later

    @base.mark_apimethod
    def create(self, obj):
        return super(Contacts, self).create(obj)

    @base.mark_apimethod
    def update(self, obj):
        return super(Contacts, self).update(obj)

    @base.mark_apimethod
    def delete(self):
        return super(Contacts, self).delete()


port.method_func(Contacts, 'create').__doc__ = """
Creates a new contact with settings specified by provided parameters.

Upstream documentation: {0}
""".format('https://www.pingdom.com/services/api-documentation-rest/'
           '#MethodCreate+Contact')

port.method_func(Contacts, 'update').__doc__ = """
Modifies a list of contacts.

Upstream documentation: {0}
""".format('https://www.pingdom.com/services/api-documentation-rest/'
           '#MethodModify+Multiple+Contacts')

port.method_func(Contacts, 'delete').__doc__ = """
Deletes a list of contacts.
示例#12
0
文件: cards.py 项目: scsi110/libsaas
        return Sticker(self, sticker_id)

    @base.resource(Labels)
    def labels(self):
        """
        Returns all labels
        """
        return Labels(self)

    @base.resource(Label)
    def label(self, color):
        """
        Returns a single label
        """
        return Label(self, color)


class Cards(TrelloCollection):
    path = 'cards'

    def get(self, *args, **kwargs):
        raise base.MethodNotSupported()


port.method_func(Card, 'get').__doc__ = """
Fetch a single object.

Upstream documentation:
https://trello.com/docs/api/card/index.html#get-1-cards-card-id-or-shortlink
"""
示例#13
0
文件: summary.py 项目: 80vs90/libsaas
    def performance(self, from_=None, to=None, resolution=None,
                    includeuptime=None, probes=None, order=None):
        params = base.get_params(None, locals(),
                                 translate_param=resource.translate_param)
        url = self.get_url('performance')
        return http.Request('GET', url, params), parsers.parse_json

    @base.apimethod
    def probes(self, from_=None, to=None):
        params = base.get_params(None, locals(),
                                 translate_param=resource.translate_param)
        url = self.get_url('probes')
        return http.Request('GET', url, params), parsers.parse_json


port.method_func(Summary, 'average').__doc__ = """
Get the average time / uptime value for a specified check and time period.

Upstream documentation: {0}
""".format('https://www.pingdom.com/services/api-documentation-rest/'
           '#ResourceSummary.average')

port.method_func(Summary, 'hoursofday').__doc__ = """
Returns the average response time for each hour of the day (0-23) for a
specific check over a selected time period.
I.e. it shows you what an average day looks like during that time period.

Upstream documentation: {0}
""".format('https://www.pingdom.com/services/api-documentation-rest/'
           '#ResourceSummary.hoursofday')
示例#14
0
from libsaas import http, parsers, port
from libsaas.services import base
from . import resource


class Single(resource.PingdomGETResource):

    path = 'single'

    @base.apimethod
    def get(self, **params):
        params = base.get_params(None,
                                 params,
                                 translate_param=resource.translate_param)

        return http.Request('GET', self.get_url(), params), parsers.parse_json


port.method_func(Single, 'get').__doc__ = """
Performs a single test using a specified Pingdom probe against a specified
target. Please note that this method is meant to be used sparingly, not to
set up your own monitoring solution.

Upstream documentation: {0}
""".format('https://www.pingdom.com/services/api-documentation-rest/'
           '#ResourceSingle')
示例#15
0
    path = 'analysis'

    @base.apimethod
    def get(self, from_=None, to=None, limit=None, offset=None):
        params = base.get_params(None,
                                 locals(),
                                 translate_param=resource.translate_param)

        return http.Request('GET', self.get_url(), params), parsers.parse_json

    @base.apimethod
    def get_raw_analysis(self, analysisid):
        """
        Get Raw Analysis Results

        :var analysisid: The specified error analysis id
        :vartype analysisid: str
        """
        url = '{0}/{1}'.format(self.get_url(), analysisid)

        request = http.Request('GET', url)
        return request, parsers.parse_json


port.method_func(Analysis, 'get').__doc__ = """
Returns a list of the latest root cause analysis results for a specified check.

Upstream documentation: {0}
""".format('https://www.pingdom.com/services/api-documentation-rest/'
           '#ResourceAnalysis')
示例#16
0
文件: credit.py 项目: scsi110/libsaas
from libsaas import port
from libsaas.services import base
from . import resource


class Credits(resource.PingdomGETResource):

    path = 'credits'

    # redefine methods to set docstring later

    @base.mark_apimethod
    def get(self):
        return super(Credits, self).get()


port.method_func(Credits, 'get').__doc__ = """
Returns information about remaining checks, SMS credits and
SMS auto-refill status.

Upstream documentation: {0}
""".format('https://www.pingdom.com/services/api-documentation-rest/'
           '#ResourceCredits')
示例#17
0
from libsaas import http, parsers, port
from libsaas.services import base
from . import resource


class Traceroute(resource.PingdomGETResource):

    path = 'traceroute'

    @base.apimethod
    def get(self, host=None, probeid=None):
        params = base.get_params(None, locals())

        return http.Request('GET', self.get_url(), params), parsers.parse_json


port.method_func(Traceroute, 'get').__doc__ = """
Perform a traceroute to a specified target from a specified Pingdom probe.

Upstream documentation: {0}
""".format('https://www.pingdom.com/services/api-documentation-rest/'
           '#ResourceTraceroute')
示例#18
0
文件: lists.py 项目: javimb/libsaas
    @base.resource(Board)
    def board(self):
        """
        Returns a single board
        """
        return Board(self)

    @base.resource(Cards)
    def cards(self):
        """
        Returns all cards
        """
        return Cards(self)


class Lists(TrelloCollection):
    path = "lists"

    def get(self, *args, **kwargs):
        raise base.MethodNotSupported()


port.method_func(
    List, "get"
).__doc__ = """
Fetch a single object.

Upstream documentation:
https://trello.com/docs/api/list/index.html#get-1-lists-idlist
"""
示例#19
0
from libsaas import port
from libsaas.services import base


class Settings(base.RESTResource):

    path = 'settings'

    def create(self, *args, **kwargs):
        raise base.MethodNotSupported()

    def delete(self, *args, **kwargs):
        raise base.MethodNotSupported()

    def require_item(self):
        pass


port.method_func(Settings, 'update').__doc__ = """
Modify account-specific settings.

Upstream documentation: {0}
""".format('https://www.pingdom.com/services/api-documentation-rest/'
           '#MethodModify+Account+Settings')
示例#20
0
文件: probes.py 项目: uberVU/libsaas
from libsaas import http, parsers, port
from libsaas.services import base
from . import resource


class Probes(resource.PingdomGETResource):

    path = 'probes'

    @base.apimethod
    def get(self,
            limit=None,
            offset=None,
            onlyactive=None,
            includedeleted=None):
        params = base.get_params(None,
                                 locals(),
                                 translate_param=resource.translate_param)

        return http.Request('GET', self.get_url(), params), parsers.parse_json


port.method_func(Probes, 'get').__doc__ = """
Returns a list of all Pingdom probe servers.

Upstream documentation: {0}
""".format('https://www.pingdom.com/services/api-documentation-rest/'
           '#ResourceProbes')
示例#21
0
from libsaas import port
from libsaas.services import base


class Settings(base.RESTResource):

    path = 'settings'

    def create(self, *args, **kwargs):
        raise base.MethodNotSupported()

    def delete(self, *args, **kwargs):
        raise base.MethodNotSupported()

    def require_item(self):
        pass

port.method_func(Settings, 'update').__doc__ = """
Modify account-specific settings.

Upstream documentation: {0}
""".format('https://www.pingdom.com/services/api-documentation-rest/'
           '#MethodModify+Account+Settings')
示例#22
0
文件: checks.py 项目: uberVU/libsaas
        """
        Returns a list overview of all checks.

        Upstream documentation: {0}
        """

        params = base.get_params(None, locals())

        return http.Request('GET', self.get_url(), params), parsers.parse_json

    get.__doc__ = get.__doc__.format(
        'https://www.pingdom.com/services/api-documentation-rest/'
        '#ResourceChecks')


port.method_func(Checks, 'create').__doc__ = """
Creates a new check with settings specified by provided parameters.

Upstream documentation: {0}
""".format('https://www.pingdom.com/services/api-documentation-rest/'
           '#MethodCreate+New+Check')

port.method_func(Checks, 'update').__doc__ = """
Pause or change resolution for multiple checks in one bulk call.

Upstream documentation: {0}
""".format('https://www.pingdom.com/services/api-documentation-rest/'
           '#MethodModify+Multiple+Checks')

port.method_func(Checks, 'delete').__doc__ = """
Deletes a list of checks. You will lose all collected data.
示例#23
0
from libsaas import http, parsers, port
from libsaas.services import base

from . import resource


class IssueComponentsBase(resource.BitBucketResource):

    path = 'components'

    def wrap_object(self, obj):
        return {'name': obj}


port.method_func(IssueComponentsBase, 'create').__doc__ = """
Add a component for issues.

:var obj: The component name.
:vartype obj: str
"""


port.method_func(IssueComponentsBase, 'update').__doc__ = """
Update a component.

:var obj: The component namt.
:vartype obj: str
"""


class IssueComponents(IssueComponentsBase):
示例#24
0
    path = 'analysis'

    @base.apimethod
    def get(self, from_=None, to=None, limit=None, offset=None):
        params = base.get_params(None, locals(),
                                 translate_param=resource.translate_param)

        return http.Request('GET', self.get_url(), params), parsers.parse_json

    @base.apimethod
    def get_raw_analysis(self, analysisid):
        """
        Get Raw Analysis Results

        :var analysisid: The specified error analysis id
        :vartype analysisid: str
        """
        url = '{0}/{1}'.format(self.get_url(), analysisid)

        request = http.Request('GET', url)
        return request, parsers.parse_json


port.method_func(Analysis, 'get').__doc__ = """
Returns a list of the latest root cause analysis results for a specified check.

Upstream documentation: {0}
""".format('https://www.pingdom.com/services/api-documentation-rest/'
           '#ResourceAnalysis')
示例#25
0
from libsaas import port
from libsaas.services import base
from . import resource


class Servertime(resource.PingdomGETResource):

    path = 'servertime'

    # redefine methods to set docstring later

    @base.mark_apimethod
    def get(self):
        return super(Servertime, self).get()


port.method_func(Servertime, 'get').__doc__ = """
Get the current time of the API server.

Upstream documentation: {0}
""".format('https://www.pingdom.com/services/api-documentation-rest/'
           '#ResourceServertime')
示例#26
0
from libsaas import port
from . import resource


class Reference(resource.PingdomGETResource):

    path = 'reference'


port.method_func(Reference, 'get').__doc__ = """
Get a reference of regions, timezones and date/time/number formats
and their identifiers.

Upstream documentation: {0}
""".format('https://www.pingdom.com/services/api-documentation-rest/'
           '#ResourceReference')
示例#27
0
        """
        Returns a list of all contacts.

        Upstream documentation: {0}
        """

        params = base.get_params(None, locals())

        return http.Request('GET', self.get_url(), params), parsers.parse_json

    get.__doc__ = get.__doc__.format(
        'https://www.pingdom.com/services/api-documentation-rest/'
        '#ResourceContacts')


port.method_func(Contacts, 'create').__doc__ = """
Creates a new contact with settings specified by provided parameters.

Upstream documentation: {0}
""".format('https://www.pingdom.com/services/api-documentation-rest/'
           '#MethodCreate+Contact')

port.method_func(Contacts, 'update').__doc__ = """
Modifies a list of contacts.

Upstream documentation: {0}
""".format('https://www.pingdom.com/services/api-documentation-rest/'
           '#MethodModify+Multiple+Contacts')

port.method_func(Contacts, 'delete').__doc__ = """
Deletes a list of contacts.
示例#28
0
        params = base.get_params(None,
                                 locals(),
                                 translate_param=resource.translate_param)
        url = self.get_url('performance')
        return http.Request('GET', url, params), parsers.parse_json

    @base.apimethod
    def probes(self, from_=None, to=None):
        params = base.get_params(None,
                                 locals(),
                                 translate_param=resource.translate_param)
        url = self.get_url('probes')
        return http.Request('GET', url, params), parsers.parse_json


port.method_func(Summary, 'average').__doc__ = """
Get the average time / uptime value for a specified check and time period.

Upstream documentation: {0}
""".format('https://www.pingdom.com/services/api-documentation-rest/'
           '#ResourceSummary.average')

port.method_func(Summary, 'hoursofday').__doc__ = """
Returns the average response time for each hour of the day (0-23) for a
specific check over a selected time period.
I.e. it shows you what an average day looks like during that time period.

Upstream documentation: {0}
""".format('https://www.pingdom.com/services/api-documentation-rest/'
           '#ResourceSummary.hoursofday')