Celerium.ITGlue
Celerium.ITGlue

CI GitHub_Pages

PoshGallery_Version PoshGallery_Platforms PoshGallery_Downloads codeSize

Contributors Forks Stargazers Issues

GitHub_License


Logo

PowerShell Gallery · Report Bug · Request Feature


Buy me a coffee

Whether you use this project, have learned something from it, or just like it, please consider supporting it by buying me a coffee, so I can dedicate more time on open-source projects like this :)

Buy Me A Coffee

About The Project

The Celerium.ITGlue PowerShell wrapper offers a way to read & (with safeguards) change the data of IT Glue’s documentation platform, such as organizations, configurations, contacts, locations, passwords, flexible assets, & documents. This module serves to abstract away the details of interacting with IT Glue’s API endpoints in such a way that is consistent with PowerShell nomenclature. This gives system administrators and PowerShell developers a convenient and familiar way of using IT Glue’s API to create documentation scripts, automation, and integrations.

A function is generated for every endpoint in the ITGlue OpenAPI spec (ITGlue-1.118.132.20261114.json) and every endpoint is tracked in the endpoints.csv file.

:warning: Any function that is not a read-only Get- function can change data. See Write functions.

In order to maintain PowerShell best practices, only approved verbs are used and PowerShell’s verb-noun nomenclature is respected. Each noun is prefixed with ITGlue in an attempt to prevent naming problems.

  • GET -> Get-ITGlue*
  • POST -> New-ITGlue*
  • PATCH -> Set-ITGlue* (& Publish-ITGlueDocument)
  • DELETE -> Remove-ITGlue*

For example, one might access the /organizations endpoint by running the following PowerShell command:

Get-ITGlueOrganization
  • Most functions cover more than one endpoint with parameter sets. Get-ITGlueConfiguration lists the configurations of the account, -OrganizationId 12345 lists the configurations of an organization, -Id 67890 gets one configuration, & -OrganizationId 12345 -Id 67890 gets one configuration of an organization
  • JSON:API query parameters are PowerShell parameters: filter[organization_id] = -FilterOrganizationId, page[size] = -PageSize, sort = -Sort, & include = -Include (tab completion shows the allowed sort & include values)
  • By default only the data of a response is returned, such as the organizations of /organizations. Use -Raw to return the full JSON:API response, including the meta, links, & included properties
  • Paged endpoints have -PageNumber & -PageSize parameters and an -AllResults switch that requests every page for you (1000 items per page, the maximum, unless -PageSize is used)

Write functions

The New-, Set-, Publish-, & Remove- functions change data in ITGlue. Use them with care on a production account:

  • Every write function supports -WhatIf, which shows what would be sent without sending anything
  • Every write function has a ConfirmImpact of High, so PowerShell asks for confirmation before the request is sent unless -Confirm:$false is used
  • A write request is never retried automatically
  • The request body is defined with -Data, the value of the JSON:API data property, such as @{ type = 'organizations'; attributes = @{ name = 'Celerium' } }
  • The unit tests, the live tests, & the examples never send a write request (the 1.x example scripts in examples/Legacy do, they are marked & never run automatically)
# Shows the request that would be sent, nothing is sent
Set-ITGlueOrganization -Id 12345 -Data @{ type = 'organizations'; attributes = @{ name = 'Celerium' } } -WhatIf

(back to top)

Install

This module can be installed directly from the PowerShell Gallery with the following command:

Install-Module -Name Celerium.ITGlue
  • :information_source: This module supports Windows PowerShell 5.1 and PowerShell 7+ on Windows, Linux, & macOS. Every change is tested on all of them by the CI workflow.
  • :information_source: If PowerShellGet is unavailable, you can manually download the main branch and place the latest version of Celerium.ITGlue from the build folder into the (default) C:\Program Files\WindowsPowerShell\Modules folder.

Celerium.ITGlue project documentation can be found on Github Pages

  • A full list of functions can be retrieved by running Get-Command -Module Celerium.ITGlue.
  • Help info and a list of parameters can be found by running Get-Help <command name>, such as:
Get-Help Get-ITGlueConfiguration
Get-Help Get-ITGlueConfiguration -Full

(back to top)

Initial Setup

