diff --git a/src/promptflow/promptflow/_sdk/_service/apis/connection.py b/src/promptflow/promptflow/_sdk/_service/apis/connection.py index a191636e68f..c1580170c85 100644 --- a/src/promptflow/promptflow/_sdk/_service/apis/connection.py +++ b/src/promptflow/promptflow/_sdk/_service/apis/connection.py @@ -64,11 +64,7 @@ class Connection(Resource): @local_user_only def get(self, name: str): connection_op = ConnectionOperations() - # parse query parameters - with_secrets = request.args.get("with_secrets", default=False, type=bool) - raise_error = request.args.get("raise_error", default=True, type=bool) - - connection = connection_op.get(name=name, with_secrets=with_secrets, raise_error=raise_error) + connection = connection_op.get(name=name, raise_error=True) connection_dict = connection._to_dict() return jsonify(connection_dict) @@ -102,3 +98,15 @@ def put(self, name: str): def delete(self, name: str): connection_op = ConnectionOperations() connection_op.delete(name=name) + + +@api.route("//listsecrets") +class ConnectionWithSecret(Resource): + @api.doc(description="Get connection with secret") + @api.response(code=200, description="Connection details with secret", model=dict_field) + @local_user_only + def get(self, name: str): + connection_op = ConnectionOperations() + connection = connection_op.get(name=name, with_secrets=True, raise_error=True) + connection_dict = connection._to_dict() + return jsonify(connection_dict) diff --git a/src/promptflow/promptflow/_sdk/_service/swagger.json b/src/promptflow/promptflow/_sdk/_service/swagger.json index 65b52fdc879..57ce48e48bd 100644 --- a/src/promptflow/promptflow/_sdk/_service/swagger.json +++ b/src/promptflow/promptflow/_sdk/_service/swagger.json @@ -32,7 +32,7 @@ "type": "string" } ], - "get": { + "put": { "responses": { "200": { "description": "Connection details", @@ -41,13 +41,21 @@ } } }, - "description": "Get connection", - "operationId": "get_connection", + "description": "Update connection", + "operationId": "put_connection", + "parameters": [ + { + "name": "connection_dict", + "in": "query", + "type": "string", + "required": true + } + ], "tags": [ "Connections" ] }, - "post": { + "get": { "responses": { "200": { "description": "Connection details", @@ -56,21 +64,25 @@ } } }, - "description": "Create connection", - "operationId": "post_connection", - "parameters": [ - { - "name": "connection_dict", - "in": "query", - "type": "string", - "required": true + "description": "Get connection", + "operationId": "get_connection", + "tags": [ + "Connections" + ] + }, + "delete": { + "responses": { + "200": { + "description": "Success" } - ], + }, + "description": "Delete connection", + "operationId": "delete_connection", "tags": [ "Connections" ] }, - "put": { + "post": { "responses": { "200": { "description": "Connection details", @@ -79,8 +91,8 @@ } } }, - "description": "Update connection", - "operationId": "put_connection", + "description": "Create connection", + "operationId": "post_connection", "parameters": [ { "name": "connection_dict", @@ -92,15 +104,28 @@ "tags": [ "Connections" ] - }, - "delete": { + } + }, + "/Connections/{name}/listsecrets": { + "parameters": [ + { + "name": "name", + "in": "path", + "required": true, + "type": "string" + } + ], + "get": { "responses": { "200": { - "description": "Success" + "description": "Connection details with secret", + "schema": { + "$ref": "#/definitions/ConnectionDict" + } } }, - "description": "Delete connection", - "operationId": "delete_connection", + "description": "Get connection with secret", + "operationId": "get_connection_with_secret", "tags": [ "Connections" ]