CloudWatch Logs (logs)
Primary Models
Primary models are models that you can act on directly. They are the models that represent resources in the AWS service, and are acted on by the managers.
- pydantic model botocraft.services.logs.LogGroup[source]
Bases:
TagsDictMixin,PrimaryBoto3ModelRepresents a log group.
Show JSON schema
{ "title": "LogGroup", "description": "Represents a log group.", "type": "object", "properties": { "session": { "anyOf": [ {}, { "type": "null" } ], "default": null, "title": "Session" }, "arn": { "default": null, "title": "Arn", "type": "string" }, "logGroupName": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Loggroupname" }, "creationTime": { "default": null, "title": "Creationtime", "type": "integer" }, "retentionInDays": { "default": null, "title": "Retentionindays", "type": "integer" }, "metricFilterCount": { "default": null, "title": "Metricfiltercount", "type": "integer" }, "storedBytes": { "default": null, "title": "Storedbytes", "type": "integer" }, "kmsKeyId": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Kmskeyid" }, "dataProtectionStatus": { "default": null, "enum": [ "ACTIVATED", "DELETED", "ARCHIVED", "DISABLED" ], "title": "Dataprotectionstatus", "type": "string" }, "inheritedProperties": { "items": { "const": "ACCOUNT_DATA_PROTECTION", "type": "string" }, "title": "Inheritedproperties", "type": "array" }, "logGroupClass": { "anyOf": [ { "enum": [ "STANDARD", "INFREQUENT_ACCESS", "DELIVERY" ], "type": "string" }, { "type": "null" } ], "default": null, "title": "Loggroupclass" }, "logGroupArn": { "default": null, "title": "Loggrouparn", "type": "string" }, "deletionProtectionEnabled": { "anyOf": [ { "type": "boolean" }, { "type": "null" } ], "default": null, "title": "Deletionprotectionenabled" }, "bearerTokenAuthenticationEnabled": { "default": null, "title": "Bearertokenauthenticationenabled", "type": "boolean" }, "Tags": { "anyOf": [ { "items": { "$ref": "#/$defs/Tag" }, "type": "array" }, { "type": "null" } ], "title": "Tags" } }, "$defs": { "Tag": { "description": "The metadata that you apply to a resource to help you categorize and\norganize them. Each tag consists of a key and an optional value. You define\nthem.\n\nThe following basic restrictions apply to tags:\n\n* Maximum number of tags per resource - 50\n* For each resource, each tag key must be unique, and each tag key can have\n only one value.\n* Maximum key length - 128 Unicode characters in UTF-8\n* Maximum value length - 256 Unicode characters in UTF-8\n* If your tagging schema is used across multiple services and resources,\n remember that other services may have restrictions on allowed characters.\n Generally allowed characters are: letters, numbers, and spaces representable in\n UTF-8, and the following characters: + - = . _ : / @.\n* Tag keys and values are case-sensitive.\n* Do not use ``aws:``, ``AWS:``, or any upper or lowercase combination of such\n as a prefix for either keys or values as it is reserved for Amazon Web Services\n use. You cannot edit or delete tag keys or values with this prefix. Tags with\n this prefix do not count against your tags per resource limit.", "properties": { "session": { "anyOf": [ {}, { "type": "null" } ], "default": null, "title": "Session" }, "Key": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Key" }, "Value": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Value" } }, "title": "Tag", "type": "object" } } }
- Config:
validate_assignment: bool = True
arbitrary_types_allowed: bool = True
- Fields:
- field Arn: str = None (alias 'arn')
The Amazon Resource Name (ARN) of the log group.
This version of the ARN includes a trailing
:*after the log group name.
- field bearerTokenAuthenticationEnabled: bool = None
Indicates whether bearer token authentication is enabled for this log group.
When enabled, bearer token authentication is allowed on operations until it is explicitly disabled.
- field creationTime: int = None
The creation time of the log group, expressed as the number of milliseconds after Jan 1, 1970 00:00:00 UTC.
- field dataProtectionStatus: Literal['ACTIVATED', 'DELETED', 'ARCHIVED', 'DISABLED'] = None
Displays whether this log group has a protection policy, or whether it had one in the past.
For more information, see P utDataProtectionPolicy.
- field deletionProtectionEnabled: bool | None = None
Indicates whether deletion protection is enabled for this log group.
When enabled, deletion protection blocks all deletion operations until it is explicitly disabled.
- field inheritedProperties: builtins.list[Literal['ACCOUNT_DATA_PROTECTION']] [Optional]
Displays all the properties that this log group has inherited from account-level settings.
- field kmsKeyId: str | None = None
The Amazon Resource Name (ARN) of the KMS key to use when encrypting log data.
- field logGroupArn: str = None
The Amazon Resource Name (ARN) of the log group.
This version of the ARN doesn’t include a trailing
:*after the log group name.
- field logGroupClass: Literal['STANDARD', 'INFREQUENT_ACCESS', 'DELIVERY'] | None = None
This specifies the log group class for this log group.
There are three classes:
- field retentionInDays: int = None
The number of days to retain the log events in the specified log group.
Possible values are: 1, 3, 5, 7, 14, 30, 60, 90, 120, 150, 180, 365, 400, 545, 731, 1096, 1827, 2192, 2557, 2922, 3288, and 3653.
- field session: Any | None = None
The boto3 session to use for this model. This is set by the manager, and is used in relationships. We have to use
Anyhere because we pydantic complains vociferously if we useboto3.session.Session. We exclude it from the model dump because it’s not something that should be serialized.
- manager_class
alias of
LogGroupManager
- tag_class
alias of
Tag
- delete()
Delete the model.
- classmethod model_construct(_fields_set: set[str] | None = None, **values: Any) Self
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed.
- !!! note
model_construct() generally respects the model_config.extra setting on the provided model. That is, if model_config.extra == ‘allow’, then all extra passed values are added to the model instance’s __dict__ and __pydantic_extra__ fields. If model_config.extra == ‘ignore’ (the default), then all extra passed values are ignored. Because no validation is performed with a call to model_construct(), having model_config.extra == ‘forbid’ does not result in an error if extra values are passed, but they will be ignored.
- Parameters:
_fields_set – A set of field names that were originally explicitly set during instantiation. If provided, this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute. Otherwise, the field names from the values argument will be used.
values – Trusted or pre-validated data dictionary.
- Returns:
A new instance of the Model class with validated data.
- classmethod model_validate_strings(obj: Any, *, strict: bool | None = None, context: Any | None = None, by_alias: bool | None = None, by_name: bool | None = None) Self
Validate the given object with string data against the Pydantic model.
- Parameters:
obj – The object containing string data to validate.
strict – Whether to enforce types strictly.
context – Extra variables to pass to the validator.
by_alias – Whether to use the field’s alias when validating against the provided input data.
by_name – Whether to use the field’s name when validating against the provided input data.
- Returns:
The validated Pydantic model.
- save(**kwargs)
Save the model.
- set_session(session: Session) None
Set the boto3 session for this model.
- Parameters:
session – The boto3 session to use.
- Returns:
The model instance.
- transform(attribute: str, transformer: str | None) Any
Transform an attribute using a regular expression into something else before it is returned.
Important
This only makes sense for attributes that are strings.
transformeris a regular expression that will be used to transform the value of the attribute.If the attribute is
None, it will be returned verbatim.If
transformerisNone, the attribute will be returned verbatim.If
transformerhas no named groups, the attribute will be replaced with the value of the first group.If
transformerhas named groups, the attribute will be replaced with a dictionary of the named groups.
- Raises:
ValueError – If the attribute does not exist on the model.
RuntimeError – If the transformer fails to match the attribute value.
- Parameters:
attribute – The attribute to transform.
transformer – The regular expression to use to transform the attribute.
- Returns:
The transformed attribute.
- property arn: str | None
Return the ARN of the model. This is the value of the
Arnattribute.- Returns:
The ARN of the model instance.
- property name: str | None
Return the name of the model. This is the value of the
logGroupNameattribute.- Returns:
The name of the model instance.
- objects: ClassVar[classproperty]
Get the manager for this model, and set it as a class property
Managers
Managers work with the primary models to provide a high-level interface to the AWS service. They are responsible for creating, updating, and deleting the resources in the service, as well as any additional operations that are available for those models.
- class botocraft.services.logs.LogGroupManager[source]
Bases:
LogGroupManagerMixin,Boto3ModelManager- create(model: LogGroup, tags: dict[str, str] | None = None) None[source]
Creates a log group with the specified name. You can create up to 1,000,000 log groups per Region per account.
- Parameters:
model – The
LogGroupto create.- Keyword Arguments:
tags – The key-value pairs to use for the tags.
- delete(logGroupName: str) None[source]
Deletes the specified log group and permanently deletes all the archived log events associated with the log group.
- Parameters:
logGroupName – The name of the log group.
- get(logGroupIdentifier: str, *, accountIdentifiers: list[str] | None = None, logGroupNamePattern: str | None = None, limit: int | None = None, includeLinkedAccounts: bool | None = None) LogGroup | None[source]
Returns information about log groups, including data sources that ingest into each log group. You can return all your log groups or filter the results by prefix. The results are ASCII-sorted by log group name.
- Parameters:
logGroupIdentifier – The identifier of the log group to get. If this is in the same account you are querying, you can use the log group name, if you also set
``includeLinkedAccounts``to``true``, you must use the log group ARN.- Keyword Arguments:
accountIdentifiers – When
includeLinkedAccountsis set totrue, use this parameter to specify the list of accounts to search. You can specify as many as 20 account IDs in the array.logGroupNamePattern – If you specify a string for this parameter, the operation returns only log groups that have names that match the string based on a case-sensitive substring search. For example, if you specify
DataLogs, log groups namedDataLogs,aws/DataLogs, andGroupDataLogswould match, butdatalogs,Data/log/sandGroupdatawould not match.limit – The maximum number of items returned. If you don’t specify a value, the default is up to 50 items.
includeLinkedAccounts – If you are using a monitoring account, set this to
trueto have the operation return log groups in the accounts listed inaccountIdentifiers.
- get_fields(*, logGroupName: str | None = None, time: int | None = None, logGroupIdentifier: str | None = None) list[botocraft.services.logs.LogGroupField][source]
Returns a list of the fields that are included in log events in the specified log group. Includes the percentage of log events that contain each field. The search is limited to a time period that you specify.
- Keyword Arguments:
logGroupName – The name of the log group to search.
time – The time to set as the center of the query. If you specify
time, the 8 minutes before and 8 minutes after this time are searched. If you omittime, the most recent 15 minutes up to the current time are searched.logGroupIdentifier – Specify either the name or ARN of the log group to view. If the log group is in a source account and you are using a monitoring account, you must specify the ARN.
- list(*, accountIdentifiers: list[str] | None = None, logGroupNamePrefix: str | None = None, logGroupNamePattern: str | None = None, limit: int | None = None, includeLinkedAccounts: bool | None = None, logGroupClass: Literal['STANDARD', 'INFREQUENT_ACCESS', 'DELIVERY'] | None = None, logGroupIdentifiers: list[str] | None = None) PrimaryBoto3ModelQuerySet[source]
Returns information about log groups, including data sources that ingest into each log group. You can return all your log groups or filter the results by prefix. The results are ASCII-sorted by log group name.
- Keyword Arguments:
accountIdentifiers – When
includeLinkedAccountsis set totrue, use this parameter to specify the list of accounts to search. You can specify as many as 20 account IDs in the array.logGroupNamePrefix – The prefix to match.
logGroupNamePattern – If you specify a string for this parameter, the operation returns only log groups that have names that match the string based on a case-sensitive substring search. For example, if you specify
DataLogs, log groups namedDataLogs,aws/DataLogs, andGroupDataLogswould match, butdatalogs,Data/log/sandGroupdatawould not match.limit – The maximum number of items returned. If you don’t specify a value, the default is up to 50 items.
includeLinkedAccounts – If you are using a monitoring account, set this to
trueto have the operation return log groups in the accounts listed inaccountIdentifiers.logGroupClass – Use this parameter to limit the results to only those log groups in the specified log group class. If you omit this parameter, log groups of all classes can be returned.
logGroupIdentifiers – Use this array to filter the list of log groups returned. If you specify this parameter, the only other filter that you can choose to specify is
includeLinkedAccounts.
Secondary Models
Secondary models are models that are used by the primary models to organize their data. They are not acted on directly, but are used to describe the structure of the fields in the primary models or other secondary models.
Request/Response Models
Request/response models are models that are used to describe the structure of the data that is sent to and received from the AWS service. They are used by the managers to send requests to the service and to parse the responses that are received.
You will not often use them directly – typically they are used by the managers internally to send requests and parse responses – but they are included here for completeness, and because occasionally we return them directly to you because they have some useful additional information.
- pydantic model botocraft.services.logs.DescribeLogGroupsResponse[source]
Bases:
Boto3ModelShow JSON schema
{ "title": "DescribeLogGroupsResponse", "type": "object", "properties": { "session": { "anyOf": [ {}, { "type": "null" } ], "default": null, "title": "Session" }, "logGroups": { "anyOf": [ { "items": { "$ref": "#/$defs/LogGroup" }, "type": "array" }, { "type": "null" } ], "title": "Loggroups" }, "nextToken": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Nexttoken" } }, "$defs": { "LogGroup": { "description": "Represents a log group.", "properties": { "session": { "anyOf": [ {}, { "type": "null" } ], "default": null, "title": "Session" }, "arn": { "default": null, "title": "Arn", "type": "string" }, "logGroupName": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Loggroupname" }, "creationTime": { "default": null, "title": "Creationtime", "type": "integer" }, "retentionInDays": { "default": null, "title": "Retentionindays", "type": "integer" }, "metricFilterCount": { "default": null, "title": "Metricfiltercount", "type": "integer" }, "storedBytes": { "default": null, "title": "Storedbytes", "type": "integer" }, "kmsKeyId": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Kmskeyid" }, "dataProtectionStatus": { "default": null, "enum": [ "ACTIVATED", "DELETED", "ARCHIVED", "DISABLED" ], "title": "Dataprotectionstatus", "type": "string" }, "inheritedProperties": { "items": { "const": "ACCOUNT_DATA_PROTECTION", "type": "string" }, "title": "Inheritedproperties", "type": "array" }, "logGroupClass": { "anyOf": [ { "enum": [ "STANDARD", "INFREQUENT_ACCESS", "DELIVERY" ], "type": "string" }, { "type": "null" } ], "default": null, "title": "Loggroupclass" }, "logGroupArn": { "default": null, "title": "Loggrouparn", "type": "string" }, "deletionProtectionEnabled": { "anyOf": [ { "type": "boolean" }, { "type": "null" } ], "default": null, "title": "Deletionprotectionenabled" }, "bearerTokenAuthenticationEnabled": { "default": null, "title": "Bearertokenauthenticationenabled", "type": "boolean" }, "Tags": { "anyOf": [ { "items": { "$ref": "#/$defs/Tag" }, "type": "array" }, { "type": "null" } ], "title": "Tags" } }, "title": "LogGroup", "type": "object" }, "Tag": { "description": "The metadata that you apply to a resource to help you categorize and\norganize them. Each tag consists of a key and an optional value. You define\nthem.\n\nThe following basic restrictions apply to tags:\n\n* Maximum number of tags per resource - 50\n* For each resource, each tag key must be unique, and each tag key can have\n only one value.\n* Maximum key length - 128 Unicode characters in UTF-8\n* Maximum value length - 256 Unicode characters in UTF-8\n* If your tagging schema is used across multiple services and resources,\n remember that other services may have restrictions on allowed characters.\n Generally allowed characters are: letters, numbers, and spaces representable in\n UTF-8, and the following characters: + - = . _ : / @.\n* Tag keys and values are case-sensitive.\n* Do not use ``aws:``, ``AWS:``, or any upper or lowercase combination of such\n as a prefix for either keys or values as it is reserved for Amazon Web Services\n use. You cannot edit or delete tag keys or values with this prefix. Tags with\n this prefix do not count against your tags per resource limit.", "properties": { "session": { "anyOf": [ {}, { "type": "null" } ], "default": null, "title": "Session" }, "Key": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Key" }, "Value": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Value" } }, "title": "Tag", "type": "object" } } }
- Config:
validate_assignment: bool = True
arbitrary_types_allowed: bool = True
- Fields:
- field logGroups: builtins.list[LogGroup] | None [Optional]
An array of structures, where each structure contains the information about one log group.
- field nextToken: str | None = None
The token for the next set of items to return.
The token expires after 24 hours.
- field session: Any | None = None
The boto3 session to use for this model. This is set by the manager, and is used in relationships. We have to use
Anyhere because we pydantic complains vociferously if we useboto3.session.Session. We exclude it from the model dump because it’s not something that should be serialized.
- classmethod model_construct(_fields_set: set[str] | None = None, **values: Any) Self
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed.
- !!! note
model_construct() generally respects the model_config.extra setting on the provided model. That is, if model_config.extra == ‘allow’, then all extra passed values are added to the model instance’s __dict__ and __pydantic_extra__ fields. If model_config.extra == ‘ignore’ (the default), then all extra passed values are ignored. Because no validation is performed with a call to model_construct(), having model_config.extra == ‘forbid’ does not result in an error if extra values are passed, but they will be ignored.
- Parameters:
_fields_set – A set of field names that were originally explicitly set during instantiation. If provided, this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute. Otherwise, the field names from the values argument will be used.
values – Trusted or pre-validated data dictionary.
- Returns:
A new instance of the Model class with validated data.
- classmethod model_validate_strings(obj: Any, *, strict: bool | None = None, context: Any | None = None, by_alias: bool | None = None, by_name: bool | None = None) Self
Validate the given object with string data against the Pydantic model.
- Parameters:
obj – The object containing string data to validate.
strict – Whether to enforce types strictly.
context – Extra variables to pass to the validator.
by_alias – Whether to use the field’s alias when validating against the provided input data.
by_name – Whether to use the field’s name when validating against the provided input data.
- Returns:
The validated Pydantic model.
- set_session(session: Session) None
Set the boto3 session for this model.
- Parameters:
session – The boto3 session to use.
- Returns:
The model instance.
- transform(attribute: str, transformer: str | None) Any
Transform an attribute using a regular expression into something else before it is returned.
Important
This only makes sense for attributes that are strings.
transformeris a regular expression that will be used to transform the value of the attribute.If the attribute is
None, it will be returned verbatim.If
transformerisNone, the attribute will be returned verbatim.If
transformerhas no named groups, the attribute will be replaced with the value of the first group.If
transformerhas named groups, the attribute will be replaced with a dictionary of the named groups.
- Raises:
ValueError – If the attribute does not exist on the model.
RuntimeError – If the transformer fails to match the attribute value.
- Parameters:
attribute – The attribute to transform.
transformer – The regular expression to use to transform the attribute.
- Returns:
The transformed attribute.
- pydantic model botocraft.services.logs.GetLogGroupFieldsResponse[source]
Bases:
Boto3ModelShow JSON schema
{ "title": "GetLogGroupFieldsResponse", "type": "object", "properties": { "session": { "anyOf": [ {}, { "type": "null" } ], "default": null, "title": "Session" }, "logGroupFields": { "anyOf": [ { "items": { "$ref": "#/$defs/LogGroupField" }, "type": "array" }, { "type": "null" } ], "title": "Loggroupfields" } }, "$defs": { "LogGroupField": { "description": "The fields contained in log events found by a ``GetLogGroupFields`` operation, along\nwith the percentage of queried log events in which each field appears.", "properties": { "session": { "anyOf": [ {}, { "type": "null" } ], "default": null, "title": "Session" }, "name": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Name" }, "percent": { "anyOf": [ { "type": "integer" }, { "type": "null" } ], "default": null, "title": "Percent" } }, "title": "LogGroupField", "type": "object" } } }
- Config:
validate_assignment: bool = True
arbitrary_types_allowed: bool = True
- Fields:
- field logGroupFields: builtins.list[LogGroupField] | None [Optional]
The array of fields found in the query.
Each object in the array contains the name of the field, along with the percentage of time it appeared in the log events that were queried.
- field session: Any | None = None
The boto3 session to use for this model. This is set by the manager, and is used in relationships. We have to use
Anyhere because we pydantic complains vociferously if we useboto3.session.Session. We exclude it from the model dump because it’s not something that should be serialized.
- classmethod model_construct(_fields_set: set[str] | None = None, **values: Any) Self
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed.
- !!! note
model_construct() generally respects the model_config.extra setting on the provided model. That is, if model_config.extra == ‘allow’, then all extra passed values are added to the model instance’s __dict__ and __pydantic_extra__ fields. If model_config.extra == ‘ignore’ (the default), then all extra passed values are ignored. Because no validation is performed with a call to model_construct(), having model_config.extra == ‘forbid’ does not result in an error if extra values are passed, but they will be ignored.
- Parameters:
_fields_set – A set of field names that were originally explicitly set during instantiation. If provided, this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute. Otherwise, the field names from the values argument will be used.
values – Trusted or pre-validated data dictionary.
- Returns:
A new instance of the Model class with validated data.
- classmethod model_validate_strings(obj: Any, *, strict: bool | None = None, context: Any | None = None, by_alias: bool | None = None, by_name: bool | None = None) Self
Validate the given object with string data against the Pydantic model.
- Parameters:
obj – The object containing string data to validate.
strict – Whether to enforce types strictly.
context – Extra variables to pass to the validator.
by_alias – Whether to use the field’s alias when validating against the provided input data.
by_name – Whether to use the field’s name when validating against the provided input data.
- Returns:
The validated Pydantic model.
- set_session(session: Session) None
Set the boto3 session for this model.
- Parameters:
session – The boto3 session to use.
- Returns:
The model instance.
- transform(attribute: str, transformer: str | None) Any
Transform an attribute using a regular expression into something else before it is returned.
Important
This only makes sense for attributes that are strings.
transformeris a regular expression that will be used to transform the value of the attribute.If the attribute is
None, it will be returned verbatim.If
transformerisNone, the attribute will be returned verbatim.If
transformerhas no named groups, the attribute will be replaced with the value of the first group.If
transformerhas named groups, the attribute will be replaced with a dictionary of the named groups.
- Raises:
ValueError – If the attribute does not exist on the model.
RuntimeError – If the transformer fails to match the attribute value.
- Parameters:
attribute – The attribute to transform.
transformer – The regular expression to use to transform the attribute.
- Returns:
The transformed attribute.
- pydantic model botocraft.services.logs.LogGroupField[source]
Bases:
Boto3ModelThe fields contained in log events found by a
GetLogGroupFieldsoperation, along with the percentage of queried log events in which each field appears.Show JSON schema
{ "title": "LogGroupField", "description": "The fields contained in log events found by a ``GetLogGroupFields`` operation, along\nwith the percentage of queried log events in which each field appears.", "type": "object", "properties": { "session": { "anyOf": [ {}, { "type": "null" } ], "default": null, "title": "Session" }, "name": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Name" }, "percent": { "anyOf": [ { "type": "integer" }, { "type": "null" } ], "default": null, "title": "Percent" } } }
- Config:
validate_assignment: bool = True
arbitrary_types_allowed: bool = True
- Fields:
- field session: Any | None = None
The boto3 session to use for this model. This is set by the manager, and is used in relationships. We have to use
Anyhere because we pydantic complains vociferously if we useboto3.session.Session. We exclude it from the model dump because it’s not something that should be serialized.
- classmethod model_construct(_fields_set: set[str] | None = None, **values: Any) Self
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed.
- !!! note
model_construct() generally respects the model_config.extra setting on the provided model. That is, if model_config.extra == ‘allow’, then all extra passed values are added to the model instance’s __dict__ and __pydantic_extra__ fields. If model_config.extra == ‘ignore’ (the default), then all extra passed values are ignored. Because no validation is performed with a call to model_construct(), having model_config.extra == ‘forbid’ does not result in an error if extra values are passed, but they will be ignored.
- Parameters:
_fields_set – A set of field names that were originally explicitly set during instantiation. If provided, this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute. Otherwise, the field names from the values argument will be used.
values – Trusted or pre-validated data dictionary.
- Returns:
A new instance of the Model class with validated data.
- classmethod model_validate_strings(obj: Any, *, strict: bool | None = None, context: Any | None = None, by_alias: bool | None = None, by_name: bool | None = None) Self
Validate the given object with string data against the Pydantic model.
- Parameters:
obj – The object containing string data to validate.
strict – Whether to enforce types strictly.
context – Extra variables to pass to the validator.
by_alias – Whether to use the field’s alias when validating against the provided input data.
by_name – Whether to use the field’s name when validating against the provided input data.
- Returns:
The validated Pydantic model.
- set_session(session: Session) None
Set the boto3 session for this model.
- Parameters:
session – The boto3 session to use.
- Returns:
The model instance.
- transform(attribute: str, transformer: str | None) Any
Transform an attribute using a regular expression into something else before it is returned.
Important
This only makes sense for attributes that are strings.
transformeris a regular expression that will be used to transform the value of the attribute.If the attribute is
None, it will be returned verbatim.If
transformerisNone, the attribute will be returned verbatim.If
transformerhas no named groups, the attribute will be replaced with the value of the first group.If
transformerhas named groups, the attribute will be replaced with a dictionary of the named groups.
- Raises:
ValueError – If the attribute does not exist on the model.
RuntimeError – If the transformer fails to match the attribute value.
- Parameters:
attribute – The attribute to transform.
transformer – The regular expression to use to transform the attribute.
- Returns:
The transformed attribute.