pinecone.core.client.exceptions

Pinecone API

No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501

The version of the OpenAPI document: version not set Contact: support@pinecone.io Generated by: https://openapi-generator.tech

  1"""
  2    Pinecone API
  3
  4    No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)  # noqa: E501
  5
  6    The version of the OpenAPI document: version not set
  7    Contact: support@pinecone.io
  8    Generated by: https://openapi-generator.tech
  9"""
 10
 11
 12from pinecone.core.exceptions import PineconeException
 13
 14
 15class OpenApiException(PineconeException):
 16    """The base exception class for all OpenAPIExceptions"""
 17
 18
 19class ApiTypeError(OpenApiException, TypeError):
 20    def __init__(self, msg, path_to_item=None, valid_classes=None, key_type=None):
 21        """Raises an exception for TypeErrors
 22
 23        Args:
 24            msg (str): the exception message
 25
 26        Keyword Args:
 27            path_to_item (list): a list of keys an indices to get to the
 28                                 current_item
 29                                 None if unset
 30            valid_classes (tuple): the primitive classes that current item
 31                                   should be an instance of
 32                                   None if unset
 33            key_type (bool): False if our value is a value in a dict
 34                             True if it is a key in a dict
 35                             False if our item is an item in a list
 36                             None if unset
 37        """
 38        self.path_to_item = path_to_item
 39        self.valid_classes = valid_classes
 40        self.key_type = key_type
 41        full_msg = msg
 42        if path_to_item:
 43            full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
 44        super(ApiTypeError, self).__init__(full_msg)
 45
 46
 47class ApiValueError(OpenApiException, ValueError):
 48    def __init__(self, msg, path_to_item=None):
 49        """
 50        Args:
 51            msg (str): the exception message
 52
 53        Keyword Args:
 54            path_to_item (list) the path to the exception in the
 55                received_data dict. None if unset
 56        """
 57
 58        self.path_to_item = path_to_item
 59        full_msg = msg
 60        if path_to_item:
 61            full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
 62        super(ApiValueError, self).__init__(full_msg)
 63
 64
 65class ApiAttributeError(OpenApiException, AttributeError):
 66    def __init__(self, msg, path_to_item=None):
 67        """
 68        Raised when an attribute reference or assignment fails.
 69
 70        Args:
 71            msg (str): the exception message
 72
 73        Keyword Args:
 74            path_to_item (None/list) the path to the exception in the
 75                received_data dict
 76        """
 77        self.path_to_item = path_to_item
 78        full_msg = msg
 79        if path_to_item:
 80            full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
 81        super(ApiAttributeError, self).__init__(full_msg)
 82
 83
 84class ApiKeyError(OpenApiException, KeyError):
 85    def __init__(self, msg, path_to_item=None):
 86        """
 87        Args:
 88            msg (str): the exception message
 89
 90        Keyword Args:
 91            path_to_item (None/list) the path to the exception in the
 92                received_data dict
 93        """
 94        self.path_to_item = path_to_item
 95        full_msg = msg
 96        if path_to_item:
 97            full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
 98        super(ApiKeyError, self).__init__(full_msg)
 99
100
101class ApiException(OpenApiException):
102    def __init__(self, status=None, reason=None, http_resp=None):
103        if http_resp:
104            self.status = http_resp.status
105            self.reason = http_resp.reason
106            self.body = http_resp.data
107            self.headers = http_resp.getheaders()
108        else:
109            self.status = status
110            self.reason = reason
111            self.body = None
112            self.headers = None
113
114    def __str__(self):
115        """Custom error messages for exception"""
116        error_message = "({0})\n" "Reason: {1}\n".format(self.status, self.reason)
117        if self.headers:
118            error_message += "HTTP response headers: {0}\n".format(self.headers)
119
120        if self.body:
121            error_message += "HTTP response body: {0}\n".format(self.body)
122
123        return error_message
124
125
126class NotFoundException(ApiException):
127    def __init__(self, status=None, reason=None, http_resp=None):
128        super(NotFoundException, self).__init__(status, reason, http_resp)
129
130
131class UnauthorizedException(ApiException):
132    def __init__(self, status=None, reason=None, http_resp=None):
133        super(UnauthorizedException, self).__init__(status, reason, http_resp)
134
135
136class ForbiddenException(ApiException):
137    def __init__(self, status=None, reason=None, http_resp=None):
138        super(ForbiddenException, self).__init__(status, reason, http_resp)
139
140
141class ServiceException(ApiException):
142    def __init__(self, status=None, reason=None, http_resp=None):
143        super(ServiceException, self).__init__(status, reason, http_resp)
144
145
146def render_path(path_to_item):
147    """Returns a string representation of a path"""
148    result = ""
149    for pth in path_to_item:
150        if isinstance(pth, int):
151            result += "[{0}]".format(pth)
152        else:
153            result += "['{0}']".format(pth)
154    return result
class OpenApiException(pinecone.core.exceptions.PineconeException):
16class OpenApiException(PineconeException):
17    """The base exception class for all OpenAPIExceptions"""

