chef / automate

Chef Automate provides a full suite of enterprise capabilities for maintaining continuous visibility into application, infrastructure, and security automation.
https://automate.chef.io/
Apache License 2.0
227 stars 113 forks source link

Notification create API backend response changes #4074

Closed vinay033 closed 4 years ago

vinay033 commented 4 years ago

changes required for notification create API backend response

needed changes for https://github.com/chef/automate/issues/3708 right now we are getting below response from creating API

{
    "messages":[],
    "id":"b64ce0bc-c733-11ea-9b23-080027ee87c4"
}

but we needed to create API response like mentioned below

  1. response for SlackAlert
    {
    "messages":[],
    "rule": 
        {
            "id":"2d543148-c733-11ea-ac94-080027ee87c4",
            "name":"test1",
            "event":"CCRFailure",
            "SlackAlert": {
                "url":"http://requestbin.sjcmmsn.com/ys9bp7ys"
            }
        }
    }
  2. response for ServiceNowAlert
    {
    "messages":[],
    "rule":
        {
            "id":"3bae247e-c733-11ea-9cd1-080027ee87c4",
            "name":"test2",
            "event":"CCRFailure",
            "ServiceNowAlert": {
                "url":"http://requestbin.sjcmmsn.com/14m628s1",
                "secret_id":"a1e2f9a4-a577-4800-a56a-fd2a55676451",
                "critical_controls_only":false
            }
        }
    }
  3. response for WebhookAlert

    {   
    "messages":[],
    "rule":
    
        {
            "id":"454705d2-c733-11ea-a46b-080027ee87c4",
            "name":"test3",
            "event":"CCRFailure",
            "WebhookAlert": {
                "url":"https://a2-dev.test/settings/data-feed/form"
            }
        }
    }
satellite15 commented 4 years ago

Changing to this format would break the existing API contract. The Response is by definition a rule and thus the nested rule is not necessary and the response below would not break the current contract.

{
    "messages":[],
    "id":"2d543148-c733-11ea-ac94-080027ee87c4",
    "name":"test1",
    "event":"CCRFailure",
    "SlackAlert": {
        "url":"http://requestbin.sjcmmsn.com/ys9bp7ys"
     }
}
vinay033 commented 4 years ago

can we make it like

{   
    "messages":[],
    "id":"454705d2-c733-11ea-a46b-080027ee87c4", 
    "rule":
        {
            "id":"454705d2-c733-11ea-a46b-080027ee87c4",
            "name":"test3",
            "event":"CCRFailure",
            "WebhookAlert": {
                "url":"https://a2-dev.test/settings/data-feed/form"
            }
        }
}
satellite15 commented 4 years ago

I have pushed code changes to a branch https://github.com/chef/automate/compare/satellite15/%234074

I had to update the notifications_compile_protobuf function to include additional src directories as recent secrets.proto changes were breaking the build.

However I have problems compiling the notifications-service I get the following errors assembling the release


Generated notifications app
==> Assembling release..
==> Building release notifications:1.0.0 using environment habitat
==> Including ERTS 10.3 from /hab/pkgs/core/erlang/21.3/20200404003757/lib/erlang/erts-10.3
==> Release failed, during .boot generation:
        Duplicated modules: 
        'Elixir.Google.Protobuf.Value' specified in google_protos and notifications
        'Elixir.Google.Protobuf.Struct.FieldsEntry' specified in google_protos and notifications
        'Elixir.Google.Protobuf.Struct' specified in google_protos and notifications
        'Elixir.Google.Protobuf.NullValue' specified in google_protos and notifications
        'Elixir.Google.Protobuf.ListValue' specified in google_protos and notifications
   notifications-service: Build time: 2m44s
   notifications-service: Exiting on error

I haven't worked out what these are yet, maybe @lancewf could shed some light on these?

satellite15 commented 4 years ago

I have these build issues sorted. Now trying to make this work.

satellite15 commented 4 years ago

@vinay033 You can test with this branch https://github.com/chef/automate/compare/satellite15/%234074

You need to build the automate-gateway and notifications-service components and deploy them to receive the updated responses. I have them as originally requested.