コード例 #1
0
ファイル: admin.py プロジェクト: uasau/lenses-python
    def UpdateSAToken(self, name=None, token=None):
        payload = {
            "token": "%s" % token,
        }

        if token:
            __RQE = self.url + "/api/v1/serviceaccount/" + name + '/revoke'
            self.updateSAToken = exec_request(
                __METHOD="put",
                __EXPECTED="json",
                __URL=__RQE,
                __HEADERS=self.admin_text_plain_headers,
                __DATA=payload
            )
        else:
            __RQE = self.url + "/api/v1/serviceaccount/" + name + '/revoke'
            self.updateSAToken = exec_request(
                __METHOD="put",
                __EXPECTED="json",
                __URL=__RQE,
                __HEADERS=self.admin_text_plain_headers,
                __DATA='{}',
                __DT='data'
            )

        return self.updateSAToken
コード例 #2
0
ファイル: topics.py プロジェクト: uasau/lenses-python
    def CreateTopic(self, topicName, replication, partitions, config):
        """
        Example of request
        {
            "topicName": "topicA",
            "replication": 1,
            "partitions": 1,
            "configs": {
            "cleanup.policy": "compact",
            "compression.type": "snappy"
                        }
        }
        :param topicName:Name of topic
        :param replication:
        :param partitions:
        :param config: is dict ,for example
        {
            "cleanup.policy": "compact",
            "compression.type": "snappy"
        }
        """
        params = dict(topicName=topicName,
                      replication=int(replication),
                      partitions=int(partitions),
                      configs=config)

        self.createTopic = exec_request(__METHOD="post",
                                        __EXPECTED="text",
                                        __URL=self.manage_topic_endpoint,
                                        __HEADERS=self.topic_headers,
                                        __DATA=params)

        return self.createTopic
コード例 #3
0
    def SetConnectorConfig(self, cluster, connector, config):
        """

        :param cluster:
        :param connector:
        :param config: For example {
            'connector.class': 'org.apache.kafka.connect.file.FileStreamSinkConnector',
            'task.max': 5,
            'topics': 'nyc_yellow_taxi_trip_data,reddit_posts,sea_vessel_position_reports,
            telecom_italia_data',
            'file': '/dev/null',
            'tasks.max': '4',
            'name': 'nullsink'
        }
        """
        __RQE = self.lenses_connect_endpoint
        __RQE = __RQE + '/' + cluster + '/connectors/'
        __RQE = __RQE + connector + '/config'
        self.setConnectorConfig = exec_request(
            __METHOD="put",
            __EXPECTED="json",
            __URL=__RQE,
            __HEADERS=self.connector_headers,
            __DATA=config
        )

        return self.setConnectorConfig
コード例 #4
0
    def RegisterNewSchema(self, subject, schema_json):
        """
            Parameters:
                - subject name (String)
                - subject's schema (Json)
                    - Example:
                    {
                        'schema':
                            '{
                                "type":"record","name":"reddit_post_key",'
                                '"namespace":"com.lensesio.social.reddit.post.key",'
                                '"fields":
                                    [
                                        {
                                            "name":"subreddit_id","type":"string"
                                        }
                                    ]
                            }'
                    }
            Returns:
                Json: {"id":subjectID}
        """
        __RQE = self.schemas_end_point
        __RQE = __RQE + '/' + subject + '/versions'
        self.registerNewSchema = exec_request(__METHOD="post",
                                              __EXPECTED="json",
                                              __URL=__RQE,
                                              __HEADERS=self.registry_headers,
                                              __DATA=schema_json,
                                              __VERIFY=self.verify_cert)

        return self.registerNewSchema
コード例 #5
0
ファイル: quotas.py プロジェクト: uasau/lenses-python
    def GetQuotas(self):
        self.getQuotas = exec_request(__METHOD="get",
                                      __EXPECTED="json",
                                      __URL=self.quotas_end_point,
                                      __HEADERS=self.quota_headers)

        return self.getQuotas
コード例 #6
0
ファイル: policy.py プロジェクト: uasau/lenses-python
    def ViewPolicy(self):
        self.viewPolicy = exec_request(__METHOD="get",
                                       __EXPECTED="json",
                                       __URL=self.lenses_policies_endpoint,
                                       __HEADERS=self.policy_headers)

        return self.viewPolicy
コード例 #7
0
ファイル: admin.py プロジェクト: uasau/lenses-python
    def CreateSA(self, name=None, owner=None, groups=None, token=None):
        if type(groups) is not list:
            groups = [groups]

        if name and groups and owner and not token:
            payload = {
                "name": "%s" % name,
                "groups": groups,
                "owner": "%s" % owner
            }
        elif name and groups and owner and token:
            payload = {
                "name": "%s" % name,
                "groups": groups,
                "owner": "%s" % owner,
                "token": "%s" % token
            }
        else:
            return "Missing parameters: name=, groups=, owner=, token="

        __RQE = self.url + "/api/v1/serviceaccount"
        self.createSA = exec_request(
            __METHOD="post",
            __EXPECTED="json",
            __URL=__RQE,
            __HEADERS=self.admin_text_plain_headers,
            __DATA=payload
        )

        return self.createSA
コード例 #8
0
ファイル: admin.py プロジェクト: uasau/lenses-python
    def UpdateSA(self, name=None, owner=None, groups=None):
        if type(groups) is not list:
            groups = [groups]

        if name and groups and owner:
            payload = {
                "name": "%s" % name,
                "groups": groups,
                "owner": "%s" % owner
            }
        elif name and groups and owner:
            payload = {
                "name": "%s" % name,
                "groups": groups,
                "owner": "%s" % owner,
            }
        else:
            return "Missing parameters: name=, groups=, owner="

        __RQE = self.url + "/api/v1/serviceaccount/" + name
        self.updateSA = exec_request(
            __METHOD="put",
            __EXPECTED="text",
            __URL=__RQE,
            __HEADERS=self.admin_text_plain_headers,
            __DATA=payload
        )

        return self.updateSA
コード例 #9
0
    def GetProcessors(self):
        self.getProcessors = exec_request(__METHOD="get",
                                          __EXPECTED="json",
                                          __URL=self.processor_end_point,
                                          __HEADERS=self.processor_headers)

        return self.getProcessors
コード例 #10
0
    def CreateProcessor(self,
                        name,
                        sql,
                        runners,
                        clusterName,
                        namespace=None,
                        pipeline=None):
        """

        :param name: string
        :param sql:string, query
        :param runners:int
        :param clusterName:string
        :param namespace:string
        :param pipeline:string, applies for Kubernetes mode
        """
        headers = {
            'Content-Type': 'application/json',
            'Accept': 'text/plain',
            'x-kafka-lenses-token': self.token
        }

        params = dict(name=name,
                      sql=sql,
                      runners=runners,
                      clusterName=clusterName)

        self.createProcessor = exec_request(__METHOD="post",
                                            __EXPECTED="text",
                                            __URL=self.processor_end_point,
                                            __HEADERS=headers,
                                            __DATA=params)

        return self.createProcessor
コード例 #11
0
ファイル: topics.py プロジェクト: uasau/lenses-python
    def GetAllTopics(self):
        self.allTopics = exec_request(__METHOD="get",
                                      __EXPECTED="json",
                                      __URL=self.topic_end_point,
                                      __HEADERS=self.topic_headers)

        return self.allTopics
コード例 #12
0
    def DelAcl(self, resourceType, resourceName, principal, permissionType,
               host, operation):
        """

        :param resourceType: string, required
        :param resourceName: string, required
        :param principal: string, required
        :param permissionType:  string, required (either Allow or Deny)
        :param host: string, required
        :param operation:  string, required
        """
        params = dict(resourceType=resourceType,
                      resourceName=resourceName,
                      principal=principal,
                      permissionType=permissionType,
                      host=host,
                      operation=operation,
                      selectedColumns=[])

        self.setAcl = exec_request(__METHOD="delete",
                                   __EXPECTED="text",
                                   __URL=self.lenses_acl_endpoint,
                                   __HEADERS=self.acls_headers,
                                   __DATA=params,
                                   __VERIFY=self.verify_cert)

        return self.setAcl
コード例 #13
0
    def GetConfig(self):
        self.getConfig = exec_request(__METHOD="get",
                                      __EXPECTED="json",
                                      __URL=self.admin_config_info_endpoint,
                                      __HEADERS=self.admin_text_plain_headers,
                                      __VERIFY=self.verify_cert)

        return self.getConfig
コード例 #14
0
ファイル: topics.py プロジェクト: uasau/lenses-python
    def DefaultTopicConfigs(self):
        self.defaultTopicConfigs = exec_request(
            __METHOD="get",
            __EXPECTED="json",
            __URL=self.topic_config_end_point,
            __HEADERS=self.topic_headers)

        return self.defaultTopicConfigs
コード例 #15
0
ファイル: topics.py プロジェクト: uasau/lenses-python
    def TopicInfo(self, topicname):
        __RQE = self.manage_topic_endpoint + '/' + topicname
        self.topicInfo = exec_request(__METHOD="get",
                                      __EXPECTED="json",
                                      __URL=__RQE,
                                      __HEADERS=self.topic_headers)

        return self.topicInfo
コード例 #16
0
    def GetConsumers(self):
        __RQE = self.lenses_consumers_endpoint
        self.getConsumers = exec_request(__METHOD="get",
                                         __EXPECTED="json",
                                         __URL=__RQE,
                                         __HEADERS=self.consumers_headers)

        return self.getConsumers
コード例 #17
0
 def GetAlerts(self, pageSize=999999999):
     __RQE = self.admin_alerts_endpoint
     __RQE = __RQE + '?pageSize=%s' % pageSize
     self.alerts = exec_request(__METHOD="get",
                                __EXPECTED="json",
                                __URL=__RQE,
                                __HEADERS=self.admin_x_headers,
                                __VERIFY=self.verify_cert)
     return self.alerts
コード例 #18
0
ファイル: schemas.py プロジェクト: uasau/lenses-python
    def GetGlobalCompatibility(self):
        __RQE = self.schemas_config_end_point
        self.getGlobalCompatibility = exec_request(
            __METHOD="get",
            __EXPECTED="json",
            __URL=__RQE,
            __HEADERS=self.registry_headers)

        return self.getGlobalCompatibility
コード例 #19
0
    def DeleteUser(self, username):
        __RQE = self.url + "/api/v1/user/" + username
        self.deleteUser = exec_request(__METHOD="delete",
                                       __EXPECTED="text",
                                       __URL=__RQE,
                                       __HEADERS=self.admin_text_plain_headers,
                                       __VERIFY=self.verify_cert)

        return self.deleteUser
コード例 #20
0
    def DeleteSA(self, name=None):
        __RQE = self.url + "/api/v1/serviceaccount/" + name
        self.deleteSA = exec_request(__METHOD="delete",
                                     __EXPECTED="text",
                                     __URL=__RQE,
                                     __HEADERS=self.admin_x_headers,
                                     __VERIFY=self.verify_cert)

        return self.deleteSA
コード例 #21
0
ファイル: topics.py プロジェクト: uasau/lenses-python
    def AvailableTopicConfigKeys(self):
        __RQE = self.topic_config_end_point + "/keys"
        self.availableTopicConfigKeys = exec_request(
            __METHOD="get",
            __EXPECTED="json",
            __URL=__RQE,
            __HEADERS=self.topic_headers)

        return self.availableTopicConfigKeys
コード例 #22
0
    def GetTopology(self):
        __RQE = self.lenses_topology_endpoint
        self.getTopology = exec_request(__METHOD="get",
                                        __EXPECTED="json",
                                        __URL=__RQE,
                                        __HEADERS=self.topology_headers,
                                        __VERIFY=self.verify_cert)

        return self.getTopology
コード例 #23
0
    def GetUsers(self):
        __RQE = self.admin_users_endpoint
        self.getUsers = exec_request(__METHOD="get",
                                     __EXPECTED="json",
                                     __URL=__RQE,
                                     __HEADERS=self.admin_x_headers,
                                     __VERIFY=self.verify_cert)

        return self.getUsers
コード例 #24
0
ファイル: admin.py プロジェクト: uasau/lenses-python
    def GetUsers(self):
        __RQE = self.admin_users_endpoint
        self.getUsers = exec_request(
            __METHOD="get",
            __EXPECTED="json",
            __URL=__RQE,
            __HEADERS=self.admin_text_plain_headers
        )

        return self.getUsers
コード例 #25
0
ファイル: admin.py プロジェクト: uasau/lenses-python
    def DeleteGroup(self, group):
        __RQE = self.url + "/api/v1/group/" + group
        self.deleteGroup = exec_request(
            __METHOD="delete",
            __EXPECTED="text",
            __URL=__RQE,
            __HEADERS=self.admin_text_plain_headers
        )

        return self.deleteGroup
コード例 #26
0
ファイル: sql.py プロジェクト: uasau/lenses-python
    def ValidateSqlQuery(self):
        self.validateSqlQuery = exec_request(
            __METHOD="get",
            __EXPECTED="text",
            __URL=self.lenses_sql_query_validation,
            __HEADERS=self.active_headers,
            __DATA=self.params)

        if 'Expected one of Alter' in self.validateSqlQuery:
            raise Exception(self.validateSqlQuery.text)
コード例 #27
0
    def CreateGroup(self, payload):
        __RQE = self.url + "/api/v1/group"
        self.createGroup = exec_request(__METHOD="post",
                                        __EXPECTED="text",
                                        __URL=__RQE,
                                        __HEADERS=self.admin_x_headers,
                                        __DATA=payload,
                                        __VERIFY=self.verify_cert)

        return self.createGroup
コード例 #28
0
ファイル: admin.py プロジェクト: uasau/lenses-python
    def UpdateGroup(self, group, payload):
        __RQE = self.url + "/api/v1/group/" + group
        self.updateGroup = exec_request(
            __METHOD="put",
            __EXPECTED="text",
            __URL=__RQE,
            __HEADERS=self.admin_text_plain_headers,
            __DATA=payload
        )

        return self.updateGroup
コード例 #29
0
ファイル: schemas.py プロジェクト: uasau/lenses-python
    def GetAllSubjects(self):
        """
            Returns:
                List with all subjects
        """
        self.getAllSubjects = exec_request(__METHOD="get",
                                           __EXPECTED="json",
                                           __URL=self.schemas_end_point,
                                           __HEADERS=self.registry_headers)

        return self.getAllSubjects
コード例 #30
0
ファイル: schemas.py プロジェクト: uasau/lenses-python
    def UpdateSchema(self, subject, schema_json):
        __RQE = self.url
        __RQE = __RQE + "/api/proxy-sr/subjects/"
        __RQE = __RQE + subject + "/versions/"
        self.registerNewSchema = exec_request(__METHOD="post",
                                              __EXPECTED="json",
                                              __URL=__RQE,
                                              __HEADERS=self.registry_headers,
                                              __DATA=schema_json)

        return self.registerNewSchema