Giter Site home page Giter Site logo

jcapi-powershell's Introduction

jcapi-powershell

Description

This repository contains the PowerShell client code for the JumpCloud V1, V2 and DirectoryInsights APIs. It also provides the tools necessary to generate this code from the API Yaml files using AutoRest. AutoRest, simply put is a tool used to generate client libraries for accessing RESTful web services.

Building from AutoRest

You can build all V1, V2 and DirectoryInsights modules using AutoRest. The BuildAutoRest script invokes AutoRest along and automates the building PowerShell functions from the JumpCloud API Swagger Spec. You can change the behavior of how AutoRest builds the SDKs by modifying the contents of the config files.

Example: Building DirectoryInsights

./BuildAutoRest -SDKName JumpCloud.SDK.DirectoryInsights -JCApiKey <ApiKey> -JCOrgId <OrgId>

Importing the generated Module

After building from AutoRest, a generated module can be imported into your local PowerShell session for testing or development

Import-Module ~/jcapi-powershell/SDKs/PowerShell/JumpCloud.SDK.DirectoryInsights/JumpCloud.SDK.DirectoryInsights.psd1

or by calling the run-module.ps1 script located within each SDK folder

./jcapi-powershell/SDKs/PowerShell/JumpCloud.SDK.DirectoryInsights/run-module.ps1

Although AutoRest can pack a NuGet package per each generated SDK, the packing and versioning of the PowerShell SDK is managed through our CI/CD pipeline.

Authentication and Authorization

Authentication to the PowerShell SDK is implemented through the Custom/Module.cs file and copied into each generated SDK. Each PowerShell SDK requires an APIKEY and an ORGID to be populated. These variables are saved as an environment variable to avoid prompting per each function invocation.

Documentation and Examples

Documentation is generated but the examples per each function need to be populated before generation. Within a given SDK directory, populate several usage examples within each SDK's /examples/ directory.

Custom Translations and Functions

During SDK generation, a transform step is applied to the swagger spec data, think of it like a dictionary of user-friendly translations. The ApiTansform.ps1 script contains those translation definitions and will need to be updated if new endpoints require a custom translation.

These SDKs contain all the functionality of the JumpCloudAPIs in addition to the following added features that have been applied during SDK generation by the BuildCustomFunctions.ps1 script:

  • Authentication through environment variables $env:JCApiKey and $env:JCOrgId. If these are not set the SDK will prompt the user to set them and in turn append the x-api-key and x-org-id headers to each API call.
  • Normalization of endpoint output. The multiple APIs return data in different ways which have been normalized through the SDKs.
  • Auto pagination and removal of Skip and Limit parameters. This enables the functions to return all data from API endpoint.

jcapi-powershell's People

Contributors

epanipinto avatar kmoorehead-jc avatar jworkmanjc avatar btstevens avatar jc-rbacon avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.