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

GraphQL and Rubrik SDK for PowerShell Get-RubrikOrganization.ps1 #637

Closed
josefrancarubrik opened this issue May 25, 2020 · 1 comment · Fixed by #638
Closed

GraphQL and Rubrik SDK for PowerShell Get-RubrikOrganization.ps1 #637

josefrancarubrik opened this issue May 25, 2020 · 1 comment · Fixed by #638

Comments

@josefrancarubrik
Copy link

Is your feature request related to a problem? Please describe.
Currently Rubrik SDK for PowerShell covers REST API implementation for workflow automation which is great! In newer CDM releases GraphQL is being introduced for some of the endpoints and would be nice to have those available with Rubrik SDK for PowerShell.

Describe the solution you'd like
Get-RubrikOrganization.ps1 will fetch data for all organizations with REST, would be really useful to have the equivalent of this request with GraphQL, the example below is a query with GraphQL to retrieve all organizations.

curl 'https://<node-ip>/api/internal/graphql' -H 'authorization: Bearer <rubrik-token>' -H 'content-type: application/json;charset=UTF-8' -H 'accept: application/json, text/plain, */*' -H 'referer: https://b-0766-lb.rubrik-lab.com/web/bin/index.html' --data-binary '{"query":"query OrganizationSummary(\n $name: String,\n $isGlobal: Boolean,\n $sortBy: String,\n $sortOrder: String,\n $first: Int,\n $after: String,\n) {\n organizationConnection(\n name: $name,\n isGlobal: $isGlobal,\n sortBy: $sortBy,\n sortOrder: $sortOrder,\n first: $first,\n after: $after\n ) {\n nodes {\n id\n name\n isGlobal\n exclusivenessLevel\n admins {\n id\n name\n }\n envoyStatus\n }\n pageInfo {\n endCursor\n hasNextPage\n }\n }\n}\n","variables":{"sortBy":"name","sortOrder":"asc","isGlobal":false }} ' --insecure

As a next item, GranphQL provides the filtering option that will enhance further the performance of requests to endpoints by returning only desired data, the example below return the first 3 organizations containing string org in the name. The first filter can be open to return all matching names.

curl 'https://<IP>/api/internal/graphql' -H 'authorization: Bearer <rubrik-token>' -H 'content-type: application/json;charset=UTF-8' -H 'accept: application/json, text/plain, */*' -H 'referer: https://b-0766-lb.rubrik-lab.com/web/bin/index.html' --data-binary '{"query":"query OrganizationSummary(\n $name: String,\n $isGlobal: Boolean,\n $sortBy: String,\n $sortOrder: String,\n $first: Int,\n $after: String,\n) {\n organizationConnection(\n name: $name,\n isGlobal: $isGlobal,\n sortBy: $sortBy,\n sortOrder: $sortOrder,\n first: $first,\n after: $after\n ) {\n nodes {\n id\n name\n isGlobal\n exclusivenessLevel\n admins {\n id\n name\n }\n envoyStatus\n }\n pageInfo {\n endCursor\n hasNextPage\n }\n }\n}\n","variables":{"sortBy":"name","sortOrder":"asc","first":3,"name":"org","isGlobal":false}}' --insecure

Describe alternatives you've considered
The available alternative at this moment is to use GraphQL with bash.

@jaapbrasser
Copy link
Contributor

Thanks for submitting this issue @josefrancarubrik, I'll take a look at how we can implement this going forward with the module.

jaapbrasser added a commit that referenced this issue May 25, 2020
mwpreston added a commit that referenced this issue Jun 18, 2020
Added Invoke-RubrikGraphQLCall to the module - Issue #637
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants