Skip to content
This repository has been archived by the owner on Jul 20, 2023. It is now read-only.

samples: update sample to use protos, until typing can be fixed #311

Merged
merged 5 commits into from
Jun 20, 2022

Conversation

juffalow
Copy link
Contributor

@juffalow juffalow commented Mar 3, 2022

Function searchUris takes an object with uri field which is a string and a threatTypes field which is array of numbers, not strings.

If strings are used, it will show error:

Argument of type '{ uri: string; threatTypes: string[]; }' is not assignable to parameter of type 'ISearchUrisRequest'.

Because searchUris first parameters is of type protos.google.cloud.webrisk.v1.ISearchUrisRequest:

interface ISearchUrisRequest {

    /** SearchUrisRequest uri */
    uri?: (string|null);

    /** SearchUrisRequest threatTypes */
    threatTypes?: (google.cloud.webrisk.v1.ThreatType[]|null);
}

And google.cloud.webrisk.v1.ThreatType is:

enum ThreatType {
    THREAT_TYPE_UNSPECIFIED = 0,
    MALWARE = 1,
    SOCIAL_ENGINEERING = 2,
    UNWANTED_SOFTWARE = 3
}

Even in web_risk_service_client.ts it is declared as:

  /**
   * ...
   * @param {number[]} request.threatTypes
   * ...
   */
  searchUris()

@juffalow juffalow requested a review from a team as a code owner March 3, 2022 23:32
@generated-files-bot
Copy link

Warning: This pull request is touching the following templated files:

@product-auto-label product-auto-label bot added the api: webrisk Issues related to the googleapis/nodejs-web-risk API. label Mar 3, 2022
@chingor13
Copy link
Contributor

This is a bug in our generated types. We want to be able to accept the stringified versions of the enums which are more friendly.

Filed googleapis/gax-nodejs#1205 on our types generator

@sofisl
Copy link
Contributor

sofisl commented Mar 28, 2022

Thanks @chingor13. In the meantime, I think it makes sense to update the sample. @juffalow, the README is generated from the quickstart. Could you make these changes to samples/quickstart, and the changes will propagate to the README? Thanks.

@product-auto-label product-auto-label bot added the size: xs Pull request size is extra small. label Apr 4, 2022
@juffalow
Copy link
Contributor Author

juffalow commented Apr 4, 2022

Thank @sofisl! I updated the code in samples/quickstart.js and dropped the old commit.

@bcoe bcoe added kokoro:run Add this label to force Kokoro to re-run the tests. owlbot:run Add this label to trigger the Owlbot post processor. labels Apr 13, 2022
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Apr 13, 2022
@yoshi-kokoro yoshi-kokoro removed the kokoro:run Add this label to force Kokoro to re-run the tests. label Apr 13, 2022
@product-auto-label product-auto-label bot added size: s Pull request size is small. and removed size: xs Pull request size is extra small. labels Apr 13, 2022
@sofisl
Copy link
Contributor

sofisl commented May 6, 2022

Sorry, one more request, would you mind adding a TODO comment on the sample like so (above the START tag):
TODO: revert threat types to strings once https://github.com/googleapis/gax-nodejs/issues/1205 is fixed

@bcoe bcoe changed the title Fix example code in README.md samples: update sample to use protos, until typing can be fixed Jun 7, 2022
@bcoe bcoe added kokoro:force-run Add this label to force Kokoro to re-run the tests. owlbot:run Add this label to trigger the Owlbot post processor. labels Jun 7, 2022
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Jun 7, 2022
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jun 7, 2022
@product-auto-label product-auto-label bot added the samples Issues that are directly related to samples. label Jun 8, 2022
@juffalow
Copy link
Contributor Author

Hi @sofisl! I added there the comment. Hope this is the place you mentioned.

@bcoe bcoe added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jun 20, 2022
@bcoe bcoe added the owlbot:run Add this label to trigger the Owlbot post processor. label Jun 20, 2022
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Jun 20, 2022
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jun 20, 2022
@bcoe bcoe merged commit bef8ba7 into googleapis:main Jun 20, 2022
@bcoe
Copy link
Contributor

bcoe commented Jun 20, 2022

@juffalow thank you for the contribution 👏

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api: webrisk Issues related to the googleapis/nodejs-web-risk API. samples Issues that are directly related to samples. size: s Pull request size is small.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants