diff --git a/authress/models/access_record.py b/authress/models/access_record.py index 7023f79..1442167 100644 --- a/authress/models/access_record.py +++ b/authress/models/access_record.py @@ -21,6 +21,8 @@ from datetime import datetime from typing import Dict, List, Optional, Union from pydantic import BaseModel, Field, StrictStr, confloat, conint, conlist, constr, validator +from authress.models.access_record_account import AccessRecordAccount +from authress.models.account_links import AccountLinks from authress.models.linked_group import LinkedGroup from authress.models.statement import Statement from authress.models.user import User @@ -35,12 +37,14 @@ class AccessRecord(BaseModel): capacity: Optional[Union[confloat(le=1, ge=0, strict=True), conint(le=1, ge=0, strict=True)]] = Field(None, description="Percentage capacity of record that is filled.") last_updated: Optional[datetime] = Field(None, alias="lastUpdated", description="The expected last time the record was updated") status: Optional[StrictStr] = Field(None, description="Current status of the access record.") + account: Optional[AccessRecordAccount] = Field(...) users: Optional[conlist(User)] = Field(None, description="The list of users this record applies to") admins: Optional[conlist(User)] = Field(None, description="The list of admin that can edit this record even if they do not have global record edit permissions.") groups: Optional[conlist(LinkedGroup)] = Field(None, description="The list of groups this record applies to. Users in these groups will be receive access to the resources listed.") statements: conlist(Statement, min_items=1) = Field(..., description="A list of statements which match roles to resources.") + links: Optional[AccountLinks] = Field(...) tags: Optional[Dict[str, constr(strict=True, max_length=128)]] = Field(None, description="The tags associated with this resource, this property is an map. { key1: value1, key2: value2 }") - __properties = ["recordId", "name", "description", "capacity", "lastUpdated", "status", "users", "admins", "groups", "statements", "tags"] + __properties = ["recordId", "name", "description", "capacity", "lastUpdated", "status", "account", "users", "admins", "groups", "statements", "links", "tags"] @validator('record_id') def record_id_validate_regular_expression(cls, value): @@ -89,6 +93,9 @@ def to_dict(self): "status", }, exclude_none=True) + # override the default output from pydantic by calling `to_dict()` of account + if self.account: + _dict['account'] = self.account.to_dict() # override the default output from pydantic by calling `to_dict()` of each item in users (list) _items = [] if self.users: @@ -117,6 +124,9 @@ def to_dict(self): if _item: _items.append(_item.to_dict()) _dict['statements'] = _items + # override the default output from pydantic by calling `to_dict()` of links + if self.links: + _dict['links'] = self.links.to_dict() # set to None if description (nullable) is None # and __fields_set__ contains the field if self.description is None and "description" in self.__fields_set__: @@ -160,10 +170,12 @@ def from_dict(cls, obj: dict) -> AccessRecord: "capacity": obj.get("capacity"), "last_updated": obj.get("lastUpdated"), "status": obj.get("status"), + "account": AccessRecordAccount.from_dict(obj.get("account")) if obj.get("account") is not None else None, "users": [User.from_dict(_item) for _item in obj.get("users")] if obj.get("users") is not None else None, "admins": [User.from_dict(_item) for _item in obj.get("admins")] if obj.get("admins") is not None else None, "groups": [LinkedGroup.from_dict(_item) for _item in obj.get("groups")] if obj.get("groups") is not None else None, "statements": [Statement.from_dict(_item) for _item in obj.get("statements")] if obj.get("statements") is not None else None, + "links": AccountLinks.from_dict(obj.get("links")) if obj.get("links") is not None else None, "tags": obj.get("tags") }) return _obj diff --git a/authress/models/access_request.py b/authress/models/access_request.py index 1f92ff1..33abf41 100644 --- a/authress/models/access_request.py +++ b/authress/models/access_request.py @@ -22,6 +22,7 @@ from typing import Dict, Optional from pydantic import BaseModel, Field, StrictStr, constr, validator from authress.models.access_template import AccessTemplate +from authress.models.account_links import AccountLinks class AccessRequest(BaseModel): """ @@ -31,8 +32,9 @@ class AccessRequest(BaseModel): last_updated: Optional[datetime] = Field(None, alias="lastUpdated", description="The expected last time the request was updated") status: Optional[StrictStr] = Field(None, description="Current status of the access request.") access: AccessTemplate = Field(...) + links: Optional[AccountLinks] = Field(...) tags: Optional[Dict[str, constr(strict=True, max_length=128)]] = Field(None, description="The tags associated with this resource, this property is an map. { key1: value1, key2: value2 }") - __properties = ["requestId", "lastUpdated", "status", "access", "tags"] + __properties = ["requestId", "lastUpdated", "status", "access", "links", "tags"] @validator('request_id') def request_id_validate_regular_expression(cls, value): @@ -81,6 +83,9 @@ def to_dict(self): # override the default output from pydantic by calling `to_dict()` of access if self.access: _dict['access'] = self.access.to_dict() + # override the default output from pydantic by calling `to_dict()` of links + if self.links: + _dict['links'] = self.links.to_dict() # set to None if tags (nullable) is None # and __fields_set__ contains the field if self.tags is None and "tags" in self.__fields_set__: @@ -102,6 +107,7 @@ def from_dict(cls, obj: dict) -> AccessRequest: "last_updated": obj.get("lastUpdated"), "status": obj.get("status"), "access": AccessTemplate.from_dict(obj.get("access")) if obj.get("access") is not None else None, + "links": AccountLinks.from_dict(obj.get("links")) if obj.get("links") is not None else None, "tags": obj.get("tags") }) return _obj diff --git a/authress/models/account.py b/authress/models/account.py index 7b426f7..acf8dcd 100644 --- a/authress/models/account.py +++ b/authress/models/account.py @@ -21,6 +21,7 @@ from datetime import datetime from typing import Any, Dict, Optional from pydantic import BaseModel, Field, constr +from authress.models.account_links import AccountLinks class Account(BaseModel): """ @@ -30,7 +31,8 @@ class Account(BaseModel): created_time: datetime = Field(..., alias="createdTime") name: Optional[constr(strict=True, max_length=32)] = None company: Dict[str, Any] = Field(...) - __properties = ["accountId", "createdTime", "name", "company"] + links: Optional[AccountLinks] = Field(...) + __properties = ["accountId", "createdTime", "name", "company", "links"] class Config: """Pydantic configuration""" @@ -57,7 +59,9 @@ def to_dict(self): "created_time", }, exclude_none=True) - + # override the default output from pydantic by calling `to_dict()` of links + if self.links: + _dict['links'] = self.links.to_dict() # set to None if name (nullable) is None # and __fields_set__ contains the field if self.name is None and "name" in self.__fields_set__: @@ -78,7 +82,8 @@ def from_dict(cls, obj: dict) -> Account: "account_id": obj.get("accountId"), "created_time": obj.get("createdTime"), "name": obj.get("name"), - "company": obj.get("company") + "company": obj.get("company"), + "links": AccountLinks.from_dict(obj.get("links")) if obj.get("links") is not None else None }) return _obj diff --git a/authress/models/extension.py b/authress/models/extension.py index 059d890..d51653c 100644 --- a/authress/models/extension.py +++ b/authress/models/extension.py @@ -30,9 +30,9 @@ class Extension(BaseModel): """ extension_id: constr(strict=True, max_length=64, min_length=1) = Field(..., alias="extensionId") name: Optional[constr(strict=True, max_length=128, min_length=1)] = Field(None, description="The name of the extension. This name is visible in the Authress management portal") - created_time: Optional[datetime] = Field(..., alias="createdTime") + created_time: datetime = Field(..., alias="createdTime") application: Optional[ExtensionApplication] = None - client: Optional[ExtensionClient] = Field(...) + client: ExtensionClient = Field(...) tags: Optional[Dict[str, constr(strict=True, max_length=128)]] = Field(None, description="The tags associated with this resource, this property is an map. { key1: value1, key2: value2 }") __properties = ["extensionId", "name", "createdTime", "application", "client", "tags"] diff --git a/authress/models/group.py b/authress/models/group.py index 5d92fb8..5767655 100644 --- a/authress/models/group.py +++ b/authress/models/group.py @@ -21,6 +21,7 @@ from datetime import datetime from typing import Dict, List, Optional from pydantic import BaseModel, Field, conlist, constr, validator +from authress.models.account_links import AccountLinks from authress.models.user import User class Group(BaseModel): @@ -32,8 +33,9 @@ class Group(BaseModel): last_updated: Optional[datetime] = Field(None, alias="lastUpdated", description="The expected last time the group was updated") users: conlist(User) = Field(..., description="The list of users in this group") admins: conlist(User) = Field(..., description="The list of admins that can edit this record even if they do not have global record edit permissions.") + links: Optional[AccountLinks] = Field(...) tags: Optional[Dict[str, constr(strict=True, max_length=128)]] = Field(None, description="The tags associated with this resource, this property is an map. { key1: value1, key2: value2 }") - __properties = ["groupId", "name", "lastUpdated", "users", "admins", "tags"] + __properties = ["groupId", "name", "lastUpdated", "users", "admins", "links", "tags"] @validator('group_id') def group_id_validate_regular_expression(cls, value): @@ -84,6 +86,9 @@ def to_dict(self): if _item: _items.append(_item.to_dict()) _dict['admins'] = _items + # override the default output from pydantic by calling `to_dict()` of links + if self.links: + _dict['links'] = self.links.to_dict() # set to None if tags (nullable) is None # and __fields_set__ contains the field if self.tags is None and "tags" in self.__fields_set__: @@ -106,6 +111,7 @@ def from_dict(cls, obj: dict) -> Group: "last_updated": obj.get("lastUpdated"), "users": [User.from_dict(_item) for _item in obj.get("users")] if obj.get("users") is not None else None, "admins": [User.from_dict(_item) for _item in obj.get("admins")] if obj.get("admins") is not None else None, + "links": AccountLinks.from_dict(obj.get("links")) if obj.get("links") is not None else None, "tags": obj.get("tags") }) return _obj diff --git a/authress/models/invite.py b/authress/models/invite.py index e6f4f87..6072db5 100644 --- a/authress/models/invite.py +++ b/authress/models/invite.py @@ -21,6 +21,7 @@ from typing import List, Optional from pydantic import BaseModel, Field, StrictStr, conlist, constr +from authress.models.account_links import AccountLinks from authress.models.statement import Statement class Invite(BaseModel): @@ -30,7 +31,8 @@ class Invite(BaseModel): invite_id: StrictStr = Field(..., alias="inviteId", description="The unique identifier for the invite. Use this ID to accept the invite. This parameter is ignored during invite creation.") tenant_id: Optional[constr(strict=True, max_length=64, min_length=0)] = Field(None, alias="tenantId") statements: conlist(Statement) = Field(..., description="A list of statements which match roles to resources. The invited user will all statements apply to them when the invite is accepted.") - __properties = ["inviteId", "tenantId", "statements"] + links: Optional[AccountLinks] = Field(...) + __properties = ["inviteId", "tenantId", "statements", "links"] class Config: """Pydantic configuration""" @@ -67,6 +69,9 @@ def to_dict(self): if _item: _items.append(_item.to_dict()) _dict['statements'] = _items + # override the default output from pydantic by calling `to_dict()` of links + if self.links: + _dict['links'] = self.links.to_dict() return _dict @classmethod @@ -82,6 +87,7 @@ def from_dict(cls, obj: dict) -> Invite: "invite_id": obj.get("inviteId"), "tenant_id": obj.get("tenantId"), "statements": [Statement.from_dict(_item) for _item in obj.get("statements")] if obj.get("statements") is not None else None, + "links": AccountLinks.from_dict(obj.get("links")) if obj.get("links") is not None else None }) return _obj diff --git a/docs/EXAMPLES.md b/docs/EXAMPLES.md index 4008361..c8ca39c 100644 --- a/docs/EXAMPLES.md +++ b/docs/EXAMPLES.md @@ -22,12 +22,9 @@ def get_resource(resourceId): authorization_token = request.headers.get('authorization') authress_client.set_token(authorization_token) - # Get the user - user_id = get_user_id(request) - # Check Authress to authorize the user try - authress_client.user_permissions.authorize_user(user_id, f'resources/{resourceId}', 'READ') + authress_client.user_permissions.authorize_user(None, f'resources/{resourceId}', 'READ') except ApiException as api_exception: # Will throw except if the user is not authorized to read the resource if api_exception.status is 403: