-
Notifications
You must be signed in to change notification settings - Fork 323
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integrating Enso Cloud with the libraries (part 1...) #8006
Conversation
e343669
to
f8ac39b
Compare
9f2b362
to
fb277b7
Compare
ff9defb
to
7e1b999
Compare
f1ae2b8
to
ac602ed
Compare
ac602ed
to
17d53c8
Compare
## Checks if the folder or file exists | ||
exists : Boolean | ||
exists self = | ||
auth_header = Utils.authorization_header | ||
response = HTTP.fetch self.internal_uri HTTP_Method.Get [auth_header] | ||
response.status_code == 200 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I read this right, we do a full GET
request, meaning we actually start downloading the file which may be costly if the file is big + will cost us data transfer.
Can we use HEAD
option here instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the cloud API, the files GET doesn't give the file it just gives the metadata for the file.
I have asked for a HEAD method to be added to the API to do exists check.
distribution/lib/Standard/Base/0.0.0-dev/src/Data/Enso_Cloud/Enso_File.enso
Outdated
Show resolved
Hide resolved
response.if_not_error <| | ||
js_object = response.decode_as_json | ||
assets = js_object.get "assets" [] | ||
files = assets.map t-> t:Enso_File |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are using this construct more and more often, I wonder if we should think about adding some support for it, like something similar to assets.cast Enso_File
(not sure about the name, as clashing with Table.cast
is not ideal).
Maybe assets.ensure_items_type Enso_File
.
Not a thing for this PR though, just a general comment about the pattern.
distribution/lib/Standard/Base/0.0.0-dev/src/Data/Enso_Cloud/Enso_Secret.enso
Outdated
Show resolved
Hide resolved
distribution/lib/Standard/Base/0.0.0-dev/src/Data/Enso_Cloud/Enso_Secret.enso
Outdated
Show resolved
Hide resolved
authorization_basic : Text -> Text -> Header | ||
authorization_basic user pass = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
authorization_basic : Text -> Text -> Header | |
authorization_basic user pass = | |
authorization_basic : Text -> Text|Enso_Secret -> Header | |
authorization_basic (user : Text) (pass : Text | Enso_Secret) = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ok I see that this would complicate the logic quite significantly.
I think useful to allow this (together with also allowing secrets in authorization_bearer
) at some point, but probably not at this PR.
distribution/lib/Standard/Base/0.0.0-dev/src/Network/HTTP/Response.enso
Outdated
Show resolved
Hide resolved
distribution/lib/Standard/Database/0.0.0-dev/src/Connection/SQLite_Format.enso
Outdated
Show resolved
Hide resolved
distribution/lib/Standard/Database/0.0.0-dev/src/Data/Column.enso
Outdated
Show resolved
Hide resolved
std-bits/base/src/main/java/org/enso/base/enso_cloud/EnsoSecretReader.java
Outdated
Show resolved
Hide resolved
std-bits/base/src/main/java/org/enso/base/enso_cloud/EnsoKeyValuePair.java
Outdated
Show resolved
Hide resolved
std-bits/base/src/main/java/org/enso/base/enso_cloud/HTTPBuilder.java
Outdated
Show resolved
Hide resolved
std-bits/base/src/main/java/org/enso/base/enso_cloud/HTTPBuilder.java
Outdated
Show resolved
Hide resolved
I think the overall structure looks great. |
98a5a0b
to
97739d7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a great step forward.
I wonder how we can approach integration testing of the cloud parts (but ofc that's for the follow-ups).
distribution/lib/Standard/Base/0.0.0-dev/src/Data/Enso_Cloud/Enso_User.enso
Outdated
Show resolved
Hide resolved
.replace("\\b", "\b") | ||
.replace("\\f", "\f") | ||
.replace("\\\\", "\\"); | ||
return json.substring(1, json.length() - 1).translateEscapes(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it may be good to include a TODO here that JSON can actually contain the Unicode escapes - if we ever run into this being an issue it would be a valuable hint.
std-bits/base/src/main/java/org/enso/base/enso_cloud/EnsoSecretHelper.java
Outdated
Show resolved
Hide resolved
js_object = response.decode_as_json | ||
js_object.into Enso_User | ||
|
||
## Lists all known users. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PRIVATE?
e087d9d
to
807dfe9
Compare
Added URI_With_Query. Fix for debugging in Windows.
9d8650b
to
62679da
Compare
Bug fixes.
Pull Request Description
File_For_Read
type. Used forFile_Format
to read files.Enso_User
representing the current user inEnso_Cloud
.Enso_Secret
representing a value defined inEnso_Cloud
.Username_And_Password
and can be used within JDBC connections.URI_With_Query
with the same API asURI
. Supporting secrets in the value.Enso_File
representing a file or a folder in the cloud.File
(like theS3_File
).enso://
URI style access.Minor fixes:
Http_Utils.java
and folded functionality into Enso code.URI
API, just returningNothing
instead of throwing as an error.JSON.into
creating aMap
.S3_File
.Vector.+
.Column
toVector
, allowing the use of columns withinVector
methods.Source_Location
so that stacktrace renders correctly in IDE.Checklist
Please ensure that the following checklist has been satisfied before submitting the PR:
Scala,
Java,
and
Rust
style guides. In case you are using a language not listed above, follow the Rust style guide.
./run ide build
.