Public-manual/New-Microservice.ps1
Function New-Microservice { <# .SYNOPSIS New microservice application .EXAMPLE PS> New-Microservice -Name $App.id -File "myapp.zip" Upload application microservice binary #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # File to be uploaded as a binary (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [string] $File, # File to be uploaded as a binary (required) [Parameter(Mandatory = $false)] [string] $Name, # Access level for other tenants. Possible values are : MARKET, PRIVATE (default) [Parameter()] [ValidateSet('MARKET','PRIVATE')] [string] $Availability, # contextPath of the hosted application. Required when application type is HOSTED [Parameter()] [string] $ContextPath, # URL to application base directory hosted on an external server. Required when application type is HOSTED [Parameter()] [string] $ResourcesUrl, # Skip the uploading of the application binary [Parameter()] [switch] $SkipUpload, # Don't subscribe to the application after it has been created and uploaded [Parameter()] [switch] $SkipSubscription, # Include raw response including pagination information [Parameter()] [switch] $Raw, # Outputfile [Parameter()] [string] $OutputFile, # NoProxy [Parameter()] [switch] $NoProxy, # Session path [Parameter()] [string] $Session, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Name")) { $Parameters["name"] = $Name } if ($PSBoundParameters.ContainsKey("Availability")) { $Parameters["availability"] = $Availability } if ($PSBoundParameters.ContainsKey("ContextPath")) { $Parameters["contextPath"] = $ContextPath } if ($PSBoundParameters.ContainsKey("ResourcesUrl")) { $Parameters["resourcesUrl"] = $ResourcesUrl } if ($PSBoundParameters.ContainsKey("SkipUpload")) { $Parameters["skipUpload"] = $SkipUpload.ToString().ToLower() } if ($PSBoundParameters.ContainsKey("SkipSubscription")) { $Parameters["skipSubscription"] = $SkipSubscription.ToString().ToLower() } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } } Process { foreach ($item in $File) { $Parameters["file"] = $item if (!$Force -and !$WhatIfPreference -and !$PSCmdlet.ShouldProcess( (PSc8y\Get-C8ySessionProperty -Name "tenant"), (Format-ConfirmationMessage -Name $PSCmdlet.MyInvocation.InvocationName -InputObject $item) )) { continue } Invoke-Command ` -Noun "microservices" ` -Verb "create" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.managedObject+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } |