AccountApi
Python SDK: the Account operations, 10 methods, each with its parameters, result and a complete example.
Python SDK · bimworks · class · 10 methods
The signed-in account: registration, password, sessions and settings
Construct it with the client of the connect step: bimworks.AccountApi(client). Each method is one operation of the API part, where it runs on its page.
| Method | Operation | Description |
|---|---|---|
change_password | ChangePassword | Change the password |
get_settings | GetSettings | Read the account settings |
list_reference_values | ListReferenceValues | The values of the settings form |
logout | Logout | Record a sign-out |
register | Register | Register an account |
request_password_reset | RequestPasswordReset | Send a password reset e-mail |
request_validation_email | RequestValidationEmail | Send a new validation e-mail |
save_settings | SaveSettings | Change the account settings |
sign_out_other_sessions | SignOutOtherSessions | Sign out every other session |
validate_email_address | ValidateEmailAddress | Confirm an e-mail address and set the password |
change_password#
def change_password(self, change_password_request: ChangePasswordRequest) -> AuthResultChange the password. Changes the password of the signed-in account and signs out every other session; this one continues on the session answered here. An account session only: an API token is refused. current_password is needed when the account has a password, code when it has two-factor authentication. An account without a password (one that signs in with e-mail codes) gets its first one, which needs a session signed in within the last 10 minutes.
| Operation | ChangePassword · POST /openapi/account/ChangePassword |
|---|---|
| Scope | account:write |
Parameters#
| Name | Type | Description |
|---|---|---|
change_password_request | ChangePasswordRequestrequired | The request: its properties are those of the model, its JSON that of ChangePassword's request body. |
Returns#
AuthResult — The new session
Example#
import json
import bimworks
# 1. Connect to BIM.works and log in with your API token
client = bimworks.ApiClient(bimworks.Configuration(host="https://bim.works/openapi"))
auth = bimworks.AuthApi(client).login_with_api_token(
bimworks.LoginWithApiTokenRequest(token="<your API token>"))
client.configuration.access_token = auth.actual_instance.var_base64
# 2. The request
request = bimworks.ChangePasswordRequest.from_json(r"""
{
"current_password": "",
"password": "",
"code": 0,
"response_format": "auth"
}
""")
# 3. The call
result = bimworks.AccountApi(client).change_password(request)
# 4. The result
print(json.dumps(client.sanitize_for_serialization(result), indent=2))get_settings#
def get_settings(self) -> AccountSettingsRead the account settings. The settings of the account behind the credential: name, country, language, time zone and the web app preferences. With an API token, those of the account that created it.
| Operation | GetSettings · POST /openapi/account/GetSettings |
|---|---|
| Scope | account:read |
Parameters#
None: the operation takes no request.
Returns#
AccountSettings — The settings
Example#
import json
import bimworks
# 1. Connect to BIM.works and log in with your API token
client = bimworks.ApiClient(bimworks.Configuration(host="https://bim.works/openapi"))
auth = bimworks.AuthApi(client).login_with_api_token(
bimworks.LoginWithApiTokenRequest(token="<your API token>"))
client.configuration.access_token = auth.actual_instance.var_base64
# 2. The request
# (GetSettings takes no request)
# 3. The call
result = bimworks.AccountApi(client).get_settings()
# 4. The result
print(json.dumps(client.sanitize_for_serialization(result), indent=2))list_reference_values#
def list_reference_values(self, list_reference_values_request: ListReferenceValuesRequest) -> List[ReferenceValue]The values of the settings form. The countries (ISO 3166 codes), languages (ISO 639-1 codes) or time zones (tz identifiers) that the settings take, with a name to show. Names are in English.
| Operation | ListReferenceValues · POST /openapi/account/ListReferenceValues |
|---|---|
| Scope | any login |
Parameters#
| Name | Type | Description |
|---|---|---|
list_reference_values_request | ListReferenceValuesRequestrequired | The request: its properties are those of the model, its JSON that of ListReferenceValues's request body. |
Returns#
List[ReferenceValue] — The values
Example#
import json
import bimworks
# 1. Connect to BIM.works and log in with your API token
client = bimworks.ApiClient(bimworks.Configuration(host="https://bim.works/openapi"))
auth = bimworks.AuthApi(client).login_with_api_token(
bimworks.LoginWithApiTokenRequest(token="<your API token>"))
client.configuration.access_token = auth.actual_instance.var_base64
# 2. The request
request = bimworks.ListReferenceValuesRequest.from_json(r"""
{
"kind": "countries"
}
""")
# 3. The call
result = bimworks.AccountApi(client).list_reference_values(request)
# 4. The result
print(json.dumps(client.sanitize_for_serialization(result), indent=2))logout#
def logout(self) -> NoneRecord a sign-out. Records that the session signed out. It revokes nothing: the bearer token stays valid until it expires. To end sessions, use SignOutOtherSessions or ChangePassword.
| Operation | Logout · POST /openapi/account/Logout |
|---|---|
| Scope | any login |
Parameters#
None: the operation takes no request.
Returns#
Nothing: the operation answers without a body (Recorded).
Example#
import bimworks
# 1. Connect to BIM.works and log in with your API token
client = bimworks.ApiClient(bimworks.Configuration(host="https://bim.works/openapi"))
auth = bimworks.AuthApi(client).login_with_api_token(
bimworks.LoginWithApiTokenRequest(token="<your API token>"))
client.configuration.access_token = auth.actual_instance.var_base64
# 2. The request
# (Logout takes no request)
# 3. The call
bimworks.AccountApi(client).logout()
# 4. The result
# (Logout answers no content: the call returns once it succeeded and throws a bimworks.ApiException otherwise)
print("Done")register#
def register(self, register_request: RegisterRequest) -> NoneRegister an account. Creates an account for an e-mail address and sends it the validation e-mail; the account is usable once the address is confirmed with ValidateEmailAddress. Refused (REGISTRATION_NOT_ALLOWED) when the instance does not allow self-registration (security.account_self_registration) or the address asked too often; an address that already has an account is refused with EMAIL_ADDRESS_ALREADY_REGISTERED.
| Operation | Register · POST /openapi/account/Register |
|---|---|
| Scope | none: callable before logging in |
Parameters#
| Name | Type | Description |
|---|---|---|
register_request | RegisterRequestrequired | The request: its properties are those of the model, its JSON that of Register's request body. |
Returns#
Nothing: the operation answers without a body (The validation e-mail is sent).
Example#
import bimworks
# 1. Connect to BIM.works (Register needs no login)
client = bimworks.ApiClient(bimworks.Configuration(host="https://bim.works/openapi"))
# 2. The request
request = bimworks.RegisterRequest.from_json(r"""
{
"username": "",
"preferred_language": ""
}
""")
# 3. The call
bimworks.AccountApi(client).register(request)
# 4. The result
# (Register answers no content: the call returns once it succeeded and throws a bimworks.ApiException otherwise)
print("Done")request_password_reset#
def request_password_reset(self, request_password_reset_request: RequestPasswordResetRequest) -> NoneSend a password reset e-mail. Sends a link to reset the password. The reset itself is completed in the BIM.works web app. It answers the same whether or not the account exists.
| Operation | RequestPasswordReset · POST /openapi/account/RequestPasswordReset |
|---|---|
| Scope | none: callable before logging in |
Parameters#
| Name | Type | Description |
|---|---|---|
request_password_reset_request | RequestPasswordResetRequestrequired | The request: its properties are those of the model, its JSON that of RequestPasswordReset's request body. |
Returns#
Nothing: the operation answers without a body (Done (whether or not an e-mail was sent)).
Example#
import bimworks
# 1. Connect to BIM.works (RequestPasswordReset needs no login)
client = bimworks.ApiClient(bimworks.Configuration(host="https://bim.works/openapi"))
# 2. The request
request = bimworks.RequestPasswordResetRequest.from_json(r"""
{
"username": ""
}
""")
# 3. The call
bimworks.AccountApi(client).request_password_reset(request)
# 4. The result
# (RequestPasswordReset answers no content: the call returns once it succeeded and throws a bimworks.ApiException otherwise)
print("Done")request_validation_email#
def request_validation_email(self, request_validation_email_request: RequestValidationEmailRequest) -> NoneSend a new validation e-mail. A new validation link for an address that registered but did not confirm yet. It answers the same whether or not such an account exists.
| Operation | RequestValidationEmail · POST /openapi/account/RequestValidationEmail |
|---|---|
| Scope | none: callable before logging in |
Parameters#
| Name | Type | Description |
|---|---|---|
request_validation_email_request | RequestValidationEmailRequestrequired | The request: its properties are those of the model, its JSON that of RequestValidationEmail's request body. |
Returns#
Nothing: the operation answers without a body (Done (whether or not an e-mail was sent)).
Example#
import bimworks
# 1. Connect to BIM.works (RequestValidationEmail needs no login)
client = bimworks.ApiClient(bimworks.Configuration(host="https://bim.works/openapi"))
# 2. The request
request = bimworks.RequestValidationEmailRequest.from_json(r"""
{
"username": ""
}
""")
# 3. The call
bimworks.AccountApi(client).request_validation_email(request)
# 4. The result
# (RequestValidationEmail answers no content: the call returns once it succeeded and throws a bimworks.ApiException otherwise)
print("Done")save_settings#
def save_settings(self, account_settings: AccountSettings) -> NoneChange the account settings. Changes the settings that are passed; the others stay as they are. With an API token, those of the account that created it.
| Operation | SaveSettings · POST /openapi/account/SaveSettings |
|---|---|
| Scope | account:write |
Parameters#
| Name | Type | Description |
|---|---|---|
account_settings | AccountSettingsrequired | The request: its properties are those of the model, its JSON that of SaveSettings's request body. |
Returns#
Nothing: the operation answers without a body (Saved).
Example#
import bimworks
# 1. Connect to BIM.works and log in with your API token
client = bimworks.ApiClient(bimworks.Configuration(host="https://bim.works/openapi"))
auth = bimworks.AuthApi(client).login_with_api_token(
bimworks.LoginWithApiTokenRequest(token="<your API token>"))
client.configuration.access_token = auth.actual_instance.var_base64
# 2. The request
request = bimworks.AccountSettings.from_json(r"""
{
"full_name": "",
"country_code": "",
"preferred_language": "",
"time_zone_id": "",
"bim_context": "",
"show_deleted_nodes": false,
"email_about_vulnerabilities": false,
"ui_mode": "END_USER"
}
""")
# 3. The call
bimworks.AccountApi(client).save_settings(request)
# 4. The result
# (SaveSettings answers no content: the call returns once it succeeded and throws a bimworks.ApiException otherwise)
print("Done")sign_out_other_sessions#
def sign_out_other_sessions(self, sign_out_other_sessions_request: Optional[SignOutOtherSessionsRequest] = None) -> AuthResultSign out every other session. Ends every session of the signed-in account except this one, which continues on the session answered here: for a lost or shared device. An account session only. API tokens are separate credentials and keep working; revoke them with DeleteApiToken.
| Operation | SignOutOtherSessions · POST /openapi/account/SignOutOtherSessions |
|---|---|
| Scope | account:write |
Parameters#
| Name | Type | Description |
|---|---|---|
sign_out_other_sessions_request | SignOutOtherSessionsRequestoptional | The request: its properties are those of the model, its JSON that of SignOutOtherSessions's request body. |
Returns#
AuthResult — The new session
Example#
import json
import bimworks
# 1. Connect to BIM.works and log in with your API token
client = bimworks.ApiClient(bimworks.Configuration(host="https://bim.works/openapi"))
auth = bimworks.AuthApi(client).login_with_api_token(
bimworks.LoginWithApiTokenRequest(token="<your API token>"))
client.configuration.access_token = auth.actual_instance.var_base64
# 2. The request
request = bimworks.SignOutOtherSessionsRequest.from_json(r"""
{
"response_format": "auth"
}
""")
# 3. The call
result = bimworks.AccountApi(client).sign_out_other_sessions(request)
# 4. The result
print(json.dumps(client.sanitize_for_serialization(result), indent=2))validate_email_address#
def validate_email_address(self, validate_email_address_request: ValidateEmailAddressRequest) -> NoneConfirm an e-mail address and set the password. Confirms the address with the token from the validation e-mail and sets the account's password (8 to 128 characters, not a common one, not the address). It does not sign in: use LoginWithUsernamePassword after. The link is valid for a day.
| Operation | ValidateEmailAddress · POST /openapi/account/ValidateEmailAddress |
|---|---|
| Scope | none: callable before logging in |
Parameters#
| Name | Type | Description |
|---|---|---|
validate_email_address_request | ValidateEmailAddressRequestrequired | The request: its properties are those of the model, its JSON that of ValidateEmailAddress's request body. |
Returns#
Nothing: the operation answers without a body (The address is confirmed).
Example#
import bimworks
# 1. Connect to BIM.works (ValidateEmailAddress needs no login)
client = bimworks.ApiClient(bimworks.Configuration(host="https://bim.works/openapi"))
# 2. The request
request = bimworks.ValidateEmailAddressRequest.from_json(r"""
{
"username": "",
"token": "",
"password": ""
}
""")
# 3. The call
bimworks.AccountApi(client).validate_email_address(request)
# 4. The result
# (ValidateEmailAddress answers no content: the call returns once it succeeded and throws a bimworks.ApiException otherwise)
print("Done")