Skip to content

Commit

Permalink
Merge pull request #331 from atlanticwave-sdx/add-archived-connection…
Browse files Browse the repository at this point in the history
…-api

Add archived connection api
  • Loading branch information
congwang09 authored Oct 9, 2024
2 parents 57fabe7 + 2e599be commit a0813f1
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 4 deletions.
22 changes: 20 additions & 2 deletions sdx_controller/controllers/l2vpn_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def delete_connection(service_id):
return "OK", 200


def getconnection_by_id(service_id):
def get_connection_by_id(service_id):
"""
Find connection by ID.
Expand All @@ -88,7 +88,7 @@ def getconnection_by_id(service_id):
return value


def getconnections(): # noqa: E501
def get_connections(): # noqa: E501
"""List all connections
connection details # noqa: E501
Expand Down Expand Up @@ -218,3 +218,21 @@ def patch_connection(service_id, body=None): # noqa: E501
return f"Failed, reason: {e}", 500

return response, code


def get_archived_connections_by_id(service_id):
"""
List archived connection by ID.
:param service_id: ID of connection that needs to be fetched
:type service_id: str
:rtype: Connection
"""

value = get_connection_status(db_instance, service_id)

if not value:
return "Connection not found", 404

return value
8 changes: 8 additions & 0 deletions sdx_controller/handlers/connection_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,14 @@ def handle_link_failure(self, te_manager, failed_links):
logger.debug(connection)
self.place_connection(te_manager, connection)

def get_archived_connections(self, service_id: str):
historical_connections = self.db_instance.read_from_db(
"historical_connections", service_id
)
if not historical_connections:
return None
return historical_connections[service_id]


def get_connection_status(db, service_id: str):
"""
Expand Down
36 changes: 34 additions & 2 deletions sdx_controller/swagger/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ paths:
- l2vpn
summary: List all l2vpn connections
description: connection details
operationId: getconnections
operationId: get_connections
responses:
"200":
description: successful operation
Expand Down Expand Up @@ -204,7 +204,7 @@ paths:
- l2vpn
summary: Find l2vpn connection by ID
description: connection details
operationId: getconnection_by_id
operationId: get_connection_by_id
parameters:
- name: service_id
in: path
Expand Down Expand Up @@ -284,6 +284,38 @@ paths:
"400":
description: Invalid Connection
x-openapi-router-controller: sdx_controller.controllers.l2vpn_controller
/l2vpn/1.0/{service_id}/archived:
get:
tags:
- l2vpn
summary: Get list of l2vpn connection historical events by ID
description: connection historical events
operationId: get_archived_connections_by_id
parameters:
- name: service_id
in: path
description: ID of l2vpn connection for querying history
required: true
style: simple
explode: false
schema:
type: string
format: uuid
responses:
"200":
description: successful operation
content:
application/json:
schema:
$ref: '#/components/schemas/connection'
application/xml:
schema:
$ref: '#/components/schemas/connection'
"400":
description: Invalid ID supplied
"404":
description: connection not found
x-openapi-router-controller: sdx_controller.controllers.l2vpn_controller
/user:
post:
tags:
Expand Down

0 comments on commit a0813f1

Please sign in to comment.