Skip to content

Commit 021f045

Browse files
Merge pull request #146 from sendgrid/api_keys_v3
Added api_keys POST, PATCH, DELETE
2 parents 338fa0d + 24fa26e commit 021f045

File tree

5 files changed

+40
-10
lines changed

5 files changed

+40
-10
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
# Change Log
22
All notable changes to this project will be documented in this file.
33

4+
## [1.5.15] - 2015-11-17 ##
5+
6+
### Added ###
7+
8+
- API Keys documentation for [POST, PATCH, DELETE]
9+
410
## [1.5.14] - 2015-11-09 ##
511

612
### Fixed ###

README.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,29 @@ List all API Keys belonging to the authenticated user.
248248
client = sendgrid.SendGridAPIClient(os.environ.get('SENDGRID_API_KEY'))
249249
status, msg = client.apikeys.get()
250250
251+
Generate a new API Key for the authenticated user
252+
253+
.. code:: python
254+
255+
client = sendgrid.SendGridAPIClient(os.environ.get('SENDGRID_API_KEY'))
256+
name = "My Amazing API Key"
257+
status, msg = client.apikeys.post(name)
258+
259+
Revoke an existing API Key
260+
261+
.. code:: python
262+
263+
client = sendgrid.SendGridAPIClient(os.environ.get('SENDGRID_API_KEY'))
264+
status, msg = client.apikeys.delete(api_key_id)
265+
266+
Update the name of an existing API Key
267+
268+
.. code:: python
269+
270+
client = sendgrid.SendGridAPIClient(os.environ.get('SENDGRID_API_KEY'))
271+
name = "My NEW API Key 3000"
272+
status, msg = client.apikeys.patch(api_key_id, name)
273+
251274
`Suppression Management`_
252275
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
253276

example_v2_test.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@
99
sg = sendgrid.SendGridClient(os.environ.get('SENDGRID_USERNAME'), os.environ.get('SENDGRID_PASSWORD'))
1010

1111
"""
12+
to = 'Jane Doe <[email protected]>'
13+
from = 'John Doe <[email protected]>'
1214
message = sendgrid.Mail()
13-
message.add_to('Elmer Thomas <[email protected]>')
15+
message.add_to(to)
1416
message.set_subject('Testing from the Python library')
1517
message.set_html('<b>This was a successful test!</b>')
1618
message.set_text('This was a successful test!')
17-
message.set_from('Elmer Thomas <[email protected]>')
19+
message.set_from(from)
1820
status, msg = sg.send(message)
1921
print status
2022
print msg

example_v3_test.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
client = sendgrid.SendGridAPIClient(os.environ.get('SENDGRID_API_KEY'))
1212

1313
"""
14-
15-
14+
1615
status, msg = client.asm_global_suppressions.delete(email)
1716
print status
1817
print msg
@@ -21,7 +20,7 @@
2120
print status
2221
print msg
2322
24-
status, msg = client.asm_global_suppressions.post(['elmer.thomas+test_global0@gmail.com'])
23+
status, msg = client.asm_global_suppressions.post(['example@example.com'])
2524
print status
2625
print msg
2726
@@ -47,24 +46,24 @@
4746
print msg
4847
4948
# In the global suppression list
50-
status, msg = client.asm_global_suppressions.get('elmer.thomas+test_global@gmail.com')
49+
status, msg = client.asm_global_suppressions.get('example@example.com')
5150
print status
5251
print msg
5352
5453
# Not in the global suppression list
55-
status, msg = client.asm_global_suppressions.get('elmer.thomas@gmail.com')
54+
status, msg = client.asm_global_suppressions.get('example@example.com')
5655
print status
5756
print msg
5857
5958
status, msg = client.apikeys.get()
6059
print status
6160
print msg
6261
63-
status, msg = client.asm_suppressions.delete(67,'elmer+test@thinkingserious.com')
62+
status, msg = client.asm_suppressions.delete(67,'example@example.com')
6463
print status
6564
print msg
6665
67-
status, msg = client.asm_suppressions.post(60, ['elmer+test@thinkingserious.com', 'elmer.thomas@yahoo.com'])
66+
status, msg = client.asm_suppressions.post(60, ['example@example.com', 'example@example.com])
6867
print status
6968
print msg
7069

sendgrid/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
version_info = (1, 5, 14)
1+
version_info = (1, 5, 15)
22
__version__ = '.'.join(str(v) for v in version_info)

0 commit comments

Comments
 (0)