Skip to content

Commit

Permalink
[pfs] Request of get connection exposes with_secrets (#1214)
Browse files Browse the repository at this point in the history
# Description

Please add an informative description that covers that changes made by
the pull request and link all relevant issues.

# All Promptflow Contribution checklist:
- [ ] **The pull request does not introduce [breaking changes].**
- [ ] **CHANGELOG is updated for new features, bug fixes or other
significant changes.**
- [ ] **I have read the [contribution guidelines](../CONTRIBUTING.md).**
- [ ] **Create an issue and link to the pull request to get dedicated
review from promptflow team. Learn more: [suggested
workflow](../CONTRIBUTING.md#suggested-workflow).**

## General Guidelines and Best Practices
- [ ] Title of the pull request is clear and informative.
- [ ] There are a small number of commits, each of which have an
informative message. This means that previously merged commits do not
appear in the history of the PR. For more information on cleaning up the
commits in your PR, [see this
page](https://github.com/Azure/azure-powershell/blob/master/documentation/development-docs/cleaning-up-commits.md).

### Testing Guidelines
- [ ] Pull request includes test coverage for the included changes.
  • Loading branch information
lalala123123 authored Nov 21, 2023
1 parent d1a5dde commit 3c4bcdb
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 26 deletions.
18 changes: 13 additions & 5 deletions src/promptflow/promptflow/_sdk/_service/apis/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -102,3 +98,15 @@ def put(self, name: str):
def delete(self, name: str):
connection_op = ConnectionOperations()
connection_op.delete(name=name)


@api.route("/<string:name>/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)
67 changes: 46 additions & 21 deletions src/promptflow/promptflow/_sdk/_service/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"type": "string"
}
],
"get": {
"put": {
"responses": {
"200": {
"description": "Connection details",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -79,8 +91,8 @@
}
}
},
"description": "Update connection",
"operationId": "put_connection",
"description": "Create connection",
"operationId": "post_connection",
"parameters": [
{
"name": "connection_dict",
Expand All @@ -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"
]
Expand Down

0 comments on commit 3c4bcdb

Please sign in to comment.