Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce PaginationResult type to return errors in WithPagination methods #1755

Merged
merged 8 commits into from
Nov 18, 2022

Conversation

skarimo
Copy link
Member

@skarimo skarimo commented Nov 15, 2022

This PR introduces a new type PaginationResult[T any] for results returned by WithPagination methods.

This change was introduced to ensure we forward any errors raised by the goroutine via the channel. Additionally the function signature for WithPagination methods have been changed as well. See below for an example:

	resp, _ := api.ListProcessesWithPagination(ctx, *datadogV2.NewListProcessesOptionalParameters().WithPageLimit(2))
	for paginationResult := range resp {
		if paginationResult.Error != nil {
			fmt.Fprintf(os.Stderr, "Error when calling `ProcessesApi.ListProcesses`: %v\n", paginationResult.Error)
		}
		responseContent, _ := json.MarshalIndent(paginationResult.Item, "", "  ")
		fmt.Fprintf(os.Stdout, "%s\n", responseContent)
	}

@skarimo skarimo added the changelog/Added Added features results into a minor version bump label Nov 15, 2022
@skarimo skarimo requested a review from a team as a code owner November 15, 2022 18:57
ci.datadog-api-spec and others added 2 commits November 15, 2022 19:47
Copy link
Contributor

@therve therve left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! 2 small things:

  1. Remove the error from the signature. I think it's useless
  2. Update the examples to check for error in the item and print the Item.

I'm wondering how we can document that breaking change. Can you update the PR description as a first step so that we have something to link? Thanks!

