-
Couldn't load subscription status.
- Fork 2
[ASOC-2016] update asset default version after creating a new asset version #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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): | ||
| 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): | ||
| """ | ||
|
|
@@ -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: | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
| asset_version_id = response['data']['createAssetVersion']['id'] | ||
| update_asset(token, organization_context, asset_id, asset_version_id) | ||
|
|
||
| return response['data'] | ||
|
|
||
|
|
||
|
|
||
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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=