Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions .github/workflows/jcapi-powershell-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ jobs:
V1: ${{ steps.set_labels.outputs.V1 }}
V2: ${{ steps.set_labels.outputs.V2 }}
DIRECTORYINSIGHTS: ${{ steps.set_labels.outputs.DIRECTORYINSIGHTS }}
# When PR has label skip-api-transform, BuildAutoRest runs with -RunApiTransform:$false
SKIP_API_TRANSFORM: ${{ steps.set_labels.outputs.SKIP_API_TRANSFORM }}
steps:
- name: Set Environment Variables from PR Labels
id: set_labels
Expand Down Expand Up @@ -74,6 +76,14 @@ jobs:
Write-Host "Module label 'DirectoryInsights' found"
echo "directoryinsights=true" >> $env:GITHUB_OUTPUT
}

# Optional: skip ApiTransform.ps1 (remote spec fetch + JSON transforms) during CI builds
if ('skip-api-transform' -in $PR_LABEL_LIST) {
Write-Host "Label 'skip-api-transform' found: BuildAutoRest will use -RunApiTransform:`$false"
echo "SKIP_API_TRANSFORM=true" >> $env:GITHUB_OUTPUT
} else {
echo "SKIP_API_TRANSFORM=false" >> $env:GITHUB_OUTPUT
}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand Down Expand Up @@ -134,6 +144,7 @@ jobs:
v2: ${{ needs.Check-PR-Labels.outputs.v2 }}
directoryinsights: ${{ needs.Check-PR-Labels.outputs.directoryinsights }}
RELEASE_TYPE: ${{ needs.Check-PR-Labels.outputs.RELEASE_TYPE }}
SKIP_API_TRANSFORM: ${{ needs.Check-PR-Labels.outputs.SKIP_API_TRANSFORM }}
run: |
# Construct the PR_LABELS variable for the Pester test script
$prLabels = @()
Expand All @@ -157,6 +168,8 @@ jobs:
if: contains(github.event.pull_request.labels.*.name, 'DirectoryInsights')
runs-on: ubuntu-latest
timeout-minutes: 70
env:
SKIP_API_TRANSFORM: ${{ needs.Check-PR-Labels.outputs.SKIP_API_TRANSFORM }}
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v3
Expand All @@ -166,7 +179,8 @@ jobs:
- name: Build JumpCloud.SDK.DirectoryInsights
shell: pwsh
run: |
./BuildAutoRest -SDKName:("JumpCloud.SDK.DirectoryInsights") -ModuleVersionIncrementType "${{ needs.Check-PR-Labels.outputs.RELEASE_TYPE }}"
$runApiTransform = $env:SKIP_API_TRANSFORM -ne 'true'
./BuildAutoRest -SDKName:("JumpCloud.SDK.DirectoryInsights") -ModuleVersionIncrementType "${{ needs.Check-PR-Labels.outputs.RELEASE_TYPE }}" -RunApiTransform:$runApiTransform
- name: Pack JumpCloud.SDK.DirectoryInsights Module
shell: pwsh
run: |
Expand Down Expand Up @@ -195,6 +209,8 @@ jobs:
if: contains(github.event.pull_request.labels.*.name, 'v1')
runs-on: ubuntu-latest
timeout-minutes: 70
env:
SKIP_API_TRANSFORM: ${{ needs.Check-PR-Labels.outputs.SKIP_API_TRANSFORM }}
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v3
Expand All @@ -204,7 +220,8 @@ jobs:
- name: Build JumpCloud.SDK.V1
shell: pwsh
run: |
./BuildAutoRest -SDKName:("JumpCloud.SDK.V1") -ModuleVersionIncrementType "${{ needs.Check-PR-Labels.outputs.RELEASE_TYPE }}"
$runApiTransform = $env:SKIP_API_TRANSFORM -ne 'true'
./BuildAutoRest -SDKName:("JumpCloud.SDK.V1") -ModuleVersionIncrementType "${{ needs.Check-PR-Labels.outputs.RELEASE_TYPE }}" -RunApiTransform:$runApiTransform
- name: Pack JumpCloud.SDK.V1 Module
shell: pwsh
run: |
Expand Down Expand Up @@ -233,6 +250,8 @@ jobs:
if: contains(github.event.pull_request.labels.*.name, 'v2')
runs-on: ubuntu-latest
timeout-minutes: 70
env:
SKIP_API_TRANSFORM: ${{ needs.Check-PR-Labels.outputs.SKIP_API_TRANSFORM }}
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v3
Expand All @@ -242,7 +261,8 @@ jobs:
- name: Build JumpCloud.SDK.V2
shell: pwsh
run: |
./BuildAutoRest -SDKName:("JumpCloud.SDK.V2") -ModuleVersionIncrementType "${{ needs.Check-PR-Labels.outputs.RELEASE_TYPE }}"
$runApiTransform = $env:SKIP_API_TRANSFORM -ne 'true'
./BuildAutoRest -SDKName:("JumpCloud.SDK.V2") -ModuleVersionIncrementType "${{ needs.Check-PR-Labels.outputs.RELEASE_TYPE }}" -RunApiTransform:$runApiTransform
- name: Pack JumpCloud.SDK.V2 Module
shell: pwsh
run: |
Expand Down
8 changes: 4 additions & 4 deletions ApiTransform.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -543,16 +543,16 @@ function Add-ParameterizedHost {

# Determine host prefix and enum values based on existing host
$hostPrefix = 'console'
$enumValues = @('console', 'console.eu')
$enumValues = @('console', 'console.eu', 'console.in')

if ($SwaggerObject.Contains('host')) {
$currentHost = $SwaggerObject['host']
if ($currentHost -like 'api.jumpcloud.com*') {
$hostPrefix = 'api'
$enumValues = @('api', 'api.eu')
$enumValues = @('api', 'api.eu', 'api.in')
} elseif ($currentHost -like 'console.jumpcloud.com*') {
$hostPrefix = 'console'
$enumValues = @('console', 'console.eu')
$enumValues = @('console', 'console.eu', 'console.in')
}
}

Expand All @@ -563,7 +563,7 @@ function Add-ParameterizedHost {
parameters = @(
[ordered]@{
name = if ($SDKName -eq "JumpCloud.SDK.DirectoryInsights") { 'apiHost' } else { 'consoleHost' }
description = "Region for JumpCloud API host. Use '$hostPrefix' for US or '$hostPrefix.eu' for EU."
description = "Region for JumpCloud API host. Use '$hostPrefix' for US, '$hostPrefix.eu' for EU or '$hostPrefix.in' for IN."
required = $true
type = 'string'
in = 'client'
Expand Down
2 changes: 1 addition & 1 deletion BuildAutoRest.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ ForEach ($SDK In $SDKName)
}
# After AutoRest generation, create a ModuleIdentifier.cs file for each SDK
$moduleIdentifierPath = "$OutputFullPath/custom/ModuleIdentifier.cs"
$sdkIdentifier = switch ($SDKNameItem) {
$sdkIdentifier = switch ($SDKName) {
Comment thread
jworkmanjc marked this conversation as resolved.
'JumpCloud.SDK.DirectoryInsights' { 'DirectoryInsights' }
'JumpCloud.SDK.V1' { 'V1' }
'JumpCloud.SDK.V2' { 'V2' }
Expand Down
2 changes: 1 addition & 1 deletion Configs/JumpCloud.SDK.DirectoryInsights.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ powershell: true
dll-name: JumpCloud.SDK.DirectoryInsights.private
base-folder: ..
debug: true
module-version: 0.1.1
module-version: 0.2.0
metadata:
iconUri: https://console.jumpcloud.com/img/login-viewport-logo.png
licenseUri: https://github.com/TheJumpCloud/jcapi-powershell/tree/$(branch)/LICENSE
Expand Down
2 changes: 1 addition & 1 deletion Configs/JumpCloud.SDK.V1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ input-file:
module-name: JumpCloud.SDK.V1
namespace: JumpCloud.SDK.V1
sample-generation: true
module-version: 0.1.3
module-version: 0.2.0
dll-name: JumpCloud.SDK.V1.private

directive:
Expand Down
2 changes: 1 addition & 1 deletion Configs/JumpCloud.SDK.V2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ verbose: true
module-name: JumpCloud.SDK.V2
output-folder: SDKs/PowerShell/JumpCloud.SDK.V2
dll-name: JumpCloud.SDK.V2.private
module-version: 0.2.1
module-version: 0.3.0
powershell: true
base-folder: ..
17 changes: 13 additions & 4 deletions Custom/Module.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ private void SetDefaultHostEnvInPowerShellSession()
apiHostValue = "api.eu";
consoleHostValue = "console.eu";
break;
case "IN":
apiHostValue = "api.in";
consoleHostValue = "console.in";
break;
case "STAGING":
apiHostValue = "api.stg01";
consoleHostValue = "console.stg01";
Expand All @@ -53,6 +57,11 @@ private void SetDefaultHostEnvInPowerShellSession()
apiHostValue = "api.eu";
consoleHostValue = "console.eu";
}
else if (userInputEnvValue.Contains(".in"))
{
apiHostValue = "api.in";
consoleHostValue = "console.in";
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Substring .in match is overly broad for region detection

Medium Severity

The Contains(".in") check in the default branch and in the HostEnv translation logic can false-positive on values containing .internal, .info, .instance, etc. Unlike .eu or .stg01, .in is a very short and common substring. A user entering a custom value like console.internal.jumpcloud.com would be incorrectly routed to the India region. This affects all four copies of Module.cs.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit c3f6953. Configure here.

else if (userInputEnvValue.Contains(".stg01"))
{
apiHostValue = "api.stg01";
Expand Down Expand Up @@ -81,8 +90,8 @@ private void SetDefaultHostEnvInPowerShellSession()
{
string defaultHostPrefix = ModuleIdentifier.SDKName == "DirectoryInsights" ? "api" : "console";
Console.WriteLine("JumpCloud SDK Module: {0} is running in the '{1}.jumpcloud.com' host environment.", ModuleIdentifier.SDKName, defaultHostPrefix);
Console.WriteLine("'{0}.jumpcloud.com' is the standard environment; '{0}.eu.jumpcloud.com' is the EU environment.", defaultHostPrefix);
Console.WriteLine("To use the EU environment, run: $ENV:{0} = 'EU' and re-import the module.", envVarNameForDefaultHostEnv);
Console.WriteLine("'{0}.jumpcloud.com' is the standard environment; '{0}.eu.jumpcloud.com' is the EU environment; '{0}.in.jumpcloud.com' is the India environment.", defaultHostPrefix);
Console.WriteLine("To use the EU or IN environments, run: $ENV:{0} = 'EU' or 'IN' and re-import the module.", envVarNameForDefaultHostEnv);
Console.WriteLine("To use the standard environment, run: $ENV:{0} = 'STANDARD' and re-import the module.", envVarNameForDefaultHostEnv);
}

Expand Down Expand Up @@ -180,8 +189,8 @@ protected async Task<HttpResponseMessage> AddAuthHeaders(HttpRequestMessage requ
System.Environment.SetEnvironmentVariable("JCEnvironment", HostEnv);

// Translate to both formats and set parameter defaults
string apiHost = HostEnv.Contains(".eu") ? "api.eu" : (HostEnv.Contains(".stg01") ? "api.stg01" : "api");
string consoleHost = HostEnv.Contains(".eu") ? "console.eu" : (HostEnv.Contains(".stg01") ? "console.stg01" : "console");
string apiHost = HostEnv.Contains(".eu") ? "api.eu" : HostEnv.Contains(".in") ? "api.in" : HostEnv.Contains(".stg01") ? "api.stg01" : "api";
string consoleHost = HostEnv.Contains(".eu") ? "console.eu" : HostEnv.Contains(".in") ? "console.in" : HostEnv.Contains(".stg01") ? "console.stg01" : "console";
SetPSDefaultHostEnvParameterValue(apiHost, consoleHost);
}

Expand Down
32 changes: 32 additions & 0 deletions JumpCloud.SDK.DirectoryInsights.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,35 @@
## JumpCloud.SDK.DirectoryInsights-0.2.0
Release Date: May 20, 2026
#### RELEASE NOTES
```
Support for the IN region has been added to the Directory Insights SDK.
```
#### FEATURES:
Support for the IN region has been added to the Directory Insights SDK.
#### IMPROVEMENTS:
NA
#### BUG FIXES:
NA
#### Generated Changes:

<details>
<summary>Functions Added</summary>

No changes
</details>

<details>
<summary>Functions Modified</summary>

No changes
</details>

<details>
<summary>Functions Removed</summary>

No changes
</details>

## JumpCloud.SDK.DirectoryInsights-0.1.1
Release Date: November 24, 2025
#### RELEASE NOTES
Expand Down
32 changes: 32 additions & 0 deletions JumpCloud.SDK.V1.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,35 @@
## JumpCloud.SDK.V1-0.2.0
Release Date: May 20, 2026
#### RELEASE NOTES
```
Support for the IN region has been added to the V1 SDK.
```
#### FEATURES:
Support for the IN region has been added to the V1 SDK.
#### IMPROVEMENTS:
NA
#### BUG FIXES:
NA
#### Generated Changes:

<details>
<summary>Functions Added</summary>

No changes
</details>

<details>
<summary>Functions Modified</summary>

No changes
</details>

<details>
<summary>Functions Removed</summary>

No changes
</details>

## JumpCloud.SDK.V1-0.1.3
Release Date: March 26, 2026
#### RELEASE NOTES
Expand Down
32 changes: 32 additions & 0 deletions JumpCloud.SDK.V2.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,35 @@
## JumpCloud.SDK.V2-0.3.0
Release Date: May 20, 2026
#### RELEASE NOTES
```
Support for the IN region has been added to the V2 SDK.
```
#### FEATURES:
Support for the IN region has been added to the V2 SDK.
#### IMPROVEMENTS:
NA
#### BUG FIXES:
NA
#### Generated Changes:

<details>
<summary>Functions Added</summary>

No changes
</details>

<details>
<summary>Functions Modified</summary>

No changes
</details>

<details>
<summary>Functions Removed</summary>

No changes
</details>

## JumpCloud.SDK.V2-0.2.1
Release Date: March 26, 2026
#### RELEASE NOTES
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Version>0.1.1</Version>
<Version>0.2.0</Version>
<LangVersion>7.1</LangVersion>
<TargetFramework>netstandard2.0</TargetFramework>
<OutputType>Library</OutputType>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
<metadata>
<id>JumpCloud.SDK.DirectoryInsights</id>
<version>0.1.1</version>
<version>0.2.0</version>
<authors>JumpCloud</authors>
<owners>JumpCloud</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# Generated by: JumpCloud
#
# Generated on: 11/24/2025
# Generated on: 5/20/2026
#

@{
Expand All @@ -12,7 +12,7 @@
RootModule = './JumpCloud.SDK.DirectoryInsights.psm1'

# Version number of this module.
ModuleVersion = '0.1.1'
ModuleVersion = '0.2.0'

# Supported PSEditions
CompatiblePSEditions = 'Core', 'Desktop'
Expand Down
21 changes: 15 additions & 6 deletions SDKs/PowerShell/JumpCloud.SDK.DirectoryInsights/custom/Module.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ private void SetDefaultHostEnvInPowerShellSession()
apiHostValue = "api.eu";
consoleHostValue = "console.eu";
break;
case "IN":
apiHostValue = "api.in";
consoleHostValue = "console.in";
break;
case "STAGING":
apiHostValue = "api.stg01";
consoleHostValue = "console.stg01";
Expand All @@ -53,6 +57,11 @@ private void SetDefaultHostEnvInPowerShellSession()
apiHostValue = "api.eu";
consoleHostValue = "console.eu";
}
else if (userInputEnvValue.Contains(".in"))
{
apiHostValue = "api.in";
consoleHostValue = "console.in";
}
else if (userInputEnvValue.Contains(".stg01"))
{
apiHostValue = "api.stg01";
Expand Down Expand Up @@ -81,8 +90,8 @@ private void SetDefaultHostEnvInPowerShellSession()
{
string defaultHostPrefix = ModuleIdentifier.SDKName == "DirectoryInsights" ? "api" : "console";
Console.WriteLine("JumpCloud SDK Module: {0} is running in the '{1}.jumpcloud.com' host environment.", ModuleIdentifier.SDKName, defaultHostPrefix);
Console.WriteLine("'{0}.jumpcloud.com' is the standard environment; '{0}.eu.jumpcloud.com' is the EU environment.", defaultHostPrefix);
Console.WriteLine("To use the EU environment, run: $ENV:{0} = 'EU' and re-import the module.", envVarNameForDefaultHostEnv);
Console.WriteLine("'{0}.jumpcloud.com' is the standard environment; '{0}.eu.jumpcloud.com' is the EU environment; '{0}.in.jumpcloud.com' is the India environment.", defaultHostPrefix);
Console.WriteLine("To use the EU or IN environments, run: $ENV:{0} = 'EU' or 'IN' and re-import the module.", envVarNameForDefaultHostEnv);
Console.WriteLine("To use the standard environment, run: $ENV:{0} = 'STANDARD' and re-import the module.", envVarNameForDefaultHostEnv);
}

Expand Down Expand Up @@ -180,8 +189,8 @@ protected async Task<HttpResponseMessage> AddAuthHeaders(HttpRequestMessage requ
System.Environment.SetEnvironmentVariable("JCEnvironment", HostEnv);

// Translate to both formats and set parameter defaults
string apiHost = HostEnv.Contains(".eu") ? "api.eu" : (HostEnv.Contains(".stg01") ? "api.stg01" : "api");
string consoleHost = HostEnv.Contains(".eu") ? "console.eu" : (HostEnv.Contains(".stg01") ? "console.stg01" : "console");
string apiHost = HostEnv.Contains(".eu") ? "api.eu" : HostEnv.Contains(".in") ? "api.in" : HostEnv.Contains(".stg01") ? "api.stg01" : "api";
string consoleHost = HostEnv.Contains(".eu") ? "console.eu" : HostEnv.Contains(".in") ? "console.in" : HostEnv.Contains(".stg01") ? "console.stg01" : "console";
SetPSDefaultHostEnvParameterValue(apiHost, consoleHost);
}

Expand Down Expand Up @@ -212,10 +221,10 @@ protected async Task<HttpResponseMessage> AddAuthHeaders(HttpRequestMessage requ
request.Headers.Add("Accept", "application/json");
}
// If headers do not contain an "UserAgent" with the correct value fix it
if (request.Headers.UserAgent.ToString() != "JumpCloud_JumpCloud.PowerShell.SDK.DirectoryInsights/0.1.1")
if (request.Headers.UserAgent.ToString() != "JumpCloud_JumpCloud.PowerShell.SDK.DirectoryInsights/0.2.0")
{
request.Headers.UserAgent.Clear();
request.Headers.UserAgent.ParseAdd("JumpCloud_JumpCloud.PowerShell.SDK.DirectoryInsights/0.1.1");
request.Headers.UserAgent.ParseAdd("JumpCloud_JumpCloud.PowerShell.SDK.DirectoryInsights/0.2.0");
}
// // request.Headers.Add("Content-Type", "application/json");
System.Net.Http.HttpResponseMessage response = await next.SendAsync(request, callback);
Expand Down
Loading
Loading