Code Monkey home page Code Monkey logo

Comments (4)

jthurman42 avatar jthurman42 commented on June 15, 2024

Other alert condition types (all that I can tell) have PolicyID either in them or stitched in, so it seems reasonable to do so here as well.

from newrelic-client-go.

sanderblue avatar sanderblue commented on June 15, 2024

I think one use case and reason why PolicyID was stitched in to some struct was to facilitate terraform import for alert conditions, NRQL alert conditions, and plugins conditions.

Given the following HCL, it would be required to also have the alert policy defined as a separate block to import, but maybe someone didn't want to have both in their HCL.

resource "newrelic_alert_condition" "foo" {
  policy_id       = 123456
  name            = "foo"
  type            = "apm_app_metric"
  entities        = [654321]
  metric          = "apdex"
  condition_scope = "application"

  term {
    // ... 
  }
}

In order for terraform import newrelic_alert_condition.foo ... to work, since the API response for an alert channel doesn't contain a policy ID association anywhere, you would need to provide the policyID in some way. And since the Terraform read functionality doesn't have a way to read the policy_id directly from the HCL and policy_id does't exist in the state yet (hence the import), that's potentially one reason why it's stitched into the struct.

The stitched in PolicyID field is also used for create and is included in the return struct which is then used to create the ID hash of the resource.

If we removed PolicyID from the alerts.Condition struct, we would need to make sure we returned a tuple of the condition and the policy ID.

TL;DR It would appear that stitching the PolicyID might be a convenience thing vs a necessary thing, but the convenience factor seems to be pretty nice.

from newrelic-client-go.

sanderblue avatar sanderblue commented on June 15, 2024

We have consensus agreement that we should remove the transient PolicyID field from the following structs to facilitate a 1:1 mapping the associated API responses.

from newrelic-client-go.

zlesnr avatar zlesnr commented on June 15, 2024

Awesome. Good work here @sanderblue.

from newrelic-client-go.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.