Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions finite_state_sdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,34 @@ def create_asset(token, organization_context, business_unit_id=None, created_by_
response = send_graphql_query(token, organization_context, graphql_query, variables)
return response['data']

"""
Call updateAsset to set the defaultVersion to the newly created AssetVersion
"""
def update_asset(token, organization_context, asset_id, asset_version_id):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Documentation for any functions in the SDK are auto-generated, so we need to update this to have the correct format (see other functions for examples)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I think the parameters should be named parameters, and make it clear that it is setting the default version, e.g. default_version=

graphql_query = '''
mutation UpdateAssetMutation($input: UpdateAssetInput!) {
updateAsset(input: $input) {
id
name
defaultVersion {
id
}
versions {
id
}
}
}
'''

variables = {
"input": {
"id": asset_id,
"defaultVersion": asset_version_id
}
}

response = send_graphql_query(token, organization_context, graphql_query, variables)
return response['data']

def create_asset_version(token, organization_context, business_unit_id=None, created_by_user_id=None, asset_id=None, asset_version_name=None, product_id=None):
"""
Expand Down Expand Up @@ -246,6 +274,11 @@ def create_asset_version(token, organization_context, business_unit_id=None, cre
variables["input"]["ctx"]["products"] = product_id

response = send_graphql_query(token, organization_context, graphql_query, variables)

if response.ok:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: GraphQL return values can be HTTP "OK", but contain errors in the return value instead of "data". The send_graphql_query checks for this, and raises an exception with the errors if the response contains errors - I'll add a test for this, because the response is not a requests object, but the actual JSON that gets returned

asset_version_id = response['data']['createAssetVersion']['id']
update_asset(token, organization_context, asset_id, asset_version_id)

return response['data']


Expand Down