Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
R
red-ci-cd
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
red-group-test
red-ci-cd
Commits
033f710d
Commit
033f710d
authored
Jun 20, 2019
by
Ristylou Dolar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Modified Application, Endpoint and Service retrieve method
parent
510a53e5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
39 deletions
+37
-39
api/viewsets/applications.py
api/viewsets/applications.py
+11
-11
api/viewsets/endpoints.py
api/viewsets/endpoints.py
+13
-14
api/viewsets/services.py
api/viewsets/services.py
+13
-14
No files found.
api/viewsets/applications.py
View file @
033f710d
...
...
@@ -94,23 +94,23 @@ class ApplicationViewSet(viewsets.ModelViewSet):
def
retrieve
(
self
,
request
,
*
args
,
**
kwargs
):
try
:
id
=
self
.
kwargs
[
'pk'
]
queryset
=
Application
.
objects
.
filter
(
id
=
id
)
serializer
=
self
.
get_serializer
(
queryset
,
many
=
True
)
if
not
queryset
.
exists
():
message
=
status_message_response
(
404
,
'failed'
,
'No record found'
,
[])
return
Response
(
message
,
status
=
status
.
HTTP_404_NOT_FOUND
)
else
:
message
=
status_message_response
(
instance
=
Application
.
objects
.
get
(
id
=
id
)
serializer
=
self
.
get_serializer
(
instance
)
message
=
status_message_response
(
200
,
'success'
,
'Application retrieved'
,
serializer
.
data
)
return
Response
(
message
,
status
=
status
.
HTTP_200_OK
)
return
Response
(
message
,
status
=
status
.
HTTP_200_OK
)
except
Application
.
DoesNotExist
:
message
=
status_message_response
(
404
,
'failed'
,
'No record found'
,
[])
return
Response
(
message
,
status
=
status
.
HTTP_404_NOT_FOUND
)
except
Exception
as
e
:
message
=
status_message_response
(
500
,
'failed'
,
500
,
'failed'
,
'Request was not able to process'
+
str
(
e
),
[]
)
return
Response
(
message
,
...
...
api/viewsets/endpoints.py
View file @
033f710d
...
...
@@ -80,24 +80,23 @@ class APIEndpointViewSet(viewsets.ModelViewSet):
def
retrieve
(
self
,
request
,
*
args
,
**
kwargs
):
try
:
id
=
self
.
kwargs
[
'pk'
]
queryset
=
APIEndpoint
.
objects
.
filter
(
id
=
id
)
serializer
=
self
.
get_serializer
(
queryset
,
many
=
True
)
instance
=
APIEndpoint
.
objects
.
get
(
id
=
id
)
serializer
=
self
.
get_serializer
(
instance
)
message
=
status_message_response
(
200
,
'success'
,
'Endpoint retrieved'
,
serializer
.
data
)
return
Response
(
message
,
status
=
status
.
HTTP_200_OK
)
if
not
queryset
.
exists
():
message
=
status_message_response
(
404
,
'failed'
,
'No record found'
,
[]
)
return
Response
(
message
,
status
=
status
.
HTTP_404_NOT_FOUND
)
else
:
message
=
status_message_response
(
200
,
'success'
,
'Endpoint retrieved'
,
serializer
.
data
)
return
Response
(
message
,
status
=
status
.
HTTP_200_OK
)
except
APIEndpoint
.
DoesNotExist
:
message
=
status_message_response
(
404
,
'failed'
,
'No record found'
,
[])
return
Response
(
message
,
status
=
status
.
HTTP_404_NOT_FOUND
)
except
Exception
as
e
:
message
=
status_message_response
(
500
,
'failed'
,
500
,
'failed'
,
'Request was not able to process'
+
str
(
e
),
[]
)
return
Response
(
message
,
...
...
api/viewsets/services.py
View file @
033f710d
...
...
@@ -76,24 +76,23 @@ class APIServiceViewSet(viewsets.ModelViewSet):
def
retrieve
(
self
,
request
,
*
args
,
**
kwargs
):
try
:
id
=
self
.
kwargs
[
'pk'
]
queryset
=
APIService
.
objects
.
filter
(
id
=
id
)
serializer
=
self
.
get_serializer
(
queryset
,
many
=
True
)
instance
=
APIService
.
objects
.
get
(
id
=
id
)
serializer
=
self
.
get_serializer
(
instance
)
message
=
status_message_response
(
200
,
'success'
,
'Service retrieved'
,
serializer
.
data
)
return
Response
(
message
,
status
=
status
.
HTTP_200_OK
)
if
not
queryset
.
exists
():
message
=
status_message_response
(
404
,
'failed'
,
'No record found'
,
[]
)
return
Response
(
message
,
status
=
status
.
HTTP_404_NOT_FOUND
)
else
:
message
=
status_message_response
(
200
,
'success'
,
'Service retrieved'
,
serializer
.
data
)
return
Response
(
message
,
status
=
status
.
HTTP_200_OK
)
except
APIService
.
DoesNotExist
:
message
=
status_message_response
(
404
,
'failed'
,
'No record found'
,
[])
return
Response
(
message
,
status
=
status
.
HTTP_404_NOT_FOUND
)
except
Exception
as
e
:
message
=
status_message_response
(
500
,
'failed'
,
500
,
'failed'
,
'Request was not able to process'
+
str
(
e
),
[]
)
return
Response
(
message
,
...
...
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