Skip to content

Commit

Permalink
Update query to create expansion rules
Browse files Browse the repository at this point in the history
  • Loading branch information
cartermak committed Jan 30, 2024
1 parent c515010 commit 025feaa
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions src/aerie_cli/aerie_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -853,6 +853,8 @@ def create_expansion_rule(
activity_name: str,
model_id: str,
command_dictionary_id: str,
name: str = None,
description: str = None
) -> int:
"""Submit expansion logic to an Aerie instance
Expand All @@ -861,34 +863,31 @@ def create_expansion_rule(
activity_name (str): Name of the activity
model_id (str): Aerie model ID
command_dictionary_id (str): Aerie command dictionary ID
name (str, Optional): Name of the expansion rule
description (str, Optional): Description of the expansion rule
Returns:
int: Expansion Rule ID in Aerie
"""

create_expansion_logic_query = """
mutation UploadExpansionLogic(
$activity_type_name: String!
$expansion_logic: String!
$command_dictionary_id: Int!
$mission_model_id: Int!
) {
addCommandExpansionTypeScript(
activityTypeName: $activity_type_name
expansionLogic: $expansion_logic
authoringCommandDictionaryId: $command_dictionary_id
authoringMissionModelId: $mission_model_id
) {
mutation CreateExpansionRule($rule: expansion_rule_insert_input!) {
createExpansionRule: insert_expansion_rule_one(object: $rule) {
id
}
}
"""
rule = {
"activity_type": activity_name,
"authoring_command_dict_id": command_dictionary_id,
"authoring_mission_model_id": model_id,
"expansion_logic": expansion_logic,
"name": name if (name is not None) else activity_name + arrow.utcnow().format("_YYYY-MM-DDTHH-mm-ss"),
"description": description if (description is not None) else ""
}
data = self.aerie_host.post_to_graphql(
create_expansion_logic_query,
activity_type_name=activity_name,
expansion_logic=expansion_logic,
mission_model_id=model_id,
command_dictionary_id=command_dictionary_id,
rule=rule
)

return data["id"]
Expand Down

0 comments on commit 025feaa

Please sign in to comment.