Skip to content

Commit 7b663aa

Browse files
committed
Create an utility to read response bodies (#1836)
We duplicate a small logic everywhere, let's refactor it. e4df6f4
1 parent 78772ab commit 7b663aa

File tree

67 files changed

+50370
-51285
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+50370
-51285
lines changed

pkg/github.com/DataDog/datadog-api-client-go/v2/api/datadog/index.html

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,9 @@ <h2 class="toggleButton" title="Click to hide Index section">Index ▾</h2>
143143
<dd><a href="#PtrTime">func PtrTime(v time.Time) *time.Time</a></dd>
144144

145145

146+
<dd><a href="#ReadBody">func ReadBody(response *http.Response) ([]byte, error)</a></dd>
147+
148+
146149
<dd><a href="#ReportError">func ReportError(format string, a ...interface{}) error</a></dd>
147150

148151

@@ -559,7 +562,7 @@ <h2 id="NewDefaultContext">func <a href="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/DataDog/datadog-api-
559562

560563

561564

562-
<h2 id="ParameterToString">func <a href="https://github.com/DataDog/datadog-api-client-go/blob/master/api/datadog/client.go#L81">ParameterToString</a>
565+
<h2 id="ParameterToString">func <a href="https://github.com/DataDog/datadog-api-client-go/blob/master/api/datadog/client.go#L90">ParameterToString</a>
563566
<a class="permalink" href="#ParameterToString">&#xb6;</a>
564567

565568

@@ -685,7 +688,21 @@ <h2 id="PtrTime">func <a href="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/DataDog/datadog-api-client-go/
685688

686689

687690

688-
<h2 id="ReportError">func <a href="https://github.com/DataDog/datadog-api-client-go/blob/master/api/datadog/client.go#L385">ReportError</a>
691+
<h2 id="ReadBody">func <a href="https://github.com/DataDog/datadog-api-client-go/blob/master/api/datadog/client.go#L69">ReadBody</a>
692+
<a class="permalink" href="#ReadBody">&#xb6;</a>
693+
694+
695+
</h2>
696+
<pre>func ReadBody(response *<a href="https://pkg.go.dev/net/http/">http</a>.<a href="https://pkg.go.dev/net/http/#Response">Response</a>) ([]<a href="https://pkg.go.dev/builtin/#byte">byte</a>, <a href="https://pkg.go.dev/builtin/#error">error</a>)</pre>
697+
<p>ReadBody returns the byte content of the response and make it available again on the response object.
698+
699+
700+
701+
702+
703+
704+
705+
<h2 id="ReportError">func <a href="https://github.com/DataDog/datadog-api-client-go/blob/master/api/datadog/client.go#L394">ReportError</a>
689706
<a class="permalink" href="#ReportError">&#xb6;</a>
690707

691708

@@ -699,13 +716,14 @@ <h2 id="ReportError">func <a href="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/DataDog/datadog-api-client
699716

700717

701718

702-
<h2 id="SetAuthKeys">func <a href="https://github.com/DataDog/datadog-api-client-go/blob/master/api/datadog/client.go#L55">SetAuthKeys</a>
719+
<h2 id="SetAuthKeys">func <a href="https://github.com/DataDog/datadog-api-client-go/blob/master/api/datadog/client.go#L56">SetAuthKeys</a>
703720
<a class="permalink" href="#SetAuthKeys">&#xb6;</a>
704721

705722

706723
</h2>
707724
<pre>func SetAuthKeys(ctx <a href="https://pkg.go.dev/context/">context</a>.<a href="https://pkg.go.dev/context/#Context">Context</a>, headerParams *map[<a href="https://pkg.go.dev/builtin/#string">string</a>]<a href="https://pkg.go.dev/builtin/#string">string</a>, keys ...[2]<a href="https://pkg.go.dev/builtin/#string">string</a>)</pre>
708-
725+
<p>SetAuthKeys sets the appropriate values in the headers parameter.
726+
709727

710728

711729

@@ -750,7 +768,7 @@ <h2 id="APIClient">type <a href="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/DataDog/datadog-api-client-g
750768

751769

752770

753-
<h3 id="NewAPIClient">func <a href="https://github.com/DataDog/datadog-api-client-go/blob/master/api/datadog/client.go#L69">NewAPIClient</a>
771+
<h3 id="NewAPIClient">func <a href="https://github.com/DataDog/datadog-api-client-go/blob/master/api/datadog/client.go#L78">NewAPIClient</a>
754772
<a class="permalink" href="#NewAPIClient">&#xb6;</a>
755773

756774

@@ -765,7 +783,7 @@ <h3 id="NewAPIClient">func <a href="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/DataDog/datadog-api-clien
765783

766784

767785

768-
<h3 id="APIClient.CallAPI">func (*APIClient) <a href="https://github.com/DataDog/datadog-api-client-go/blob/master/api/datadog/client.go#L108">CallAPI</a>
786+
<h3 id="APIClient.CallAPI">func (*APIClient) <a href="https://github.com/DataDog/datadog-api-client-go/blob/master/api/datadog/client.go#L117">CallAPI</a>
769787
<a class="permalink" href="#APIClient.CallAPI">&#xb6;</a>
770788

771789

@@ -778,7 +796,7 @@ <h3 id="APIClient.CallAPI">func (*APIClient) <a href="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/DataDog
778796

779797

780798

781-
<h3 id="APIClient.Decode">func (*APIClient) <a href="https://github.com/DataDog/datadog-api-client-go/blob/master/api/datadog/client.go#L339">Decode</a>
799+
<h3 id="APIClient.Decode">func (*APIClient) <a href="https://github.com/DataDog/datadog-api-client-go/blob/master/api/datadog/client.go#L348">Decode</a>
782800
<a class="permalink" href="#APIClient.Decode">&#xb6;</a>
783801

784802

@@ -791,7 +809,7 @@ <h3 id="APIClient.Decode">func (*APIClient) <a href="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/DataDog/
791809

792810

793811

794-
<h3 id="APIClient.GetConfig">func (*APIClient) <a href="https://github.com/DataDog/datadog-api-client-go/blob/master/api/datadog/client.go#L142">GetConfig</a>
812+
<h3 id="APIClient.GetConfig">func (*APIClient) <a href="https://github.com/DataDog/datadog-api-client-go/blob/master/api/datadog/client.go#L151">GetConfig</a>
795813
<a class="permalink" href="#APIClient.GetConfig">&#xb6;</a>
796814

797815

@@ -805,7 +823,7 @@ <h3 id="APIClient.GetConfig">func (*APIClient) <a href="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/DataD
805823

806824

807825

808-
<h3 id="APIClient.PrepareRequest">func (*APIClient) <a href="https://github.com/DataDog/datadog-api-client-go/blob/master/api/datadog/client.go#L147">PrepareRequest</a>
826+
<h3 id="APIClient.PrepareRequest">func (*APIClient) <a href="https://github.com/DataDog/datadog-api-client-go/blob/master/api/datadog/client.go#L156">PrepareRequest</a>
809827
<a class="permalink" href="#APIClient.PrepareRequest">&#xb6;</a>
810828

811829

@@ -1052,7 +1070,7 @@ <h2 id="FormFile">type <a href="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/DataDog/datadog-api-client-go
10521070

10531071

10541072

1055-
<h2 id="GenericOpenAPIError">type <a href="https://github.com/DataDog/datadog-api-client-go/blob/master/api/datadog/client.go#L447">GenericOpenAPIError</a>
1073+
<h2 id="GenericOpenAPIError">type <a href="https://github.com/DataDog/datadog-api-client-go/blob/master/api/datadog/client.go#L456">GenericOpenAPIError</a>
10561074
<a class="permalink" href="#GenericOpenAPIError">&#xb6;</a>
10571075

10581076

@@ -1078,7 +1096,7 @@ <h2 id="GenericOpenAPIError">type <a href="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/DataDog/datadog-ap
10781096

10791097

10801098

1081-
<h3 id="GenericOpenAPIError.Body">func (GenericOpenAPIError) <a href="https://github.com/DataDog/datadog-api-client-go/blob/master/api/datadog/client.go#L459">Body</a>
1099+
<h3 id="GenericOpenAPIError.Body">func (GenericOpenAPIError) <a href="https://github.com/DataDog/datadog-api-client-go/blob/master/api/datadog/client.go#L468">Body</a>
10821100
<a class="permalink" href="#GenericOpenAPIError.Body">&#xb6;</a>
10831101

10841102

@@ -1091,7 +1109,7 @@ <h3 id="GenericOpenAPIError.Body">func (GenericOpenAPIError) <a href="https://gi
10911109

10921110

10931111

1094-
<h3 id="GenericOpenAPIError.Error">func (GenericOpenAPIError) <a href="https://github.com/DataDog/datadog-api-client-go/blob/master/api/datadog/client.go#L454">Error</a>
1112+
<h3 id="GenericOpenAPIError.Error">func (GenericOpenAPIError) <a href="https://github.com/DataDog/datadog-api-client-go/blob/master/api/datadog/client.go#L463">Error</a>
10951113
<a class="permalink" href="#GenericOpenAPIError.Error">&#xb6;</a>
10961114

10971115

@@ -1104,7 +1122,7 @@ <h3 id="GenericOpenAPIError.Error">func (GenericOpenAPIError) <a href="https://g
11041122

11051123

11061124

1107-
<h3 id="GenericOpenAPIError.Model">func (GenericOpenAPIError) <a href="https://github.com/DataDog/datadog-api-client-go/blob/master/api/datadog/client.go#L464">Model</a>
1125+
<h3 id="GenericOpenAPIError.Model">func (GenericOpenAPIError) <a href="https://github.com/DataDog/datadog-api-client-go/blob/master/api/datadog/client.go#L473">Model</a>
11081126
<a class="permalink" href="#GenericOpenAPIError.Model">&#xb6;</a>
11091127

11101128

0 commit comments

Comments
 (0)