-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
Expand file tree
/
Copy pathDataQuery.ps1
More file actions
151 lines (119 loc) · 3.78 KB
/
DataQuery.ps1
File metadata and controls
151 lines (119 loc) · 3.78 KB
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#
# Echo Server API
# Echo Server API
# Version: 0.1.0
# Contact: team@openapitools.org
# Generated by OpenAPI Generator: https://openapi-generator.tech
#
<#
.SYNOPSIS
No summary available.
.DESCRIPTION
No description available.
.PARAMETER Id
Query
.PARAMETER Outcomes
No description available.
.PARAMETER Suffix
test suffix
.PARAMETER Text
Some text containing white spaces
.PARAMETER Date
A date
.OUTPUTS
DataQuery<PSCustomObject>
#>
function Initialize-DataQuery {
[CmdletBinding()]
Param (
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
[System.Nullable[Int64]]
${Id},
[Parameter(Position = 1, ValueFromPipelineByPropertyName = $true)]
[ValidateSet("SUCCESS", "FAILURE", "SKIPPED")]
[String[]]
${Outcomes},
[Parameter(Position = 2, ValueFromPipelineByPropertyName = $true)]
[String]
${Suffix},
[Parameter(Position = 3, ValueFromPipelineByPropertyName = $true)]
[String]
${Text},
[Parameter(Position = 4, ValueFromPipelineByPropertyName = $true)]
[System.Nullable[System.DateTime]]
${Date}
)
Process {
'Creating PSCustomObject: PSOpenAPITools => DataQuery' | Write-Debug
$PSBoundParameters | Out-DebugParameter | Write-Debug
$PSO = [PSCustomObject]@{
'id' = ${Id}
'outcomes' = ${Outcomes}
'suffix' = ${Suffix}
'text' = ${Text}
'date' = ${Date}
}
return $PSO
}
}
<#
.SYNOPSIS
Convert from JSON to DataQuery<PSCustomObject>
.DESCRIPTION
Convert from JSON to DataQuery<PSCustomObject>
.PARAMETER Json
Json object
.OUTPUTS
DataQuery<PSCustomObject>
#>
function ConvertFrom-JsonToDataQuery {
Param(
[AllowEmptyString()]
[string]$Json
)
Process {
'Converting JSON to PSCustomObject: PSOpenAPITools => DataQuery' | Write-Debug
$PSBoundParameters | Out-DebugParameter | Write-Debug
$JsonParameters = ConvertFrom-Json -InputObject $Json
# check if Json contains properties not defined in DataQuery
$AllProperties = ('id', 'outcomes', 'suffix', 'text', 'date')
foreach ($name in $JsonParameters.PsObject.Properties.Name) {
if (!($AllProperties.Contains($name))) {
throw "Error! JSON key '$name' not found in the properties: $($AllProperties)"
}
}
if (!([bool]($JsonParameters.PSobject.Properties.name -match 'id'))) { #optional property not found
$Id = $null
} else {
$Id = $JsonParameters.PSobject.Properties['id'].value
}
if (!([bool]($JsonParameters.PSobject.Properties.name -match 'outcomes'))) { #optional property not found
$Outcomes = $null
} else {
$Outcomes = $JsonParameters.PSobject.Properties['outcomes'].value
}
if (!([bool]($JsonParameters.PSobject.Properties.name -match 'suffix'))) { #optional property not found
$Suffix = $null
} else {
$Suffix = $JsonParameters.PSobject.Properties['suffix'].value
}
if (!([bool]($JsonParameters.PSobject.Properties.name -match 'text'))) { #optional property not found
$Text = $null
} else {
$Text = $JsonParameters.PSobject.Properties['text'].value
}
if (!([bool]($JsonParameters.PSobject.Properties.name -match 'date'))) { #optional property not found
$Date = $null
} else {
$Date = $JsonParameters.PSobject.Properties['date'].value
}
$PSO = [PSCustomObject]@{
'id' = ${Id}
'outcomes' = ${Outcomes}
'suffix' = ${Suffix}
'text' = ${Text}
'date' = ${Date}
}
return $PSO
}
}