SCRT-HQ / PSGSuite

Powershell module for Google / G Suite API calls wrapped in handy functions. Authentication is established using a service account via P12 key to negate the consent popup and allow for greater handsoff automation capabilities
https://psgsuite.io/
Apache License 2.0
235 stars 67 forks source link

Issue updating Resource ID using Update-GSResource #239

Closed cmason34 closed 4 years ago

cmason34 commented 4 years ago

We are working on creating new resources as well as updating existing ones. We want to change the id on some of our resources and am trying your example "Update-GSResource -ResourceId Train01 -Id TrainingRoom01" using our test resource and it is returning an error. We are able to update the capacity successfully using the same ResourceId, but get a "resource not found" error when we try to do -id.

scrthq commented 4 years ago

Alright, so did some digging @cmason34 - The Id parameter there is a convenience parameter for Calendar Resources that I added on the Update function since it was being returned when using Get. The confusion on my end was that I'm adding that property to the returned object on the Get function, so it doesn't actually exist. On the Update function, what happens is it first sets the ResourceId to the value set for that parameter (which would be the actual ResourceId of the resource), then the additional pass of a value for Id overwrites that with an expectedly non-existent ResourceId, resulting in failure to find the Resource.

Checking Google's REST documentation here, you can see that...

  1. There is no property on the object named Id
  2. The resourceId property is actually not writable, meaning that once set, you can't change it from what I can tell.

I'm going to remove the additional Id parameter to avoid confusion and subsequent failures. Thank you for bringing this to my attention!

Let me know if you have any questions regarding this!!

scrthq commented 4 years ago

hey @cmason34 - Updates have been deployed that remove the Id parameter as mentioned to avoid confusion! Docs also updated with a working example.