Skip to content

Commit

Permalink
Changed the Request parameters, and removed group_uuid in entity whic…
Browse files Browse the repository at this point in the history
…h will not exist in some circumstances.
  • Loading branch information
ChuckKollar committed Aug 6, 2024
1 parent da1d640 commit 7798bf4
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 20 deletions.
28 changes: 10 additions & 18 deletions entity-api-spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2540,22 +2540,18 @@ paths:
content:
application/json:
schema:
type: object
properties:
entities:
type: array
items:
$ref: '#/components/schemas/Dataset'
type: array
items:
$ref: '#/components/schemas/Dataset'
responses:
'202':
description: request is being processed
content:
application/json:
schema:
type: array
properties:
uuid:
type: string
items:
type: string
description: The uuids of the entities being processed
'500':
description: Internal error
Expand All @@ -2567,22 +2563,18 @@ paths:
content:
application/json:
schema:
type: object
properties:
entities:
type: array
items:
$ref: '#/components/schemas/Upload'
type: array
items:
$ref: '#/components/schemas/Upload'
responses:
'202':
description: request is being processed
content:
application/json:
schema:
type: array
properties:
uuid:
type: string
items:
type: string
description: The uuids of the entities being processed
'500':
description: Internal error
Expand Down
16 changes: 14 additions & 2 deletions src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -4290,6 +4290,7 @@ def bulk_update_entities(
if idx < len(entity_updates) - 1:
time.sleep(throttle)

logger.info(f"bulk_update_entities() results: {results}")
return results


Expand All @@ -4316,6 +4317,17 @@ def update_datasets_uploads(entity_updates: list, token: str, entity_api_url: st
# Shirey: With this use case we're not worried about a lot of concurrent calls to this endpoint (only one user,
# Brendan, will be ever using it). Just start a thread on request and loop through the Datasets/Uploads to change
# with a 5 second delay or so between them to allow some time for reindexing.
#
# Example call
# 1) pick Dataset entities to change by querying Neo4J...
# URL: http://18.205.215.12:7474/browser/
# query: MATCH (e:Dataset {entity_type: 'Dataset'}) RETURN e.uuid, e.status, e.ingest_task, e.assigned_to_group_name LIMIT 100
#
# curl --request PUT \
# --url ${ENTITY_API}/datasets \
# --header "Content-Type: application/json" \
# --header "Authorization: Bearer ${TOKEN}" \
# --data '[{"uuid":"6ce8d4515bc87213e787397c2b4d2f99", "assigned_to_group_name":"TMC - Cal Tech"}, {"uuid":"a44a78bfbe0e702cdc172707b6061a16", "assigned_to_group_name":"TMC - Cal Tech"}]'
@app.route('/datasets', methods=['PUT'])
@app.route('/uploads', methods=['PUT'])
def entity_bulk_update():
Expand All @@ -4326,7 +4338,7 @@ def entity_bulk_update():
validate_token_if_auth_header_exists(request)
require_json(request)

entities = request.get_json().get('entities')
entities = request.get_json()
if entities is None or not isinstance(entities, list) or len(entities) == 0:
bad_request_error("Request object field 'entities' is either missing, "
"does not contain a list, or contains an empty list")
Expand Down Expand Up @@ -4539,7 +4551,7 @@ def validate_user_update_privilege(entity, user_token):
user_group_uuids = [d['uuid'] for d in user_write_groups]
if entity.get('group_uuid') not in user_group_uuids and is_admin is False:
forbidden_error(f"User does not have write privileges for this entity. "
f"Reach out to the help desk ([email protected]) to request access to group: {entity['group_uuid']}.")
"Please reach out to the help desk ([email protected]) to request access.")


"""
Expand Down

0 comments on commit 7798bf4

Please sign in to comment.