diff --git a/Build.ps1 b/Build.ps1 index a32dea2..e2d449f 100644 --- a/Build.ps1 +++ b/Build.ps1 @@ -61,11 +61,11 @@ $Manifest = @{ ReleaseNotes = 'https://github.com/okta/okta-powershell-cli/releases' - ModuleVersion = '1.0.3' + ModuleVersion = '1.0.4' RootModule = 'Okta.PowerShell.psm1' - Guid = '{5E82B81C-92D5-47BC-A10F-E26B40081903}' # Has to be static, otherwise each new build will be considered different module + Guid = '{257FCF83-C4E5-475C-B2C7-E624D7A7B6F3}' # Has to be static, otherwise each new build will be considered different module PowerShellVersion = '6.2' diff --git a/README.md b/README.md index 4e289cf..84df672 100644 --- a/README.md +++ b/README.md @@ -190,6 +190,14 @@ _links : @{logo=System.Object[]; users=; apps=} > Note: If you want to remove the access token from configuration you can execute `Invoke-OktaRemoveAccessToken` +### Configure a proxy + +```powershell +$proxyUrl = "http://127.0.0.1:8888" +$webProxy = New-Object System.Net.WebProxy($proxyUrl) +$Configuration.Proxy = $webProxy +``` + ### Get a user ```powershell @@ -259,6 +267,17 @@ $NewApp = Initialize-OktaOpenIdConnectApplication -Label "New App" -SignOnMode " > Note: For more API samples checkout our [tests](https://github.com/okta/okta-powershell-cli/tree/main/tests/) +### Get logs + +Since the System Log API requires `since` and `until` query params to be ISO 8601 compliant timestamp, make sure to format dates accordingly: + +```powershell +$since = (Get-Date).AddMonths(-6).ToString("yyyy-MM-ddTHH:mm:ssZ") +$until = (Get-Date).ToString("yyyy-MM-ddTHH:mm:ssZ") +Get-OktaLogs -since $since -until $until + +``` + ## Rate Limiting The Okta API will return 429 responses if too many requests are made within a given time. Please see [Rate Limiting at Okta] for a complete list of which endpoints are rate limited. When a 429 error is received, the `X-Rate-Limit-Reset` header will tell you the time at which you can retry. This section discusses methods for handling rate limiting with this SDK. diff --git a/docs/OktaSystemLogApi.md b/docs/OktaSystemLogApi.md index 006ad27..4b7d289 100644 --- a/docs/OktaSystemLogApi.md +++ b/docs/OktaSystemLogApi.md @@ -10,13 +10,13 @@ Method | HTTP request | Description # **Get-OktaLogs** > LogEvent[] Get-OktaLogs
->         [-Since]
->         [-Until]
+>         [-Since]
+>         [-Until]
+>         [-After]
>         [-Filter]
>         [-Q]
>         [-Limit]
>         [-SortOrder]
->         [-After]
List all System Log Events @@ -31,17 +31,17 @@ $Configuration = Get-OktaConfiguration $Configuration.ClientId = "YOUR_CLIENT_ID" $Configuration.Scope = "OKTA_SCOPES" # for example okta.users.read -$Since = (Get-Date) # System.DateTime | (optional) -$Until = (Get-Date) # System.DateTime | (optional) -$Filter = "MyFilter" # String | (optional) -$Q = "MyQ" # String | (optional) -$Limit = 56 # Int32 | (optional) (default to 100) -$SortOrder = "MySortOrder" # String | (optional) (default to "ASCENDING") -$After = "MyAfter" # String | (optional) +$Since = "MySince" # String | Filters the lower time bound of the log events `published` property for bounded queries or persistence time for polling queries (optional) (default to "7 days prior to until") +$Until = "MyUntil" # String | Filters the upper time bound of the log events `published` property for bounded queries or persistence time for polling queries. (optional) (default to "current time") +$After = "MyAfter" # String | Retrieves the next page of results. Okta returns a link in the HTTP Header (`rel=next`) that includes the after query parameter (optional) +$Filter = "MyFilter" # String | Filter expression that filters the results. All operators except [ ] are supported. See [Filter](https://developer.okta.com/docs/api/#filter). (optional) +$Q = "MyQ" # String | Filters log events results by one or more case insensitive keywords. (optional) +$Limit = 56 # Int32 | Sets the number of results that are returned in the response (optional) (default to 100) +$SortOrder = "ASCENDING" # String | The order of the returned events that are sorted by the `published` property (optional) (default to "ASCENDING") # List all System Log Events try { - $Result = Get-OktaLogs -Since $Since -Until $Until -Filter $Filter -Q $Q -Limit $Limit -SortOrder $SortOrder -After $After + $Result = Get-OktaLogs -Since $Since -Until $Until -After $After -Filter $Filter -Q $Q -Limit $Limit -SortOrder $SortOrder } catch { Write-Host ("Exception occurred when calling Get-OktaLogs: {0}" -f ($_.ErrorDetails | ConvertFrom-Json)) Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json)) @@ -52,13 +52,13 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **Since** | **System.DateTime**| | [optional] - **Until** | **System.DateTime**| | [optional] - **Filter** | **String**| | [optional] - **Q** | **String**| | [optional] - **Limit** | **Int32**| | [optional] [default to 100] - **SortOrder** | **String**| | [optional] [default to "ASCENDING"] - **After** | **String**| | [optional] + **Since** | **String**| Filters the lower time bound of the log events `published` property for bounded queries or persistence time for polling queries | [optional] [default to "7 days prior to until"] + **Until** | **String**| Filters the upper time bound of the log events `published` property for bounded queries or persistence time for polling queries. | [optional] [default to "current time"] + **After** | **String**| Retrieves the next page of results. Okta returns a link in the HTTP Header (`rel=next`) that includes the after query parameter | [optional] + **Filter** | **String**| Filter expression that filters the results. All operators except [ ] are supported. See [Filter](https://developer.okta.com/docs/api/#filter). | [optional] + **Q** | **String**| Filters log events results by one or more case insensitive keywords. | [optional] + **Limit** | **Int32**| Sets the number of results that are returned in the response | [optional] [default to 100] + **SortOrder** | **String**| The order of the returned events that are sorted by the `published` property | [optional] [default to "ASCENDING"] ### Return type diff --git a/openapi3/config.json b/openapi3/config.json index 3da7c0c..92928fe 100644 --- a/openapi3/config.json +++ b/openapi3/config.json @@ -14,7 +14,7 @@ "templateDir": "./codegen-templates", "outputDir" : "../", "inputSpec" : "./management.yaml", - "packageVersion" : "1.0.3", + "packageVersion" : "1.0.4", "packageDescription" : "Official PowerShell CLI for the Okta API", "packageTitle" : "Official PowerShell for the Okta API", "packageCompany" : "Okta, Inc.", diff --git a/openapi3/management.yaml b/openapi3/management.yaml index a99e621..cda1023 100644 --- a/openapi3/management.yaml +++ b/openapi3/management.yaml @@ -10572,37 +10572,53 @@ paths: operationId: getLogs parameters: - name: since + description: Filters the lower time bound of the log events `published` property for bounded queries or persistence time for polling queries in: query schema: type: string - format: date-time + format: ISO 8601 compliant timestamp + default: 7 days prior to until - name: until + description: Filters the upper time bound of the log events `published` property for bounded queries or persistence time for polling queries. in: query schema: type: string - format: date-time + format: ISO 8601 compliant timestamp + default: current time + - name: after + description: Retrieves the next page of results. Okta returns a link in the HTTP Header (`rel=next`) that includes the after query parameter + in: query + schema: + type: string + format: Opaque token - name: filter + description: Filter expression that filters the results. All operators except [ ] are supported. See [Filter](https://developer.okta.com/docs/api/#filter). in: query schema: type: string + format: SCIM Filter expression - name: q + description: Filters log events results by one or more case insensitive keywords. in: query schema: type: string + format: URL encoded string. Max length is 40 characters per keyword, with a maximum of 10 keyword filters per query (before encoding) - name: limit + description: Sets the number of results that are returned in the response in: query schema: type: integer + format: Integer between 0 and 1000 default: 100 - name: sortOrder + description: The order of the returned events that are sorted by the `published` property in: query schema: type: string + enum: + - ASCENDING + - DESCENDING default: ASCENDING - - name: after - in: query - schema: - type: string responses: '200': description: Success diff --git a/src/Okta.PowerShell/Api/OktaSystemLogApi.ps1 b/src/Okta.PowerShell/Api/OktaSystemLogApi.ps1 index 19868c6..b15507e 100644 --- a/src/Okta.PowerShell/Api/OktaSystemLogApi.ps1 +++ b/src/Okta.PowerShell/Api/OktaSystemLogApi.ps1 @@ -16,25 +16,25 @@ List all System Log Events No description available. .PARAMETER Since -No description available. +Filters the lower time bound of the log events `published` property for bounded queries or persistence time for polling queries .PARAMETER Until -No description available. +Filters the upper time bound of the log events `published` property for bounded queries or persistence time for polling queries. + +.PARAMETER After +Retrieves the next page of results. Okta returns a link in the HTTP Header (`rel=next`) that includes the after query parameter .PARAMETER Filter -No description available. +Filter expression that filters the results. All operators except [ ] are supported. See [Filter](https://developer.okta.com/docs/api/#filter). .PARAMETER Q -No description available. +Filters log events results by one or more case insensitive keywords. .PARAMETER Limit -No description available. +Sets the number of results that are returned in the response .PARAMETER SortOrder -No description available. - -.PARAMETER After -No description available. +The order of the returned events that are sorted by the `published` property .PARAMETER Uri @@ -57,26 +57,27 @@ function Get-OktaLogs { [CmdletBinding()] Param ( [Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)] - [System.Nullable[System.DateTime]] + [String] ${Since}, [Parameter(Position = 1, ValueFromPipelineByPropertyName = $true, Mandatory = $false)] - [System.Nullable[System.DateTime]] + [String] ${Until}, [Parameter(Position = 2, ValueFromPipelineByPropertyName = $true, Mandatory = $false)] [String] - ${Filter}, + ${After}, [Parameter(Position = 3, ValueFromPipelineByPropertyName = $true, Mandatory = $false)] [String] - ${Q}, + ${Filter}, [Parameter(Position = 4, ValueFromPipelineByPropertyName = $true, Mandatory = $false)] + [String] + ${Q}, + [Parameter(Position = 5, ValueFromPipelineByPropertyName = $true, Mandatory = $false)] [System.Nullable[Int32]] ${Limit}, - [Parameter(Position = 5, ValueFromPipelineByPropertyName = $true, Mandatory = $false)] - [String] - ${SortOrder}, [Parameter(Position = 6, ValueFromPipelineByPropertyName = $true, Mandatory = $false)] + [ValidateSet("ASCENDING", "DESCENDING")] [String] - ${After}, + ${SortOrder}, [Parameter(ValueFromPipelineByPropertyName = $true, Mandatory = $false)] [String] ${Uri}, @@ -119,6 +120,10 @@ function Get-OktaLogs { $LocalVarQueryParameters['until'] = $Until } + if ($After) { + $LocalVarQueryParameters['after'] = $After + } + if ($Filter) { $LocalVarQueryParameters['filter'] = $Filter } @@ -135,10 +140,6 @@ function Get-OktaLogs { $LocalVarQueryParameters['sortOrder'] = $SortOrder } - if ($After) { - $LocalVarQueryParameters['after'] = $After - } - if ($Configuration["ApiKey"] -and $Configuration["ApiKey"]["apiToken"]) { $LocalVarHeaderParameters['apiToken'] = $Configuration["ApiKey"]["apiToken"] Write-Verbose ("Using API key 'apiToken' in the header for authentication in {0}" -f $MyInvocation.MyCommand) diff --git a/src/Okta.PowerShell/Okta.PowerShell.psd1 b/src/Okta.PowerShell/Okta.PowerShell.psd1 index 8a2d0fa..89ddd7e 100644 --- a/src/Okta.PowerShell/Okta.PowerShell.psd1 +++ b/src/Okta.PowerShell/Okta.PowerShell.psd1 @@ -3,7 +3,7 @@ # # Generated by: Okta, Inc. # -# Generated on: 2024-10-29 +# Generated on: 2024-12-16 # @{ @@ -12,13 +12,13 @@ RootModule = 'Okta.PowerShell.psm1' # Version number of this module. -ModuleVersion = '1.0.3' +ModuleVersion = '1.0.4' # Supported PSEditions CompatiblePSEditions = 'Core' # ID used to uniquely identify this module -GUID = '5e82b81c-92d5-47bc-a10f-e26b40081903' +GUID = '257fcf83-c4e5-475c-b2c7-e624d7a7b6f3' # Author of this module Author = 'Okta, Inc.' diff --git a/src/Okta.PowerShell/Private/OktaApiClient.ps1 b/src/Okta.PowerShell/Private/OktaApiClient.ps1 index 3f064e2..9296f4f 100644 --- a/src/Okta.PowerShell/Private/OktaApiClient.ps1 +++ b/src/Okta.PowerShell/Private/OktaApiClient.ps1 @@ -131,7 +131,7 @@ function Invoke-OktaApiClient { } } - $OktaUserAgent = [Microsoft.PowerShell.Commands.PSUserAgent]::Chrome + " okta-powershell-module/1.0.3" + $OktaUserAgent = [Microsoft.PowerShell.Commands.PSUserAgent]::Chrome + " okta-powershell-module/1.0.4" # Setting up vars for retry diff --git a/src/Okta.PowerShell/en-US/about_Okta.PowerShell.help.txt b/src/Okta.PowerShell/en-US/about_Okta.PowerShell.help.txt index 3da90d0..d5ebec4 100644 --- a/src/Okta.PowerShell/en-US/about_Okta.PowerShell.help.txt +++ b/src/Okta.PowerShell/en-US/about_Okta.PowerShell.help.txt @@ -10,7 +10,7 @@ LONG DESCRIPTION This PowerShell module is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project: - API version: 3.0.0 - - SDK version: 1.0.3 + - SDK version: 1.0.4 - Build package: org.openapitools.codegen.languages.PowerShellClientCodegen For more information, please visit [https://developer.okta.com/](https://developer.okta.com/)