After installing this module, you will need to configure both the base URI & API access token that are used to talk with the ITGlue API.

  1. Run Add-ITGlueBaseURI
    • By default, ITGlue’s https://api.itglue.com uri is used (this is also the default when the module is imported)
    • Use Add-ITGlueBaseURI -DataCenter EU (https://api.eu.itglue.com) or -DataCenter AU (https://api.au.itglue.com) for the other data centers
    • If you have your own API gateway or proxy, you can use Add-ITGlueBaseURI -BaseURI https://myapi.gateway.example.org, only https is supported
  2. Run Add-ITGlueAPIKey
    • It will prompt you to enter your API key as a secure string, or use Add-ITGlueAPIKey -ApiKey 'your-api-key'
    • Create API keys in ITGlue via Account > Settings > API Keys. Use a key without password access unless passwords are required
    • The API key is sent in the x-api-key header
  3. [optional] Run Test-ITGlueAPIKey
    • Makes a single GET request to the /regions endpoint to validate the base uri & API key
  4. [optional] Run Export-ITGlueModuleSettings
    • This will create a config file at %UserProfile%\Celerium.ITGlue that holds the base uri & API key information.
    • Next time you run Import-Module -Name Celerium.ITGlue, this configuration file will automatically be loaded.
    • :warning: Exporting module settings encrypts your API key in a format that can only be unencrypted by the user principal that encrypted the secret. It makes use of .NET DPAPI, which for Windows uses reversible encrypted tied to your user principal. This means that you cannot copy your configuration file to another computer or user account and expect it to work.
    • :warning: However in Linux\Unix operating systems the API key is more obfuscated than encrypted so it is recommend to use environment variables or a more secure & cross-platform storage method.

Environment variables (recommended for CI\CD, Linux, & macOS) are loaded when the module is imported and take precedence over the configuration file:

$env:ITGLUE_BASE_URI    = 'https://api.itglue.com'   # Optional
$env:ITGLUE_API_KEY     = 'your-api-key'
Import-Module -Name Celerium.ITGlue

(back to top)

Usage

Calling an API endpoint is as simple as running its Get-ITGlue* function.

# Get the first 50 organizations (the default page size of the API)
Get-ITGlueOrganization

# Get every organization, 1000 at a time
Get-ITGlueOrganization -AllResults

# Filter, sort, & page
Get-ITGlueOrganization -FilterName 'Celerium' -Sort '-updated_at' -PageNumber 2 -PageSize 10

# The configurations of an organization & a single configuration with its passwords
Get-ITGlueConfiguration -OrganizationId 12345 -AllResults
Get-ITGlueConfiguration -Id 67890 -Include 'passwords'

# Get the meta data (such as the total count), links, & included items
(Get-ITGlueOrganization -PageSize 1 -Raw).meta.'total-count'

# Flexible assets need the flexible asset type
Get-ITGlueFlexibleAsset -FilterFlexibleAssetTypeId 123 -FilterOrganizationId 12345
  • The full list of endpoints & their functions is tracked in the endpoints.csv file and on Github Pages.
  • Example scripts can be found in the examples folder of this repository. They only use read-only requests. The 1.x example scripts are kept in examples/Legacy for reference: most of them create, change, & delete example data & they use the 1.x response format (.data)

Supported functions

The module has 114 public functions in 37 categories that cover all 209 endpoints in the spec (86 GET, 36 POST, 54 PATCH, & 33 DELETE). 35 are read-only Get- functions & 79 are write functions. Every endpoint & its function is listed in the endpoints.csv file.

Category Functions
Organizations Get-, New-, Set-, & Remove-ITGlueOrganization
Configurations Get-, New-, Set-, & Remove-ITGlueConfiguration, *-ITGlueConfigurationInterface, Status, & Type
Contacts & Locations Get-, New-, Set-, & Remove-ITGlueContact, ITGlueContactType, & ITGlueLocation
Documents *-ITGlueDocument, Publish-ITGlueDocument, *-ITGlueDocumentFolder, DocumentImage, & DocumentSection
Flexible assets *-ITGlueFlexibleAsset, FlexibleAssetType, & FlexibleAssetField
Passwords *-ITGluePassword, PasswordCategory, & PasswordFolder
Relationships *-ITGlueAttachment, RelatedItem, & ResourceAccess
Account *-ITGlueGroup, User, UserMetric, Checklist, Export, Expiration, Domain, & Log
Reference data Get-ITGlueCountry, Region, Manufacturer, Model, OperatingSystem, Platform, & OrganizationStatus\Type

Upgrading from 1.x

Version 2.0.0 generates every function from the OpenAPI spec. Every function name of version 1.3.0 still exists, but some behavior changed:

  • Functions return the data of a response instead of the full response. Code such as (Get-ITGlueOrganization).data becomes Get-ITGlueOrganization. Use -Raw for the full response (data, meta, links, & included)
  • -AllResults requests 1000 items per page (unless -PageSize is used) & returns the items of every page. With -Raw the included items of every page are returned as well
  • Write functions ask for confirmation (ConfirmImpact High), use -Confirm:$false in scripts that must not prompt
  • The boolean filters & parameters are [bool] parameters instead of strings or switches, such as -FilterArchived $false, -FilterImportant $true, -FilterEnabled $true, & -ShowPassword $false ('true' & 'false' strings are no longer accepted)
  • -Sort & -Include accept any value (several values can be comma separated), tab completion shows the documented values
  • -Id is only bound from the pipeline by value (12345 | Get-ITGlueOrganization), a piped object is not used as an ID because every ITGlue object has an id property
  • -FilterRange of Get-ITGlueOrganization & Get-ITGlueExpiration was removed, use -FilterRangeMyGlueAccountId & -FilterRangeExpirationDate
  • -Type of New-, Set-, & Remove-ITGlueResourceAccess was removed, the type is always resource-accesses
  • Remove-ITGlueChecklist, Remove-ITGlueConfiguration, Remove-ITGlueDocument, & Remove-ITGlueDocumentFolder accept one or more IDs with -Id & send them as a bulk delete
  • The parameter sets have new names (List, ById, ByOrganization, ByOrganizationById, BulkUpdate, BulkDestroy, etc.)
  • New functions: Remove-ITGlueConfigurationInterface, Remove-ITGlueConfigurationType, Remove-ITGlueContactType, Remove-ITGlueFlexibleAssetType, & Remove-ITGlueOrganizationType, and Set-ITGlueUser can bulk update users
  • The API key can be loaded from the ITGLUE_API_KEY & ITGLUE_BASE_URI environment variables. A configuration file created by version 1.x is still loaded
  • The example scripts of version 1.x, which create & change example data, moved to examples/Legacy (each one has a LEGACY banner) & a read-only example was added

Development

The module is built from the files in this repository with the scripts in the build folder. The same steps are run by the GitHub Actions workflows in .github/workflows.

Script Description
Install-Prerequisites.ps1 Installs the latest ModuleBuilder, Pester, Microsoft.PowerShell.PlatyPS, & PSScriptAnalyzer
New-PublicFunctions.ps1 (PowerShell 7+) Regenerates every public function, the manifest entries, & docs/endpoints.csv from the spec
Get-ITGlueSpec.ps1 (PowerShell 7+) Downloads the online spec (raw.githubusercontent.com) & saves it as docs/ITGlue-<version>.json
Compare-ITGlueSpec.ps1 Compares the newest local spec in docs with the online spec & optionally updates it
Invoke-ModuleBuild.ps1 Builds the module & the spec into build/Celerium.ITGlue/<version>
Invoke-PesterTests.ps1 Runs the Pester tests against the source or built module
Invoke-HelpContent.ps1 Regenerates the GitHub pages documentation in docs with Microsoft.PowerShell.PlatyPS
Publish-CeleriumModule.ps1 Publishes the built module to the PowerShell Gallery

The scripts never delete files. Public functions that are no longer generated are moved to build/Archive/<date>.

./build/Install-Prerequisites.ps1
./build/Invoke-ModuleBuild.ps1 -Version 2.0.0
./build/Invoke-PesterTests.ps1 -Version 2.0.0 -BuildTarget built

To support a newer version of the API, run ./build/Compare-ITGlueSpec.ps1 to see what changed in the online spec compared with the newest spec in docs. Run ./build/Get-ITGlueSpec.ps1 to download the online spec as docs/ITGlue-<version>.json (a different file with the same name is first copied to build/Archive), then run ./build/New-PublicFunctions.ps1. The function names of the endpoints are defined in the $FunctionNameMap table of New-PublicFunctions.ps1 & the convenience parameters of version 1.x in the $BodyAttributeMap table.

Live tests make real, read-only GET requests (about 12). They are excluded unless the following environment variables are set and the Live tag is included:

$env:ITGLUE_API_KEY     = 'your-api-key'
$env:ITGLUE_BASE_URI    = 'https://api.itglue.com'   # Optional
./build/Invoke-PesterTests.ps1 -Version 2.0.0 -IncludeTag Live -ExcludeTag Online

(back to top)


Contributing

Contributions are what makes the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag “enhancement”. Don’t forget to give the project a star! Thanks again!

See the CONTRIBUTING guide for more information about contributing.

(back to top)

License

Distributed under the MIT license. See LICENSE for more information.

GitHub_License

(back to top)


Table of contents