Browse Source

HUE-5553 [metadata] Update the lib with missing files

Romain Rigaux 9 năm trước cách đây
mục cha
commit
ceed03f

+ 2 - 2
desktop/core/ext-py/navoptapi-0.1.0/PKG-INFO

@@ -21,8 +21,8 @@ Description: Cloudera Navigator Optimizer Api SDK
         * Import the module
           from navoptapi.api_lib import *
         
-        * Create NavOpt object passing hostname, access key and private key:
-            nav = ApiLib("navopt", "121.0.0.1", "e0819f3a-1e6f-4904-be69-5b704b299bbb", "-----BEGIN PRIVATE KEY-----\n..............\n-----END PRIVATE KEY-----")
+        * Create NavOpt object passing hostname/address, access key and private key:
+          nav = ApiLib("navopt", "127.0.0.1", "e0819f3a-1e6f-4904-be69-4ftrf56983", "-----BEGIN PRIVATE KEY-----\ngm9aeam8fgZ5VXPbXRo9EYepZcWPWeYO1WjPyI\nF17opGTl9M/2H+kXmsmyPwLBSQE96Q==\n-----END PRIVATE KEY-----")
         
         * Upload a file to NavOpt:
            resp = nav.call_api("upload", {"tenant" : "6bd23dea-13aa-ce13-4a6d-1614151428fc", "fileLocation": "/Users/harshil/Downloads/tmpbUMdbb.csv", "sourcePlatform": "hive", "colDelim": ",", "rowDelim": "\n", "headerFields": [{"count": 0, "coltype": "SQL_ID", "use": True, "tag": "", "name": "SQL_ID"}, {"count": 0, "coltype": "NONE", "use": True, "tag": "", "name": "ELAPSED_TIME"}, {"count": 0, "coltype": "SQL_QUERY", "use": True, "tag": "", "name": "SQL_FULLTEXT"}]})

+ 2 - 2
desktop/core/ext-py/navoptapi-0.1.0/README.rst

@@ -13,8 +13,8 @@ Example Usage for the Api
 * Import the module
   from navoptapi.api_lib import *
 
-* Create NavOpt object passing hostname, access key and private key:
-  nav = ApiLib("navopt", "121.0.0.1", "e0819f3a-1e6f-4904-be69-5b704b299bbb", "-----BEGIN PRIVATE KEY-----\n..............\n-----END PRIVATE KEY-----")
+* Create NavOpt object passing hostname/address, access key and private key:
+  nav = ApiLib("navopt", "127.0.0.1", "e0819f3a-1e6f-4904-be69-4ftrf56983", "-----BEGIN PRIVATE KEY-----\ngm9aeam8fgZ5VXPbXRo9EYepZcWPWeYO1WjPyI\nF17opGTl9M/2H+kXmsmyPwLBSQE96Q==\n-----END PRIVATE KEY-----")
 
 * Upload a file to NavOpt:
    resp = nav.call_api("upload", {"tenant" : "6bd23dea-13aa-ce13-4a6d-1614151428fc", "fileLocation": "/Users/harshil/Downloads/tmpbUMdbb.csv", "sourcePlatform": "hive", "colDelim": ",", "rowDelim": "\n", "headerFields": [{"count": 0, "coltype": "SQL_ID", "use": True, "tag": "", "name": "SQL_ID"}, {"count": 0, "coltype": "NONE", "use": True, "tag": "", "name": "ELAPSED_TIME"}, {"count": 0, "coltype": "SQL_QUERY", "use": True, "tag": "", "name": "SQL_FULLTEXT"}]})

+ 15 - 0
desktop/core/ext-py/navoptapi-0.1.0/navoptapi/api_lib.py

@@ -1,3 +1,18 @@
+# Licensed to Cloudera, Inc. under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  Cloudera, Inc. licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
 
 import json
 import logging

+ 48 - 0
desktop/core/ext-py/navoptapi-0.1.0/navoptapi/credentials.py

@@ -0,0 +1,48 @@
+# Copyright 2012-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+#
+# Modifications made by Cloudera are:
+#     Copyright (c) 2016 Cloudera, Inc. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"). You
+# may not use this file except in compliance with the License. A copy of
+# the License is located at
+#
+#     http://aws.amazon.com/apache2.0/
+#
+# or in the "license" file accompanying this file. This file is
+# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
+# ANY KIND, either express or implied. See the License for the specific
+# language governing permissions and limitations under the License.
+
+from collections import namedtuple
+
+import six
+
+ReadOnlyCredentials = namedtuple('ReadOnlyCredentials',
+                                 ['access_key_id', 'private_key', 'method'])
+
+
+class Credentials(object):
+    """
+    Holds the credentials needed to authenticate requests.
+    """
+
+    def __init__(self, access_key_id, private_key, method):
+        self.access_key_id = access_key_id
+        self.private_key = private_key
+        self.method = method
+        self._normalize()
+
+    def ensure_unicode(self, s, encoding='utf-8', errors='strict'):
+        if isinstance(s, six.text_type):
+            return s
+        return unicode(s, encoding, errors)
+
+    def _normalize(self):
+        self.access_key_id = self.ensure_unicode(self.access_key_id)
+        self.private_key = self.ensure_unicode(self.private_key)
+
+    def get_frozen_credentials(self):
+        return ReadOnlyCredentials(self.access_key_id,
+                                   self.private_key,
+                                   self.method)

+ 77 - 0
desktop/core/ext-py/navoptapi-0.1.0/navoptapi/serialize.py

@@ -0,0 +1,77 @@
+# Copyright 2012-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+#
+# Modifications made by Cloudera are:
+#     Copyright (c) 2016 Cloudera, Inc. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"). You
+# may not use this file except in compliance with the License. A copy of
+# the License is located at
+#
+#     http://aws.amazon.com/apache2.0/
+#
+# or in the "license" file accompanying this file. This file is
+# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
+# ANY KIND, either express or implied. See the License for the specific
+# language governing permissions and limitations under the License.
+
+from collections import OrderedDict
+import json
+
+
+class Serializer(object):
+    DEFAULT_ENCODING = 'utf-8'
+
+    def serialize_to_request(self, parameters, operation_model):
+        # Don't serialize any parameter with a None value.
+        filtered_parameters = OrderedDict(
+            (k, v) for k, v in parameters.items() if v is not None)
+
+        serialized = {}
+        # serialized['method'] = operation_model.http['method']
+        # serialized['headers'] = {'Content-Type': 'application/json'}
+        # serialized['url_path'] = operation_model.http['requestUri']
+
+        serialized_body = OrderedDict()
+        if len(filtered_parameters) != 0:
+            self._serialize(serialized_body, filtered_parameters, None)
+
+        serialized['body'] = json.dumps(serialized_body).encode(self.DEFAULT_ENCODING)
+
+        return serialized
+
+    def _serialize(self, serialized, value, shape, key=None):
+        # serialize_method_name = '_serialize_type_%s' % shape.type_name
+        # method = getattr(self, serialize_method_name, self._default_serialize)
+        self._default_serialize(serialized, value, shape, key)
+
+    def _serialize_type_object(self, serialized, value, shape, key):
+        if key is not None:
+            # If a key is provided, this is a result of a recursive call, so we
+            # need to add a new child dict as the value of the passed in dict.
+            # Below we will add all the structure members to the new serialized
+            # dictionary we just created.
+            serialized[key] = OrderedDict()
+            serialized = serialized[key]
+
+        for member_key, member_value in value.items():
+            member_shape = shape.members[member_key]
+            self._serialize(serialized, member_value, member_shape, member_key)
+
+    def _serialize_type_array(self, serialized, value, shape, key):
+        array_obj = []
+        serialized[key] = array_obj
+        for array_item in value:
+            wrapper = {}
+            # JSON list serialization is the only case where we aren't setting
+            # a key on a dict.  We handle this by using a __current__ key on a
+            # wrapper dict to serialize each list item before appending it to
+            # the serialized list.
+            self._serialize(wrapper, array_item, shape.member, "__current__")
+            array_obj.append(wrapper["__current__"])
+
+    def _default_serialize(self, serialized, value, shape, key):
+        if key:
+            serialized[key] = value
+        else:
+            for member_key, member_value in value.items():
+                serialized[member_key] = member_value

