-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathappcenter-create-app.psm1
93 lines (70 loc) · 2.51 KB
/
appcenter-create-app.psm1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# {
# "description": "test from api",
# "display_name": "test-to-delete",
# "name": "test-to-delete",
# "os": "iOS",
# "platform": "Xamarin"
# }
# curl -X POST "https://api.appcenter.ms/v0.1/orgs/Avantime/apps" -H "accept: application/json" -H "X-API-Token: 2cb63562dfsd4fsdf32rfsdf5e7a35" -H "Content-Type: application/json" -d "{ \"description\": \"test from api\", \"display_name\": \"test-to-delete\", \"name\": \"test-to-delete\", \"os\": \"iOS\", \"platform\": \"Xamarin\"}"
Function AppCenter-CreateApp {
[CmdletBinding(SupportsShouldProcess = $true)]
Param
(
[Parameter(Mandatory = $true)]
[Alias('n')][String]$Name,
[Parameter(Mandatory = $true)]
[Alias('dn')][String]$DisplayName,
[Parameter(Mandatory = $true)]
[Alias('d')][String]$Description,
[Parameter(Mandatory = $true)]
[Alias('o')][String]$Os,
[Parameter(Mandatory = $true)]
[Alias('p')][String]$Platform,
[Parameter(Mandatory = $true)]
[Alias('a')][String]$apikey,
[Parameter(Mandatory = $true)]
[Alias('c')][String]$Org
)
$Body = @{
description = $Description
display_name = $DisplayName
name = $Name
os = $Os
platform = $Platform
}
If ($PSCmdlet.ShouldProcess("Convert txt file to Word Document file.")) {
$Uri = "https://api.appcenter.ms/v0.1/orgs/$org/apps";
$Method = "Post"
$Headers = @{
"X-API-Token" = $apikey
"Content-Type" = "application/json"
};
$bp = ConvertTo-Json $Body -Compress
$resp = Invoke-RestMethod -Uri $Uri -Method $Method -Headers $Headers -Body $bp -Verbose
#Write-Output $resp;
if ($resp) {
return $resp.app_secret;
}
}
return [string]::Empty;
}
Function AppCenter-GetApp {
[CmdletBinding(SupportsShouldProcess = $true)]
Param
(
[Parameter(Mandatory = $true)]
[Alias('n')][String]$Name,
[Parameter(Mandatory = $true)]
[Alias('c')][String]$Org
)
If ($PSCmdlet.ShouldProcess("Convert txt file to Word Document file.")) {
$Uri = "https://api.appcenter.ms/v0.1/apps/$Org/$Name";
$Method = "Get"
$Headers = @{
"X-API-Token" = $apikey
"Accept" = "application/json"
};
return Invoke-RestMethod -Uri $Uri -Method $Method -Headers $Headers
}
return $null;
}