Skip to content

Commit f8ebd5f

Browse files
committed
Changed the header keys inline with the change to the H51 application
1 parent e8a198b commit f8ebd5f

File tree

3 files changed

+21
-22
lines changed

3 files changed

+21
-22
lines changed

h51/client.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
class Client:
1212
"""
13-
A client for the Hangar51 API.
13+
A client for the H51 (Hangar51) API.
1414
"""
1515

1616
def __init__(self, api_key, api_base_url='https://api.h51.io'):
@@ -60,7 +60,7 @@ def __call__(self,
6060
"""Call the API"""
6161

6262
# Build headers
63-
headers = {'X-Hangar51-APIKey': self._api_key}
63+
headers = {'X-H51-APIKey': self._api_key}
6464

6565
if json_type_body:
6666
headers['Content-Type'] = 'application/json'
@@ -83,12 +83,12 @@ def __call__(self,
8383
)
8484

8585
# Update the rate limit
86-
if 'X-Hangar51-RateLimit-Limit' in r.headers:
87-
self._rate_limit = int(r.headers['X-Hangar51-RateLimit-Limit'])
86+
if 'X-H51-RateLimit-Limit' in r.headers:
87+
self._rate_limit = int(r.headers['X-H51-RateLimit-Limit'])
8888
self._rate_limit_reset \
89-
= float(r.headers['X-Hangar51-RateLimit-Reset'])
89+
= float(r.headers['X-H51-RateLimit-Reset'])
9090
self._rate_limit_remaining \
91-
= int(r.headers['X-Hangar51-RateLimit-Remaining'])
91+
= int(r.headers['X-H51-RateLimit-Remaining'])
9292

9393
# Handle a successful response
9494
if r.status_code in [200, 204]:

h51/resources.py

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,19 @@ def __init__(self, client, document):
9999
def __str__(self):
100100
return f'Asset: {self.uid}'
101101

102+
def analyze(self, analyzers, notification_url=None):
103+
"""Analyze the asset"""
104+
105+
r = self._client(
106+
'post',
107+
f'assets/{self.uid}/analyze',
108+
params={'notification_url': notification_url},
109+
json_type_body=[a.to_json_type() for a in analyzers]
110+
)
111+
112+
if not notification_url:
113+
self.meta = r['meta']
114+
102115
def download(self):
103116
"""Download the asset"""
104117
return self._client(
@@ -121,8 +134,7 @@ def expire(self, seconds):
121134

122135
self._document.update(r)
123136

124-
125-
def persist(self,):
137+
def persist(self):
126138
"""Set the asset to persist (remove the expires time)"""
127139

128140
r = self._client(
@@ -132,19 +144,6 @@ def persist(self,):
132144

133145
self._document.update(r)
134146

135-
def analyze(self, analyzers, notification_url=None):
136-
"""Analyze the asset"""
137-
138-
r = self._client(
139-
'post',
140-
f'assets/{self.uid}/analyze',
141-
params={'notification_url': notification_url},
142-
json_type_body=[a.to_json_type() for a in analyzers]
143-
)
144-
145-
if not notification_url:
146-
self.meta = r['meta']
147-
148147
@classmethod
149148
def all(self, client, secure=None, type=None, q=None, rate_buffer=0):
150149
"""

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
# Versions should comply with PEP440. For a discussion on single-sourcing
2222
# the version across setup.py and the project code, see
2323
# https://packaging.python.org/en/latest/single_source_version.html
24-
version='0.0.1',
24+
version='0.0.2',
2525
description=\
2626
'The H51 Python library provides a pythonic interface to the H51 API.',
2727
long_description=long_description,

0 commit comments

Comments
 (0)