Skip to content

Commit

Permalink
named sturct variables (#2258)
Browse files Browse the repository at this point in the history
  • Loading branch information
skarimo authored Nov 1, 2023
1 parent aefcec2 commit 8bf2f7b
Show file tree
Hide file tree
Showing 26 changed files with 70 additions and 70 deletions.
4 changes: 2 additions & 2 deletions .generator/src/generator/templates/api.j2
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ func (a *{{ classname }}) {{ operation.operationId }}WithPagination(ctx _context
resp, _, err := a.{{ operation.operationId }}(ctx{% for name, parameter in operation|parameters if parameter.required or parameter.in == "path" %}, {{ name|variable_name}}{% endfor %}{%- for name, parameter in operation|parameters if not parameter.required and parameter.in != "path" %}{%- if loop.first %}, o...{% endif %}{% endfor %})
if err != nil {
var returnItem {{ itemType }}
items <- datadog.PaginationResult[{{ itemType }}]{returnItem, err}
items <- datadog.PaginationResult[{{ itemType }}]{Item: returnItem, Error: err}
break
}
{%- if pagination.resultsPath %}
Expand All @@ -386,7 +386,7 @@ func (a *{{ classname }}) {{ operation.operationId }}WithPagination(ctx _context

for _, item := range results {
select {
case items <- datadog.PaginationResult[{{ itemType }}]{item, nil}:
case items <- datadog.PaginationResult[{{ itemType }}]{Item: item, Error: nil}:
case <-ctx.Done():
close(items)
return
Expand Down
2 changes: 1 addition & 1 deletion .generator/src/generator/templates/client.j2
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ func (c *APIClient) PrepareRequest(
return nil, err
}
} else { // form value
w.WriteField(k, iv)
_ = w.WriteField(k, iv)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion api/datadog/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ func (c *APIClient) PrepareRequest(
return nil, err
}
} else { // form value
w.WriteField(k, iv)
_ = w.WriteField(k, iv)
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions api/datadogV1/api_dashboards.go
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,7 @@ func (a *DashboardsApi) ListDashboardsWithPagination(ctx _context.Context, o ...
resp, _, err := a.ListDashboards(ctx, o...)
if err != nil {
var returnItem DashboardSummaryDefinition
items <- datadog.PaginationResult[DashboardSummaryDefinition]{returnItem, err}
items <- datadog.PaginationResult[DashboardSummaryDefinition]{Item: returnItem, Error: err}
break
}
respDashboards, ok := resp.GetDashboardsOk()
Expand All @@ -843,7 +843,7 @@ func (a *DashboardsApi) ListDashboardsWithPagination(ctx _context.Context, o ...

for _, item := range results {
select {
case items <- datadog.PaginationResult[DashboardSummaryDefinition]{item, nil}:
case items <- datadog.PaginationResult[DashboardSummaryDefinition]{Item: item, Error: nil}:
case <-ctx.Done():
close(items)
return
Expand Down
4 changes: 2 additions & 2 deletions api/datadogV1/api_monitors.go
Original file line number Diff line number Diff line change
Expand Up @@ -746,14 +746,14 @@ func (a *MonitorsApi) ListMonitorsWithPagination(ctx _context.Context, o ...List
resp, _, err := a.ListMonitors(ctx, o...)
if err != nil {
var returnItem Monitor
items <- datadog.PaginationResult[Monitor]{returnItem, err}
items <- datadog.PaginationResult[Monitor]{Item: returnItem, Error: err}
break
}
results := resp

for _, item := range results {
select {
case items <- datadog.PaginationResult[Monitor]{item, nil}:
case items <- datadog.PaginationResult[Monitor]{Item: item, Error: nil}:
case <-ctx.Done():
close(items)
return
Expand Down
4 changes: 2 additions & 2 deletions api/datadogV1/api_notebooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ func (a *NotebooksApi) ListNotebooksWithPagination(ctx _context.Context, o ...Li
resp, _, err := a.ListNotebooks(ctx, o...)
if err != nil {
var returnItem NotebooksResponseData
items <- datadog.PaginationResult[NotebooksResponseData]{returnItem, err}
items <- datadog.PaginationResult[NotebooksResponseData]{Item: returnItem, Error: err}
break
}
respData, ok := resp.GetDataOk()
Expand All @@ -439,7 +439,7 @@ func (a *NotebooksApi) ListNotebooksWithPagination(ctx _context.Context, o ...Li

for _, item := range results {
select {
case items <- datadog.PaginationResult[NotebooksResponseData]{item, nil}:
case items <- datadog.PaginationResult[NotebooksResponseData]{Item: item, Error: nil}:
case <-ctx.Done():
close(items)
return
Expand Down
4 changes: 2 additions & 2 deletions api/datadogV1/api_service_level_objective_corrections.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ func (a *ServiceLevelObjectiveCorrectionsApi) ListSLOCorrectionWithPagination(ct
resp, _, err := a.ListSLOCorrection(ctx, o...)
if err != nil {
var returnItem SLOCorrection
items <- datadog.PaginationResult[SLOCorrection]{returnItem, err}
items <- datadog.PaginationResult[SLOCorrection]{Item: returnItem, Error: err}
break
}
respData, ok := resp.GetDataOk()
Expand All @@ -358,7 +358,7 @@ func (a *ServiceLevelObjectiveCorrectionsApi) ListSLOCorrectionWithPagination(ct

for _, item := range results {
select {
case items <- datadog.PaginationResult[SLOCorrection]{item, nil}:
case items <- datadog.PaginationResult[SLOCorrection]{Item: item, Error: nil}:
case <-ctx.Done():
close(items)
return
Expand Down
4 changes: 2 additions & 2 deletions api/datadogV1/api_service_level_objectives.go
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,7 @@ func (a *ServiceLevelObjectivesApi) ListSLOsWithPagination(ctx _context.Context,
resp, _, err := a.ListSLOs(ctx, o...)
if err != nil {
var returnItem ServiceLevelObjective
items <- datadog.PaginationResult[ServiceLevelObjective]{returnItem, err}
items <- datadog.PaginationResult[ServiceLevelObjective]{Item: returnItem, Error: err}
break
}
respData, ok := resp.GetDataOk()
Expand All @@ -823,7 +823,7 @@ func (a *ServiceLevelObjectivesApi) ListSLOsWithPagination(ctx _context.Context,

for _, item := range results {
select {
case items <- datadog.PaginationResult[ServiceLevelObjective]{item, nil}:
case items <- datadog.PaginationResult[ServiceLevelObjective]{Item: item, Error: nil}:
case <-ctx.Done():
close(items)
return
Expand Down
4 changes: 2 additions & 2 deletions api/datadogV1/api_synthetics.go
Original file line number Diff line number Diff line change
Expand Up @@ -1743,7 +1743,7 @@ func (a *SyntheticsApi) ListTestsWithPagination(ctx _context.Context, o ...ListT
resp, _, err := a.ListTests(ctx, o...)
if err != nil {
var returnItem SyntheticsTestDetails
items <- datadog.PaginationResult[SyntheticsTestDetails]{returnItem, err}
items <- datadog.PaginationResult[SyntheticsTestDetails]{Item: returnItem, Error: err}
break
}
respTests, ok := resp.GetTestsOk()
Expand All @@ -1754,7 +1754,7 @@ func (a *SyntheticsApi) ListTestsWithPagination(ctx _context.Context, o ...ListT

for _, item := range results {
select {
case items <- datadog.PaginationResult[SyntheticsTestDetails]{item, nil}:
case items <- datadog.PaginationResult[SyntheticsTestDetails]{Item: item, Error: nil}:
case <-ctx.Done():
close(items)
return
Expand Down
8 changes: 4 additions & 4 deletions api/datadogV2/api_audit.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ func (a *AuditApi) ListAuditLogsWithPagination(ctx _context.Context, o ...ListAu
resp, _, err := a.ListAuditLogs(ctx, o...)
if err != nil {
var returnItem AuditLogsEvent
items <- datadog.PaginationResult[AuditLogsEvent]{returnItem, err}
items <- datadog.PaginationResult[AuditLogsEvent]{Item: returnItem, Error: err}
break
}
respData, ok := resp.GetDataOk()
Expand All @@ -198,7 +198,7 @@ func (a *AuditApi) ListAuditLogsWithPagination(ctx _context.Context, o ...ListAu

for _, item := range results {
select {
case items <- datadog.PaginationResult[AuditLogsEvent]{item, nil}:
case items <- datadog.PaginationResult[AuditLogsEvent]{Item: item, Error: nil}:
case <-ctx.Done():
close(items)
return
Expand Down Expand Up @@ -356,7 +356,7 @@ func (a *AuditApi) SearchAuditLogsWithPagination(ctx _context.Context, o ...Sear
resp, _, err := a.SearchAuditLogs(ctx, o...)
if err != nil {
var returnItem AuditLogsEvent
items <- datadog.PaginationResult[AuditLogsEvent]{returnItem, err}
items <- datadog.PaginationResult[AuditLogsEvent]{Item: returnItem, Error: err}
break
}
respData, ok := resp.GetDataOk()
Expand All @@ -367,7 +367,7 @@ func (a *AuditApi) SearchAuditLogsWithPagination(ctx _context.Context, o ...Sear

for _, item := range results {
select {
case items <- datadog.PaginationResult[AuditLogsEvent]{item, nil}:
case items <- datadog.PaginationResult[AuditLogsEvent]{Item: item, Error: nil}:
case <-ctx.Done():
close(items)
return
Expand Down
8 changes: 4 additions & 4 deletions api/datadogV2/api_ci_visibility_pipelines.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ func (a *CIVisibilityPipelinesApi) ListCIAppPipelineEventsWithPagination(ctx _co
resp, _, err := a.ListCIAppPipelineEvents(ctx, o...)
if err != nil {
var returnItem CIAppPipelineEvent
items <- datadog.PaginationResult[CIAppPipelineEvent]{returnItem, err}
items <- datadog.PaginationResult[CIAppPipelineEvent]{Item: returnItem, Error: err}
break
}
respData, ok := resp.GetDataOk()
Expand All @@ -352,7 +352,7 @@ func (a *CIVisibilityPipelinesApi) ListCIAppPipelineEventsWithPagination(ctx _co

for _, item := range results {
select {
case items <- datadog.PaginationResult[CIAppPipelineEvent]{item, nil}:
case items <- datadog.PaginationResult[CIAppPipelineEvent]{Item: item, Error: nil}:
case <-ctx.Done():
close(items)
return
Expand Down Expand Up @@ -508,7 +508,7 @@ func (a *CIVisibilityPipelinesApi) SearchCIAppPipelineEventsWithPagination(ctx _
resp, _, err := a.SearchCIAppPipelineEvents(ctx, o...)
if err != nil {
var returnItem CIAppPipelineEvent
items <- datadog.PaginationResult[CIAppPipelineEvent]{returnItem, err}
items <- datadog.PaginationResult[CIAppPipelineEvent]{Item: returnItem, Error: err}
break
}
respData, ok := resp.GetDataOk()
Expand All @@ -519,7 +519,7 @@ func (a *CIVisibilityPipelinesApi) SearchCIAppPipelineEventsWithPagination(ctx _

for _, item := range results {
select {
case items <- datadog.PaginationResult[CIAppPipelineEvent]{item, nil}:
case items <- datadog.PaginationResult[CIAppPipelineEvent]{Item: item, Error: nil}:
case <-ctx.Done():
close(items)
return
Expand Down
8 changes: 4 additions & 4 deletions api/datadogV2/api_ci_visibility_tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ func (a *CIVisibilityTestsApi) ListCIAppTestEventsWithPagination(ctx _context.Co
resp, _, err := a.ListCIAppTestEvents(ctx, o...)
if err != nil {
var returnItem CIAppTestEvent
items <- datadog.PaginationResult[CIAppTestEvent]{returnItem, err}
items <- datadog.PaginationResult[CIAppTestEvent]{Item: returnItem, Error: err}
break
}
respData, ok := resp.GetDataOk()
Expand All @@ -269,7 +269,7 @@ func (a *CIVisibilityTestsApi) ListCIAppTestEventsWithPagination(ctx _context.Co

for _, item := range results {
select {
case items <- datadog.PaginationResult[CIAppTestEvent]{item, nil}:
case items <- datadog.PaginationResult[CIAppTestEvent]{Item: item, Error: nil}:
case <-ctx.Done():
close(items)
return
Expand Down Expand Up @@ -425,7 +425,7 @@ func (a *CIVisibilityTestsApi) SearchCIAppTestEventsWithPagination(ctx _context.
resp, _, err := a.SearchCIAppTestEvents(ctx, o...)
if err != nil {
var returnItem CIAppTestEvent
items <- datadog.PaginationResult[CIAppTestEvent]{returnItem, err}
items <- datadog.PaginationResult[CIAppTestEvent]{Item: returnItem, Error: err}
break
}
respData, ok := resp.GetDataOk()
Expand All @@ -436,7 +436,7 @@ func (a *CIVisibilityTestsApi) SearchCIAppTestEventsWithPagination(ctx _context.

for _, item := range results {
select {
case items <- datadog.PaginationResult[CIAppTestEvent]{item, nil}:
case items <- datadog.PaginationResult[CIAppTestEvent]{Item: item, Error: nil}:
case <-ctx.Done():
close(items)
return
Expand Down
4 changes: 2 additions & 2 deletions api/datadogV2/api_container_images.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func (a *ContainerImagesApi) ListContainerImagesWithPagination(ctx _context.Cont
resp, _, err := a.ListContainerImages(ctx, o...)
if err != nil {
var returnItem ContainerImageItem
items <- datadog.PaginationResult[ContainerImageItem]{returnItem, err}
items <- datadog.PaginationResult[ContainerImageItem]{Item: returnItem, Error: err}
break
}
respData, ok := resp.GetDataOk()
Expand All @@ -191,7 +191,7 @@ func (a *ContainerImagesApi) ListContainerImagesWithPagination(ctx _context.Cont

for _, item := range results {
select {
case items <- datadog.PaginationResult[ContainerImageItem]{item, nil}:
case items <- datadog.PaginationResult[ContainerImageItem]{Item: item, Error: nil}:
case <-ctx.Done():
close(items)
return
Expand Down
4 changes: 2 additions & 2 deletions api/datadogV2/api_containers.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func (a *ContainersApi) ListContainersWithPagination(ctx _context.Context, o ...
resp, _, err := a.ListContainers(ctx, o...)
if err != nil {
var returnItem ContainerItem
items <- datadog.PaginationResult[ContainerItem]{returnItem, err}
items <- datadog.PaginationResult[ContainerItem]{Item: returnItem, Error: err}
break
}
respData, ok := resp.GetDataOk()
Expand All @@ -191,7 +191,7 @@ func (a *ContainersApi) ListContainersWithPagination(ctx _context.Context, o ...

for _, item := range results {
select {
case items <- datadog.PaginationResult[ContainerItem]{item, nil}:
case items <- datadog.PaginationResult[ContainerItem]{Item: item, Error: nil}:
case <-ctx.Done():
close(items)
return
Expand Down
4 changes: 2 additions & 2 deletions api/datadogV2/api_downtimes.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ func (a *DowntimesApi) ListDowntimesWithPagination(ctx _context.Context, o ...Li
resp, _, err := a.ListDowntimes(ctx, o...)
if err != nil {
var returnItem DowntimeResponseData
items <- datadog.PaginationResult[DowntimeResponseData]{returnItem, err}
items <- datadog.PaginationResult[DowntimeResponseData]{Item: returnItem, Error: err}
break
}
respData, ok := resp.GetDataOk()
Expand All @@ -406,7 +406,7 @@ func (a *DowntimesApi) ListDowntimesWithPagination(ctx _context.Context, o ...Li

for _, item := range results {
select {
case items <- datadog.PaginationResult[DowntimeResponseData]{item, nil}:
case items <- datadog.PaginationResult[DowntimeResponseData]{Item: item, Error: nil}:
case <-ctx.Done():
close(items)
return
Expand Down
8 changes: 4 additions & 4 deletions api/datadogV2/api_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ func (a *EventsApi) ListEventsWithPagination(ctx _context.Context, o ...ListEven
resp, _, err := a.ListEvents(ctx, o...)
if err != nil {
var returnItem EventResponse
items <- datadog.PaginationResult[EventResponse]{returnItem, err}
items <- datadog.PaginationResult[EventResponse]{Item: returnItem, Error: err}
break
}
respData, ok := resp.GetDataOk()
Expand All @@ -204,7 +204,7 @@ func (a *EventsApi) ListEventsWithPagination(ctx _context.Context, o ...ListEven

for _, item := range results {
select {
case items <- datadog.PaginationResult[EventResponse]{item, nil}:
case items <- datadog.PaginationResult[EventResponse]{Item: item, Error: nil}:
case <-ctx.Done():
close(items)
return
Expand Down Expand Up @@ -367,7 +367,7 @@ func (a *EventsApi) SearchEventsWithPagination(ctx _context.Context, o ...Search
resp, _, err := a.SearchEvents(ctx, o...)
if err != nil {
var returnItem EventResponse
items <- datadog.PaginationResult[EventResponse]{returnItem, err}
items <- datadog.PaginationResult[EventResponse]{Item: returnItem, Error: err}
break
}
respData, ok := resp.GetDataOk()
Expand All @@ -378,7 +378,7 @@ func (a *EventsApi) SearchEventsWithPagination(ctx _context.Context, o ...Search

for _, item := range results {
select {
case items <- datadog.PaginationResult[EventResponse]{item, nil}:
case items <- datadog.PaginationResult[EventResponse]{Item: item, Error: nil}:
case <-ctx.Done():
close(items)
return
Expand Down
8 changes: 4 additions & 4 deletions api/datadogV2/api_incidents.go
Original file line number Diff line number Diff line change
Expand Up @@ -1145,7 +1145,7 @@ func (a *IncidentsApi) ListIncidentsWithPagination(ctx _context.Context, o ...Li
resp, _, err := a.ListIncidents(ctx, o...)
if err != nil {
var returnItem IncidentResponseData
items <- datadog.PaginationResult[IncidentResponseData]{returnItem, err}
items <- datadog.PaginationResult[IncidentResponseData]{Item: returnItem, Error: err}
break
}
respData, ok := resp.GetDataOk()
Expand All @@ -1156,7 +1156,7 @@ func (a *IncidentsApi) ListIncidentsWithPagination(ctx _context.Context, o ...Li

for _, item := range results {
select {
case items <- datadog.PaginationResult[IncidentResponseData]{item, nil}:
case items <- datadog.PaginationResult[IncidentResponseData]{Item: item, Error: nil}:
case <-ctx.Done():
close(items)
return
Expand Down Expand Up @@ -1331,7 +1331,7 @@ func (a *IncidentsApi) SearchIncidentsWithPagination(ctx _context.Context, query
resp, _, err := a.SearchIncidents(ctx, query, o...)
if err != nil {
var returnItem IncidentSearchResponseIncidentsData
items <- datadog.PaginationResult[IncidentSearchResponseIncidentsData]{returnItem, err}
items <- datadog.PaginationResult[IncidentSearchResponseIncidentsData]{Item: returnItem, Error: err}
break
}
respData, ok := resp.GetDataOk()
Expand All @@ -1350,7 +1350,7 @@ func (a *IncidentsApi) SearchIncidentsWithPagination(ctx _context.Context, query

for _, item := range results {
select {
case items <- datadog.PaginationResult[IncidentSearchResponseIncidentsData]{item, nil}:
case items <- datadog.PaginationResult[IncidentSearchResponseIncidentsData]{Item: item, Error: nil}:
case <-ctx.Done():
close(items)
return
Expand Down
Loading

0 comments on commit 8bf2f7b

Please sign in to comment.