Skip to content

CUT-2378: -Attribues Object needs custom type #69

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

Merged
merged 6 commits into from
Feb 8, 2024

Conversation

gweinjc
Copy link
Contributor

@gweinjc gweinjc commented Feb 7, 2024

Issues

  • CUT-2378 - -Attribues Object needs custom type

What does this solve?

Through some discovery it was determined that the -Attributes object is being flattened by the SDKs and does not necessarily need a custom type.

As an example the following script would set sudo to enabled and withoutPassword to false

$attributes = [JumpCloud.SDK.V2.Models.IGraphOperationSystemAttributes]@{ 'sudo' = @{'enabled' = $true; 'withoutPassword' = $false } }
Set-JcSdkSystemAssociation -SystemId 61982961719e942987898f39 -id 5ef5fe69a899bd46963ab24a -op 'update' -type 'user' -Attributes $attributes

We can achieve the same result by doing the following:

Set-JcSdkSystemAssociation -SystemId 61982961719e942987898f39 -id 5ef5fe69a899bd46963ab24a -op 'update' -type 'user' -Attributes @{ 'sudoEnabled' = $true; 'SudoWithoutPassword' = $true }

This is due to the SDKs doing a sort of flattening to the sudo object and allowing us to instead call the sudoEnabled or SudoWithoutPassword property to set those values.

Rather than creating a custom object, we can update the documentation for this functionality

This behavior can also be applied to the Set-JcSdkUserAssociation function

Is there anything particularly tricky?

N/A

How should this be tested?

Pull the branch and import the updated version of the V2 SDK
Attempt to run the following script and ensure that the results are updated in the console:

Set-JcSdkSystemAssociation -SystemId <SystemID> -id <UserID> -op 'update' -type 'user' -Attributes @{ 'sudoEnabled' = $true; 'SudoWithoutPassword' = $true }

@gweinjc gweinjc added patch Patch SDK Release Version SDK SDK Release Label labels Feb 7, 2024
@gweinjc gweinjc requested a review from a team as a code owner February 7, 2024 21:02
Copy link
Contributor

@jworkmanjc jworkmanjc left a comment

Choose a reason for hiding this comment

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

I think everything looks fine to me, Just two suggestions on the examples, if you remove associations from on object you technically don't need to pass in an attributes object. I think we should mark our examples this way but open for debate

Copy link
Contributor

@jworkmanjc jworkmanjc left a comment

Choose a reason for hiding this comment

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

Thanks for the examples!

Copy link
Contributor

@kmaranionjc kmaranionjc left a comment

Choose a reason for hiding this comment

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

Tests worked and code looks good. Great work

@jworkmanjc jworkmanjc merged commit 95c2ffd into master Feb 8, 2024
@jworkmanjc jworkmanjc deleted the CUT-2378_SystemAttributesObject branch February 8, 2024 22:25
@jworkmanjc jworkmanjc temporarily deployed to PublishToPSGallery February 8, 2024 22:25 — with GitHub Actions Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
patch Patch SDK Release Version SDK SDK Release Label
Development

Successfully merging this pull request may close these issues.

3 participants