@github-actions github-actions bot added the documentation Documentation related changes label Nov 16, 2022
ci.datadog-api-spec and others added 2 commits November 16, 2022 20:19
@skarimo skarimo changed the title Return errors in pagination Introduce PaginationResult type to return pagination errors in WithPagination methods Nov 17, 2022
@skarimo skarimo changed the title Introduce PaginationResult type to return pagination errors in WithPagination methods Introduce PaginationResult type to return errors in WithPagination methods Nov 17, 2022
@therve therve merged commit 57f5c91 into master Nov 18, 2022
@therve therve deleted the sherz/pagination-errors branch November 18, 2022 07:58
github-actions bot pushed a commit that referenced this pull request Nov 18, 2022
…methods (#1755)

* return error in pagination channel

* user generics and named attr

* pre-commit fixes

* bump ci go version

* code review suggestions

* pre-commit fixes

* fix test

Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
Co-authored-by: Thomas Hervé <thomas.herve@datadoghq.com> 57f5c91
kodiakhq bot pushed a commit to cloudquery/cloudquery that referenced this pull request Jan 1, 2023
…to v2.6.1 (#6185)

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [github.com/DataDog/datadog-api-client-go/v2](https://togithub.com/DataDog/datadog-api-client-go) | require | minor | `v2.5.0` -> `v2.6.1` |

---

### Release Notes

<details>
<summary>DataDog/datadog-api-client-go</summary>

### [`v2.6.1`](https://togithub.com/DataDog/datadog-api-client-go/releases/tag/v2.6.1)

[Compare Source](https://togithub.com/DataDog/datadog-api-client-go/compare/v2.6.0...v2.6.1)

<!-- Release notes generated using configuration in .github/release.yml at v2.6.1 -->

#### What's Changed

##### Fixed

-   Remove incorrect required fields from CloudConfigurationComplianceRuleOptions by [@&#8203;api-clients-generation-pipeline](https://togithub.com/api-clients-generation-pipeline) in [DataDog/datadog-api-client-go#1801

**Full Changelog**: DataDog/datadog-api-client-go@v2.6.0...v2.6.1

### [`v2.6.0`](https://togithub.com/DataDog/datadog-api-client-go/releases/tag/v2.6.0)

[Compare Source](https://togithub.com/DataDog/datadog-api-client-go/compare/v2.5.0...v2.6.0)

<!-- Release notes generated using configuration in .github/release.yml at v2.6.0 -->

#### What's Changed

##### Fixed

-   Fix service catalog schema change by [@&#8203;api-clients-generation-pipeline](https://togithub.com/api-clients-generation-pipeline) in [DataDog/datadog-api-client-go#1749
-   Add missing response fields to MTD usage attribution endpoint by [@&#8203;api-clients-generation-pipeline](https://togithub.com/api-clients-generation-pipeline) in [DataDog/datadog-api-client-go#1776
-   Fix missing field in Synthetics tests authentication configuration by [@&#8203;api-clients-generation-pipeline](https://togithub.com/api-clients-generation-pipeline) in [DataDog/datadog-api-client-go#1782
-   Mark `hosts` response version fields as nullable by [@&#8203;api-clients-generation-pipeline](https://togithub.com/api-clients-generation-pipeline) in [DataDog/datadog-api-client-go#1778

##### Added

-   Add fields for CSPM GCP usage by [@&#8203;api-clients-generation-pipeline](https://togithub.com/api-clients-generation-pipeline) in [DataDog/datadog-api-client-go#1756
-   Introduce `PaginationResult` type to return errors in WithPagination methods by [@&#8203;skarimo](https://togithub.com/skarimo) in [DataDog/datadog-api-client-go#1755
-   Add offset and limit parameter to SLO correction API by [@&#8203;api-clients-generation-pipeline](https://togithub.com/api-clients-generation-pipeline) in [DataDog/datadog-api-client-go#1759
-   Add documentation for Logs Pipelines ReferenceTableLogsLookupProcessor  by [@&#8203;api-clients-generation-pipeline](https://togithub.com/api-clients-generation-pipeline) in [DataDog/datadog-api-client-go#1758
-   Adding new field for the usage metering infra hosts by [@&#8203;api-clients-generation-pipeline](https://togithub.com/api-clients-generation-pipeline) in [DataDog/datadog-api-client-go#1761
-   Add `include_percentiles` field in Logs Custom Metrics by [@&#8203;api-clients-generation-pipeline](https://togithub.com/api-clients-generation-pipeline) in [DataDog/datadog-api-client-go#1740
-   Add OAuth support for Synthetics tests by [@&#8203;api-clients-generation-pipeline](https://togithub.com/api-clients-generation-pipeline) in [DataDog/datadog-api-client-go#1764
-   Add new billable summary fields by [@&#8203;api-clients-generation-pipeline](https://togithub.com/api-clients-generation-pipeline) in [DataDog/datadog-api-client-go#1774
-   RUM Applications Management API add client_token by [@&#8203;api-clients-generation-pipeline](https://togithub.com/api-clients-generation-pipeline) in [DataDog/datadog-api-client-go#1765
-   Support GRPC unary calls in Synthetics by [@&#8203;api-clients-generation-pipeline](https://togithub.com/api-clients-generation-pipeline) in [DataDog/datadog-api-client-go#1772
-   Add style object to dashboard widget formulas by [@&#8203;api-clients-generation-pipeline](https://togithub.com/api-clients-generation-pipeline) in [DataDog/datadog-api-client-go#1787
-   Add enable_samples monitor option by [@&#8203;api-clients-generation-pipeline](https://togithub.com/api-clients-generation-pipeline) in [DataDog/datadog-api-client-go#1789
-   Update security_monitoring endpoints for cloud_configuration rules by [@&#8203;api-clients-generation-pipeline](https://togithub.com/api-clients-generation-pipeline) in [DataDog/datadog-api-client-go#1790
-   Add support for sensitive data scanner APIs by [@&#8203;api-clients-generation-pipeline](https://togithub.com/api-clients-generation-pipeline) in [DataDog/datadog-api-client-go#1784
-   Add synthetics_parallel_testing to Usage Metering API by [@&#8203;api-clients-generation-pipeline](https://togithub.com/api-clients-generation-pipeline) in [DataDog/datadog-api-client-go#1792
-   Synthetics add pagination params to get all tests endpoint by [@&#8203;api-clients-generation-pipeline](https://togithub.com/api-clients-generation-pipeline) in [DataDog/datadog-api-client-go#1793

**Full Changelog**: DataDog/datadog-api-client-go@v2.5.0...v2.6.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "before 3am on the first day of the month" (UTC), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://togithub.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNC40Mi4wIiwidXBkYXRlZEluVmVyIjoiMzQuNDIuMCJ9-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog/Added Added features results into a minor version bump documentation Documentation related changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New v2 CIVisibility api doesn't return an error from a pagination function
2 participants