+ 58 - 0
desktop/core/ext-py/navoptapi-0.1.0/navoptapi/signers.py

@@ -0,0 +1,58 @@
+# Copyright 2014 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+#
+# Modifications made by Cloudera are:
+#     Copyright (c) 2016 Cloudera, Inc. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"). You
+# may not use this file except in compliance with the License. A copy of
+# the License is located at
+#
+# http://aws.amazon.com/apache2.0/
+#
+# or in the "license" file accompanying this file. This file is
+# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
+# ANY KIND, either express or implied. See the License for the specific
+# language governing permissions and limitations under the License.
+
+import navoptapi.auth
+
+UNSIGNED = object()
+
+
+class RequestSigner(object):
+    """
+    An object to sign requests before they go out over the wire using
+    one of the authentication mechanisms defined in ``auth.py``.
+    """
+    def __init__(self, signature_version, credentials):
+        self._signature_version = signature_version
+        self._credentials = credentials
+
+    @property
+    def signature_version(self):
+        return self._signature_version
+
+    def sign(self, request):
+        """
+        Sign a request before it goes out over the wire.
+        """
+        if self._signature_version != UNSIGNED:
+            signer = self.get_auth_instance(self._signature_version)
+            signer.add_auth(request)
+
+    def get_auth_instance(self, signature_version, **kwargs):
+        """
+        Get an auth instance which can be used to sign a request
+        using the given signature version.
+        """
+        cls = navoptapi.auth.AUTH_TYPE_MAPS.get(signature_version)
+        if cls is None:
+            return
+        # If there's no credentials provided (i.e credentials is None),
+        # then we'll pass a value of "None" over to the auth classes,
+        # which already handle the cases where no credentials have
+        # been provided.
+        frozen_credentials = self._credentials.get_frozen_credentials()
+        kwargs['credentials'] = frozen_credentials
+        auth = cls(**kwargs)
+        return auth

+ 2 - 2
desktop/libs/indexer/src/indexer/templates/importer.mako

@@ -261,7 +261,7 @@ ${ assist.assistPanel() }
 
             <div class="control-group" data-bind="visible: createWizard.source.inputFormat() == 'table'">
               <label for="path" class="control-label"><div>${ _('Table') }</div>
-                <input type="text" data-bind="value: createWizard.source.table, hivechooser: createWizard.source.table, skipColumns: true">
+                <input type="text" data-bind="value: createWizard.source.table, hivechooser: createWizard.source.table, skipColumns: true" placeholder="${ _('Table name or <database>.<table>') }">
               </label>
             </div>
 
@@ -335,7 +335,7 @@ ${ assist.assistPanel() }
 
           <!-- ko if: ouputFormat() == 'table' || ouputFormat() == 'database' -->
             <label for="path" class="control-label">
-              <input type="text" data-bind="value: name, hivechooser: name, skipColumns: true, valueUpdate: 'afterkeydown'" placeholder="${ _('Name') }">
+              <input type="text" data-bind="value: name, hivechooser: name, skipColumns: true, valueUpdate: 'afterkeydown'" placeholder="${ _('Table name or <database>.<table>') }">
             </label>
           <!-- /ko -->
 

+ 14 - 7
desktop/libs/notebook/src/notebook/templates/notebook_ko_components.mako

@@ -170,7 +170,7 @@ except ImportError, e:
     </form>
 
     <div class="hover-dropdown" data-bind="visible: snippet.status() == 'available' && snippet.result.hasSomeResults() && snippet.result.type() == 'table'" style="display:none;">
-      <a class="snippet-side-btn inactive-action dropdown-toggle pointer" style="padding-right:0" data-toggle="dropdown" title="${ _('Get results') }">
+      <a class="snippet-side-btn inactive-action dropdown-toggle pointer" style="padding-right:0" data-toggle="dropdown" title="${ _('Export results') }">
         <!-- ko ifnot: isDownloading -->
         <i class="fa fa-fw fa-download"></i>
         <!-- /ko -->
@@ -191,10 +191,17 @@ except ImportError, e:
           </a>
         </li>
         <li>
