-
Notifications
You must be signed in to change notification settings - Fork 1
/
GetStreamWindowData.pqm
104 lines (104 loc) · 4.14 KB
/
GetStreamWindowData.pqm
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
let
GetStreamWindowData = (
token as text,
resource as text,
apiVersion as text,
tenantId as text,
namespaceId as text,
streamId as text,
startIndex as datetime,
endIndex as datetime
) as table =>
let
// construct Stream data query
dataQuery = "/api/"
& apiVersion
& "/Tenants/"
& tenantId
& "/Namespaces/"
& namespaceId
& "/Streams/"
& streamId
& "/Data?startIndex="
& DateTime.ToText(startIndex, "o")
& "&endIndex="
& DateTime.ToText(endIndex, "o"),
getJsonQuery = Json.Document(
Web.Contents(resource, [
RelativePath = dataQuery,
Headers = [Authorization = token]
])
),
tableOfData = Table.FromList(getJsonQuery, Splitter.SplitByNothing(), null, null, ExtraValues.Error)
in
tableOfData,
GetStreamWindowDataType = type function (
token as (
type text meta [
Documentation.FieldCaption = "Token",
Documentation.FieldDescription = "OAuth bearer token. Generate using GetToken.",
Documentation.SampleValues = {"Generate using GetToken()"}
]
),
resource as (
type text meta [
Documentation.FieldCaption = "Resource",
Documentation.FieldDescription = "Region Endpoint.",
Documentation.SampleValues = {"https://uswe.datahub.connect.aveva.com"}
]
),
apiVersion as (
type text meta [
Documentation.FieldCaption = "API Version",
Documentation.FieldDescription = "API Version.",
Documentation.SampleValues = {"v1"}
]
),
tenantId as (
type text meta [
Documentation.FieldCaption = "Tenant Id",
Documentation.FieldDescription = "Tenant Identifier.",
Documentation.SampleValues = {"Enter Tenant Id"}
]
),
namespaceId as (
type text meta [
Documentation.FieldCaption = "Namespace Id",
Documentation.FieldDescription = "Namespace Identifier.",
Documentation.SampleValues = {"Enter Namespace Id"}
]
),
streamId as (
type text meta [
Documentation.FieldCaption = "Stream Id",
Documentation.FieldDescription = "Stream Identifier.",
Documentation.SampleValues = {"Enter Stream Id"}
]
),
startIndex as (
type datetime meta [
Documentation.FieldCaption = "Start Index",
Documentation.FieldDescription = "Index identifying the beginning of the series of events to return."
]
),
endIndex as (
type datetime meta [
Documentation.FieldCaption = "End Index",
Documentation.FieldDescription = "Index identifying the end of the series of events to return."
]
)
) as binary meta [
Documentation.Name = "Get Stream Window Data",
Documentation.LongDescription = "Returns a collection of stored values based on request parameters.
<br>
<br>     <b>Token</b>: OAuth bearer token. Generate using GetToken().
<br>     <b>Resource</b>: Region Endpoint.
<br>     <b>API Version</b>: API Version.
<br>     <b>Tenant Id</b>: Tenant Identifier.
<br>     <b>Namespace Id</b>: Namespace Identifier.
<br>     <b>Stream Id</b>: Stream Identifier.
<br>     <b>Start Index</b>: Index identifying the beginning of the series of events to return.
<br>     <b>End Index</b>: Index identifying the end of the series of events to return."
]
in
Value.ReplaceType(GetStreamWindowData, GetStreamWindowDataType)