|
| 1 | +```https://api.github.com/repos/StartAutomating/PipeScript/issues``` is a valid command. |
| 2 | + |
| 3 | +So is ```get https://api.github.com/repos/StartAutomating/PipeScript/issues```. |
| 4 | + |
| 5 | +So is ```MyCustomProtocol:// -Parameter value```. |
| 6 | + |
| 7 | +PipeScript supports transpiling protocols. |
| 8 | + |
| 9 | +To be considered a protocol transpiler, a transpiler must: |
| 10 | + |
| 11 | +1. Accept a ```[uri]``` from the pipeline |
| 12 | +2. Have a parameter -CommandAST ```[Management.Automation.Language.CommandAST]``` |
| 13 | +3. Be valid, given a ```[Management.Automation.Language.CommandAST]``` |
| 14 | + |
| 15 | + |
| 16 | +|DisplayName |Synopsis | |
| 17 | +|--------------------------------------|--------------------------------------| |
| 18 | +|[Http.Protocol](Http.Protocol.psx.ps1)|[http protocol](Http.Protocol.psx.ps1)| |
| 19 | + |
| 20 | + |
| 21 | + |
| 22 | + |
| 23 | +## Http.Protocol Example 1 |
| 24 | + |
| 25 | + |
| 26 | +~~~PowerShell |
| 27 | + .> { |
| 28 | + https://api.github.com/repos/StartAutomating/PipeScript |
| 29 | + } |
| 30 | +~~~ |
| 31 | + |
| 32 | +## Http.Protocol Example 2 |
| 33 | + |
| 34 | + |
| 35 | +~~~PowerShell |
| 36 | + { |
| 37 | + get https://api.github.com/repos/StartAutomating/PipeScript |
| 38 | + } | .>PipeScript |
| 39 | +~~~ |
| 40 | + |
| 41 | +## Http.Protocol Example 3 |
| 42 | + |
| 43 | + |
| 44 | +~~~PowerShell |
| 45 | + Invoke-PipeScript { |
| 46 | + $GitHubApi = 'api.github.com' |
| 47 | + $UserName = 'StartAutomating' |
| 48 | + https://$GitHubApi/users/$UserName |
| 49 | + } |
| 50 | +~~~ |
| 51 | + |
| 52 | +## Http.Protocol Example 4 |
| 53 | + |
| 54 | + |
| 55 | +~~~PowerShell |
| 56 | + .> -ScriptBlock { |
| 57 | + https://$GitHubApi/users/$UserName -GitHubApi api.github.com -UserName StartAutomating |
| 58 | + } |
| 59 | +~~~ |
| 60 | + |
| 61 | +## Http.Protocol Example 5 |
| 62 | + |
| 63 | + |
| 64 | +~~~PowerShell |
| 65 | + .> -ScriptBlock { |
| 66 | + https://$GitHubApi/users/$UserName -GitHubApi api.github.com -UserName StartAutomating |
| 67 | + } |
| 68 | +~~~ |
| 69 | + |
| 70 | +## Http.Protocol Example 6 |
| 71 | + |
| 72 | + |
| 73 | +~~~PowerShell |
| 74 | + .> -ScriptBlock { |
| 75 | + @(foreach ($repo in https://api.github.com/users/StartAutomating/repos?per_page=100) { |
| 76 | + $repo | .Name .Stars { $_.stargazers_count } |
| 77 | + }) | Sort-Object Stars -Descending |
| 78 | + } |
| 79 | +~~~ |
| 80 | + |
| 81 | +## Http.Protocol Example 7 |
| 82 | + |
| 83 | + |
| 84 | +~~~PowerShell |
| 85 | +.> { |
| 86 | + http://text-processing.com/api/sentiment/ -Method POST -ContentType 'application/x-www-form-urlencoded' -Body "text=amazing!" | |
| 87 | + Select-Object -ExpandProperty Probability -Property Label |
| 88 | +} |
| 89 | +~~~ |
| 90 | + |
| 91 | + |
0 commit comments