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

feat(diregapic)(LRO): Add minimum wrapper for mitigate future full-implementation diregapic LRO change #967

Merged
merged 8 commits into from
Sep 2, 2021

Conversation

summer-ji-eng
Copy link
Collaborator

@summer-ji-eng summer-ji-eng commented Aug 30, 2021

Wrap an unary operations, that made it return a response compatible with the eventual LRO operation. In another word, utilize duck typing to return the similar structure, but no ".promise" field.

Sample code test on generated client library:

async function main() {
  const projectId = await regionOperationClient.getProjectId();
  const region = 'us-central1';
  const rand = Math.floor(Math.random() * 1000);
  const addressResource = {
    name: `operation-insert-address-test-${rand}`,
  };
  const [operation] = await addressClient.insert({
    addressResource: addressResource,
    project: projectId,
    region: region
  })
  console.log('insert address operation.id:: ', operation);
  }

The output:
insert address operation.id:: {
latestResponse: {
warnings: [],
id: '3894509470566436984',
_id: 'id',
startTime: '2021-08-29T22:37:27.644-07:00',
_startTime: 'startTime',
targetLink: 'https://www.googleapis.com/compute/v1/projects/gapic-images/regions/us-central1/addresses/operation-insert-address-test-188',
_targetLink: 'targetLink',
progress: 0,
_progress: 'progress',
region: 'https://www.googleapis.com/compute/v1/projects/gapic-images/regions/us-central1',
_region: 'region',
operationType: 'insert',
_operationType: 'operationType',
status: 'RUNNING',
_status: 'status',
...
},
done: false,
name: '3894509470566436984',
metadata: null,
result: {}
}

@summer-ji-eng summer-ji-eng requested a review from a team as a code owner August 30, 2021 00:32
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Aug 30, 2021
method.options?.['.google.api.http'].get ||
(method.name === 'Wait' && method.options?.['.google.api.http'].post)
)
? true
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: there is no need to write booleanValue ? true : false, just booleanValue is enough. So you can just remove lines 180 and 181.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I removed line 180 and 181, but update isDiregapic with the type boolean | '' | null | undefined

Copy link
Contributor

@alexander-fenster alexander-fenster left a comment

Choose a reason for hiding this comment

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

Looks good to me, let's just get rid of any :)

@@ -372,14 +377,22 @@ export class AddressesClient {
'project': request.project || '',
});
this.initialize();
return this.innerApiCalls.delete(request, options, callback);
return this.innerApiCalls.delete(request, options, callback)
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: no need to disable no-explicit-any now :)

@summer-ji-eng summer-ji-eng added the automerge Merge the pull request once unit tests and other checks pass. label Sep 2, 2021
@summer-ji-eng summer-ji-eng merged commit e12a72d into master Sep 2, 2021
@summer-ji-eng summer-ji-eng deleted the mitigate_unary_lro branch September 2, 2021 21:47
@gcf-merge-on-green gcf-merge-on-green bot removed the automerge Merge the pull request once unit tests and other checks pass. label Sep 2, 2021
@summer-ji-eng summer-ji-eng changed the title feat: Add minimum wrapper for mitigate future full-implementation diregapic LRO change feat: [diregapic][LRO]Add minimum wrapper for mitigate future full-implementation diregapic LRO change Sep 9, 2021
@summer-ji-eng summer-ji-eng changed the title feat: [diregapic][LRO]Add minimum wrapper for mitigate future full-implementation diregapic LRO change feat(diregapic)(LRO): Add minimum wrapper for mitigate future full-implementation diregapic LRO change Sep 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants