Пример #1
0
    def run(self):
        try:
            Initializer.switch_user(self.user, self.environment, self.token,
                                    self.sdk_config, self.proxy)

            print('Getting records for User: '******'Status Code: ' + str(response.get_status_code()))

                if response.get_status_code() in [204, 304]:
                    print('No Content' if response.get_status_code() ==
                          204 else 'Not Modified')
                    return

                # Get object from response
                response_object = response.get_object()

                if response_object is not None:

                    # Check if expected ResponseWrapper instance is received.
                    if isinstance(response_object, ResponseWrapper):
                        # Get the list of obtained Record instances
                        record_list = response_object.get_data()

                        for record in record_list:
                            for key, value in record.get_key_values().items():
                                print(key + " : " + str(value))

                    # Check if the request returned an exception
                    elif isinstance(response_object, APIException):
                        # Get the Status
                        print("Status: " +
                              response_object.get_status().get_value())

                        # Get the Code
                        print("Code: " +
                              response_object.get_code().get_value())

                        print("Details")

                        # Get the details dict
                        details = response_object.get_details()

                        for key, value in details.items():
                            print(key + ' : ' + str(value))

                        # Get the Message
                        print("Message: " +
                              response_object.get_message().get_value())

        except Exception as e:
            print(e)
Пример #2
0
    def run(self):
        try:
            Initializer.switch_user(self.user, self.environment, self.token, self.sdk_config)

            print('Getting records for User: ' + Initializer.get_initializer().user.email)

            response = RecordOperations().get_records(self.module_api_name)

            print(response)

        except Exception as e:
            print(e)