|
5 | 5 | from dateutil import parser |
6 | 6 |
|
7 | 7 | from .types import ( |
| 8 | + AuthenticationEventFailureReason, |
| 9 | + AuthenticationEventMFAType, |
| 10 | + AuthenticationEventMethod, |
| 11 | + AuthenticationEventOrigin, |
| 12 | + AuthenticationEventResult, |
8 | 13 | AccountOrganizationInfo, |
9 | 14 | AccountProjectInfo, |
10 | 15 | AccountUserInfo, |
|
27 | 32 | LoadBalancerRouteInfo, |
28 | 33 | SecretManagerSecretInfo, |
29 | 34 | SecretManagerSecretVersionInfo, |
| 35 | + Resource, |
| 36 | + AuthenticationEvent, |
| 37 | + ListAuthenticationEventsResponse, |
30 | 38 | EventPrincipal, |
31 | 39 | EventSystem, |
32 | | - Resource, |
33 | 40 | Event, |
34 | 41 | ListEventsResponse, |
35 | 42 | ProductService, |
36 | 43 | Product, |
37 | 44 | ListProductsResponse, |
38 | 45 | ) |
| 46 | +from ...std.types import ( |
| 47 | + CountryCode as StdCountryCode, |
| 48 | +) |
39 | 49 |
|
40 | 50 |
|
41 | 51 | def unmarshal_AccountOrganizationInfo(data: Any) -> AccountOrganizationInfo: |
@@ -456,40 +466,6 @@ def unmarshal_SecretManagerSecretVersionInfo( |
456 | 466 | return SecretManagerSecretVersionInfo(**args) |
457 | 467 |
|
458 | 468 |
|
459 | | -def unmarshal_EventPrincipal(data: Any) -> EventPrincipal: |
460 | | - if not isinstance(data, dict): |
461 | | - raise TypeError( |
462 | | - "Unmarshalling the type 'EventPrincipal' failed as data isn't a dictionary." |
463 | | - ) |
464 | | - |
465 | | - args: Dict[str, Any] = {} |
466 | | - |
467 | | - field = data.get("id", None) |
468 | | - if field is not None: |
469 | | - args["id"] = field |
470 | | - else: |
471 | | - args["id"] = None |
472 | | - |
473 | | - return EventPrincipal(**args) |
474 | | - |
475 | | - |
476 | | -def unmarshal_EventSystem(data: Any) -> EventSystem: |
477 | | - if not isinstance(data, dict): |
478 | | - raise TypeError( |
479 | | - "Unmarshalling the type 'EventSystem' failed as data isn't a dictionary." |
480 | | - ) |
481 | | - |
482 | | - args: Dict[str, Any] = {} |
483 | | - |
484 | | - field = data.get("name", None) |
485 | | - if field is not None: |
486 | | - args["name"] = field |
487 | | - else: |
488 | | - args["name"] = None |
489 | | - |
490 | | - return EventSystem(**args) |
491 | | - |
492 | | - |
493 | 469 | def unmarshal_Resource(data: Any) -> Resource: |
494 | 470 | if not isinstance(data, dict): |
495 | 471 | raise TypeError( |
@@ -693,6 +669,156 @@ def unmarshal_Resource(data: Any) -> Resource: |
693 | 669 | return Resource(**args) |
694 | 670 |
|
695 | 671 |
|
| 672 | +def unmarshal_AuthenticationEvent(data: Any) -> AuthenticationEvent: |
| 673 | + if not isinstance(data, dict): |
| 674 | + raise TypeError( |
| 675 | + "Unmarshalling the type 'AuthenticationEvent' failed as data isn't a dictionary." |
| 676 | + ) |
| 677 | + |
| 678 | + args: Dict[str, Any] = {} |
| 679 | + |
| 680 | + field = data.get("id", None) |
| 681 | + if field is not None: |
| 682 | + args["id"] = field |
| 683 | + else: |
| 684 | + args["id"] = None |
| 685 | + |
| 686 | + field = data.get("organization_id", None) |
| 687 | + if field is not None: |
| 688 | + args["organization_id"] = field |
| 689 | + else: |
| 690 | + args["organization_id"] = None |
| 691 | + |
| 692 | + field = data.get("source_ip", None) |
| 693 | + if field is not None: |
| 694 | + args["source_ip"] = field |
| 695 | + else: |
| 696 | + args["source_ip"] = None |
| 697 | + |
| 698 | + field = data.get("resources", None) |
| 699 | + if field is not None: |
| 700 | + args["resources"] = ( |
| 701 | + [unmarshal_Resource(v) for v in field] if field is not None else None |
| 702 | + ) |
| 703 | + else: |
| 704 | + args["resources"] = [] |
| 705 | + |
| 706 | + field = data.get("result", None) |
| 707 | + if field is not None: |
| 708 | + args["result"] = field |
| 709 | + else: |
| 710 | + args["result"] = AuthenticationEventResult.UNKNOWN_RESULT |
| 711 | + |
| 712 | + field = data.get("method", None) |
| 713 | + if field is not None: |
| 714 | + args["method"] = field |
| 715 | + else: |
| 716 | + args["method"] = AuthenticationEventMethod.UNKNOWN_METHOD |
| 717 | + |
| 718 | + field = data.get("origin", None) |
| 719 | + if field is not None: |
| 720 | + args["origin"] = field |
| 721 | + else: |
| 722 | + args["origin"] = AuthenticationEventOrigin.UNKNOWN_ORIGIN |
| 723 | + |
| 724 | + field = data.get("recorded_at", None) |
| 725 | + if field is not None: |
| 726 | + args["recorded_at"] = ( |
| 727 | + parser.isoparse(field) if isinstance(field, str) else field |
| 728 | + ) |
| 729 | + else: |
| 730 | + args["recorded_at"] = None |
| 731 | + |
| 732 | + field = data.get("user_agent", None) |
| 733 | + if field is not None: |
| 734 | + args["user_agent"] = field |
| 735 | + else: |
| 736 | + args["user_agent"] = None |
| 737 | + |
| 738 | + field = data.get("failure_reason", None) |
| 739 | + if field is not None: |
| 740 | + args["failure_reason"] = field |
| 741 | + else: |
| 742 | + args["failure_reason"] = AuthenticationEventFailureReason.UNKNOWN_FAILURE_REASON |
| 743 | + |
| 744 | + field = data.get("country_code", None) |
| 745 | + if field is not None: |
| 746 | + args["country_code"] = field |
| 747 | + else: |
| 748 | + args["country_code"] = StdCountryCode.UNKNOWN_COUNTRY_CODE |
| 749 | + |
| 750 | + field = data.get("mfa_type", None) |
| 751 | + if field is not None: |
| 752 | + args["mfa_type"] = field |
| 753 | + else: |
| 754 | + args["mfa_type"] = AuthenticationEventMFAType.UNKNOWN_MFA_TYPE |
| 755 | + |
| 756 | + return AuthenticationEvent(**args) |
| 757 | + |
| 758 | + |
| 759 | +def unmarshal_ListAuthenticationEventsResponse( |
| 760 | + data: Any, |
| 761 | +) -> ListAuthenticationEventsResponse: |
| 762 | + if not isinstance(data, dict): |
| 763 | + raise TypeError( |
| 764 | + "Unmarshalling the type 'ListAuthenticationEventsResponse' failed as data isn't a dictionary." |
| 765 | + ) |
| 766 | + |
| 767 | + args: Dict[str, Any] = {} |
| 768 | + |
| 769 | + field = data.get("events", None) |
| 770 | + if field is not None: |
| 771 | + args["events"] = ( |
| 772 | + [unmarshal_AuthenticationEvent(v) for v in field] |
| 773 | + if field is not None |
| 774 | + else None |
| 775 | + ) |
| 776 | + else: |
| 777 | + args["events"] = None |
| 778 | + |
| 779 | + field = data.get("next_page_token", None) |
| 780 | + if field is not None: |
| 781 | + args["next_page_token"] = field |
| 782 | + else: |
| 783 | + args["next_page_token"] = None |
| 784 | + |
| 785 | + return ListAuthenticationEventsResponse(**args) |
| 786 | + |
| 787 | + |
| 788 | +def unmarshal_EventPrincipal(data: Any) -> EventPrincipal: |
| 789 | + if not isinstance(data, dict): |
| 790 | + raise TypeError( |
| 791 | + "Unmarshalling the type 'EventPrincipal' failed as data isn't a dictionary." |
| 792 | + ) |
| 793 | + |
| 794 | + args: Dict[str, Any] = {} |
| 795 | + |
| 796 | + field = data.get("id", None) |
| 797 | + if field is not None: |
| 798 | + args["id"] = field |
| 799 | + else: |
| 800 | + args["id"] = None |
| 801 | + |
| 802 | + return EventPrincipal(**args) |
| 803 | + |
| 804 | + |
| 805 | +def unmarshal_EventSystem(data: Any) -> EventSystem: |
| 806 | + if not isinstance(data, dict): |
| 807 | + raise TypeError( |
| 808 | + "Unmarshalling the type 'EventSystem' failed as data isn't a dictionary." |
| 809 | + ) |
| 810 | + |
| 811 | + args: Dict[str, Any] = {} |
| 812 | + |
| 813 | + field = data.get("name", None) |
| 814 | + if field is not None: |
| 815 | + args["name"] = field |
| 816 | + else: |
| 817 | + args["name"] = None |
| 818 | + |
| 819 | + return EventSystem(**args) |
| 820 | + |
| 821 | + |
696 | 822 | def unmarshal_Event(data: Any) -> Event: |
697 | 823 | if not isinstance(data, dict): |
698 | 824 | raise TypeError( |
|
0 commit comments