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

Add Historical Job endpoints to Datadog API spec #2765

Merged

Conversation

api-clients-generation-pipeline[bot]
Copy link
Contributor

@api-clients-generation-pipeline api-clients-generation-pipeline bot requested a review from a team as a code owner November 6, 2024 10:11
@api-clients-generation-pipeline api-clients-generation-pipeline bot added the changelog/Added Added features results into a minor version bump label Nov 6, 2024
}

localVarPath := localBasePath + "/api/v2/siem-historical-detections/jobs/{job_id}"
localVarPath = strings.Replace(localVarPath, "{"+"job_id"+"}", _neturl.PathEscape(datadog.ParameterToString(jobId, "")), -1)

Choose a reason for hiding this comment

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

🟠 Code Quality Violation

Suggested change
localVarPath = strings.Replace(localVarPath, "{"+"job_id"+"}", _neturl.PathEscape(datadog.ParameterToString(jobId, "")), -1)
localVarPath = strings.ReplaceAll(localVarPath, "{"+"job_id"+"}", _neturl.PathEscape(datadog.ParameterToString(jobId, "")))
Do not call Replace with a negative limit, use ReplaceAll instead (...read more)

In Go, the strings.Replace() function is used to replace a certain substring within a string with another substring. The function takes in four parameters: the original string, the old substring to be replaced, the new substring that will replace the old one, and an integer limit dictating how many replacements to be made.

Calling strings.Replace() with a negative limit doesn't really make sense. According to the Go documentation, if limit is negative, there is no limit on the number of replacements. Which means it will replace all instances of old substring in the original string with a new substring.

For example:

fmt.Println(strings.Replace("oink oink oink", "k", "ky", -2))

In this example, Replace returns a copy of the string "oink oink oink" where "k" is replaced by "ky" everywhere it appears, because limit is -2.

So it's not necessarily "incorrect" to use a negative limit, but it can create misunderstandings in your code. It's best to use a limit of -1 when you want to replace all instances, as this convention is more commonly understood to mean "no limit".

But if you specifically want to avoid using negative limit for Replace or looking for replace method with better efficiency, using strings.NewReplacer() could be a better option when there are multiple string pairs need to be replaced, where you can specify a list of old-new string pairs.

Or you can use strings.ReplaceAll(). It is equivalent to Replace with a limit of -1. It's arguably clearer and more self-explanatory than using a negative limit with strings.Replace().

For example:

fmt.Println(strings.ReplaceAll("oink oink oink", "o", "ky"))

It replaces all instances of "o" in the string "oink oink oink" by "ky".

View in Datadog  Leave us feedback  Documentation

@api-clients-generation-pipeline api-clients-generation-pipeline bot force-pushed the datadog-api-spec/generated/3251 branch from 641be0a to b0beace Compare November 6, 2024 13:08
}

localVarPath := localBasePath + "/api/v2/siem-historical-detections/jobs/{job_id}/cancel"
localVarPath = strings.Replace(localVarPath, "{"+"job_id"+"}", _neturl.PathEscape(datadog.ParameterToString(jobId, "")), -1)

Choose a reason for hiding this comment

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

🟠 Code Quality Violation

Suggested change
localVarPath = strings.Replace(localVarPath, "{"+"job_id"+"}", _neturl.PathEscape(datadog.ParameterToString(jobId, "")), -1)
localVarPath = strings.ReplaceAll(localVarPath, "{"+"job_id"+"}", _neturl.PathEscape(datadog.ParameterToString(jobId, "")))
Do not call Replace with a negative limit, use ReplaceAll instead (...read more)

In Go, the strings.Replace() function is used to replace a certain substring within a string with another substring. The function takes in four parameters: the original string, the old substring to be replaced, the new substring that will replace the old one, and an integer limit dictating how many replacements to be made.

Calling strings.Replace() with a negative limit doesn't really make sense. According to the Go documentation, if limit is negative, there is no limit on the number of replacements. Which means it will replace all instances of old substring in the original string with a new substring.

For example:

fmt.Println(strings.Replace("oink oink oink", "k", "ky", -2))

In this example, Replace returns a copy of the string "oink oink oink" where "k" is replaced by "ky" everywhere it appears, because limit is -2.

So it's not necessarily "incorrect" to use a negative limit, but it can create misunderstandings in your code. It's best to use a limit of -1 when you want to replace all instances, as this convention is more commonly understood to mean "no limit".

But if you specifically want to avoid using negative limit for Replace or looking for replace method with better efficiency, using strings.NewReplacer() could be a better option when there are multiple string pairs need to be replaced, where you can specify a list of old-new string pairs.

