Skip to content

Commit

Permalink
Support (without tests) for 3.5.0+
Browse files Browse the repository at this point in the history
PSDayUK 2023 special!
  • Loading branch information
codaamok committed Mar 1, 2023
1 parent 7298088 commit bb67b9e
Show file tree
Hide file tree
Showing 11 changed files with 260 additions and 45 deletions.
4 changes: 2 additions & 2 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"label": "Build (with docs)",
"type": "process",
"command": "pwsh",
"args": ["-noprofile","-command","Invoke-Build","-File","./invoke.build.ps1","-Author","'codaamok'","-ModuleName","'PSShlink'","-UpdateDocs"],
"args": ["-noprofile","-command","Invoke-Build","-File","./invoke.build.ps1","-Author","'codaamok'","-ModuleName","'PSShlink'","-UpdateDocs","$true"],
"group": {
"kind": "build",
"isDefault": true
Expand All @@ -42,7 +42,7 @@
"label": "Build Docker container",
"type": "process",
"command": "docker",
"args": ["run", "--name", "my_shlink_psshlink", "-p", "8080:8080", "-e", "DEFAULT_DOMAIN=psshlink.codaamok", "-e", "IS_HTTPS_ENABLED=false", "-e", "INITIAL_API_KEY=18c65bc9-e4fb-449d-b3e0-c6427cbac735","shlinkio/shlink:stable"],
"args": ["run", "--name", "my_shlink_psshlink", "-p", "80:8080", "-e", "DEFAULT_DOMAIN=psshlink.codaamok", "-e", "IS_HTTPS_ENABLED=false", "-e", "INITIAL_API_KEY=18c65bc9-e4fb-449d-b3e0-c6427cbac735","shlinkio/shlink:stable"],
"group": {
"kind": "build",
"isDefault": true
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Added
- Added `-AndroidLongUrl` and `-IOSLongUrl` and `-DesktopLongUrl` to `Set-Shlinkurl`
- Added `-AndroidLongUrl` and `-IOSLongUrl` and `-DesktopLongUrl` to `New-Shlinkurl`
- Added `-ExcludeMaxVisitsReached` and `-ExcludePastValidUntil` to `Get-ShlinkUrl`
- Added `-OrderBy` permitted values `nonBotVisits-ASC` and `nonBotVisits-DESC` to `Get-ShlinkUrl`

### Changed
- Minimum Shlink version updated to 3.5.0
- Deprecation warning added to `New-ShlinkUrl` for `-ValidateUrl`, which is true since Shlink 3.5.0
- Changed API permission to 3, from 2

## [0.9.4] - 2022-02-26
### Added
Expand Down
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ An unofficial PowerShell module for Shlink (https://shlink.io), an open-source s
## Requirements

- PowerShell 5.1 or newer (including PowerShell Core, 7.0 or newer)
- Shlink 3.0.0 or newer
- Shlink 3.5.0 or newer
- If you need support for older versions of Shlink, you can still source older versions of PSShlink [here](https://github.com/codaamok/PSShlink/releases) or use the `-RequiredVersion` parameter of `Install-Module` when installed from the PowerShell Gallery

## Getting started

Install and import:

```powershell
PS C:\> Install-Module PSShlink -Scope CurrentUser
PS C:\> Import-Module PSShlink
Install-Module PSShlink -Scope CurrentUser
Import-Module PSShlink
```

Be sure to check out the examples below.
Expand All @@ -58,45 +58,45 @@ If the first function you use after importing PSShlink requires `-ShlinkServer`
All functions come with complete comment based help, so it is possible to find examples for each function using `Get-Help`. For example, use the following to see detailed help including examples for `Save-ShlinkUrlQrCode`:

```powershell
PS C:\> Get-Help Save-ShlinkUrlQrCode
Get-Help Save-ShlinkUrlQrCode
```

___

```powershell
PS C:\> $Key = "ba6c52ed-flk5-4e84-9fc7-9c7e34825da0" | ConvertTo-SecureString -AsPlainText -Force
PS C:\> Get-ShlinkUrl -SearchTerm "oldWebsite" -ShlinkServer "https://myshlinkserver.com" -ShlinkApiKey $Key
$Key = "ba6c52ed-flk5-4e84-9fc7-9c7e34825da0" | ConvertTo-SecureString -AsPlainText -Force
Get-ShlinkUrl -SearchTerm "oldWebsite" -ShlinkServer "https://myshlinkserver.com" -ShlinkApiKey $Key
```

Returns all short codes which match the search term `oldWebsite`.

___

```powershell
PS C:\> Get-ShlinkUrl -SearchTerm "oldWebsite" | Remove-ShlinkUrl
Get-ShlinkUrl -SearchTerm "oldWebsite" | Remove-ShlinkUrl
```

Deletes all short codes from the Shlink server which match the search term `oldWebsite`.

___

```powershell
PS C:\> Get-ShlinkUrl -SearchTerm "newWebsite" | Save-ShlinkUrlQrCode
Get-ShlinkUrl -SearchTerm "newWebsite" | Save-ShlinkUrlQrCode
```

Saves QR codes for all short URLs which match the search term `newWebsite`. All files will be saved as the default values for size (300x300) and type (png). All files by default are saved in your Downloads directory using the naming convention: `ShlinkQRCode_<shortCode>_<domain>_<size>.<format>`. e.g. `ShlinkQRCode_asFk2_example-com_300.png`.

___

```powershell
PS C:\> Get-ShlinkUrl -SearchTerm "newWebsite" | Set-ShlinkUrl -Tags "newWebsite" -MaxVisits 100
Get-ShlinkUrl -SearchTerm "newWebsite" | Set-ShlinkUrl -Tags "newWebsite" -MaxVisits 100
```

Sets the tag `newWebsite` on all short codes matching the search term `newWebsite`. Also sets all matching short codes with a max visits value of 100.
___

```powershell
PS C:\> New-ShlinkUrl -LongUrl "https://tools.ietf.org/html/rfc2549" -CustomSlug "rfc2549" -Domain "cookadam.co.uk" -DoNotValidateUrl
New-ShlinkUrl -LongUrl "https://tools.ietf.org/html/rfc2549" -CustomSlug "rfc2549" -Domain "cookadam.co.uk" -DoNotValidateUrl
```

Creates a new short code named `rfc2549` under the non-default domain `cookadam.co.uk`. The short code will redirect to `https://tools.ietf.org/html/rfc2549`. URL validation is not enforced.
Expand Down
34 changes: 32 additions & 2 deletions docs/Get-ShlinkUrl.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ Get details of all short codes, or just one.
### ListShortUrls (Default)
```
Get-ShlinkUrl [-SearchTerm <String>] [-Tags <String[]>] [-TagsMode <String>] [-OrderBy <String>]
[-StartDate <DateTime>] [-EndDate <DateTime>] [-ShlinkServer <String>] [-ShlinkApiKey <SecureString>]
[<CommonParameters>]
[-StartDate <DateTime>] [-EndDate <DateTime>] [-ExcludeMaxVisitsReached] [-ExcludePastValidUntil]
[-ShlinkServer <String>] [-ShlinkApiKey <SecureString>] [<CommonParameters>]
```

### ParseShortCode
Expand Down Expand Up @@ -203,6 +203,36 @@ Accept pipeline input: False
Accept wildcard characters: False
```

### -ExcludeMaxVisitsReached
Short URLs which already reached their maximum amount of visits will be excluded.

```yaml
Type: SwitchParameter
Parameter Sets: ListShortUrls
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
```

### -ExcludePastValidUntil
Short URLs which validUntil date is on the past will be excluded.

```yaml
Type: SwitchParameter
Parameter Sets: ListShortUrls
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
```

### -ShlinkServer
The URL of your Shlink server (including schema).
For example "https://example.com".
Expand Down
76 changes: 61 additions & 15 deletions docs/New-ShlinkUrl.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ Creates a new Shlink short code on your Shlink server.
## SYNTAX

```
New-ShlinkUrl [-LongUrl] <String> [[-CustomSlug] <String>] [[-Tags] <String[]>] [[-ValidSince] <DateTime>]
New-ShlinkUrl [-LongUrl] <String> [[-AndroidLongUrl] <String>] [[-IOSLongUrl] <String>]
[[-DesktopLongUrl] <String>] [[-CustomSlug] <String>] [[-Tags] <String[]>] [[-ValidSince] <DateTime>]
[[-ValidUntil] <DateTime>] [[-MaxVisits] <Int32>] [[-Title] <String>] [[-Domain] <String>]
[[-ShortCodeLength] <Int32>] [[-FindIfExists] <Boolean>] [[-ValidateUrl] <Boolean>]
[[-ForwardQuery] <Boolean>] [[-Crawlable] <Boolean>] [[-ShlinkServer] <String>]
Expand Down Expand Up @@ -60,6 +61,51 @@ Accept pipeline input: False
Accept wildcard characters: False
```

### -AndroidLongUrl
The long URL to redirect to when the short URL is visited from a device running Android.

```yaml
Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -IOSLongUrl
The long URL to redirect to when the short URL is visited from a device running iOS.

```yaml
Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: 3
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -DesktopLongUrl
The long URL to redirect to when the short URL is visited from a desktop browser.

```yaml
Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: 4
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -CustomSlug
Define a custom slug for the new short code.

Expand All @@ -69,7 +115,7 @@ Parameter Sets: (All)
Aliases:

Required: False
Position: 2
Position: 5
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Expand All @@ -84,7 +130,7 @@ Parameter Sets: (All)
Aliases:

Required: False
Position: 3
Position: 6
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Expand All @@ -99,7 +145,7 @@ Parameter Sets: (All)
Aliases:

Required: False
Position: 4
Position: 7
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Expand All @@ -114,7 +160,7 @@ Parameter Sets: (All)
Aliases:

Required: False
Position: 5
Position: 8
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Expand All @@ -129,7 +175,7 @@ Parameter Sets: (All)
Aliases:

Required: False
Position: 6
Position: 9
Default value: 0
Accept pipeline input: False
Accept wildcard characters: False
Expand All @@ -144,7 +190,7 @@ Parameter Sets: (All)
Aliases:

Required: False
Position: 7
Position: 10
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Expand All @@ -160,7 +206,7 @@ Parameter Sets: (All)
Aliases:

Required: False
Position: 8
Position: 11
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Expand All @@ -175,7 +221,7 @@ Parameter Sets: (All)
Aliases:

Required: False
Position: 9
Position: 12
Default value: 0
Accept pipeline input: False
Accept wildcard characters: False
Expand All @@ -190,7 +236,7 @@ Parameter Sets: (All)
Aliases:

Required: False
Position: 10
Position: 13
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
Expand All @@ -205,7 +251,7 @@ Parameter Sets: (All)
Aliases:

Required: False
Position: 11
Position: 14
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
Expand All @@ -220,7 +266,7 @@ Parameter Sets: (All)
Aliases:

Required: False
Position: 12
Position: 15
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
Expand All @@ -235,7 +281,7 @@ Parameter Sets: (All)
Aliases:

Required: False
Position: 13
Position: 16
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
Expand All @@ -253,7 +299,7 @@ Parameter Sets: (All)
Aliases:

Required: False
Position: 14
Position: 17
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Expand All @@ -270,7 +316,7 @@ Parameter Sets: (All)
Aliases:

Required: False
Position: 15
Position: 18
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Expand Down
Loading

0 comments on commit bb67b9e

Please sign in to comment.