Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions docs/v4/peer-group/url-api-v4-peer-group/environment.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,18 @@ Environment associations

Add or remove environment associations for an existing Peer Group.

URL::
POST URL::

/api/v4/peer-group/{peer_group_id}/environment

The trailing slash is optional. The endpoint requires the Peer Group
DELETE URL::

/api/v4/peer-group/{peer_group_id}/environment/{environment_id}

The trailing slash is optional. Both endpoints require the Peer Group
management write permission.

Request body for both methods:
POST request body:

.. code-block:: json

Expand Down Expand Up @@ -38,9 +42,8 @@ An environment already associated with the Peer Group is rejected with HTTP
DELETE
******

Removes only the associations matching the listed environment IDs. Other
environment associations are preserved. The request returns HTTP 200 with an
empty object::
Removes the association identified by the URL's ``environment_id``. Other environment associations are preserved. The request
returns HTTP 200 with an empty object::

{}

Expand Down
2 changes: 2 additions & 0 deletions networkapi/api_peer_group/v4/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
'',
url(r'^peer-group/(?P<peer_group_id>\d+)/environment/?$',
views.EnvironmentPeerGroupDBView.as_view()),
url(r'^peer-group/(?P<peer_group_id>\d+)/environment/(?P<environment_id>\d+)/?$',
views.EnvironmentPeerGroupDBView.as_view()),
url(r'^peer-group/((?P<obj_ids>[;\w]+)/)?$',
views.PeerGroupDBView.as_view()),
)
9 changes: 3 additions & 6 deletions networkapi/api_peer_group/v4/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,18 +137,15 @@ def post(self, request, *args, **kwargs):
return Response(response, status=status.HTTP_201_CREATED)

@logs_method_apiview
@raise_json_validate('environment_peer_group_delete_v4')
@raise_json_validate('')
@permission_classes_apiview((IsAuthenticated, Write))
@commit_on_success
def delete(self, request, *args, **kwargs):
"""Delete environment associations from an existing PeerGroup."""

objects = request.DATA
json_validate(SPECS.get('environment_peer_group_delete_v4')).validate(objects)
peer_group_id = kwargs.get('peer_group_id')
for environment_id in objects['environments_ids']:
facade.delete_environment_peer_group(
environment_id, peer_group_id)
environment_id = kwargs.get('environment_id')
facade.delete_environment_peer_group(environment_id, peer_group_id)

return Response({}, status=status.HTTP_200_OK)

Expand Down
4 changes: 0 additions & 4 deletions networkapi/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -654,10 +654,6 @@ def local_files(path):
PROJECT_ROOT_PATH,
'api_peer_group/v4/specs/environment_peer_group_post.json'
),
'environment_peer_group_delete_v4': os.path.join(
PROJECT_ROOT_PATH,
'api_peer_group/v4/specs/environment_peer_group_post.json'
),
'simple_env_post': os.path.join(
PROJECT_ROOT_PATH,
'api_environment/specs/simple_env_post.json'
Expand Down
Loading