|
| 1 | +# The Okta software accompanied by this notice is provided pursuant to the following terms: |
| 2 | +# Copyright © 2025-Present, Okta, Inc. |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the |
| 4 | +# License. |
| 5 | +# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. |
| 6 | +# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS |
| 7 | +# IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 8 | +# See the License for the specific language governing permissions and limitations under the License. |
| 9 | +# coding: utf-8 |
| 10 | + |
| 11 | +""" |
| 12 | +Okta Admin Management |
| 13 | +
|
| 14 | +Allows customers to easily access the Okta Management APIs |
| 15 | +
|
| 16 | +The version of the OpenAPI document: 5.1.0 |
| 17 | +Contact: devex-public@okta.com |
| 18 | +Generated by OpenAPI Generator (https://openapi-generator.tech) |
| 19 | +
|
| 20 | +Do not edit the class manually. |
| 21 | +""" # noqa: E501 |
| 22 | + |
| 23 | +from __future__ import annotations |
| 24 | + |
| 25 | +import json |
| 26 | +import pprint |
| 27 | +import re # noqa: F401 |
| 28 | +from typing import Any, ClassVar, Dict, List |
| 29 | +from typing import Optional, Set |
| 30 | + |
| 31 | +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator |
| 32 | +from typing_extensions import Self |
| 33 | + |
| 34 | + |
| 35 | +class LogUserBehavior(BaseModel): |
| 36 | + """ |
| 37 | + The result of the user behavior detection models associated with the event |
| 38 | + """ # noqa: E501 |
| 39 | + |
| 40 | + name: Optional[StrictStr] = Field( |
| 41 | + default=None, |
| 42 | + description="The name of the user behavior detection model [configured by admins](" |
| 43 | + "https://developer.okta.com/docs/api/openapi/okta-management/management/tag/Behavior/)", |
| 44 | + ) |
| 45 | + id: Optional[StrictStr] = Field( |
| 46 | + default=None, |
| 47 | + description="The unique identifier of the user behavior detection model", |
| 48 | + ) |
| 49 | + result: Optional[StrictStr] = Field( |
| 50 | + default=None, description="The result of the user behavior analysis" |
| 51 | + ) |
| 52 | + __properties: ClassVar[List[str]] = ["name", "id", "result"] |
| 53 | + |
| 54 | + @field_validator("result") |
| 55 | + def result_validate_enum(cls, value): |
| 56 | + """Validates the enum""" |
| 57 | + if value is None: |
| 58 | + return value |
| 59 | + |
| 60 | + if value not in set(["UNKNOWN", "POSITIVE", "NEGATIVE", "BAD_REQUEST"]): |
| 61 | + raise ValueError( |
| 62 | + "must be one of enum values ('UNKNOWN', 'POSITIVE', 'NEGATIVE', 'BAD_REQUEST')" |
| 63 | + ) |
| 64 | + return value |
| 65 | + |
| 66 | + model_config = ConfigDict( |
| 67 | + populate_by_name=True, |
| 68 | + validate_assignment=True, |
| 69 | + protected_namespaces=(), |
| 70 | + ) |
| 71 | + |
| 72 | + def to_str(self) -> str: |
| 73 | + """Returns the string representation of the model using alias""" |
| 74 | + return pprint.pformat(self.model_dump(by_alias=True)) |
| 75 | + |
| 76 | + def to_json(self) -> str: |
| 77 | + """Returns the JSON representation of the model using alias""" |
| 78 | + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead |
| 79 | + return json.dumps(self.to_dict()) |
| 80 | + |
| 81 | + @classmethod |
| 82 | + def from_json(cls, json_str: str) -> Optional[Self]: |
| 83 | + """Create an instance of LogUserBehavior from a JSON string""" |
| 84 | + return cls.from_dict(json.loads(json_str)) |
| 85 | + |
| 86 | + def to_dict(self) -> Dict[str, Any]: |
| 87 | + """Return the dictionary representation of the model using alias. |
| 88 | +
|
| 89 | + This has the following differences from calling pydantic's |
| 90 | + `self.model_dump(by_alias=True)`: |
| 91 | +
|
| 92 | + * `None` is only added to the output dict for nullable fields that |
| 93 | + were set at model initialization. Other fields with value `None` |
| 94 | + are ignored. |
| 95 | + * OpenAPI `readOnly` fields are excluded. |
| 96 | + * OpenAPI `readOnly` fields are excluded. |
| 97 | + * OpenAPI `readOnly` fields are excluded. |
| 98 | + """ |
| 99 | + excluded_fields: Set[str] = set( |
| 100 | + [ |
| 101 | + "name", |
| 102 | + "id", |
| 103 | + "result", |
| 104 | + ] |
| 105 | + ) |
| 106 | + |
| 107 | + _dict = self.model_dump( |
| 108 | + by_alias=True, |
| 109 | + exclude=excluded_fields, |
| 110 | + exclude_none=True, |
| 111 | + ) |
| 112 | + # set to None if name (nullable) is None |
| 113 | + # and model_fields_set contains the field |
| 114 | + if self.name is None and "name" in self.model_fields_set: |
| 115 | + _dict["name"] = None |
| 116 | + |
| 117 | + # set to None if id (nullable) is None |
| 118 | + # and model_fields_set contains the field |
| 119 | + if self.id is None and "id" in self.model_fields_set: |
| 120 | + _dict["id"] = None |
| 121 | + |
| 122 | + # set to None if result (nullable) is None |
| 123 | + # and model_fields_set contains the field |
| 124 | + if self.result is None and "result" in self.model_fields_set: |
| 125 | + _dict["result"] = None |
| 126 | + |
| 127 | + return _dict |
| 128 | + |
| 129 | + @classmethod |
| 130 | + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: |
| 131 | + """Create an instance of LogUserBehavior from a dict""" |
| 132 | + if obj is None: |
| 133 | + return None |
| 134 | + |
| 135 | + if not isinstance(obj, dict): |
| 136 | + return cls.model_validate(obj) |
| 137 | + |
| 138 | + _obj = cls.model_validate( |
| 139 | + {"name": obj.get("name"), "id": obj.get("id"), "result": obj.get("result")} |
| 140 | + ) |
| 141 | + return _obj |
0 commit comments