You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2022/07/31 20:13:40 UTC

[GitHub] [iceberg] Fokko opened a new pull request, #5402: Python: Follow up on REST comments

Fokko opened a new pull request, #5402:
URL: https://github.com/apache/iceberg/pull/5402

   Some small comments pending from: https://github.com/apache/iceberg/pull/5287


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


[GitHub] [iceberg] rdblue commented on a diff in pull request #5402: Python: Follow up on REST comments

Posted by GitBox <gi...@apache.org>.
rdblue commented on code in PR #5402:
URL: https://github.com/apache/iceberg/pull/5402#discussion_r934036190


##########
python/pyiceberg/catalog/rest.py:
##########
@@ -200,32 +196,36 @@ def _split_credential(token: str) -> Tuple[str, str]:
 
     @property
     def headers(self) -> Properties:
-        return {
-            AUTHORIZATION_HEADER: f"{BEARER_PREFIX} {self.token}",
+        headers = {
             "Content-type": "application/json",
             "X-Client-Version": __version__,
         }
+        if self.token:
+            headers[AUTHORIZATION_HEADER] = f"{BEARER_PREFIX} {self.token}"
+        return headers
 
-    def url(self, endpoint: str, prefixed: bool = True, **kwargs) -> str:
+    def url(self, uri: str, prefixed: bool = True, **kwargs) -> str:
         """Constructs the endpoint
 
         Args:
+            uri: Resource identifier that points to the REST catalog
             prefixed: If the prefix return by the config needs to be appended
 
         Returns:
             The base url of the rest catalog
         """
 
-        url = self.host
+        url = self.uri
         url = url + "v1/" if url.endswith("/") else url + "/v1/"
 
         if prefixed:
             url += self.config.get(PREFIX, "")
             url = url if url.endswith("/") else url + "/"
 
-        return url + endpoint.format(**kwargs)
+        return url + uri.format(**kwargs)

Review Comment:
   Looks like this refactor caught a little too much. Both the `endpoint` argument and `url` instance field have been changed to `uri`. I think you want to revert the `endpoint` to `uri` rename?
   
   I think this still works since `self.uri` and `uri` are distinct, but it makes this method harder to read.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


[GitHub] [iceberg] rdblue merged pull request #5402: Python: Follow up on REST comments

Posted by GitBox <gi...@apache.org>.
rdblue merged PR #5402:
URL: https://github.com/apache/iceberg/pull/5402


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


[GitHub] [iceberg] Fokko commented on a diff in pull request #5402: Python: Follow up on REST comments

Posted by GitBox <gi...@apache.org>.
Fokko commented on code in PR #5402:
URL: https://github.com/apache/iceberg/pull/5402#discussion_r934041666


##########
python/pyiceberg/catalog/rest.py:
##########
@@ -200,32 +196,36 @@ def _split_credential(token: str) -> Tuple[str, str]:
 
     @property
     def headers(self) -> Properties:
-        return {
-            AUTHORIZATION_HEADER: f"{BEARER_PREFIX} {self.token}",
+        headers = {
             "Content-type": "application/json",
             "X-Client-Version": __version__,
         }
+        if self.token:
+            headers[AUTHORIZATION_HEADER] = f"{BEARER_PREFIX} {self.token}"
+        return headers
 
-    def url(self, endpoint: str, prefixed: bool = True, **kwargs) -> str:
+    def url(self, uri: str, prefixed: bool = True, **kwargs) -> str:
         """Constructs the endpoint
 
         Args:
+            uri: Resource identifier that points to the REST catalog
             prefixed: If the prefix return by the config needs to be appended
 
         Returns:
             The base url of the rest catalog
         """
 
-        url = self.host
+        url = self.uri
         url = url + "v1/" if url.endswith("/") else url + "/v1/"
 
         if prefixed:
             url += self.config.get(PREFIX, "")
             url = url if url.endswith("/") else url + "/"
 
-        return url + endpoint.format(**kwargs)
+        return url + uri.format(**kwargs)

Review Comment:
   Fair point, I've reverted it 👍🏻 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


[GitHub] [iceberg] rdblue commented on pull request #5402: Python: Follow up on REST comments

Posted by GitBox <gi...@apache.org>.
rdblue commented on PR #5402:
URL: https://github.com/apache/iceberg/pull/5402#issuecomment-1201838481

   Thanks, @Fokko!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org