Skip to content

Commit

Permalink
Merge pull request #38 from ambitioninc/develop
Browse files Browse the repository at this point in the history
Merge Develop
  • Loading branch information
travistruett authored Apr 2, 2019
2 parents eb3de8d + f3e0000 commit ef24f9b
Show file tree
Hide file tree
Showing 32 changed files with 2,693 additions and 347 deletions.
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
root = true

[*]
end_of_line = lf
charset = utf-8
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = tab
indent_size = 4

[*.py]
indent_style = space
indent_size = 4
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ htmlcov/

# Python egg metadata, regenerated from source files by setuptools.
/*.egg-info
/*.egg
/*.eggs

# Virtualenv
env/
venv/
.venv/

# OSX
.DS_Store
Expand Down
23 changes: 15 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
sudo: false
---

sudo: required
dist: xenial

language: python
python:
- '2.7'
- '3.3'
- '3.4'
install:
- pip install coveralls nose flake8
- python setup.py install
- '3.6'
- '3.7'

branches:
only:
- develop
- master

script:
- flake8 .
- python setup.py nosetests
- make test

after_success:
coveralls
32 changes: 32 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
PATH := $(PWD)/.venv/bin:$(shell printenv PATH)
SHELL := env PATH=$(PATH) /bin/bash
VENV_DIR=.venv

.PHONY: clean
## Destroy docker instances, remove virtualenv, molecule temp, .pyc files
clean:
rm -rf .venv

.PHONY: deps
## Create virtualenv, install dependencies
deps:
test -d ${VENV_DIR} || virtualenv ${VENV_DIR}
${VENV_DIR}/bin/pip install -r requirements/main.txt
virtualenv --relocatable ${VENV_DIR}
python setup.py install

.PHONY: help
help:
@awk -v skip=1 \
'/^##/ { sub(/^[#[:blank:]]*/, "", $$0); doc_h=$$0; doc=""; skip=0; next } \
skip { next } \
/^#/ { doc=doc "\n" substr($$0, 2); next } \
/:/ { sub(/:.*/, "", $$0); \
printf "\033[34m%-30s\033[0m\033[1m%s\033[0m %s\n\n", $$0, doc_h, doc; skip=1 }' \
$(MAKEFILE_LIST)

.PHONY: test
## Run tests
test: deps
flake8 newrelic_api
python setup.py nosetests
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
:target: https://coveralls.io/r/ambitioninc/newrelic-api?branch=develop

.. image:: https://pypip.in/v/newrelic-api/badge.png
:target: https://crate.io/packages/newrelic-api/
:target: https://pypi.python.org/pypi/newrelic-api
:alt: Latest PyPI version

.. image:: https://pypip.in/d/newrelic-api/badge.png
:target: https://crate.io/packages/newrelic-api/
:target: https://pypi.python.org/pypi/newrelic-api
:alt: Number of PyPI downloads

newrelic-api: A Python interface to New Relic's API
Expand Down
2 changes: 1 addition & 1 deletion docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ clean:
rm -rf $(BUILDDIR)/*

html:
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
$(SPHINXBUILD) -b html -W $(ALLSPHINXOPTS) $(BUILDDIR)/html
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."

Expand Down
23 changes: 17 additions & 6 deletions docs/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Applications & AlertPolicies Example
------------------------------------

**Scenario:** Say we want to move our application, 'Marketing Website' from
the default Alert Policy to a second Alert Policy, 'Marketing Policy'.
the default Alert Policy, 'Marketing Policy', to a second Alert Policy, 'Marketing Policy2'.

First we need to get the ID for our application and the alert policy that we
want to add it to:
Expand All @@ -29,6 +29,7 @@ want to add it to:
filter_enabled=True
)['alert_policies'][0]
Next, we need to determine if our application is already in the alert_policy.
Since each alert_policy dictionary in the the AlertPolicies ``.list()``
method response has an inner dictionary ``links`` with a key ``applications``
Expand All @@ -45,14 +46,24 @@ policy for 'Marketing Policy'.

.. code-block:: python
if not app_in_policy:
if app_in_policy:
app_ids = marketing_policy['links']['applications']
app_ids.append(website_app_id)
new_alert_policy = marketing_policy.copy()
new_alert_policy['links']['applications'] = app_ids
new_alert_policy = AlertPolicies().list(
filter_name='Marketing Policy2',
filter_type=['application'],
filter_enabled=True
)['alert_policies'][0]
new_alert_policy_wrapper = {"alert_policy": {"test":"test"}}
new_alert_policy_wrapper['alert_policy'] = new_alert_policy
new_alert_policy_wrapper['alert_policy']['links']['applications'] = app_ids
AlertPolicies().update(
id=new_alert_policy['id'],
policy_update=new_alert_policy
id=new_alert_policy_wrapper['alert_policy']['id'],
policy_update=new_alert_policy_wrapper
)
2 changes: 2 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ Currently Supported Resources
* Applications (:doc:`API Reference <ref/applications>`)
* Application Hosts (:doc:`API Reference <ref/application_hosts>`)
* Application Instances (:doc:`API Reference <ref/application_instances>`)
* Browser Applications (:doc:`API Reference <ref/browser_applications>`)
* Components (:doc:`API Reference <ref/components>`)
* Key Transactions (:doc:`API Reference <ref/key_transactions>`)
* Labels (:doc:`API Reference <ref/labels>`)
* Notification Channels (:doc:`API Reference <ref/notification_channels>`)
* Plugins (:doc:`API Reference <ref/plugins>`)
* Servers (:doc:`API Reference <ref/servers>`)
Expand Down
14 changes: 14 additions & 0 deletions docs/ref/browser_applications.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.. _ref-browser_applications:

Browser Applications
====================

newrelic_api.browser_applications
---------------------------------

.. automodule:: newrelic_api.browser_applications
.. autoclass:: newrelic_api.browser_applications.BrowserApplications
:members:
:undoc-members:

.. automethod:: __init__
14 changes: 14 additions & 0 deletions docs/ref/labels.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.. _ref-labels:

Labels
======

newrelic_api.labels
-------------------

.. automodule:: newrelic_api.labels
.. autoclass:: newrelic_api.labels.Labels
:members:
:undoc-members:

.. automethod:: __init__
3 changes: 2 additions & 1 deletion docs/toc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ Table of Contents
ref/applications
ref/application_hosts
ref/application_instances
ref/browser_applications
ref/components
ref/key_transactions
ref/labels
ref/notification_channels
ref/plugins
ref/servers
ref/servers
ref/users
ref/base
ref/exceptions
Expand Down
4 changes: 4 additions & 0 deletions newrelic_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@
from .version import __version__

from .alert_policies import AlertPolicies
from .alert_conditions import AlertConditions
from .alert_conditions_infra import AlertConditionsInfra
from .alert_conditions_nrql import AlertConditionsNRQL
from .applications import Applications
from .application_hosts import ApplicationHosts
from .application_instances import ApplicationInstances
from .components import Components
from .dashboards import Dashboards
from .key_transactions import KeyTransactions
from .notification_channels import NotificationChannels
from .plugins import Plugins
Expand Down
Loading

0 comments on commit ef24f9b

Please sign in to comment.