hakai_api 1.1.2__tar.gz → 1.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- hakai_api-1.3.0/PKG-INFO +73 -0
- {hakai_api-1.1.2 → hakai_api-1.3.0}/README.md +7 -1
- {hakai_api-1.1.2 → hakai_api-1.3.0}/hakai_api/Client.py +37 -25
- hakai_api-1.3.0/hakai_api.egg-info/PKG-INFO +73 -0
- hakai_api-1.1.2/PKG-INFO +0 -68
- hakai_api-1.1.2/hakai_api.egg-info/PKG-INFO +0 -68
- {hakai_api-1.1.2 → hakai_api-1.3.0}/hakai_api/__init__.py +0 -0
- {hakai_api-1.1.2 → hakai_api-1.3.0}/hakai_api.egg-info/SOURCES.txt +0 -0
- {hakai_api-1.1.2 → hakai_api-1.3.0}/hakai_api.egg-info/dependency_links.txt +0 -0
- {hakai_api-1.1.2 → hakai_api-1.3.0}/hakai_api.egg-info/requires.txt +0 -0
- {hakai_api-1.1.2 → hakai_api-1.3.0}/hakai_api.egg-info/top_level.txt +0 -0
- {hakai_api-1.1.2 → hakai_api-1.3.0}/setup.cfg +0 -0
- {hakai_api-1.1.2 → hakai_api-1.3.0}/setup.py +0 -0
hakai_api-1.3.0/PKG-INFO
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: hakai_api
|
|
3
|
+
Version: 1.3.0
|
|
4
|
+
Summary: Get Hakai database resources using http calls
|
|
5
|
+
Home-page: https://github.com/HakaiInstitute/hakai-api-client-python
|
|
6
|
+
Author: Taylor Denouden
|
|
7
|
+
Author-email: taylor.denouden@hakai.org
|
|
8
|
+
License: MIT
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
|
|
11
|
+
# Hakai Api Python Client
|
|
12
|
+
|
|
13
|
+
This project exports a single Python class that can be used to make HTTP requests to the Hakai API resource server.
|
|
14
|
+
The exported `Client` class extends the functionality of the Python [requests library](https://docs.python-requests.org/en/master/) to supply Hakai OAuth2 credentials with url requests.
|
|
15
|
+
|
|
16
|
+
# Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
pip install hakai-api
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
# Requirements
|
|
23
|
+
Python 3.6 or higher
|
|
24
|
+
|
|
25
|
+
# Quickstart
|
|
26
|
+
|
|
27
|
+
```python
|
|
28
|
+
from hakai_api import Client
|
|
29
|
+
|
|
30
|
+
# Get the api request client
|
|
31
|
+
client = Client() # Follow stdout prompts to get an API token
|
|
32
|
+
|
|
33
|
+
# Make a data request for chlorophyll data
|
|
34
|
+
url = '%s/%s' % (client.api_root, 'eims/views/output/chlorophyll?limit=50')
|
|
35
|
+
response = client.get(url)
|
|
36
|
+
|
|
37
|
+
print(url) # https://hecate.hakai.org/api/eims/views/output/chlorophyll...
|
|
38
|
+
print(response.json()) # [{'action': '', 'event_pk': 7064, 'rn': '1', 'date': '2012-05-17', 'work_area': 'CALVERT'...
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
# Methods
|
|
42
|
+
|
|
43
|
+
This library exports a single client name `Client`. Instantiating this class produces a `requests.Session` client from the Python requests library. The Hakai API Python Client inherits directly from `requests.Session` thus all methods available on that parent class are available. For details see the [requests documentation](http://docs.python-requests.org/).
|
|
44
|
+
|
|
45
|
+
The hakai_api `Client` class also contains a property `api_root` which is useful for constructing urls to access data from the API. The above [Quickstart example](#quickstart) demonstrates using this property to construct a url to access project names.
|
|
46
|
+
|
|
47
|
+
# API endpoints
|
|
48
|
+
|
|
49
|
+
For details about the API, including available endpoints where data can be requested from, see the [Hakai API documentation](https://github.com/HakaiInstitute/hakai-api).
|
|
50
|
+
|
|
51
|
+
# Advanced usage
|
|
52
|
+
|
|
53
|
+
You can specify which API to access when instantiating the Client. By default, the API uses `https://hecate.hakai.org/api` as the API root. It may be useful to use this library to access a locally running API instance or to access the Goose API for testing purposes. If you are always going to be accessing data from a locally running API instance, you are better off using the requests.py library directly since Authorization is not required for local requests.
|
|
54
|
+
|
|
55
|
+
```python
|
|
56
|
+
# Get a client for a locally running API instance
|
|
57
|
+
client = Client("http://localhost:8666")
|
|
58
|
+
print(client.api_root) # http://localhost:8666
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
You can also pass in the credentials string retrieved from the hakai API login page while initiating the Client class.
|
|
62
|
+
|
|
63
|
+
```python
|
|
64
|
+
# Pass a credentials token as the Client Class is initiated
|
|
65
|
+
client = Client(credentials="CREDENTIAL_TOKEN")
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
# Development
|
|
69
|
+
The business code for this package is in the file [`hakai_api/Client.py`](hakai_api/Client.py).
|
|
70
|
+
The `./setup.py` file is important for giving details about how to install the package when users do `pip install hakai-api`.
|
|
71
|
+
|
|
72
|
+
To build a new PyPi package version push a tag matching the pattern `v[0-9]+.[0-9]+.[0-9]+` or `v[0-9]+.[0-9]+.[0-9]+rc[0-9]+` to the origin (e.g. `v0.4.1` or `v0.5.2rc1`).
|
|
73
|
+
Github Actions should take care of packaging and pushing it to Hakai's PyPi repository from there.
|
|
@@ -48,10 +48,16 @@ client = Client("http://localhost:8666")
|
|
|
48
48
|
print(client.api_root) # http://localhost:8666
|
|
49
49
|
```
|
|
50
50
|
|
|
51
|
+
You can also pass in the credentials string retrieved from the hakai API login page while initiating the Client class.
|
|
52
|
+
|
|
53
|
+
```python
|
|
54
|
+
# Pass a credentials token as the Client Class is initiated
|
|
55
|
+
client = Client(credentials="CREDENTIAL_TOKEN")
|
|
56
|
+
```
|
|
57
|
+
|
|
51
58
|
# Development
|
|
52
59
|
The business code for this package is in the file [`hakai_api/Client.py`](hakai_api/Client.py).
|
|
53
60
|
The `./setup.py` file is important for giving details about how to install the package when users do `pip install hakai-api`.
|
|
54
61
|
|
|
55
62
|
To build a new PyPi package version push a tag matching the pattern `v[0-9]+.[0-9]+.[0-9]+` or `v[0-9]+.[0-9]+.[0-9]+rc[0-9]+` to the origin (e.g. `v0.4.1` or `v0.5.2rc1`).
|
|
56
63
|
Github Actions should take care of packaging and pushing it to Hakai's PyPi repository from there.
|
|
57
|
-
|
|
@@ -5,39 +5,47 @@ Last updated: April 2021
|
|
|
5
5
|
"""
|
|
6
6
|
|
|
7
7
|
import os
|
|
8
|
-
import
|
|
8
|
+
import json
|
|
9
9
|
from datetime import datetime
|
|
10
10
|
from time import mktime, sleep
|
|
11
11
|
from typing import Dict, Union
|
|
12
12
|
|
|
13
|
-
from pytz import utc
|
|
14
13
|
from requests_oauthlib import OAuth2Session
|
|
15
14
|
|
|
16
15
|
|
|
17
16
|
class Client(OAuth2Session):
|
|
18
|
-
_credentials_file = os.path.expanduser(
|
|
19
|
-
|
|
20
|
-
def __init__(
|
|
21
|
-
|
|
17
|
+
_credentials_file = os.path.expanduser("~/.hakai-api-auth")
|
|
18
|
+
|
|
19
|
+
def __init__(
|
|
20
|
+
self,
|
|
21
|
+
api_root: str = "https://hecate.hakai.org/api",
|
|
22
|
+
login_page: str = "https://hecate.hakai.org/api-client-login",
|
|
23
|
+
credentials: Union[str, Dict] = None,
|
|
24
|
+
):
|
|
22
25
|
"""Create a new Client class with credentials.
|
|
23
26
|
|
|
24
27
|
Params:
|
|
25
28
|
api_root: The base url of the hakai api you want to call.
|
|
26
29
|
Defaults to the production server.
|
|
27
|
-
|
|
30
|
+
credentials (str, Dict): Credentials token retrieved from the hakai api login page.
|
|
31
|
+
If `None`, loads cached credentials or prompts for log in.
|
|
32
|
+
"""
|
|
28
33
|
self._api_root = api_root
|
|
29
34
|
self._authorization_base_url = login_page
|
|
30
35
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
36
|
+
if credentials is None:
|
|
37
|
+
# Try to get cached credentials, prompt user if the file can't be loaded
|
|
38
|
+
self._credentials = self._try_to_load_credentials_file() or self._get_credentials_from_web()
|
|
39
|
+
elif isinstance(credentials, str):
|
|
40
|
+
# Parse credentials from string
|
|
41
|
+
self._credentials = dict(map(lambda x: x.split("="), credentials.split("&")))
|
|
42
|
+
elif isinstance(credentials, dict):
|
|
34
43
|
self._credentials = credentials
|
|
35
44
|
else:
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
self._credentials = credentials
|
|
45
|
+
raise ValueError("`credentials` parameter should be str, dict, or None type.")
|
|
46
|
+
|
|
47
|
+
# Cache the credentials
|
|
48
|
+
self._save_credentials(self._credentials)
|
|
41
49
|
|
|
42
50
|
# Init the OAuth2Session parent class with credentials
|
|
43
51
|
super(Client, self).__init__(token=self._credentials)
|
|
@@ -59,24 +67,28 @@ class Client(OAuth2Session):
|
|
|
59
67
|
|
|
60
68
|
def _save_credentials(self, credentials: Dict):
|
|
61
69
|
"""Save the credentials object to a file."""
|
|
62
|
-
with open(self._credentials_file,
|
|
63
|
-
|
|
70
|
+
with open(self._credentials_file, "w") as outfile:
|
|
71
|
+
json.dump(credentials, outfile)
|
|
64
72
|
|
|
65
|
-
def
|
|
73
|
+
def _try_to_load_credentials_file(self) -> Union[Dict, bool]:
|
|
66
74
|
"""Try to load the cached credentials file."""
|
|
67
75
|
if not os.path.isfile(self._credentials_file):
|
|
68
76
|
return False
|
|
69
77
|
|
|
70
|
-
with open(self._credentials_file,
|
|
78
|
+
with open(self._credentials_file, "rb") as infile:
|
|
71
79
|
try:
|
|
72
|
-
credentials =
|
|
73
|
-
expires_at = int(credentials[
|
|
80
|
+
credentials = json.load(infile)
|
|
81
|
+
expires_at = int(credentials["expires_at"])
|
|
74
82
|
except (KeyError, ValueError):
|
|
75
83
|
os.remove(self._credentials_file)
|
|
76
84
|
return False
|
|
77
85
|
|
|
78
|
-
now = int(
|
|
79
|
-
|
|
86
|
+
now = int(
|
|
87
|
+
(
|
|
88
|
+
mktime(datetime.now().timetuple())
|
|
89
|
+
+ datetime.now().microsecond / 1000000.0
|
|
90
|
+
)
|
|
91
|
+
) # utc timestamp
|
|
80
92
|
|
|
81
93
|
if now > expires_at:
|
|
82
94
|
os.remove(self._credentials_file)
|
|
@@ -86,11 +98,11 @@ class Client(OAuth2Session):
|
|
|
86
98
|
|
|
87
99
|
def _get_credentials_from_web(self) -> Dict:
|
|
88
100
|
"""Get user credentials from a web sign-in."""
|
|
89
|
-
print(
|
|
101
|
+
print("Please go here and authorize:")
|
|
90
102
|
print(self._authorization_base_url)
|
|
91
103
|
|
|
92
104
|
sleep(0.05) # Workaround for input / print stream race condition
|
|
93
|
-
response = input(
|
|
105
|
+
response = input("\nCopy and past your credentials from the login page:\n")
|
|
94
106
|
|
|
95
107
|
# Reformat response to dict
|
|
96
108
|
credentials = dict(map(lambda x: x.split("="), response.split("&")))
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: hakai-api
|
|
3
|
+
Version: 1.3.0
|
|
4
|
+
Summary: Get Hakai database resources using http calls
|
|
5
|
+
Home-page: https://github.com/HakaiInstitute/hakai-api-client-python
|
|
6
|
+
Author: Taylor Denouden
|
|
7
|
+
Author-email: taylor.denouden@hakai.org
|
|
8
|
+
License: MIT
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
|
|
11
|
+
# Hakai Api Python Client
|
|
12
|
+
|
|
13
|
+
This project exports a single Python class that can be used to make HTTP requests to the Hakai API resource server.
|
|
14
|
+
The exported `Client` class extends the functionality of the Python [requests library](https://docs.python-requests.org/en/master/) to supply Hakai OAuth2 credentials with url requests.
|
|
15
|
+
|
|
16
|
+
# Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
pip install hakai-api
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
# Requirements
|
|
23
|
+
Python 3.6 or higher
|
|
24
|
+
|
|
25
|
+
# Quickstart
|
|
26
|
+
|
|
27
|
+
```python
|
|
28
|
+
from hakai_api import Client
|
|
29
|
+
|
|
30
|
+
# Get the api request client
|
|
31
|
+
client = Client() # Follow stdout prompts to get an API token
|
|
32
|
+
|
|
33
|
+
# Make a data request for chlorophyll data
|
|
34
|
+
url = '%s/%s' % (client.api_root, 'eims/views/output/chlorophyll?limit=50')
|
|
35
|
+
response = client.get(url)
|
|
36
|
+
|
|
37
|
+
print(url) # https://hecate.hakai.org/api/eims/views/output/chlorophyll...
|
|
38
|
+
print(response.json()) # [{'action': '', 'event_pk': 7064, 'rn': '1', 'date': '2012-05-17', 'work_area': 'CALVERT'...
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
# Methods
|
|
42
|
+
|
|
43
|
+
This library exports a single client name `Client`. Instantiating this class produces a `requests.Session` client from the Python requests library. The Hakai API Python Client inherits directly from `requests.Session` thus all methods available on that parent class are available. For details see the [requests documentation](http://docs.python-requests.org/).
|
|
44
|
+
|
|
45
|
+
The hakai_api `Client` class also contains a property `api_root` which is useful for constructing urls to access data from the API. The above [Quickstart example](#quickstart) demonstrates using this property to construct a url to access project names.
|
|
46
|
+
|
|
47
|
+
# API endpoints
|
|
48
|
+
|
|
49
|
+
For details about the API, including available endpoints where data can be requested from, see the [Hakai API documentation](https://github.com/HakaiInstitute/hakai-api).
|
|
50
|
+
|
|
51
|
+
# Advanced usage
|
|
52
|
+
|
|
53
|
+
You can specify which API to access when instantiating the Client. By default, the API uses `https://hecate.hakai.org/api` as the API root. It may be useful to use this library to access a locally running API instance or to access the Goose API for testing purposes. If you are always going to be accessing data from a locally running API instance, you are better off using the requests.py library directly since Authorization is not required for local requests.
|
|
54
|
+
|
|
55
|
+
```python
|
|
56
|
+
# Get a client for a locally running API instance
|
|
57
|
+
client = Client("http://localhost:8666")
|
|
58
|
+
print(client.api_root) # http://localhost:8666
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
You can also pass in the credentials string retrieved from the hakai API login page while initiating the Client class.
|
|
62
|
+
|
|
63
|
+
```python
|
|
64
|
+
# Pass a credentials token as the Client Class is initiated
|
|
65
|
+
client = Client(credentials="CREDENTIAL_TOKEN")
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
# Development
|
|
69
|
+
The business code for this package is in the file [`hakai_api/Client.py`](hakai_api/Client.py).
|
|
70
|
+
The `./setup.py` file is important for giving details about how to install the package when users do `pip install hakai-api`.
|
|
71
|
+
|
|
72
|
+
To build a new PyPi package version push a tag matching the pattern `v[0-9]+.[0-9]+.[0-9]+` or `v[0-9]+.[0-9]+.[0-9]+rc[0-9]+` to the origin (e.g. `v0.4.1` or `v0.5.2rc1`).
|
|
73
|
+
Github Actions should take care of packaging and pushing it to Hakai's PyPi repository from there.
|
hakai_api-1.1.2/PKG-INFO
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: hakai_api
|
|
3
|
-
Version: 1.1.2
|
|
4
|
-
Summary: Get Hakai database resources using http calls
|
|
5
|
-
Home-page: https://github.com/HakaiInstitute/hakai-api-client-python
|
|
6
|
-
Author: Taylor Denouden
|
|
7
|
-
Author-email: taylor.denouden@hakai.org
|
|
8
|
-
License: MIT
|
|
9
|
-
Description: # Hakai Api Python Client
|
|
10
|
-
|
|
11
|
-
This project exports a single Python class that can be used to make HTTP requests to the Hakai API resource server.
|
|
12
|
-
The exported `Client` class extends the functionality of the Python [requests library](https://docs.python-requests.org/en/master/) to supply Hakai OAuth2 credentials with url requests.
|
|
13
|
-
|
|
14
|
-
# Installation
|
|
15
|
-
|
|
16
|
-
```bash
|
|
17
|
-
pip install hakai-api
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
# Requirements
|
|
21
|
-
Python 3.6 or higher
|
|
22
|
-
|
|
23
|
-
# Quickstart
|
|
24
|
-
|
|
25
|
-
```python
|
|
26
|
-
from hakai_api import Client
|
|
27
|
-
|
|
28
|
-
# Get the api request client
|
|
29
|
-
client = Client() # Follow stdout prompts to get an API token
|
|
30
|
-
|
|
31
|
-
# Make a data request for chlorophyll data
|
|
32
|
-
url = '%s/%s' % (client.api_root, 'eims/views/output/chlorophyll?limit=50')
|
|
33
|
-
response = client.get(url)
|
|
34
|
-
|
|
35
|
-
print(url) # https://hecate.hakai.org/api/eims/views/output/chlorophyll...
|
|
36
|
-
print(response.json()) # [{'action': '', 'event_pk': 7064, 'rn': '1', 'date': '2012-05-17', 'work_area': 'CALVERT'...
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
# Methods
|
|
40
|
-
|
|
41
|
-
This library exports a single client name `Client`. Instantiating this class produces a `requests.Session` client from the Python requests library. The Hakai API Python Client inherits directly from `requests.Session` thus all methods available on that parent class are available. For details see the [requests documentation](http://docs.python-requests.org/).
|
|
42
|
-
|
|
43
|
-
The hakai_api `Client` class also contains a property `api_root` which is useful for constructing urls to access data from the API. The above [Quickstart example](#quickstart) demonstrates using this property to construct a url to access project names.
|
|
44
|
-
|
|
45
|
-
# API endpoints
|
|
46
|
-
|
|
47
|
-
For details about the API, including available endpoints where data can be requested from, see the [Hakai API documentation](https://github.com/HakaiInstitute/hakai-api).
|
|
48
|
-
|
|
49
|
-
# Advanced usage
|
|
50
|
-
|
|
51
|
-
You can specify which API to access when instantiating the Client. By default, the API uses `https://hecate.hakai.org/api` as the API root. It may be useful to use this library to access a locally running API instance or to access the Goose API for testing purposes. If you are always going to be accessing data from a locally running API instance, you are better off using the requests.py library directly since Authorization is not required for local requests.
|
|
52
|
-
|
|
53
|
-
```python
|
|
54
|
-
# Get a client for a locally running API instance
|
|
55
|
-
client = Client("http://localhost:8666")
|
|
56
|
-
print(client.api_root) # http://localhost:8666
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
# Development
|
|
60
|
-
The business code for this package is in the file [`hakai_api/Client.py`](hakai_api/Client.py).
|
|
61
|
-
The `./setup.py` file is important for giving details about how to install the package when users do `pip install hakai-api`.
|
|
62
|
-
|
|
63
|
-
To build a new PyPi package version push a tag matching the pattern `v[0-9]+.[0-9]+.[0-9]+` or `v[0-9]+.[0-9]+.[0-9]+rc[0-9]+` to the origin (e.g. `v0.4.1` or `v0.5.2rc1`).
|
|
64
|
-
Github Actions should take care of packaging and pushing it to Hakai's PyPi repository from there.
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
Platform: UNKNOWN
|
|
68
|
-
Description-Content-Type: text/markdown
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: hakai-api
|
|
3
|
-
Version: 1.1.2
|
|
4
|
-
Summary: Get Hakai database resources using http calls
|
|
5
|
-
Home-page: https://github.com/HakaiInstitute/hakai-api-client-python
|
|
6
|
-
Author: Taylor Denouden
|
|
7
|
-
Author-email: taylor.denouden@hakai.org
|
|
8
|
-
License: MIT
|
|
9
|
-
Description: # Hakai Api Python Client
|
|
10
|
-
|
|
11
|
-
This project exports a single Python class that can be used to make HTTP requests to the Hakai API resource server.
|
|
12
|
-
The exported `Client` class extends the functionality of the Python [requests library](https://docs.python-requests.org/en/master/) to supply Hakai OAuth2 credentials with url requests.
|
|
13
|
-
|
|
14
|
-
# Installation
|
|
15
|
-
|
|
16
|
-
```bash
|
|
17
|
-
pip install hakai-api
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
# Requirements
|
|
21
|
-
Python 3.6 or higher
|
|
22
|
-
|
|
23
|
-
# Quickstart
|
|
24
|
-
|
|
25
|
-
```python
|
|
26
|
-
from hakai_api import Client
|
|
27
|
-
|
|
28
|
-
# Get the api request client
|
|
29
|
-
client = Client() # Follow stdout prompts to get an API token
|
|
30
|
-
|
|
31
|
-
# Make a data request for chlorophyll data
|
|
32
|
-
url = '%s/%s' % (client.api_root, 'eims/views/output/chlorophyll?limit=50')
|
|
33
|
-
response = client.get(url)
|
|
34
|
-
|
|
35
|
-
print(url) # https://hecate.hakai.org/api/eims/views/output/chlorophyll...
|
|
36
|
-
print(response.json()) # [{'action': '', 'event_pk': 7064, 'rn': '1', 'date': '2012-05-17', 'work_area': 'CALVERT'...
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
# Methods
|
|
40
|
-
|
|
41
|
-
This library exports a single client name `Client`. Instantiating this class produces a `requests.Session` client from the Python requests library. The Hakai API Python Client inherits directly from `requests.Session` thus all methods available on that parent class are available. For details see the [requests documentation](http://docs.python-requests.org/).
|
|
42
|
-
|
|
43
|
-
The hakai_api `Client` class also contains a property `api_root` which is useful for constructing urls to access data from the API. The above [Quickstart example](#quickstart) demonstrates using this property to construct a url to access project names.
|
|
44
|
-
|
|
45
|
-
# API endpoints
|
|
46
|
-
|
|
47
|
-
For details about the API, including available endpoints where data can be requested from, see the [Hakai API documentation](https://github.com/HakaiInstitute/hakai-api).
|
|
48
|
-
|
|
49
|
-
# Advanced usage
|
|
50
|
-
|
|
51
|
-
You can specify which API to access when instantiating the Client. By default, the API uses `https://hecate.hakai.org/api` as the API root. It may be useful to use this library to access a locally running API instance or to access the Goose API for testing purposes. If you are always going to be accessing data from a locally running API instance, you are better off using the requests.py library directly since Authorization is not required for local requests.
|
|
52
|
-
|
|
53
|
-
```python
|
|
54
|
-
# Get a client for a locally running API instance
|
|
55
|
-
client = Client("http://localhost:8666")
|
|
56
|
-
print(client.api_root) # http://localhost:8666
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
# Development
|
|
60
|
-
The business code for this package is in the file [`hakai_api/Client.py`](hakai_api/Client.py).
|
|
61
|
-
The `./setup.py` file is important for giving details about how to install the package when users do `pip install hakai-api`.
|
|
62
|
-
|
|
63
|
-
To build a new PyPi package version push a tag matching the pattern `v[0-9]+.[0-9]+.[0-9]+` or `v[0-9]+.[0-9]+.[0-9]+rc[0-9]+` to the origin (e.g. `v0.4.1` or `v0.5.2rc1`).
|
|
64
|
-
Github Actions should take care of packaging and pushing it to Hakai's PyPi repository from there.
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
Platform: UNKNOWN
|
|
68
|
-
Description-Content-Type: text/markdown
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|