Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
configuration
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
configuration
Commits
a7f2388f
Commit
a7f2388f
authored
Aug 31, 2015
by
Edward Zarecor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP: simple working API client, sample play.
parent
2a482e9e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
82 additions
and
0 deletions
+82
-0
playbooks/edx-east/mms.yml
+19
-0
playbooks/library/mms_alert.py
+63
-0
No files found.
playbooks/edx-east/mms.yml
0 → 100644
View file @
a7f2388f
---
-
name
:
Test MMS role
hosts
:
all
connection
:
local
gather_facts
:
False
vars
:
state
:
"
present"
tasks
:
-
name
:
Test MMS
mms_alert
:
base_url
:
'
https://cloud.mongodb.com'
group_id
:
'
foo'
api_user
:
'
ed@example.com'
api_key
:
'
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
register
:
api_output
-
debug
:
var=api_output
\ No newline at end of file
playbooks/library/mms_alert.py
0 → 100644
View file @
a7f2388f
#!/usr/bin/env python
DOCUMENTATION
=
"""
---
module: mms_alert
short_description:
description:
version_added: "1.9.3"
author: Edward Zarecor
options:
"""
EXAMPLES
=
'''
'''
from
ansible.module_utils.basic
import
*
import
json
import
requests
class
CloudManagerClient
(
object
):
def
__init__
(
self
,
base_url
,
group_id
,
api_user
,
api_key
):
self
.
base_url
=
base_url
+
"/api/public/v1.0"
self
.
group_id
=
group_id
self
.
http_digest_auth
=
requests
.
auth
.
HTTPDigestAuth
(
api_user
,
api_key
)
def
get
(
self
,
path
):
api_target
=
self
.
base_url
+
path
r
=
requests
.
get
(
api_target
,
auth
=
self
.
http_digest_auth
)
return
r
.
json
()
def
put
():
pass
def
post
():
pass
def
delete
():
pass
class
ArgumentError
(
Exception
):
pass
def
main
():
arg_spec
=
dict
(
base_url
=
dict
(
required
=
True
,
type
=
'str'
),
group_id
=
dict
(
required
=
True
,
type
=
'str'
),
api_user
=
dict
(
required
=
True
,
type
=
'str'
),
api_key
=
dict
(
required
=
True
,
type
=
'str'
),
)
module
=
AnsibleModule
(
argument_spec
=
arg_spec
,
supports_check_mode
=
False
)
base_url
=
module
.
params
.
get
(
'base_url'
)
group_id
=
module
.
params
.
get
(
'group_id'
)
api_user
=
module
.
params
.
get
(
'api_user'
)
api_key
=
module
.
params
.
get
(
'api_key'
)
c
=
CloudManagerClient
(
base_url
,
group_id
,
api_user
,
api_key
)
module
.
exit_json
(
api_output
=
c
.
get
(
'/groups/{group_id}/alertConfigs'
.
format
(
group_id
=
group_id
)))
main
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment