Python API¶
Classes¶
- class polar.Relation(kind: str, other_type: str, my_field: str, other_field: str)¶
An object representing a relation between two types registered with Oso.
- class polar.DataFilter(model, relations, conditions, types)¶
An object representing an abstract query over a particular data type
- class polar.Condition(left, cmp, right)¶
An object representing a WHERE condition on a query.
cmp is an equality or inequality operator.
left and right may be Projections or literal data.
- class polar.Projection(source, field)¶
An object representing a named property (field) of a particular data type (source). field may be None, which user code must translate to a field (usually the primary key column in a database) that uniquely identifies the record.
- class polar.data.adapter.sqlalchemy_adapter.SqlAlchemyAdapter(session: Session)¶
Exceptions¶
- exception oso.exceptions.ForbiddenError¶
Bases:
AuthorizationErrorThrown by the
authorize,authorize_field, andauthorize_requestmethods when the action is not allowed.Most of the time, your app should handle this error by returning a 403 HTTP error to the client.
- exception oso.exceptions.NotFoundError¶
Bases:
AuthorizationErrorThrown by the
authorizemethod of anOsoinstance. This error indicates that the actor is not only not allowed to perform the given action but also is not allowed to"read"the given resource.Most of the time, your app should handle this error by returning a 404 HTTP error to the client.
To control which action is used for the distinction between
NotFoundErrorandForbiddenError, you can customize theread_actionon yourOsoinstance.
Exceptions used within Oso.
- exception polar.exceptions.DuplicateClassAliasError(name, old, new)¶
Bases:
PolarRuntimeErrorRaised on attempts to register a class with the same name as a class that has already been registered
- exception polar.exceptions.DuplicateInstanceRegistrationError(message=None, details=None)¶
Bases:
PolarRuntimeError
- exception polar.exceptions.ExtraToken(message=None, details=None)¶
Bases:
ParserError
- exception polar.exceptions.FFIErrorNotFound(message=None, details=None)¶
Bases:
OsoErrorRaised when an error is generated by the Oso Rust core, but the error type is not found.
- exception polar.exceptions.InlineQueryFailedError(source)¶
Bases:
PolarRuntimeError
- exception polar.exceptions.IntegerOverflow(message=None, details=None)¶
Bases:
ParserError
- exception polar.exceptions.InvalidCallError(message=None, details=None)¶
Bases:
PolarRuntimeErrorInvalid attempt to call a field or method on an object in Polar
- exception polar.exceptions.InvalidConstructorError(message=None, details=None)¶
Bases:
PolarRuntimeError
- exception polar.exceptions.InvalidIteratorError(message=None, details=None)¶
Bases:
PolarRuntimeErrorInvalid attempt to iterate over a non-iterable value
- exception polar.exceptions.InvalidQueryTypeError(message=None, details=None)¶
Bases:
PolarRuntimeError
- exception polar.exceptions.InvalidToken(message=None, details=None)¶
Bases:
ParserError
- exception polar.exceptions.InvalidTokenCharacter(message=None, details=None)¶
Bases:
ParserError
- exception polar.exceptions.OperationalError(message=None, details=None)¶
Bases:
OsoErrorErrors from polar that are not necessarily the user’s fault. OOM etc…
- exception polar.exceptions.OsoError(message=None, details=None)¶
Bases:
ExceptionBase exception class for Oso.
- exception polar.exceptions.ParserError(message=None, details=None)¶
Bases:
OsoErrorParse time errors.
- exception polar.exceptions.PolarFileExtensionError(file)¶
Bases:
PolarRuntimeError
- exception polar.exceptions.PolarFileNotFoundError(file)¶
Bases:
PolarRuntimeError
- exception polar.exceptions.PolarRuntimeError(message=None, details=None)¶
Bases:
OsoErrorErrors generated by Oso at runtime
- exception polar.exceptions.PolarTypeError(message=None, details=None)¶
Bases:
PolarRuntimeErrorError related to the type of a Polar object, generated by the Rust core
- exception polar.exceptions.StackOverflowError(message=None, details=None)¶
Bases:
PolarRuntimeErrorPolar stack overflow error, generated by the Rust core
- exception polar.exceptions.UnexpectedPolarTypeError(message=None, details=None)¶
Bases:
PolarRuntimeError
- exception polar.exceptions.UnknownError(message=None, details=None)¶
Bases:
OperationalError
- exception polar.exceptions.UnrecognizedEOF(message=None, details=None)¶
Bases:
ParserError
- exception polar.exceptions.UnrecognizedToken(message=None, details=None)¶
Bases:
ParserError
- exception polar.exceptions.UnregisteredClassError(message=None, details=None)¶
Bases:
PolarRuntimeErrorRaised on attempts to reference unregistered Python classes from a Polar policy.
- exception polar.exceptions.UnregisteredInstanceError(message=None, details=None)¶
Bases:
PolarRuntimeError
- exception polar.exceptions.UnsupportedError(message=None, details=None)¶
Bases:
PolarRuntimeErrorUnsupported action error generated by the Rust core