The base exception class for all OpenAPIExceptions

Inherited Members
builtins.Exception
Exception
builtins.BaseException
with_traceback
add_note
args
class ApiTypeError(OpenApiException, builtins.TypeError):
20class ApiTypeError(OpenApiException, TypeError):
21    def __init__(self, msg, path_to_item=None, valid_classes=None, key_type=None):
22        """Raises an exception for TypeErrors
23
24        Args:
25            msg (str): the exception message
26
27        Keyword Args:
28            path_to_item (list): a list of keys an indices to get to the
29                                 current_item
30                                 None if unset
31            valid_classes (tuple): the primitive classes that current item
32                                   should be an instance of
33                                   None if unset
34            key_type (bool): False if our value is a value in a dict
35                             True if it is a key in a dict
36                             False if our item is an item in a list
37                             None if unset
38        """
39        self.path_to_item = path_to_item
40        self.valid_classes = valid_classes
41        self.key_type = key_type
42        full_msg = msg
43        if path_to_item:
44            full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
45        super(ApiTypeError, self).__init__(full_msg)

The base exception class for all OpenAPIExceptions

ApiTypeError(msg, path_to_item=None, valid_classes=None, key_type=None)
21    def __init__(self, msg, path_to_item=None, valid_classes=None, key_type=None):
22        """Raises an exception for TypeErrors
23
24        Args:
25            msg (str): the exception message
26
27        Keyword Args:
28            path_to_item (list): a list of keys an indices to get to the
29                                 current_item
30                                 None if unset
31            valid_classes (tuple): the primitive classes that current item
32                                   should be an instance of
33                                   None if unset
34            key_type (bool): False if our value is a value in a dict
35                             True if it is a key in a dict
36                             False if our item is an item in a list
37                             None if unset
38        """
39        self.path_to_item = path_to_item
40        self.valid_classes = valid_classes
41        self.key_type = key_type
42        full_msg = msg
43        if path_to_item:
44            full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
45        super(ApiTypeError, self).__init__(full_msg)

Raises an exception for TypeErrors

Arguments:
  • msg (str): the exception message
Keyword Args:

path_to_item (list): a list of keys an indices to get to the current_item None if unset valid_classes (tuple): the primitive classes that current item should be an instance of None if unset key_type (bool): False if our value is a value in a dict True if it is a key in a dict False if our item is an item in a list None if unset

path_to_item
valid_classes
key_type
Inherited Members
builtins.BaseException
with_traceback
add_note
args
class ApiValueError(OpenApiException, builtins.ValueError):
48class ApiValueError(OpenApiException, ValueError):
49    def __init__(self, msg, path_to_item=None):
50        """
51        Args:
52            msg (str): the exception message
53
54        Keyword Args:
55            path_to_item (list) the path to the exception in the
56                received_data dict. None if unset
57        """
58
59        self.path_to_item = path_to_item
60        full_msg = msg
61        if path_to_item:
62            full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
63        super(ApiValueError, self).__init__(full_msg)

The base exception class for all OpenAPIExceptions

ApiValueError(msg, path_to_item=None)
49    def __init__(self, msg, path_to_item=None):
50        """
51        Args:
52            msg (str): the exception message
53
54        Keyword Args:
55            path_to_item (list) the path to the exception in the
56                received_data dict. None if unset
57        """
58
59        self.path_to_item = path_to_item
60        full_msg = msg
61        if path_to_item:
62            full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
63        super(ApiValueError, self).__init__(full_msg)
Arguments:
  • msg (str): the exception message
Keyword Args:

path_to_item (list) the path to the exception in the received_data dict. None if unset

path_to_item
Inherited Members
builtins.BaseException
with_traceback
add_note
args
class ApiAttributeError(OpenApiException, builtins.AttributeError):
66class ApiAttributeError(OpenApiException, AttributeError):
67    def __init__(self, msg, path_to_item=None):
68        """
69        Raised when an attribute reference or assignment fails.
70
71        Args:
72            msg (str): the exception message
73
74        Keyword Args:
75            path_to_item (None/list) the path to the exception in the
76                received_data dict
77        """
78        self.path_to_item = path_to_item
79        full_msg = msg
80        if path_to_item:
81            full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
82        super(ApiAttributeError, self).__init__(full_msg)

The base exception class for all OpenAPIExceptions

ApiAttributeError(msg, path_to_item=None)
67    def __init__(self, msg, path_to_item=None):
68        """
69        Raised when an attribute reference or assignment fails.
70
71        Args:
72            msg (str): the exception message
73
74        Keyword Args:
75            path_to_item (None/list) the path to the exception in the
76                received_data dict
77        """
78        self.path_to_item = path_to_item
79        full_msg = msg
80        if path_to_item:
81            full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
82        super(ApiAttributeError, self).__init__(full_msg)

Raised when an attribute reference or assignment fails.

Arguments:
  • msg (str): the exception message
Keyword Args:

path_to_item (None/list) the path to the exception in the received_data dict