-          <a class="inactive-action download" href="javascript:void(0)" data-bind="click: function() { $('#saveResultsModal').modal('show'); }" title="${ _('Save the results to a large file or a new table') }">
+          <a class="inactive-action download" href="javascript:void(0)" data-bind="click: function() { $('#saveResultsModal').modal('show'); }" title="${ _('Save the result in a file, a new table...') }">
             <i class="fa fa-fw fa-save"></i> ${ _('Export') }
           </a>
         </li>
+        % if hasattr(ENABLE_NEW_INDEXER, 'get') and ENABLE_NEW_INDEXER.get():
+        <li>
+          <a class="inactive-action download" href="javascript:void(0)" data-bind="click: function() { $('#saveResultsModal').modal('show'); }" title="${ _('Explore the result in an analytic dashboard') }">
+            <i class="fa fa-fw fa-area-chart"></i> ${ _('Dashboard') }
+          </a>
+        </li>
+        % endif
       </ul>
     </div>
 
@@ -207,7 +214,7 @@ except ImportError, e:
 
       <div class="modal-header">
         <a href="#" class="close" data-dismiss="modal">&times;</a>
-        <h3>${_('Save query result in')}</h3>
+        <h3>${_('Save query result in a')}</h3>
       </div>
       <div class="modal-body" style="padding: 4px">
         <form id="saveResultsForm" method="POST" class="form form-inline">
@@ -217,7 +224,7 @@ except ImportError, e:
               <div class="controls">
                 <label class="radio">
                   <input data-bind="checked: saveTarget" type="radio" name="save-results-type" value="hdfs-file">
-                  &nbsp;${ _('A file (max %s cells)') % DOWNLOAD_CELL_LIMIT.get() }
+                  &nbsp;${ _('File (max %s cells)') % DOWNLOAD_CELL_LIMIT.get() }
                 </label>
                 <div data-bind="visible: saveTarget() == 'hdfs-file'" class="inline">
                   <input data-bind="value: savePath, valueUpdate:'afterkeydown', filechooser: { value: savePath, isNestedModal: true }, filechooserOptions: { uploadFile: false, skipInitialPathIfEmpty: true, linkMarkup: true }, hdfsAutocomplete: savePath" type="text" name="target_file" placeholder="${_('Path to CSV file')}" class="pathChooser margin-left-10">
@@ -232,7 +239,7 @@ except ImportError, e:
               <div class="controls" data-bind="visible: snippet.type() == 'hive'">
                 <label class="radio">
                   <input data-bind="checked: saveTarget" type="radio" name="save-results-type" value="hdfs-directory">
-                  &nbsp;${ _('A file (large result)') }
+                  &nbsp;${ _('File (large result)') }
                 </label>
                 <div data-bind="visible: saveTarget() == 'hdfs-directory'" class="inline">
                   <input data-bind="value: savePath, valueUpdate:'afterkeydown', filechooser: { value: savePath, isNestedModal: true }, filechooserOptions: { uploadFile: false, skipInitialPathIfEmpty: true, displayOnlyFolders: true, linkMarkup: true }, hdfsAutocomplete: savePath" type="text" name="target_dir" placeholder="${_('Path to empty directory')}" class="pathChooser margin-left-10">
@@ -246,7 +253,7 @@ except ImportError, e:
               <div class="controls">
                 <label class="radio">
                   <input data-bind="checked: saveTarget" type="radio" name="save-results-type" value="hive-table">
-                  &nbsp;${ _('A new table') }
+                  &nbsp;${ _('Table') }
                 </label>
                 <div data-bind="visible: saveTarget() == 'hive-table'" class="inline">
                   <input data-bind="hivechooser: savePath" type="text" name="target_table" class="input-xlarge margin-left-10" placeholder="${_('Table name or <database>.<table>')}">
@@ -258,7 +265,7 @@ except ImportError, e:
               <div class="controls">
                 <label class="radio">
                   <input data-bind="checked: saveTarget" type="radio" name="save-results-type" value="search-index">
-                  &nbsp;${ _('A search dashboard') }
+                  &nbsp;${ _('Dashboard') }
                 </label>
                 <div data-bind="visible: saveTarget() == 'search-index'" class="inline">
                   <input data-bind="value: savePath, valueUpdate:'afterkeydown'" type="text" name="target_index" class="input-xlarge margin-left-10" placeholder="${_('Index name')}">