Skip to content

Commit

Permalink
Merge pull request #146 from sendgrid/api_keys_v3
Browse files Browse the repository at this point in the history
Added api_keys POST, PATCH, DELETE
  • Loading branch information
thinkingserious committed Nov 17, 2015
2 parents 338fa0d + 24fa26e commit 021f045
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 10 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Change Log
All notable changes to this project will be documented in this file.

## [1.5.15] - 2015-11-17 ##

### Added ###

- API Keys documentation for [POST, PATCH, DELETE]

## [1.5.14] - 2015-11-09 ##

### Fixed ###
Expand Down
23 changes: 23 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,29 @@ List all API Keys belonging to the authenticated user.
client = sendgrid.SendGridAPIClient(os.environ.get('SENDGRID_API_KEY'))
status, msg = client.apikeys.get()
Generate a new API Key for the authenticated user

.. code:: python
client = sendgrid.SendGridAPIClient(os.environ.get('SENDGRID_API_KEY'))
name = "My Amazing API Key"
status, msg = client.apikeys.post(name)
Revoke an existing API Key

.. code:: python
client = sendgrid.SendGridAPIClient(os.environ.get('SENDGRID_API_KEY'))
status, msg = client.apikeys.delete(api_key_id)
Update the name of an existing API Key

.. code:: python
client = sendgrid.SendGridAPIClient(os.environ.get('SENDGRID_API_KEY'))
name = "My NEW API Key 3000"
status, msg = client.apikeys.patch(api_key_id, name)
`Suppression Management`_
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
6 changes: 4 additions & 2 deletions example_v2_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@
sg = sendgrid.SendGridClient(os.environ.get('SENDGRID_USERNAME'), os.environ.get('SENDGRID_PASSWORD'))

"""
to = 'Jane Doe <[email protected]>'
from = 'John Doe <[email protected]>'
message = sendgrid.Mail()
message.add_to('Elmer Thomas <[email protected]>')
message.add_to(to)
message.set_subject('Testing from the Python library')
message.set_html('<b>This was a successful test!</b>')
message.set_text('This was a successful test!')
message.set_from('Elmer Thomas <[email protected]>')
message.set_from(from)
status, msg = sg.send(message)
print status
print msg
Expand Down
13 changes: 6 additions & 7 deletions example_v3_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
client = sendgrid.SendGridAPIClient(os.environ.get('SENDGRID_API_KEY'))

"""
email = '[email protected]'
email = '[email protected]'
status, msg = client.asm_global_suppressions.delete(email)
print status
print msg
Expand All @@ -21,7 +20,7 @@
print status
print msg
status, msg = client.asm_global_suppressions.post(['elmer.thomas+test_global0@gmail.com'])
status, msg = client.asm_global_suppressions.post(['example@example.com'])
print status
print msg
Expand All @@ -47,24 +46,24 @@
print msg
# In the global suppression list
status, msg = client.asm_global_suppressions.get('elmer.thomas+test_global@gmail.com')
status, msg = client.asm_global_suppressions.get('example@example.com')
print status
print msg
# Not in the global suppression list
status, msg = client.asm_global_suppressions.get('elmer.thomas@gmail.com')
status, msg = client.asm_global_suppressions.get('example@example.com')
print status
print msg
status, msg = client.apikeys.get()
print status
print msg
status, msg = client.asm_suppressions.delete(67,'elmer+test@thinkingserious.com')
status, msg = client.asm_suppressions.delete(67,'example@example.com')
print status
print msg
status, msg = client.asm_suppressions.post(60, ['elmer+test@thinkingserious.com', 'elmer.thomas@yahoo.com'])
status, msg = client.asm_suppressions.post(60, ['example@example.com', 'example@example.com])
print status
print msg
Expand Down
2 changes: 1 addition & 1 deletion sendgrid/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version_info = (1, 5, 14)
version_info = (1, 5, 15)
__version__ = '.'.join(str(v) for v in version_info)

0 comments on commit 021f045

Please sign in to comment.