Skip to content

Commit 7b568a1

Browse files
Webhook Templates Resources, Data sources, Subscription changes and Documentation Update (IBM-Cloud#5713)
1 parent 8b2bb36 commit 7b568a1

20 files changed

+806
-66
lines changed

go.mod

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ require (
1717
github.com/IBM/configuration-aggregator-go-sdk v0.0.1
1818
github.com/IBM/container-registry-go-sdk v1.1.0
1919
github.com/IBM/continuous-delivery-go-sdk v1.8.2
20-
github.com/IBM/event-notifications-go-admin-sdk v0.9.0
20+
github.com/IBM/event-notifications-go-admin-sdk v0.10.0
2121
github.com/IBM/eventstreams-go-sdk v1.4.0
2222
github.com/IBM/go-sdk-core v1.1.0
2323
github.com/IBM/go-sdk-core/v3 v3.2.4
@@ -63,7 +63,7 @@ require (
6363
github.com/rook/rook v1.11.4
6464
github.com/softlayer/softlayer-go v1.0.3
6565
github.com/stretchr/testify v1.9.0
66-
golang.org/x/crypto v0.25.0
66+
golang.org/x/crypto v0.27.0
6767
gopkg.in/yaml.v3 v3.0.1
6868
gotest.tools v2.2.0+incompatible
6969
k8s.io/api v0.26.3
@@ -105,7 +105,7 @@ require (
105105
github.com/fatih/color v1.16.0 // indirect
106106
github.com/frankban/quicktest v1.14.3 // indirect
107107
github.com/fsnotify/fsnotify v1.7.0 // indirect
108-
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
108+
github.com/gabriel-vasile/mimetype v1.4.5 // indirect
109109
github.com/go-jose/go-jose/v3 v3.0.3 // indirect
110110
github.com/go-logr/logr v1.4.1 // indirect
111111
github.com/go-logr/stdr v1.2.2 // indirect
@@ -121,7 +121,7 @@ require (
121121
github.com/go-ozzo/ozzo-validation/v4 v4.3.0 // indirect
122122
github.com/go-playground/locales v0.14.1 // indirect
123123
github.com/go-playground/universal-translator v0.18.1 // indirect
124-
github.com/go-playground/validator/v10 v10.22.0 // indirect
124+
github.com/go-playground/validator/v10 v10.22.1 // indirect
125125
github.com/gogo/protobuf v1.3.2 // indirect
126126
github.com/golang/protobuf v1.5.3 // indirect
127127
github.com/golang/snappy v0.0.4 // indirect
@@ -212,7 +212,7 @@ require (
212212
github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect
213213
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
214214
github.com/zclconf/go-cty v1.14.1 // indirect
215-
go.mongodb.org/mongo-driver v1.16.0 // indirect
215+
go.mongodb.org/mongo-driver v1.16.1 // indirect
216216
go.opentelemetry.io/otel v1.14.0 // indirect
217217
go.opentelemetry.io/otel/trace v1.14.0 // indirect
218218
go.uber.org/ratelimit v0.2.0 // indirect

go.sum

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ github.com/IBM/container-registry-go-sdk v1.1.0 h1:sYyknIod8R4RJZQqAheiduP6wbSTp
142142
github.com/IBM/container-registry-go-sdk v1.1.0/go.mod h1:4TwsCnQtVfZ4Vkapy/KPvQBKFc3VOyUZYkwRU4FTPrs=
143143
github.com/IBM/continuous-delivery-go-sdk v1.8.2 h1:L2hyoJSxgCa0/HKviHKtut1z4Mn2qGz1gnJZ43LV0o0=
144144
github.com/IBM/continuous-delivery-go-sdk v1.8.2/go.mod h1:5umVUaXEoTP2ULARgXRBPcR3vWDCmKD66P6XgNqpzZk=
145-
github.com/IBM/event-notifications-go-admin-sdk v0.9.0 h1:eaCd+GkxhNyot+8rA9WkAQdlVYrRD20LYiXjEytFO6M=
146-
github.com/IBM/event-notifications-go-admin-sdk v0.9.0/go.mod h1:OByvqfrNVxs7G6ggv8pwQCEVw10/TBJCLh7NM3z707w=
145+
github.com/IBM/event-notifications-go-admin-sdk v0.10.0 h1:SbEG6Z9lJWQxNYexYmLRzF+seFokOW7bRKBgiyfYsls=
146+
github.com/IBM/event-notifications-go-admin-sdk v0.10.0/go.mod h1:za2mdfBpox6hdsKaYTbE5ooCv2im8BYPq5yuKc7x5Ao=
147147
github.com/IBM/eventstreams-go-sdk v1.4.0 h1:yS/Ns29sBOe8W2tynQmz9HTKqQZ0ckse4Py5Oy/F2rM=
148148
github.com/IBM/eventstreams-go-sdk v1.4.0/go.mod h1:2tuAxaYLctfqfr5jvyqSrxxEQGMwYPm3yJGWSj85YVQ=
149149
github.com/IBM/go-sdk-core v1.1.0 h1:pV73lZqr9r1xKb3h08c1uNG3AphwoV5KzUzhS+pfEqY=
@@ -491,8 +491,9 @@ github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbS
491491
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
492492
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
493493
github.com/fullsailor/pkcs7 v0.0.0-20190404230743-d7302db945fa/go.mod h1:KnogPXtdwXqoenmZCw6S+25EAm2MkxbG0deNDu4cbSA=
494-
github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0=
495494
github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk=
495+
github.com/gabriel-vasile/mimetype v1.4.5 h1:J7wGKdGu33ocBOhGy0z653k/lFKLFDPJMG8Gql0kxn4=
496+
github.com/gabriel-vasile/mimetype v1.4.5/go.mod h1:ibHel+/kbxn9x2407k1izTA1S81ku1z/DlgOW2QE0M4=
496497
github.com/gammazero/deque v0.0.0-20190130191400-2afb3858e9c7/go.mod h1:GeIq9qoE43YdGnDXURnmKTnGg15pQz4mYkXSTChbneI=
497498
github.com/gammazero/workerpool v0.0.0-20190406235159-88d534f22b56/go.mod h1:w9RqFVO2BM3xwWEcAB8Fwp0OviTBBEiRmSBDfbXnd3w=
498499
github.com/getkin/kin-openapi v0.76.0/go.mod h1:660oXbgy5JFMKreazJaQTw7o+X00qeSyhcnluiMv+Xg=
@@ -638,8 +639,8 @@ github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl
638639
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
639640
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
640641
github.com/go-playground/validator/v10 v10.19.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM=
641-
github.com/go-playground/validator/v10 v10.22.0 h1:k6HsTZ0sTnROkhS//R0O+55JgM8C4Bx7ia+JlgcnOao=
642-
github.com/go-playground/validator/v10 v10.22.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM=
642+
github.com/go-playground/validator/v10 v10.22.1 h1:40JcKH+bBNGFczGuoBYgX4I6m/i27HYW8P9FDk5PbgA=
643+
github.com/go-playground/validator/v10 v10.22.1/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM=
643644
github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
644645
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
645646
github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE=
@@ -1709,8 +1710,8 @@ go.mongodb.org/mongo-driver v1.7.5/go.mod h1:VXEWRZ6URJIkUq2SCAyapmhH0ZLRBP+FT4x
17091710
go.mongodb.org/mongo-driver v1.10.0/go.mod h1:wsihk0Kdgv8Kqu1Anit4sfK+22vSFbUrAVEYRhCXrA8=
17101711
go.mongodb.org/mongo-driver v1.11.3/go.mod h1:PTSz5yu21bkT/wXpkS7WR5f0ddqw5quethTUn9WM+2g=
17111712
go.mongodb.org/mongo-driver v1.14.0/go.mod h1:Vzb0Mk/pa7e6cWw85R4F/endUC3u0U9jGcNU603k65c=
1712-
go.mongodb.org/mongo-driver v1.16.0 h1:tpRsfBJMROVHKpdGyc1BBEzzjDUWjItxbVSZ8Ls4BQ4=
1713-
go.mongodb.org/mongo-driver v1.16.0/go.mod h1:oB6AhJQvFQL4LEHyXi6aJzQJtBiTQHiAd83l0GdFaiw=
1713+
go.mongodb.org/mongo-driver v1.16.1 h1:rIVLL3q0IHM39dvE+z2ulZLp9ENZKThVfuvN/IiN4l8=
1714+
go.mongodb.org/mongo-driver v1.16.1/go.mod h1:oB6AhJQvFQL4LEHyXi6aJzQJtBiTQHiAd83l0GdFaiw=
17141715
go.opencensus.io v0.19.1/go.mod h1:gug0GbSHa8Pafr0d2urOSgoXHZ6x/RUlaiT0d9pqb4A=
17151716
go.opencensus.io v0.19.2/go.mod h1:NO/8qkisMZLZ1FCsKNqtJPwc8/TaclWyY0B6wcYNg9M=
17161717
go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk=
@@ -1789,8 +1790,8 @@ golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq
17891790
golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
17901791
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
17911792
golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs=
1792-
golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30=
1793-
golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M=
1793+
golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A=
1794+
golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
17941795
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
17951796
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
17961797
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
@@ -1919,8 +1920,8 @@ golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
19191920
golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U=
19201921
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
19211922
golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
1922-
golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys=
1923-
golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE=
1923+
golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo=
1924+
golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0=
19241925
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
19251926
golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
19261927
golang.org/x/oauth2 v0.0.0-20190130055435-99b60b757ec1/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
@@ -1958,8 +1959,8 @@ golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
19581959
golang.org/x/sync v0.2.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
19591960
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
19601961
golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
1961-
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
1962-
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
1962+
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
1963+
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
19631964
golang.org/x/sys v0.0.0-20170830134202-bb24a47a89ea/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
19641965
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
19651966
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
@@ -2091,8 +2092,8 @@ golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U=
20912092
golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0=
20922093
golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
20932094
golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58=
2094-
golang.org/x/term v0.22.0 h1:BbsgPEJULsl2fV/AT3v15Mjva5yXKQDyKf+TbDz7QJk=
2095-
golang.org/x/term v0.22.0/go.mod h1:F3qCibpT5AMpCRfhfT53vVJwhLtIVHhB9XDjfFvnMI4=
2095+
golang.org/x/term v0.24.0 h1:Mh5cbb+Zk2hqqXNO7S1iTjEphVL+jb8ZWaqh/g+JWkM=
2096+
golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8=
20962097
golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
20972098
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
20982099
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
@@ -2115,8 +2116,8 @@ golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
21152116
golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
21162117
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
21172118
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
2118-
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
2119-
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
2119+
golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
2120+
golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
21202121
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
21212122
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
21222123
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=

ibm/provider/provider.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -914,6 +914,7 @@ func Provider() *schema.Provider {
914914
"ibm_en_slack_template": eventnotification.DataSourceIBMEnSlackTemplate(),
915915
"ibm_en_metrics": eventnotification.DataSourceIBMEnMetrics(),
916916
"ibm_en_smtp_allowed_ips": eventnotification.DataSourceIBMEnSMTPAllowedIps(),
917+
"ibm_en_webhook_template": eventnotification.DataSourceIBMEnWebhookTemplate(),
917918

918919
// Added for Toolchain
919920
"ibm_cd_toolchain": cdtoolchain.DataSourceIBMCdToolchain(),
@@ -1535,6 +1536,7 @@ func Provider() *schema.Provider {
15351536
"ibm_en_smtp_user": eventnotification.ResourceIBMEnSMTPUser(),
15361537
"ibm_en_slack_template": eventnotification.ResourceIBMEnSlackTemplate(),
15371538
"ibm_en_smtp_setting": eventnotification.ResourceIBMEnSMTPSetting(),
1539+
"ibm_en_webhook_template": eventnotification.ResourceIBMEnWebhookTemplate(),
15381540

15391541
// Added for Toolchain
15401542
"ibm_cd_toolchain": cdtoolchain.ResourceIBMCdToolchain(),

ibm/service/eventnotification/data_source_ibm_en_Webhook_subscription.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ func DataSourceIBMEnWebhookSubscription() *schema.Resource {
5959
Computed: true,
6060
Description: "Signing webhook attributes.",
6161
},
62+
"template_id_notification": {
63+
Type: schema.TypeString,
64+
Computed: true,
65+
Description: "The templete id for notification",
66+
},
6267
"additional_properties": {
6368
Type: schema.TypeMap,
6469
Computed: true,
@@ -145,6 +150,10 @@ func enWebhookSubscriptionToMap(attributeItem *en.SubscriptionAttributes) (attri
145150
attributeMap["signing_enabled"] = attributeItem.SigningEnabled
146151
}
147152

153+
if attributeItem.TemplateIDNotification != nil {
154+
attributeMap["template_id_notification"] = attributeItem.TemplateIDNotification
155+
}
156+
148157
attributeMap["additional_properties"] = attributeItem.GetProperties()
149158

150159
return attributeMap

ibm/service/eventnotification/data_source_ibm_en_slack_subscription.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,14 @@ func DataSourceIBMEnSlackSubscription() *schema.Resource {
5656
Schema: map[string]*schema.Schema{
5757
"attachment_color": {
5858
Type: schema.TypeString,
59-
Optional: true,
59+
Computed: true,
6060
Description: "attachment color code",
6161
},
62+
"template_id_notification": {
63+
Type: schema.TypeString,
64+
Computed: true,
65+
Description: "The templete id for notification",
66+
},
6267
"channels": &schema.Schema{
6368
Type: schema.TypeList,
6469
Computed: true,
@@ -151,6 +156,10 @@ func enSlackSubscriptionToMap(attributeItem *en.SubscriptionAttributes) (attribu
151156
attributeMap["attachment_color"] = attributeItem.AttachmentColor
152157
}
153158

159+
if attributeItem.TemplateIDNotification != nil {
160+
attributeMap["template_id_notification"] = attributeItem.TemplateIDNotification
161+
}
162+
154163
if attributeItem.Channels != nil {
155164
channels := []map[string]interface{}{}
156165
for _, channelsItem := range attributeItem.Channels {

ibm/service/eventnotification/data_source_ibm_en_slack_template.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func DataSourceIBMEnSlackTemplate() *schema.Resource {
4242
"type": {
4343
Type: schema.TypeString,
4444
Computed: true,
45-
Description: "Template type smtp_custom.notification/smtp_custom.invitation.",
45+
Description: "Template type slack.notification.",
4646
},
4747
"updated_at": {
4848
Type: schema.TypeString,

ibm/service/eventnotification/data_source_ibm_en_subscription_email.go

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -77,24 +77,6 @@ func DataSourceIBMEnEmailSubscription() *schema.Resource {
7777
Computed: true,
7878
Description: "The email address username of source email address.",
7979
},
80-
// "invited": {
81-
// Type: schema.TypeList,
82-
// Optional: true,
83-
// Computed: true,
84-
// Description: "The email id to be invited",
85-
// },
86-
// "subscribed": {
87-
// Type: schema.TypeList,
88-
// Optional: true,
89-
// Computed: true,
90-
// Description: "The Email address which should be subscribed from smtp_ibm.",
91-
// },
92-
// "unsubscribed": {
93-
// Type: schema.TypeList,
94-
// Optional: true,
95-
// Computed: true,
96-
// Description: "The Email address which should be unsubscribed from smtp_ibm.",
97-
// },
9880
"invited": {
9981
Type: schema.TypeList,
10082
Computed: true,
@@ -230,22 +212,6 @@ func enEmailSubscriptionFlattenAttributes(result en.SubscriptionAttributesIntf)
230212
attributes := result.(*en.SubscriptionAttributes)
231213

232214
finalMap := enEmailSubscriptionToMap(attributes)
233-
// finalList = append(finalList, finalMap)
234-
// invitedmap := make(map[string]interface{})
235-
// if attributes.Invited != nil {
236-
// invitedmap["invited"] = attributes.Invited
237-
// }
238-
// finalList = append(finalList, invitedmap)
239-
// subscribedmap := make(map[string]interface{})
240-
// if attributes.Subscribed != nil {
241-
// subscribedmap["subscribed"] = attributes.Subscribed
242-
// }
243-
// finalList = append(finalList, subscribedmap)
244-
// unsubscribedmap := make(map[string]interface{})
245-
// if attributes.Unsubscribed != nil {
246-
// unsubscribedmap["unsubscribed"] = attributes.Unsubscribed
247-
// }
248-
// finalList = append(finalList, unsubscribedmap)
249215
finalList = append(finalList, finalMap)
250216

251217
return finalList
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
// Copyright IBM Corp. 2021 All Rights Reserved.
2+
// Licensed under the Mozilla Public License v2.0
3+
4+
package eventnotification
5+
6+
import (
7+
"context"
8+
"fmt"
9+
10+
"github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns"
11+
"github.com/IBM-Cloud/terraform-provider-ibm/ibm/flex"
12+
en "github.com/IBM/event-notifications-go-admin-sdk/eventnotificationsv1"
13+
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
14+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
15+
)
16+
17+
func DataSourceIBMEnWebhookTemplate() *schema.Resource {
18+
return &schema.Resource{
19+
ReadContext: dataSourceIBMEnWebhookTemplateRead,
20+
21+
Schema: map[string]*schema.Schema{
22+
"instance_guid": {
23+
Type: schema.TypeString,
24+
Required: true,
25+
Description: "Unique identifier for IBM Cloud Event Notifications instance.",
26+
},
27+
"template_id": {
28+
Type: schema.TypeString,
29+
Required: true,
30+
Description: "Unique identifier for Template.",
31+
},
32+
"name": {
33+
Type: schema.TypeString,
34+
Computed: true,
35+
Description: "Template name.",
36+
},
37+
"description": {
38+
Type: schema.TypeString,
39+
Computed: true,
40+
Description: "Templaten description.",
41+
},
42+
"type": {
43+
Type: schema.TypeString,
44+
Computed: true,
45+
Description: "Template type webhook.notification.",
46+
},
47+
"updated_at": {
48+
Type: schema.TypeString,
49+
Computed: true,
50+
Description: "Last updated time.",
51+
},
52+
"subscription_count": {
53+
Type: schema.TypeInt,
54+
Computed: true,
55+
Description: "Number of subscriptions.",
56+
},
57+
"subscription_names": {
58+
Type: schema.TypeList,
59+
Computed: true,
60+
Description: "List of subscriptions.",
61+
Elem: &schema.Schema{
62+
Type: schema.TypeString,
63+
},
64+
},
65+
},
66+
}
67+
}
68+
69+
func dataSourceIBMEnWebhookTemplateRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
70+
enClient, err := meta.(conns.ClientSession).EventNotificationsApiV1()
71+
if err != nil {
72+
return diag.FromErr(err)
73+
}
74+
75+
options := &en.GetTemplateOptions{}
76+
77+
options.SetInstanceID(d.Get("instance_guid").(string))
78+
options.SetID(d.Get("template_id").(string))
79+
80+
result, response, err := enClient.GetTemplateWithContext(context, options)
81+
if err != nil {
82+
return diag.FromErr(fmt.Errorf("GetTemplate failed %s\n%s", err, response))
83+
}
84+
85+
d.SetId(fmt.Sprintf("%s/%s", *options.InstanceID, *options.ID))
86+
87+
if err = d.Set("name", result.Name); err != nil {
88+
return diag.FromErr(fmt.Errorf("[ERROR] Error setting name: %s", err))
89+
}
90+
91+
if result.Description != nil {
92+
if err = d.Set("description", result.Description); err != nil {
93+
return diag.FromErr(fmt.Errorf("[ERROR] Error setting description: %s", err))
94+
}
95+
}
96+
97+
if err = d.Set("type", result.Type); err != nil {
98+
return diag.FromErr(fmt.Errorf("[ERROR] Error setting type: %s", err))
99+
}
100+
101+
if result.SubscriptionNames != nil {
102+
err = d.Set("subscription_names", result.SubscriptionNames)
103+
if err != nil {
104+
return diag.FromErr(fmt.Errorf("[ERROR] Error setting subscription_names %s", err))
105+
}
106+
}
107+
108+
if err = d.Set("updated_at", flex.DateTimeToString(result.UpdatedAt)); err != nil {
109+
return diag.FromErr(fmt.Errorf("[ERROR] Error setting updated_at: %s", err))
110+
}
111+
112+
if err = d.Set("subscription_count", flex.IntValue(result.SubscriptionCount)); err != nil {
113+
return diag.FromErr(fmt.Errorf("[ERROR] Error setting subscription_count: %s", err))
114+
}
115+
116+
return nil
117+
}

0 commit comments

Comments
 (0)