Or you can use strings.ReplaceAll(). It is equivalent to Replace with a limit of -1. It's arguably clearer and more self-explanatory than using a negative limit with strings.Replace().

For example:

fmt.Println(strings.ReplaceAll("oink oink oink", "o", "ky"))

It replaces all instances of "o" in the string "oink oink oink" by "ky".

View in Datadog  Leave us feedback  Documentation

@api-clients-generation-pipeline api-clients-generation-pipeline bot changed the title [SEC-14638] Add Historical Job endpoints to Datadog API spec Add Historical Job endpoints to Datadog API spec Nov 6, 2024
@api-clients-generation-pipeline api-clients-generation-pipeline bot force-pushed the datadog-api-spec/generated/3251 branch from b0beace to 544bb43 Compare November 6, 2024 13:17
}

localVarPath := localBasePath + "/api/v2/siem-historical-detections/jobs/{job_id}"
localVarPath = strings.Replace(localVarPath, "{"+"job_id"+"}", _neturl.PathEscape(datadog.ParameterToString(jobId, "")), -1)

Choose a reason for hiding this comment

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

🟠 Code Quality Violation

Suggested change
localVarPath = strings.Replace(localVarPath, "{"+"job_id"+"}", _neturl.PathEscape(datadog.ParameterToString(jobId, "")), -1)
localVarPath = strings.ReplaceAll(localVarPath, "{"+"job_id"+"}", _neturl.PathEscape(datadog.ParameterToString(jobId, "")))
Do not call Replace with a negative limit, use ReplaceAll instead (...read more)

In Go, the strings.Replace() function is used to replace a certain substring within a string with another substring. The function takes in four parameters: the original string, the old substring to be replaced, the new substring that will replace the old one, and an integer limit dictating how many replacements to be made.

Calling strings.Replace() with a negative limit doesn't really make sense. According to the Go documentation, if limit is negative, there is no limit on the number of replacements. Which means it will replace all instances of old substring in the original string with a new substring.

For example:

fmt.Println(strings.Replace("oink oink oink", "k", "ky", -2))

In this example, Replace returns a copy of the string "oink oink oink" where "k" is replaced by "ky" everywhere it appears, because limit is -2.

So it's not necessarily "incorrect" to use a negative limit, but it can create misunderstandings in your code. It's best to use a limit of -1 when you want to replace all instances, as this convention is more commonly understood to mean "no limit".

But if you specifically want to avoid using negative limit for Replace or looking for replace method with better efficiency, using strings.NewReplacer() could be a better option when there are multiple string pairs need to be replaced, where you can specify a list of old-new string pairs.

Or you can use strings.ReplaceAll(). It is equivalent to Replace with a limit of -1. It's arguably clearer and more self-explanatory than using a negative limit with strings.Replace().

For example:

fmt.Println(strings.ReplaceAll("oink oink oink", "o", "ky"))

It replaces all instances of "o" in the string "oink oink oink" by "ky".

View in Datadog  Leave us feedback  Documentation

@api-clients-generation-pipeline api-clients-generation-pipeline bot force-pushed the datadog-api-spec/generated/3251 branch 13 times, most recently from 2f464d0 to df64fdc Compare November 8, 2024 10:07
@api-clients-generation-pipeline api-clients-generation-pipeline bot force-pushed the datadog-api-spec/generated/3251 branch from fc5d33b to 3f52a13 Compare November 8, 2024 14:13
@api-clients-generation-pipeline api-clients-generation-pipeline bot force-pushed the datadog-api-spec/generated/3251 branch from baee605 to 8b4a6d5 Compare November 8, 2024 14:27
@api-clients-generation-pipeline api-clients-generation-pipeline bot merged commit df64067 into master Nov 8, 2024
12 checks passed
@api-clients-generation-pipeline api-clients-generation-pipeline bot deleted the datadog-api-spec/generated/3251 branch November 8, 2024 15:09
github-actions bot pushed a commit that referenced this pull request Nov 8, 2024
* Regenerate client from commit d907813e of spec repo

* pre-commit fixes

* pre-commit fixes

* pre-commit fixes

* pre-commit fixes

* pre-commit fixes

* pre-commit fixes

* pre-commit fixes

* pre-commit fixes

* pre-commit fixes

* pre-commit fixes

* pre-commit fixes

* pre-commit fixes

* pre-commit fixes

* pre-commit fixes

* pre-commit fixes

---------

Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com> df64067
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant