-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds support for REST endpoint to get objects (#34)
* feat: Working REST endpoint to fetch objects instead of GraphQL * hack: Temporarily exposed rest function * feat: Added OAuth test login * chore: Cleanup for release
- Loading branch information
Showing
5 changed files
with
136 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
(server as text, optional streamId as text, optional objectId as text) as table => | ||
let | ||
apiKey = try Extension.CurrentCredential()[Key] otherwise null, | ||
Source = Web.Contents( | ||
Text.Combine({server, "objects", streamId, objectId}, "/"), | ||
[ | ||
Headers = [ | ||
#"Method" = "GET", | ||
#"Content-Type" = "application/json", | ||
#"Authorization" = if apiKey = null then "" else Text.Format("Bearer #{0}", {apiKey}) | ||
], | ||
ManualStatusHandling = {400} | ||
] | ||
), | ||
json = Json.Document(Source), | ||
clean = List.Select(json, each _[speckle_type] <> "Speckle.Core.Models.DataChunk"), | ||
t = Table.FromColumns({clean}, {"data"}), | ||
addStreamUrl = Table.AddColumn(t, "Stream URL", each server & "/streams/" & streamId), | ||
addObjectIdCol = Table.AddColumn(addStreamUrl, "Object ID", each try _[data][id] otherwise null), | ||
addSpeckleTypeCol = Table.AddColumn( | ||
addObjectIdCol, "speckle_type", each try _[data][speckle_type] otherwise null | ||
), | ||
Speckle.CleanUpObjects = Extension.LoadFunction("CleanUpObjects.pqm"), | ||
Extension.LoadFunction = (fileName as text) => | ||
let | ||
binary = Extension.Contents(fileName), asText = Text.FromBinary(binary) | ||
in | ||
try | ||
Expression.Evaluate(asText, #shared) catch (e) => | ||
error | ||
[ | ||
Reason = "Extension.LoadFunction Failure", | ||
Message.Format = "Loading '#{0}' failed - '#{1}': '#{2}'", | ||
Message.Parameters = {fileName, e[Reason], e[Message]}, | ||
Detail = [File = fileName, Error = e] | ||
] | ||
in | ||
addSpeckleTypeCol |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// Use this file to write queries to test your data connector | ||
let | ||
result = Speckle.Api.REST.GetObject( | ||
"https://latest.speckle.dev", "5f284e5c70", "85e5f250fe591ea74d8d5dc1137a9341" | ||
) | ||
in | ||
result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
// Use this file to write queries to test your data connector | ||
let result = Speckle.GetByUrl("https://latest.speckle.dev/streams/3d25474a18") in result | ||
let result = Speckle.GetByUrl("https://latest.speckle.dev/streams/5f284e5c70/objects/85e5f250fe591ea74d8d5dc1137a9341") in result |