From 38dd6a7118f7a25dec96d8e2463bc5038f8997ff Mon Sep 17 00:00:00 2001 From: skarimo Date: Mon, 27 Apr 2020 14:04:10 -0400 Subject: [PATCH] update resource metric_metadata to utilize Datadog go client and update cassettes --- .../TestAccDatadogMetricMetadata_Basic.freeze | 2 +- .../TestAccDatadogMetricMetadata_Basic.yaml | 106 +++++---- ...estAccDatadogMetricMetadata_Updated.freeze | 2 +- .../TestAccDatadogMetricMetadata_Updated.yaml | 206 +++++++++++------- datadog/resource_datadog_metric_metadata.go | 42 ++-- 5 files changed, 217 insertions(+), 141 deletions(-) diff --git a/datadog/cassettes/TestAccDatadogMetricMetadata_Basic.freeze b/datadog/cassettes/TestAccDatadogMetricMetadata_Basic.freeze index a828ac6a5..e124e6f2b 100644 --- a/datadog/cassettes/TestAccDatadogMetricMetadata_Basic.freeze +++ b/datadog/cassettes/TestAccDatadogMetricMetadata_Basic.freeze @@ -1 +1 @@ -2020-03-16T14:05:11.225471+01:00 \ No newline at end of file +2020-04-27T14:03:32.36541-04:00 \ No newline at end of file diff --git a/datadog/cassettes/TestAccDatadogMetricMetadata_Basic.yaml b/datadog/cassettes/TestAccDatadogMetricMetadata_Basic.yaml index 4aec79f4d..752740ae3 100644 --- a/datadog/cassettes/TestAccDatadogMetricMetadata_Basic.yaml +++ b/datadog/cassettes/TestAccDatadogMetricMetadata_Basic.yaml @@ -2,14 +2,18 @@ version: 1 interactions: - request: - body: '{"type":"gauge","description":"some description","short_name":"short name - for metric_metadata foo","unit":"byte","per_unit":"second","statsd_interval":1}' + body: | + {"description":"some description","per_unit":"second","short_name":"short name for metric_metadata foo","statsd_interval":1,"type":"gauge","unit":"byte"} form: {} headers: + Accept: + - application/json Content-Type: - application/json + Dd-Operation-Id: + - UpdateMetricMetadata User-Agent: - - Datadog/dev/terraform (go1.13) + - datadog-api-client-go/1.0.0-beta.1+dev.1 (go go1.13.4; os darwin; arch amd64) url: https://api.datadoghq.com/api/v1/metrics/foo method: PUT response: @@ -25,13 +29,13 @@ interactions: Content-Type: - application/json Date: - - Mon, 16 Mar 2020 13:05:11 GMT + - Mon, 27 Apr 2020 18:03:32 GMT Dd-Pool: - dogweb_events Pragma: - no-cache Set-Cookie: - - DD-PSHARD=233; Max-Age=604800; Path=/; expires=Mon, 23-Mar-2020 13:05:10 GMT; + - DD-PSHARD=233; Max-Age=604800; Path=/; expires=Mon, 04-May-2020 18:03:32 GMT; secure; HttpOnly Strict-Transport-Security: - max-age=15724800; @@ -40,9 +44,9 @@ interactions: X-Content-Type-Options: - nosniff X-Dd-Debug: - - Hg0qbUWq3UNc1+Z0ILmqwiuwRGxW+Dbzjjt0JbVwnaO1iSOIZ33BCjpcfkWZbyrs + - TOJ8EU/Z0l7vO3mGB6xZoJHKsRes/sigTytHkDjWxs5OSPKBGX/xh2ufITzyawaI X-Dd-Version: - - "35.2282030" + - "35.2439015" X-Frame-Options: - SAMEORIGIN X-Ratelimit-Limit: @@ -52,7 +56,7 @@ interactions: X-Ratelimit-Remaining: - "1999" X-Ratelimit-Reset: - - "50" + - "28" status: 200 OK code: 200 duration: "" @@ -60,8 +64,12 @@ interactions: body: "" form: {} headers: + Accept: + - application/json + Dd-Operation-Id: + - GetMetricMetadata User-Agent: - - Datadog/dev/terraform (go1.13) + - datadog-api-client-go/1.0.0-beta.1+dev.1 (go go1.13.4; os darwin; arch amd64) url: https://api.datadoghq.com/api/v1/metrics/foo method: GET response: @@ -77,13 +85,13 @@ interactions: Content-Type: - application/json Date: - - Mon, 16 Mar 2020 13:05:11 GMT + - Mon, 27 Apr 2020 18:03:32 GMT Dd-Pool: - dogweb_events Pragma: - no-cache Set-Cookie: - - DD-PSHARD=233; Max-Age=604800; Path=/; expires=Mon, 23-Mar-2020 13:05:11 GMT; + - DD-PSHARD=233; Max-Age=604800; Path=/; expires=Mon, 04-May-2020 18:03:32 GMT; secure; HttpOnly Strict-Transport-Security: - max-age=15724800; @@ -92,22 +100,22 @@ interactions: X-Content-Type-Options: - nosniff X-Dd-Debug: - - z/KKCx268mojs/b9jMof/H+B6sr+/7w434aVzi5OU2tFfYXahuXL/mYd/rey3jWy + - Bz3SBKuYZzK/+BkeBBXRw0olUGHa30rRM6UA2kojrkjvqW/EYpJqZatXHCNLCO6m X-Dd-Version: - - "35.2282030" + - "35.2439015" X-Frame-Options: - SAMEORIGIN status: 200 OK code: 200 duration: "" - request: - body: '{"series":[{"metric":"foo","points":[[1584363911,1]]}]}' + body: '{"series":[{"metric":"foo","points":[[1588010612,1]]}]}' form: {} headers: Content-Type: - application/json User-Agent: - - Datadog/dev/terraform (go1.13) + - Datadog/dev/terraform (go1.13.4) url: https://api.datadoghq.com/api/v1/series method: POST response: @@ -122,7 +130,7 @@ interactions: Content-Type: - text/json Date: - - Mon, 16 Mar 2020 13:05:11 GMT + - Mon, 27 Apr 2020 18:03:32 GMT Dd-Pool: - propjoe Strict-Transport-Security: @@ -139,7 +147,7 @@ interactions: form: {} headers: User-Agent: - - Datadog/dev/terraform (go1.13) + - Datadog/dev/terraform (go1.13.4) url: https://api.datadoghq.com/api/v1/metrics/foo method: GET response: @@ -155,13 +163,13 @@ interactions: Content-Type: - application/json Date: - - Mon, 16 Mar 2020 13:05:11 GMT + - Mon, 27 Apr 2020 18:03:32 GMT Dd-Pool: - dogweb_events Pragma: - no-cache Set-Cookie: - - DD-PSHARD=233; Max-Age=604800; Path=/; expires=Mon, 23-Mar-2020 13:05:11 GMT; + - DD-PSHARD=233; Max-Age=604800; Path=/; expires=Mon, 04-May-2020 18:03:32 GMT; secure; HttpOnly Strict-Transport-Security: - max-age=15724800; @@ -170,9 +178,9 @@ interactions: X-Content-Type-Options: - nosniff X-Dd-Debug: - - hvrOLb8Aw5n8m2huOQoduWv7l3WxC3IMnAmJ2uPbLp2pSuXr/WvagTn4Htqb0MaF + - t8tEO+HpUpG1Qs+j+ZeM2/gjIL2TAAtoLRq9Q1p4qDsym6iP/JukAQ1FzBM1jBsk X-Dd-Version: - - "35.2282030" + - "35.2439015" X-Frame-Options: - SAMEORIGIN status: 200 OK @@ -182,8 +190,12 @@ interactions: body: "" form: {} headers: + Accept: + - application/json + Dd-Operation-Id: + - GetMetricMetadata User-Agent: - - Datadog/dev/terraform (go1.13) + - datadog-api-client-go/1.0.0-beta.1+dev.1 (go go1.13.4; os darwin; arch amd64) url: https://api.datadoghq.com/api/v1/metrics/foo method: GET response: @@ -199,13 +211,13 @@ interactions: Content-Type: - application/json Date: - - Mon, 16 Mar 2020 13:05:11 GMT + - Mon, 27 Apr 2020 18:03:32 GMT Dd-Pool: - dogweb_events Pragma: - no-cache Set-Cookie: - - DD-PSHARD=233; Max-Age=604800; Path=/; expires=Mon, 23-Mar-2020 13:05:11 GMT; + - DD-PSHARD=233; Max-Age=604800; Path=/; expires=Mon, 04-May-2020 18:03:32 GMT; secure; HttpOnly Strict-Transport-Security: - max-age=15724800; @@ -214,9 +226,9 @@ interactions: X-Content-Type-Options: - nosniff X-Dd-Debug: - - DVnTXELnQR9QWqm0kffLcrAYUBO0NmNiRBVL+E/lBJmQrmPQPgP9PD6n7jaY8zSj + - 7MHOK9xH21KpxQmKlhxDPEd/SptvCYwy5bui3s4ZObk/QEBh0bNW5oyU+/uld+r8 X-Dd-Version: - - "35.2282030" + - "35.2439015" X-Frame-Options: - SAMEORIGIN status: 200 OK @@ -226,8 +238,12 @@ interactions: body: "" form: {} headers: + Accept: + - application/json + Dd-Operation-Id: + - GetMetricMetadata User-Agent: - - Datadog/dev/terraform (go1.13) + - datadog-api-client-go/1.0.0-beta.1+dev.1 (go go1.13.4; os darwin; arch amd64) url: https://api.datadoghq.com/api/v1/metrics/foo method: GET response: @@ -243,13 +259,13 @@ interactions: Content-Type: - application/json Date: - - Mon, 16 Mar 2020 13:05:11 GMT + - Mon, 27 Apr 2020 18:03:32 GMT Dd-Pool: - dogweb_events Pragma: - no-cache Set-Cookie: - - DD-PSHARD=233; Max-Age=604800; Path=/; expires=Mon, 23-Mar-2020 13:05:11 GMT; + - DD-PSHARD=233; Max-Age=604800; Path=/; expires=Mon, 04-May-2020 18:03:32 GMT; secure; HttpOnly Strict-Transport-Security: - max-age=15724800; @@ -258,9 +274,9 @@ interactions: X-Content-Type-Options: - nosniff X-Dd-Debug: - - e9PSFCVReAHo33fC5ZlYB0o5MG2bXGZpmWQWKX+H9cA7jxeT4SnUfc/nZKlRzoI4 + - nkKTvUHT89oYIwb+2s0QkDxhTrg05HH7W3Vd7sGZKit0kWt8SnmuA8wQFRSa51WK X-Dd-Version: - - "35.2282030" + - "35.2439015" X-Frame-Options: - SAMEORIGIN status: 200 OK @@ -270,8 +286,12 @@ interactions: body: "" form: {} headers: + Accept: + - application/json + Dd-Operation-Id: + - GetMetricMetadata User-Agent: - - Datadog/dev/terraform (go1.13) + - datadog-api-client-go/1.0.0-beta.1+dev.1 (go go1.13.4; os darwin; arch amd64) url: https://api.datadoghq.com/api/v1/metrics/foo method: GET response: @@ -287,13 +307,13 @@ interactions: Content-Type: - application/json Date: - - Mon, 16 Mar 2020 13:05:11 GMT + - Mon, 27 Apr 2020 18:03:32 GMT Dd-Pool: - dogweb_events Pragma: - no-cache Set-Cookie: - - DD-PSHARD=233; Max-Age=604800; Path=/; expires=Mon, 23-Mar-2020 13:05:11 GMT; + - DD-PSHARD=233; Max-Age=604800; Path=/; expires=Mon, 04-May-2020 18:03:32 GMT; secure; HttpOnly Strict-Transport-Security: - max-age=15724800; @@ -302,9 +322,9 @@ interactions: X-Content-Type-Options: - nosniff X-Dd-Debug: - - Ck6no/k62ihPULFZ1okt85zjeCW4gMe1FK8hD9i7msKeA+3cNc5MnSY0hI/nQDM3 + - IxwolBfkUDyUlBmmJW5LL5nADcdmnYQkEcHRVj7zszHJaN1uRcdfLGOUPjz0AX7/ X-Dd-Version: - - "35.2282030" + - "35.2439015" X-Frame-Options: - SAMEORIGIN status: 200 OK @@ -314,8 +334,12 @@ interactions: body: "" form: {} headers: + Accept: + - application/json + Dd-Operation-Id: + - GetMetricMetadata User-Agent: - - Datadog/dev/terraform (go1.13) + - datadog-api-client-go/1.0.0-beta.1+dev.1 (go go1.13.4; os darwin; arch amd64) url: https://api.datadoghq.com/api/v1/metrics/foo method: GET response: @@ -331,13 +355,13 @@ interactions: Content-Type: - application/json Date: - - Mon, 16 Mar 2020 13:05:12 GMT + - Mon, 27 Apr 2020 18:03:32 GMT Dd-Pool: - dogweb_events Pragma: - no-cache Set-Cookie: - - DD-PSHARD=233; Max-Age=604800; Path=/; expires=Mon, 23-Mar-2020 13:05:12 GMT; + - DD-PSHARD=233; Max-Age=604800; Path=/; expires=Mon, 04-May-2020 18:03:32 GMT; secure; HttpOnly Strict-Transport-Security: - max-age=15724800; @@ -346,9 +370,9 @@ interactions: X-Content-Type-Options: - nosniff X-Dd-Debug: - - ks+N4afsD/XZdTEJJuYeBz+DC+EAmEQboBW1Li/tuPGDHSoK4S4t4V+ApyGA1sCr + - i88VE4uHAwA5IXh/0IEXQAhr5hGCH9aMkIrX0bISt7VZwzJ4lfiprkupftdl3u1X X-Dd-Version: - - "35.2282030" + - "35.2439015" X-Frame-Options: - SAMEORIGIN status: 200 OK diff --git a/datadog/cassettes/TestAccDatadogMetricMetadata_Updated.freeze b/datadog/cassettes/TestAccDatadogMetricMetadata_Updated.freeze index 6db3a09d6..371cdcc8c 100644 --- a/datadog/cassettes/TestAccDatadogMetricMetadata_Updated.freeze +++ b/datadog/cassettes/TestAccDatadogMetricMetadata_Updated.freeze @@ -1 +1 @@ -2020-03-16T14:05:12.60617+01:00 \ No newline at end of file +2020-04-27T14:03:33.033052-04:00 \ No newline at end of file diff --git a/datadog/cassettes/TestAccDatadogMetricMetadata_Updated.yaml b/datadog/cassettes/TestAccDatadogMetricMetadata_Updated.yaml index 7ae55e668..a03da24ed 100644 --- a/datadog/cassettes/TestAccDatadogMetricMetadata_Updated.yaml +++ b/datadog/cassettes/TestAccDatadogMetricMetadata_Updated.yaml @@ -2,14 +2,18 @@ version: 1 interactions: - request: - body: '{"type":"gauge","description":"some description","short_name":"short name - for metric_metadata foo","unit":"byte","per_unit":"second","statsd_interval":1}' + body: | + {"description":"some description","per_unit":"second","short_name":"short name for metric_metadata foo","statsd_interval":1,"type":"gauge","unit":"byte"} form: {} headers: + Accept: + - application/json Content-Type: - application/json + Dd-Operation-Id: + - UpdateMetricMetadata User-Agent: - - Datadog/dev/terraform (go1.13) + - datadog-api-client-go/1.0.0-beta.1+dev.1 (go go1.13.4; os darwin; arch amd64) url: https://api.datadoghq.com/api/v1/metrics/foo method: PUT response: @@ -25,13 +29,13 @@ interactions: Content-Type: - application/json Date: - - Mon, 16 Mar 2020 13:05:12 GMT + - Mon, 27 Apr 2020 18:03:32 GMT Dd-Pool: - dogweb_events Pragma: - no-cache Set-Cookie: - - DD-PSHARD=233; Max-Age=604800; Path=/; expires=Mon, 23-Mar-2020 13:05:12 GMT; + - DD-PSHARD=233; Max-Age=604800; Path=/; expires=Mon, 04-May-2020 18:03:32 GMT; secure; HttpOnly Strict-Transport-Security: - max-age=15724800; @@ -40,9 +44,9 @@ interactions: X-Content-Type-Options: - nosniff X-Dd-Debug: - - xu6QH8k0ZJWrz0NXi4QztBhGhBBKkuA6UOMCp4bdoqgupy8p8tZfj82JWLQxU570 + - +LOKqLSPfuXsSbjeeg9e5mJQ6iLH37RX337AF2UwmrgfzTlv3DYBvkJLNTOjcY4k X-Dd-Version: - - "35.2282030" + - "35.2439015" X-Frame-Options: - SAMEORIGIN X-Ratelimit-Limit: @@ -52,7 +56,7 @@ interactions: X-Ratelimit-Remaining: - "1998" X-Ratelimit-Reset: - - "48" + - "28" status: 200 OK code: 200 duration: "" @@ -60,8 +64,12 @@ interactions: body: "" form: {} headers: + Accept: + - application/json + Dd-Operation-Id: + - GetMetricMetadata User-Agent: - - Datadog/dev/terraform (go1.13) + - datadog-api-client-go/1.0.0-beta.1+dev.1 (go go1.13.4; os darwin; arch amd64) url: https://api.datadoghq.com/api/v1/metrics/foo method: GET response: @@ -77,13 +85,13 @@ interactions: Content-Type: - application/json Date: - - Mon, 16 Mar 2020 13:05:12 GMT + - Mon, 27 Apr 2020 18:03:33 GMT Dd-Pool: - dogweb_events Pragma: - no-cache Set-Cookie: - - DD-PSHARD=233; Max-Age=604800; Path=/; expires=Mon, 23-Mar-2020 13:05:12 GMT; + - DD-PSHARD=233; Max-Age=604800; Path=/; expires=Mon, 04-May-2020 18:03:33 GMT; secure; HttpOnly Strict-Transport-Security: - max-age=15724800; @@ -92,22 +100,22 @@ interactions: X-Content-Type-Options: - nosniff X-Dd-Debug: - - WPX1FiwPIOToBtA8rF7hAKQLs3/IeLuNdRiWLhNgmOO7nzaG1v9cHH4bBkWLMLDg + - wNBYBBxxd2HlZLw/FUccp03kfgdlkZ9JbXuHpz2RsLnmIlsxxq3eFife9i+24O7e X-Dd-Version: - - "35.2282030" + - "35.2439015" X-Frame-Options: - SAMEORIGIN status: 200 OK code: 200 duration: "" - request: - body: '{"series":[{"metric":"foo","points":[[1584363912,1]]}]}' + body: '{"series":[{"metric":"foo","points":[[1588010613,1]]}]}' form: {} headers: Content-Type: - application/json User-Agent: - - Datadog/dev/terraform (go1.13) + - Datadog/dev/terraform (go1.13.4) url: https://api.datadoghq.com/api/v1/series method: POST response: @@ -122,7 +130,7 @@ interactions: Content-Type: - text/json Date: - - Mon, 16 Mar 2020 13:05:12 GMT + - Mon, 27 Apr 2020 18:03:33 GMT Dd-Pool: - propjoe Strict-Transport-Security: @@ -139,7 +147,7 @@ interactions: form: {} headers: User-Agent: - - Datadog/dev/terraform (go1.13) + - Datadog/dev/terraform (go1.13.4) url: https://api.datadoghq.com/api/v1/metrics/foo method: GET response: @@ -155,13 +163,13 @@ interactions: Content-Type: - application/json Date: - - Mon, 16 Mar 2020 13:05:12 GMT + - Mon, 27 Apr 2020 18:03:33 GMT Dd-Pool: - dogweb_events Pragma: - no-cache Set-Cookie: - - DD-PSHARD=233; Max-Age=604800; Path=/; expires=Mon, 23-Mar-2020 13:05:12 GMT; + - DD-PSHARD=233; Max-Age=604800; Path=/; expires=Mon, 04-May-2020 18:03:33 GMT; secure; HttpOnly Strict-Transport-Security: - max-age=15724800; @@ -170,9 +178,9 @@ interactions: X-Content-Type-Options: - nosniff X-Dd-Debug: - - zxB6NFKPou6mjdgdkt0pMTZ2qClfkjPWbQ/3N007nuVuZ3OZ5Hbkk9dlsim4kEgt + - dSsk7+mRnrkNk8jmsYspqDYb9PFSuOAKl7zpeZ3FD2V8Z5oA7LTnXEbTrmPx3WMZ X-Dd-Version: - - "35.2282030" + - "35.2439015" X-Frame-Options: - SAMEORIGIN status: 200 OK @@ -182,8 +190,12 @@ interactions: body: "" form: {} headers: + Accept: + - application/json + Dd-Operation-Id: + - GetMetricMetadata User-Agent: - - Datadog/dev/terraform (go1.13) + - datadog-api-client-go/1.0.0-beta.1+dev.1 (go go1.13.4; os darwin; arch amd64) url: https://api.datadoghq.com/api/v1/metrics/foo method: GET response: @@ -199,13 +211,13 @@ interactions: Content-Type: - application/json Date: - - Mon, 16 Mar 2020 13:05:12 GMT + - Mon, 27 Apr 2020 18:03:33 GMT Dd-Pool: - dogweb_events Pragma: - no-cache Set-Cookie: - - DD-PSHARD=233; Max-Age=604800; Path=/; expires=Mon, 23-Mar-2020 13:05:12 GMT; + - DD-PSHARD=233; Max-Age=604800; Path=/; expires=Mon, 04-May-2020 18:03:33 GMT; secure; HttpOnly Strict-Transport-Security: - max-age=15724800; @@ -214,9 +226,9 @@ interactions: X-Content-Type-Options: - nosniff X-Dd-Debug: - - AujpVCQUrK6kW/hFogelTq0ca1mFGBsPUN+WzOJY1gkcW9fGYbqfZ0B2U2WWOTiq + - Gkx1MqzgkAZ8tasPkceKYTohSmpGzJu9aWTVVkY8/0uD6+jJS5IU6wl8s0PuxJk+ X-Dd-Version: - - "35.2282030" + - "35.2439015" X-Frame-Options: - SAMEORIGIN status: 200 OK @@ -226,8 +238,12 @@ interactions: body: "" form: {} headers: + Accept: + - application/json + Dd-Operation-Id: + - GetMetricMetadata User-Agent: - - Datadog/dev/terraform (go1.13) + - datadog-api-client-go/1.0.0-beta.1+dev.1 (go go1.13.4; os darwin; arch amd64) url: https://api.datadoghq.com/api/v1/metrics/foo method: GET response: @@ -243,13 +259,13 @@ interactions: Content-Type: - application/json Date: - - Mon, 16 Mar 2020 13:05:13 GMT + - Mon, 27 Apr 2020 18:03:33 GMT Dd-Pool: - dogweb_events Pragma: - no-cache Set-Cookie: - - DD-PSHARD=233; Max-Age=604800; Path=/; expires=Mon, 23-Mar-2020 13:05:13 GMT; + - DD-PSHARD=233; Max-Age=604800; Path=/; expires=Mon, 04-May-2020 18:03:33 GMT; secure; HttpOnly Strict-Transport-Security: - max-age=15724800; @@ -258,9 +274,9 @@ interactions: X-Content-Type-Options: - nosniff X-Dd-Debug: - - ZH5nEaaw9idA5jDdJNpb5QoWAGAysb6o6h4mg/IEQEBeFEM63x+jbnHOBnP3HdOY + - +MBbg8m7leBxuvV6GEiU4GM6upN2DwwJCzEkgaJ6d1wIARIzXkMXtKDzvV0EcEJa X-Dd-Version: - - "35.2282030" + - "35.2439015" X-Frame-Options: - SAMEORIGIN status: 200 OK @@ -270,8 +286,12 @@ interactions: body: "" form: {} headers: + Accept: + - application/json + Dd-Operation-Id: + - GetMetricMetadata User-Agent: - - Datadog/dev/terraform (go1.13) + - datadog-api-client-go/1.0.0-beta.1+dev.1 (go go1.13.4; os darwin; arch amd64) url: https://api.datadoghq.com/api/v1/metrics/foo method: GET response: @@ -287,13 +307,13 @@ interactions: Content-Type: - application/json Date: - - Mon, 16 Mar 2020 13:05:13 GMT + - Mon, 27 Apr 2020 18:03:33 GMT Dd-Pool: - dogweb_events Pragma: - no-cache Set-Cookie: - - DD-PSHARD=233; Max-Age=604800; Path=/; expires=Mon, 23-Mar-2020 13:05:13 GMT; + - DD-PSHARD=233; Max-Age=604800; Path=/; expires=Mon, 04-May-2020 18:03:33 GMT; secure; HttpOnly Strict-Transport-Security: - max-age=15724800; @@ -302,9 +322,9 @@ interactions: X-Content-Type-Options: - nosniff X-Dd-Debug: - - cTGoYbqChxDAjzDml3Mtcv1n81aZ/AI153GiSNOHY92FcRYbkxQAsJm68lzR6u/t + - HiuGvIj2FObLYJ7BnY9qjywhB3oqrrJmsaDKFy//H1FYkl9FnsT1Jgrv/RgLafrB X-Dd-Version: - - "35.2282030" + - "35.2439015" X-Frame-Options: - SAMEORIGIN status: 200 OK @@ -314,8 +334,12 @@ interactions: body: "" form: {} headers: + Accept: + - application/json + Dd-Operation-Id: + - GetMetricMetadata User-Agent: - - Datadog/dev/terraform (go1.13) + - datadog-api-client-go/1.0.0-beta.1+dev.1 (go go1.13.4; os darwin; arch amd64) url: https://api.datadoghq.com/api/v1/metrics/foo method: GET response: @@ -331,13 +355,13 @@ interactions: Content-Type: - application/json Date: - - Mon, 16 Mar 2020 13:05:13 GMT + - Mon, 27 Apr 2020 18:03:33 GMT Dd-Pool: - dogweb_events Pragma: - no-cache Set-Cookie: - - DD-PSHARD=233; Max-Age=604800; Path=/; expires=Mon, 23-Mar-2020 13:05:13 GMT; + - DD-PSHARD=233; Max-Age=604800; Path=/; expires=Mon, 04-May-2020 18:03:33 GMT; secure; HttpOnly Strict-Transport-Security: - max-age=15724800; @@ -346,23 +370,27 @@ interactions: X-Content-Type-Options: - nosniff X-Dd-Debug: - - inRQQ3OIW+QktfomWIQqfbbCe4c3Y/B7HDhdQlToG1go3UF3n8k243RF8haVKvPK + - 3lmko5i3fHWSjOAgn/GBptVefdo4CMTWRgNPYMphjhGtCsLSHM9gTQHXLq+RuYT1 X-Dd-Version: - - "35.2282030" + - "35.2439015" X-Frame-Options: - SAMEORIGIN status: 200 OK code: 200 duration: "" - request: - body: '{"type":"gauge","description":"a different description","short_name":"short - name for metric_metadata foo","unit":"byte","per_unit":"second","statsd_interval":1}' + body: | + {"description":"a different description","per_unit":"second","short_name":"short name for metric_metadata foo","statsd_interval":1,"type":"gauge","unit":"byte"} form: {} headers: + Accept: + - application/json Content-Type: - application/json + Dd-Operation-Id: + - UpdateMetricMetadata User-Agent: - - Datadog/dev/terraform (go1.13) + - datadog-api-client-go/1.0.0-beta.1+dev.1 (go go1.13.4; os darwin; arch amd64) url: https://api.datadoghq.com/api/v1/metrics/foo method: PUT response: @@ -378,13 +406,13 @@ interactions: Content-Type: - application/json Date: - - Mon, 16 Mar 2020 13:05:13 GMT + - Mon, 27 Apr 2020 18:03:33 GMT Dd-Pool: - dogweb_events Pragma: - no-cache Set-Cookie: - - DD-PSHARD=233; Max-Age=604800; Path=/; expires=Mon, 23-Mar-2020 13:05:13 GMT; + - DD-PSHARD=233; Max-Age=604800; Path=/; expires=Mon, 04-May-2020 18:03:33 GMT; secure; HttpOnly Strict-Transport-Security: - max-age=15724800; @@ -393,9 +421,9 @@ interactions: X-Content-Type-Options: - nosniff X-Dd-Debug: - - 4WmLzujJordyBf+eJTJ6N2mys3JPZtDGjDvvYxTMJFkvFVHGZtg/PV/bjA2D8/Aw + - zzPGmpaNCXFO8JEWVRJgSu8LJtio50jZqYzr421L5obRpm1Hr7j3x1mrSpKub2vD X-Dd-Version: - - "35.2282030" + - "35.2439015" X-Frame-Options: - SAMEORIGIN X-Ratelimit-Limit: @@ -405,7 +433,7 @@ interactions: X-Ratelimit-Remaining: - "1997" X-Ratelimit-Reset: - - "47" + - "27" status: 200 OK code: 200 duration: "" @@ -413,8 +441,12 @@ interactions: body: "" form: {} headers: + Accept: + - application/json + Dd-Operation-Id: + - GetMetricMetadata User-Agent: - - Datadog/dev/terraform (go1.13) + - datadog-api-client-go/1.0.0-beta.1+dev.1 (go go1.13.4; os darwin; arch amd64) url: https://api.datadoghq.com/api/v1/metrics/foo method: GET response: @@ -430,13 +462,13 @@ interactions: Content-Type: - application/json Date: - - Mon, 16 Mar 2020 13:05:14 GMT + - Mon, 27 Apr 2020 18:03:33 GMT Dd-Pool: - dogweb_events Pragma: - no-cache Set-Cookie: - - DD-PSHARD=233; Max-Age=604800; Path=/; expires=Mon, 23-Mar-2020 13:05:14 GMT; + - DD-PSHARD=233; Max-Age=604800; Path=/; expires=Mon, 04-May-2020 18:03:33 GMT; secure; HttpOnly Strict-Transport-Security: - max-age=15724800; @@ -445,9 +477,9 @@ interactions: X-Content-Type-Options: - nosniff X-Dd-Debug: - - N9crabZsFdu+uziIZi0QyNxZnT75nCFrBucU1Hnb5wNM13tGX6mmTd5RrcsGklHT + - 8dI8aUSv3Fzq9LYH3wEHxmDECF/kuDIyQi68LDtl+z4qh8Ctb4ijNpflOPW/2exL X-Dd-Version: - - "35.2282030" + - "35.2439015" X-Frame-Options: - SAMEORIGIN status: 200 OK @@ -458,7 +490,7 @@ interactions: form: {} headers: User-Agent: - - Datadog/dev/terraform (go1.13) + - Datadog/dev/terraform (go1.13.4) url: https://api.datadoghq.com/api/v1/metrics/foo method: GET response: @@ -474,13 +506,13 @@ interactions: Content-Type: - application/json Date: - - Mon, 16 Mar 2020 13:05:14 GMT + - Mon, 27 Apr 2020 18:03:33 GMT Dd-Pool: - dogweb_events Pragma: - no-cache Set-Cookie: - - DD-PSHARD=233; Max-Age=604800; Path=/; expires=Mon, 23-Mar-2020 13:05:14 GMT; + - DD-PSHARD=233; Max-Age=604800; Path=/; expires=Mon, 04-May-2020 18:03:33 GMT; secure; HttpOnly Strict-Transport-Security: - max-age=15724800; @@ -489,9 +521,9 @@ interactions: X-Content-Type-Options: - nosniff X-Dd-Debug: - - q6BEz3Ndqd2YDq68fvY2T/dRXIBlbCDDtosoP8mtGo8zDxVpPHVuMCTSLLGdmvh6 + - cOBMEIzGbcr/TTaHVelgaC5EG7/lRdPgrbc2AbNb3MzctTQ5eAlKtKEr4T1bta3B X-Dd-Version: - - "35.2282030" + - "35.2439015" X-Frame-Options: - SAMEORIGIN status: 200 OK @@ -501,8 +533,12 @@ interactions: body: "" form: {} headers: + Accept: + - application/json + Dd-Operation-Id: + - GetMetricMetadata User-Agent: - - Datadog/dev/terraform (go1.13) + - datadog-api-client-go/1.0.0-beta.1+dev.1 (go go1.13.4; os darwin; arch amd64) url: https://api.datadoghq.com/api/v1/metrics/foo method: GET response: @@ -518,13 +554,13 @@ interactions: Content-Type: - application/json Date: - - Mon, 16 Mar 2020 13:05:14 GMT + - Mon, 27 Apr 2020 18:03:33 GMT Dd-Pool: - dogweb_events Pragma: - no-cache Set-Cookie: - - DD-PSHARD=233; Max-Age=604800; Path=/; expires=Mon, 23-Mar-2020 13:05:14 GMT; + - DD-PSHARD=233; Max-Age=604800; Path=/; expires=Mon, 04-May-2020 18:03:33 GMT; secure; HttpOnly Strict-Transport-Security: - max-age=15724800; @@ -533,9 +569,9 @@ interactions: X-Content-Type-Options: - nosniff X-Dd-Debug: - - l8/CyYQgxNlUR8N5qpJ+81qUuKw1c6vxal7Wn/ZZn0o078k9CV+532vQSdW5AOoH + - XeG1DE3ESqn659d0cMz6hOQfV3CVzyQxZOgiBhxnE9Q2Qo5eS3XwYHdfv2trfpeC X-Dd-Version: - - "35.2282030" + - "35.2439015" X-Frame-Options: - SAMEORIGIN status: 200 OK @@ -545,8 +581,12 @@ interactions: body: "" form: {} headers: + Accept: + - application/json + Dd-Operation-Id: + - GetMetricMetadata User-Agent: - - Datadog/dev/terraform (go1.13) + - datadog-api-client-go/1.0.0-beta.1+dev.1 (go go1.13.4; os darwin; arch amd64) url: https://api.datadoghq.com/api/v1/metrics/foo method: GET response: @@ -562,13 +602,13 @@ interactions: Content-Type: - application/json Date: - - Mon, 16 Mar 2020 13:05:14 GMT + - Mon, 27 Apr 2020 18:03:33 GMT Dd-Pool: - dogweb_events Pragma: - no-cache Set-Cookie: - - DD-PSHARD=233; Max-Age=604800; Path=/; expires=Mon, 23-Mar-2020 13:05:14 GMT; + - DD-PSHARD=233; Max-Age=604800; Path=/; expires=Mon, 04-May-2020 18:03:33 GMT; secure; HttpOnly Strict-Transport-Security: - max-age=15724800; @@ -577,9 +617,9 @@ interactions: X-Content-Type-Options: - nosniff X-Dd-Debug: - - +zchwakmLCHxthSHEDXnGvSP1yrlqs7ERH6FsSIgdQHan219bhHY/kUDzjhyCCQx + - YiqTrjt6LCEfPUSVn9xKI6SC+YQr4Cv5Uw74jVF8Pd4vkDdHKpAVFccXhgIybTKX X-Dd-Version: - - "35.2282030" + - "35.2439015" X-Frame-Options: - SAMEORIGIN status: 200 OK @@ -589,8 +629,12 @@ interactions: body: "" form: {} headers: + Accept: + - application/json + Dd-Operation-Id: + - GetMetricMetadata User-Agent: - - Datadog/dev/terraform (go1.13) + - datadog-api-client-go/1.0.0-beta.1+dev.1 (go go1.13.4; os darwin; arch amd64) url: https://api.datadoghq.com/api/v1/metrics/foo method: GET response: @@ -606,13 +650,13 @@ interactions: Content-Type: - application/json Date: - - Mon, 16 Mar 2020 13:05:14 GMT + - Mon, 27 Apr 2020 18:03:33 GMT Dd-Pool: - dogweb_events Pragma: - no-cache Set-Cookie: - - DD-PSHARD=233; Max-Age=604800; Path=/; expires=Mon, 23-Mar-2020 13:05:14 GMT; + - DD-PSHARD=233; Max-Age=604800; Path=/; expires=Mon, 04-May-2020 18:03:33 GMT; secure; HttpOnly Strict-Transport-Security: - max-age=15724800; @@ -621,9 +665,9 @@ interactions: X-Content-Type-Options: - nosniff X-Dd-Debug: - - XGzrDUzj8MNRtd/iGgmItHnvewaoDZHZo8ezW4sW5fCcr8fKWFbbN+qUJPs0UCac + - BvyE/KcV3eyeW0ADYGwuBBMAX4cD0GoRoUSk/v+1endhdIPEwx2gUI65Uyc5Iop9 X-Dd-Version: - - "35.2282030" + - "35.2439015" X-Frame-Options: - SAMEORIGIN status: 200 OK @@ -633,8 +677,12 @@ interactions: body: "" form: {} headers: + Accept: + - application/json + Dd-Operation-Id: + - GetMetricMetadata User-Agent: - - Datadog/dev/terraform (go1.13) + - datadog-api-client-go/1.0.0-beta.1+dev.1 (go go1.13.4; os darwin; arch amd64) url: https://api.datadoghq.com/api/v1/metrics/foo method: GET response: @@ -650,13 +698,13 @@ interactions: Content-Type: - application/json Date: - - Mon, 16 Mar 2020 13:05:14 GMT + - Mon, 27 Apr 2020 18:03:33 GMT Dd-Pool: - dogweb_events Pragma: - no-cache Set-Cookie: - - DD-PSHARD=233; Max-Age=604800; Path=/; expires=Mon, 23-Mar-2020 13:05:14 GMT; + - DD-PSHARD=233; Max-Age=604800; Path=/; expires=Mon, 04-May-2020 18:03:33 GMT; secure; HttpOnly Strict-Transport-Security: - max-age=15724800; @@ -665,9 +713,9 @@ interactions: X-Content-Type-Options: - nosniff X-Dd-Debug: - - ngZPGzZnOLNwrwBxxEiJGwBXSNmoeXxJOBNze1beoIpYVe94Mfymr9P2K6iw8S9w + - xjL+CwAwe25Cg4YC4lldISBWo52l6QW3fr77YGzNbenbLDrPtkmM/QH8qDRYPhsa X-Dd-Version: - - "35.2282030" + - "35.2439015" X-Frame-Options: - SAMEORIGIN status: 200 OK diff --git a/datadog/resource_datadog_metric_metadata.go b/datadog/resource_datadog_metric_metadata.go index 9fc986234..07c717223 100644 --- a/datadog/resource_datadog_metric_metadata.go +++ b/datadog/resource_datadog_metric_metadata.go @@ -3,8 +3,8 @@ package datadog import ( "strings" + datadogV1 "github.com/DataDog/datadog-api-client-go/api/v1/datadog" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - "github.com/zorkian/go-datadog-api" ) func resourceDatadogMetricMetadata() *schema.Resource { @@ -51,14 +51,14 @@ func resourceDatadogMetricMetadata() *schema.Resource { } } -func buildMetricMetadataStruct(d *schema.ResourceData) (string, *datadog.MetricMetadata) { - return d.Get("metric").(string), &datadog.MetricMetadata{ - Type: datadog.String(d.Get("type").(string)), - Description: datadog.String(d.Get("description").(string)), - ShortName: datadog.String(d.Get("short_name").(string)), - Unit: datadog.String(d.Get("unit").(string)), - PerUnit: datadog.String(d.Get("per_unit").(string)), - StatsdInterval: datadog.Int(d.Get("statsd_interval").(int)), +func buildMetricMetadataStruct(d *schema.ResourceData) (string, *datadogV1.MetricMetadata) { + return d.Get("metric").(string), &datadogV1.MetricMetadata{ + Type: datadogV1.PtrString(d.Get("type").(string)), + Description: datadogV1.PtrString(d.Get("description").(string)), + ShortName: datadogV1.PtrString(d.Get("short_name").(string)), + Unit: datadogV1.PtrString(d.Get("unit").(string)), + PerUnit: datadogV1.PtrString(d.Get("per_unit").(string)), + StatsdInterval: datadogV1.PtrInt64(int64(d.Get("statsd_interval").(int))), } } @@ -66,11 +66,12 @@ func resourceDatadogMetricMetadataExists(d *schema.ResourceData, meta interface{ // Exists - This is called to verify a resource still exists. It is called prior to Read, // and lowers the burden of Read to be able to assume the resource exists. providerConf := meta.(*ProviderConfiguration) - client := providerConf.CommunityClient + datadogClientV1 := providerConf.DatadogClientV1 + authV1 := providerConf.AuthV1 id, _ := buildMetricMetadataStruct(d) - if _, err := client.ViewMetricMetadata(id); err != nil { + if _, _, err := datadogClientV1.MetricsApi.GetMetricMetadata(authV1, id).Execute(); err != nil { if strings.Contains(err.Error(), "404 Not Found") { return false, nil } @@ -82,10 +83,11 @@ func resourceDatadogMetricMetadataExists(d *schema.ResourceData, meta interface{ func resourceDatadogMetricMetadataCreate(d *schema.ResourceData, meta interface{}) error { providerConf := meta.(*ProviderConfiguration) - client := providerConf.CommunityClient + datadogClientV1 := providerConf.DatadogClientV1 + authV1 := providerConf.AuthV1 id, m := buildMetricMetadataStruct(d) - _, err := client.EditMetricMetadata(id, m) + _, _, err := datadogClientV1.MetricsApi.UpdateMetricMetadata(authV1, id).Body(*m).Execute() if err != nil { return translateClientError(err, "error creating metric metadata") } @@ -97,11 +99,12 @@ func resourceDatadogMetricMetadataCreate(d *schema.ResourceData, meta interface{ func resourceDatadogMetricMetadataRead(d *schema.ResourceData, meta interface{}) error { providerConf := meta.(*ProviderConfiguration) - client := providerConf.CommunityClient + datadogClientV1 := providerConf.DatadogClientV1 + authV1 := providerConf.AuthV1 id, _ := buildMetricMetadataStruct(d) - m, err := client.ViewMetricMetadata(id) + m, _, err := datadogClientV1.MetricsApi.GetMetricMetadata(authV1, id).Execute() if err != nil { return translateClientError(err, "error getting metric metadata") } @@ -118,9 +121,10 @@ func resourceDatadogMetricMetadataRead(d *schema.ResourceData, meta interface{}) func resourceDatadogMetricMetadataUpdate(d *schema.ResourceData, meta interface{}) error { providerConf := meta.(*ProviderConfiguration) - client := providerConf.CommunityClient + datadogClientV1 := providerConf.DatadogClientV1 + authV1 := providerConf.AuthV1 - m := &datadog.MetricMetadata{} + m := &datadogV1.MetricMetadata{} id := d.Get("metric").(string) if attr, ok := d.GetOk("type"); ok { @@ -139,10 +143,10 @@ func resourceDatadogMetricMetadataUpdate(d *schema.ResourceData, meta interface{ m.SetPerUnit(attr.(string)) } if attr, ok := d.GetOk("statsd_interval"); ok { - m.SetStatsdInterval(attr.(int)) + m.SetStatsdInterval(int64(attr.(int))) } - if _, err := client.EditMetricMetadata(id, m); err != nil { + if _, _, err := datadogClientV1.MetricsApi.UpdateMetricMetadata(authV1, id).Body(*m).Execute(); err != nil { return translateClientError(err, "error updating metric metadata") }