MCPcopy Create free account
hub / github.com/ScienciaLAB/document-qa / call_api

Method call_api

document_qa/ner_client_generic.py:98–141  ·  view source on GitHub ↗

Call API. This returns object containing data, with error details if applicable. Args: method (str): The HTTP method to use. url (str): Resource location relative to the base URL. headers (dict or None): Extra request headers to set.

(
        self,
        method,
        url,
        headers=None,
        params=None,
        data=None,
        files=None,
        timeout=None,
    )

Source from the content-addressed store, hash-verified

96 return {"username": self.username, "api_key": self.api_key}
97
98 def call_api(
99 self,
100 method,
101 url,
102 headers=None,
103 params=None,
104 data=None,
105 files=None,
106 timeout=None,
107 ):
108 """Call API.
109
110 This returns object containing data, with error details if applicable.
111
112 Args:
113 method (str): The HTTP method to use.
114 url (str): Resource location relative to the base URL.
115 headers (dict or None): Extra request headers to set.
116 params (dict or None): Query-string parameters.
117 data (dict or None): Request body contents for POST or PUT requests.
118 files (dict or None: Files to be passed to the request.
119 timeout (int): Maximum time before timing out.
120
121 Returns:
122 ResultParser or ErrorParser.
123 """
124 headers = deepcopy(headers) or {}
125 headers["Accept"] = self.accept_type if "Accept" not in headers else headers["Accept"]
126 params = deepcopy(params) or {}
127 data = data or {}
128 files = files or {}
129 # if self.username is not None and self.api_key is not None:
130 # params.update(self.get_credentials())
131 r = requests.request(
132 method,
133 url,
134 headers=headers,
135 params=params,
136 files=files,
137 data=data,
138 timeout=timeout,
139 )
140
141 return r, r.status_code
142
143 def get(self, url, params=None, **kwargs):
144 """Call the API with a GET request.

Callers 5

getMethod · 0.95
deleteMethod · 0.95
putMethod · 0.95
postMethod · 0.95
service_statusMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected