arazzo: 1.0.1 info: title: New Relic Associate Entity With Condition summary: Create a policy condition then associate an entity with it. description: >- Targets a specific entity with an alert condition. The workflow resolves a policy by name, creates a metric condition on it, and then associates a named entity with that condition so the condition evaluates against the chosen entity. Every step spells out its request inline so the flow can be read and executed without opening the underlying OpenAPI description. version: 1.0.0 sourceDescriptions: - name: newRelicApi url: ../openapi/new-relic-openapi.yml type: openapi workflows: - workflowId: associate-entity-with-condition summary: Create a condition on a policy then bind an entity to it. description: >- Resolves the policy id by name, creates a metric condition, captures the new condition id, and associates an entity with that condition. inputs: type: object required: - policyName - conditionName - conditionType - metric - entityId - entityType properties: policyName: type: string description: The exact name of the alert policy to create the condition on. conditionName: type: string description: A title for the alert condition. conditionType: type: string description: Condition type (e.g. apm_app_metric, browser_metric). metric: type: string description: The metric the condition evaluates. entityId: type: integer description: The id of the entity to associate with the condition. entityType: type: string description: The entity type (BrowserApplication, Application, MobileApplication, Server, KeyTransaction). steps: - stepId: findPolicy description: Resolve the alert policy id by exact name. operationId: getAlertsPolicies parameters: - name: filter[name] in: query value: $inputs.policyName successCriteria: - condition: $statusCode == 200 outputs: policyId: $response.body#/policy/id - stepId: createCondition description: >- Create a metric condition on the resolved policy, returning the condition id used for the entity association. operationId: postAlertsConditionsPoliciesPolicyId parameters: - name: policy_id in: path value: $steps.findPolicy.outputs.policyId requestBody: contentType: application/json payload: condition: name: $inputs.conditionName type: $inputs.conditionType metric: $inputs.metric enabled: true successCriteria: - condition: $statusCode == 200 outputs: conditionId: $response.body#/condition/id - stepId: associateEntity description: >- Associate the supplied entity with the new condition so the condition evaluates specifically against that entity. operationId: putAlertsEntityConditionsEntityId parameters: - name: entity_id in: path value: $inputs.entityId - name: entity_type in: query value: $inputs.entityType - name: condition_id in: query value: $steps.createCondition.outputs.conditionId successCriteria: - condition: $statusCode == 200 outputs: condition: $response.body#/condition outputs: policyId: $steps.findPolicy.outputs.policyId conditionId: $steps.createCondition.outputs.conditionId