path_to_item
Inherited Members
builtins.AttributeError
name
obj
builtins.BaseException
with_traceback
add_note
args
class ApiKeyError(OpenApiException, builtins.KeyError):
85class ApiKeyError(OpenApiException, KeyError):
86    def __init__(self, msg, path_to_item=None):
87        """
88        Args:
89            msg (str): the exception message
90
91        Keyword Args:
92            path_to_item (None/list) the path to the exception in the
93                received_data dict
94        """
95        self.path_to_item = path_to_item
96        full_msg = msg
97        if path_to_item:
98            full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
99        super(ApiKeyError, self).__init__(full_msg)

The base exception class for all OpenAPIExceptions

ApiKeyError(msg, path_to_item=None)
86    def __init__(self, msg, path_to_item=None):
87        """
88        Args:
89            msg (str): the exception message
90
91        Keyword Args:
92            path_to_item (None/list) the path to the exception in the
93                received_data dict
94        """
95        self.path_to_item = path_to_item
96        full_msg = msg
97        if path_to_item:
98            full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
99        super(ApiKeyError, self).__init__(full_msg)
Arguments:
  • msg (str): the exception message
Keyword Args:

path_to_item (None/list) the path to the exception in the received_data dict

path_to_item
Inherited Members
builtins.BaseException
with_traceback
add_note
args
class ApiException(OpenApiException):
102class ApiException(OpenApiException):
103    def __init__(self, status=None, reason=None, http_resp=None):
104        if http_resp:
105            self.status = http_resp.status
106            self.reason = http_resp.reason
107            self.body = http_resp.data
108            self.headers = http_resp.getheaders()
109        else:
110            self.status = status
111            self.reason = reason
112            self.body = None
113            self.headers = None
114
115    def __str__(self):
116        """Custom error messages for exception"""
117        error_message = "({0})\n" "Reason: {1}\n".format(self.status, self.reason)
118        if self.headers:
119            error_message += "HTTP response headers: {0}\n".format(self.headers)
120
121        if self.body:
122            error_message += "HTTP response body: {0}\n".format(self.body)
123
124        return error_message

The base exception class for all OpenAPIExceptions

ApiException(status=None, reason=None, http_resp=None)
103    def __init__(self, status=None, reason=None, http_resp=None):
104        if http_resp:
105            self.status = http_resp.status
106            self.reason = http_resp.reason
107            self.body = http_resp.data
108            self.headers = http_resp.getheaders()
109        else:
110            self.status = status
111            self.reason = reason
112            self.body = None
113            self.headers = None
Inherited Members
builtins.BaseException
with_traceback
add_note
args
class NotFoundException(ApiException):
127class NotFoundException(ApiException):
128    def __init__(self, status=None, reason=None, http_resp=None):
129        super(NotFoundException, self).__init__(status, reason, http_resp)

The base exception class for all OpenAPIExceptions

NotFoundException(status=None, reason=None, http_resp=None)
128    def __init__(self, status=None, reason=None, http_resp=None):
129        super(NotFoundException, self).__init__(status, reason, http_resp)
Inherited Members
builtins.BaseException
with_traceback
add_note
args
class UnauthorizedException(ApiException):
132class UnauthorizedException(ApiException):
133    def __init__(self, status=None, reason=None, http_resp=None):
134        super(UnauthorizedException, self).__init__(status, reason, http_resp)

The base exception class for all OpenAPIExceptions

UnauthorizedException(status=None, reason=None, http_resp=None)
133    def __init__(self, status=None, reason=None, http_resp=None):
134        super(UnauthorizedException, self).__init__(status, reason, http_resp)
Inherited Members
builtins.BaseException
with_traceback
add_note
args
class ForbiddenException(ApiException):
137class ForbiddenException(ApiException):
138    def __init__(self, status=None, reason=None, http_resp=None):
139        super(ForbiddenException, self).__init__(status, reason, http_resp)

The base exception class for all OpenAPIExceptions

ForbiddenException(status=None, reason=None, http_resp=None)
138    def __init__(self, status=None, reason=None, http_resp=None):
139        super(ForbiddenException, self).__init__(status, reason, http_resp)
Inherited Members
builtins.BaseException
with_traceback
add_note
args
class ServiceException(ApiException):
142class ServiceException(ApiException):
143    def __init__(self, status=None, reason=None, http_resp=None):
144        super(ServiceException, self).__init__(status, reason, http_resp)

The base exception class for all OpenAPIExceptions

ServiceException(status=None, reason=None, http_resp=None)
143    def __init__(self, status=None, reason=None, http_resp=None):
144        super(ServiceException, self).__init__(status, reason, http_resp)
Inherited Members
builtins.BaseException
with_traceback
add_note
args
def render_path(path_to_item):
147def render_path(path_to_item):
148    """Returns a string representation of a path"""
149    result = ""
150    for pth in path_to_item:
151        if isinstance(pth, int):
152            result += "[{0}]".format(pth)
153        else:
154            result += "['{0}']".format(pth)
155    return result

Returns a string representation of a path