|
19 | 19 | ListOffersRequestOrderBy,
|
20 | 20 | CheckUserOwnsDomainRequest,
|
21 | 21 | CheckUserOwnsDomainResponse,
|
| 22 | + ClassicMailApiCreateMailboxRequest, |
| 23 | + ClassicMailApiUpdateMailboxRequest, |
22 | 24 | ControlPanel,
|
23 | 25 | CreateHostingRequest,
|
24 | 26 | CreateHostingRequestDomainConfiguration,
|
25 | 27 | DnsRecords,
|
| 28 | + EmailAddress, |
26 | 29 | Hosting,
|
27 | 30 | ListControlPanelsResponse,
|
28 | 31 | ListHostingsResponse,
|
| 32 | + ListMailboxesResponse, |
29 | 33 | ListOffersResponse,
|
| 34 | + Mailbox, |
30 | 35 | ResetHostingPasswordResponse,
|
31 | 36 | Session,
|
32 | 37 | UpdateHostingRequest,
|
|
36 | 41 | )
|
37 | 42 | from .marshalling import (
|
38 | 43 | unmarshal_Hosting,
|
| 44 | + unmarshal_Mailbox, |
39 | 45 | unmarshal_CheckUserOwnsDomainResponse,
|
40 | 46 | unmarshal_DnsRecords,
|
41 | 47 | unmarshal_ListControlPanelsResponse,
|
42 | 48 | unmarshal_ListHostingsResponse,
|
| 49 | + unmarshal_ListMailboxesResponse, |
43 | 50 | unmarshal_ListOffersResponse,
|
44 | 51 | unmarshal_ResetHostingPasswordResponse,
|
45 | 52 | unmarshal_Session,
|
46 | 53 | marshal_CheckUserOwnsDomainRequest,
|
| 54 | + marshal_ClassicMailApiCreateMailboxRequest, |
| 55 | + marshal_ClassicMailApiUpdateMailboxRequest, |
47 | 56 | marshal_CreateHostingRequest,
|
48 | 57 | marshal_UpdateHostingRequest,
|
49 | 58 | )
|
@@ -686,3 +695,260 @@ async def reset_hosting_password(
|
686 | 695 |
|
687 | 696 | self._throw_on_error(res)
|
688 | 697 | return unmarshal_ResetHostingPasswordResponse(res.json())
|
| 698 | + |
| 699 | + |
| 700 | +class WebhostingV1Alpha1ClassicMailAPI(API): |
| 701 | + """ |
| 702 | + This API allows you to manage your mailboxes for your Web Hosting services. |
| 703 | + """ |
| 704 | + |
| 705 | + async def create_mailbox( |
| 706 | + self, |
| 707 | + *, |
| 708 | + online_id: int, |
| 709 | + password: str, |
| 710 | + region: Optional[Region] = None, |
| 711 | + email: Optional[EmailAddress] = None, |
| 712 | + ) -> Mailbox: |
| 713 | + """ |
| 714 | + Create a new mailbox within your hosting plan. |
| 715 | + :param online_id: The Online hosting ID. |
| 716 | + :param password: Password for the new mailbox. |
| 717 | + :param region: Region to target. If none is passed will use default region from the config. |
| 718 | + :param email: The email address of the mailbox. |
| 719 | + :return: :class:`Mailbox <Mailbox>` |
| 720 | +
|
| 721 | + Usage: |
| 722 | + :: |
| 723 | +
|
| 724 | + result = await api.create_mailbox( |
| 725 | + online_id=1, |
| 726 | + password="example", |
| 727 | + ) |
| 728 | + """ |
| 729 | + |
| 730 | + param_region = validate_path_param( |
| 731 | + "region", region or self.client.default_region |
| 732 | + ) |
| 733 | + param_online_id = validate_path_param("online_id", online_id) |
| 734 | + |
| 735 | + res = self._request( |
| 736 | + "POST", |
| 737 | + f"/webhosting/v1alpha1/regions/{param_region}/classic-hostings/{param_online_id}/mailboxes", |
| 738 | + body=marshal_ClassicMailApiCreateMailboxRequest( |
| 739 | + ClassicMailApiCreateMailboxRequest( |
| 740 | + online_id=online_id, |
| 741 | + password=password, |
| 742 | + region=region, |
| 743 | + email=email, |
| 744 | + ), |
| 745 | + self.client, |
| 746 | + ), |
| 747 | + ) |
| 748 | + |
| 749 | + self._throw_on_error(res) |
| 750 | + return unmarshal_Mailbox(res.json()) |
| 751 | + |
| 752 | + async def get_mailbox( |
| 753 | + self, |
| 754 | + *, |
| 755 | + online_id: int, |
| 756 | + mailbox_id: int, |
| 757 | + region: Optional[Region] = None, |
| 758 | + ) -> Mailbox: |
| 759 | + """ |
| 760 | + Get a mailbox by id within your hosting plan. |
| 761 | + :param online_id: The Online hosting ID. |
| 762 | + :param mailbox_id: The ID of the mailbox to get. |
| 763 | + :param region: Region to target. If none is passed will use default region from the config. |
| 764 | + :return: :class:`Mailbox <Mailbox>` |
| 765 | +
|
| 766 | + Usage: |
| 767 | + :: |
| 768 | +
|
| 769 | + result = await api.get_mailbox( |
| 770 | + online_id=1, |
| 771 | + mailbox_id=1, |
| 772 | + ) |
| 773 | + """ |
| 774 | + |
| 775 | + param_region = validate_path_param( |
| 776 | + "region", region or self.client.default_region |
| 777 | + ) |
| 778 | + param_online_id = validate_path_param("online_id", online_id) |
| 779 | + param_mailbox_id = validate_path_param("mailbox_id", mailbox_id) |
| 780 | + |
| 781 | + res = self._request( |
| 782 | + "GET", |
| 783 | + f"/webhosting/v1alpha1/regions/{param_region}/classic-hostings/{param_online_id}/mailboxes/{param_mailbox_id}", |
| 784 | + ) |
| 785 | + |
| 786 | + self._throw_on_error(res) |
| 787 | + return unmarshal_Mailbox(res.json()) |
| 788 | + |
| 789 | + async def list_mailboxes( |
| 790 | + self, |
| 791 | + *, |
| 792 | + online_id: int, |
| 793 | + region: Optional[Region] = None, |
| 794 | + page: Optional[int] = None, |
| 795 | + page_size: Optional[int] = None, |
| 796 | + domain: Optional[str] = None, |
| 797 | + ) -> ListMailboxesResponse: |
| 798 | + """ |
| 799 | + List all mailboxes within your hosting plan. |
| 800 | + :param online_id: The Online hosting ID. |
| 801 | + :param region: Region to target. If none is passed will use default region from the config. |
| 802 | + :param page: Page number (must be a positive integer). |
| 803 | + :param page_size: Number of mailboxes to return (must be a positive integer lower or equal to 100). |
| 804 | + :param domain: Domain to filter the mailboxes. |
| 805 | + :return: :class:`ListMailboxesResponse <ListMailboxesResponse>` |
| 806 | +
|
| 807 | + Usage: |
| 808 | + :: |
| 809 | +
|
| 810 | + result = await api.list_mailboxes( |
| 811 | + online_id=1, |
| 812 | + ) |
| 813 | + """ |
| 814 | + |
| 815 | + param_region = validate_path_param( |
| 816 | + "region", region or self.client.default_region |
| 817 | + ) |
| 818 | + param_online_id = validate_path_param("online_id", online_id) |
| 819 | + |
| 820 | + res = self._request( |
| 821 | + "GET", |
| 822 | + f"/webhosting/v1alpha1/regions/{param_region}/classic-hostings/{param_online_id}/mailboxes", |
| 823 | + params={ |
| 824 | + "domain": domain, |
| 825 | + "page": page, |
| 826 | + "page_size": page_size or self.client.default_page_size, |
| 827 | + }, |
| 828 | + ) |
| 829 | + |
| 830 | + self._throw_on_error(res) |
| 831 | + return unmarshal_ListMailboxesResponse(res.json()) |
| 832 | + |
| 833 | + async def list_mailboxes_all( |
| 834 | + self, |
| 835 | + *, |
| 836 | + online_id: int, |
| 837 | + region: Optional[Region] = None, |
| 838 | + page: Optional[int] = None, |
| 839 | + page_size: Optional[int] = None, |
| 840 | + domain: Optional[str] = None, |
| 841 | + ) -> List[Mailbox]: |
| 842 | + """ |
| 843 | + List all mailboxes within your hosting plan. |
| 844 | + :param online_id: The Online hosting ID. |
| 845 | + :param region: Region to target. If none is passed will use default region from the config. |
| 846 | + :param page: Page number (must be a positive integer). |
| 847 | + :param page_size: Number of mailboxes to return (must be a positive integer lower or equal to 100). |
| 848 | + :param domain: Domain to filter the mailboxes. |
| 849 | + :return: :class:`List[Mailbox] <List[Mailbox]>` |
| 850 | +
|
| 851 | + Usage: |
| 852 | + :: |
| 853 | +
|
| 854 | + result = await api.list_mailboxes_all( |
| 855 | + online_id=1, |
| 856 | + ) |
| 857 | + """ |
| 858 | + |
| 859 | + return await fetch_all_pages_async( |
| 860 | + type=ListMailboxesResponse, |
| 861 | + key="mailboxes", |
| 862 | + fetcher=self.list_mailboxes, |
| 863 | + args={ |
| 864 | + "online_id": online_id, |
| 865 | + "region": region, |
| 866 | + "page": page, |
| 867 | + "page_size": page_size, |
| 868 | + "domain": domain, |
| 869 | + }, |
| 870 | + ) |
| 871 | + |
| 872 | + async def delete_mailbox( |
| 873 | + self, |
| 874 | + *, |
| 875 | + online_id: int, |
| 876 | + mailbox_id: int, |
| 877 | + region: Optional[Region] = None, |
| 878 | + ) -> Mailbox: |
| 879 | + """ |
| 880 | + :param online_id: The Online hosting ID. |
| 881 | + :param mailbox_id: The ID of the mailbox to delete. |
| 882 | + :param region: Region to target. If none is passed will use default region from the config. |
| 883 | + :return: :class:`Mailbox <Mailbox>` |
| 884 | +
|
| 885 | + Usage: |
| 886 | + :: |
| 887 | +
|
| 888 | + result = await api.delete_mailbox( |
| 889 | + online_id=1, |
| 890 | + mailbox_id=1, |
| 891 | + ) |
| 892 | + """ |
| 893 | + |
| 894 | + param_region = validate_path_param( |
| 895 | + "region", region or self.client.default_region |
| 896 | + ) |
| 897 | + param_online_id = validate_path_param("online_id", online_id) |
| 898 | + param_mailbox_id = validate_path_param("mailbox_id", mailbox_id) |
| 899 | + |
| 900 | + res = self._request( |
| 901 | + "DELETE", |
| 902 | + f"/webhosting/v1alpha1/regions/{param_region}/classic-hostings/{param_online_id}/mailboxes/{param_mailbox_id}", |
| 903 | + ) |
| 904 | + |
| 905 | + self._throw_on_error(res) |
| 906 | + return unmarshal_Mailbox(res.json()) |
| 907 | + |
| 908 | + async def update_mailbox( |
| 909 | + self, |
| 910 | + *, |
| 911 | + online_id: int, |
| 912 | + mailbox_id: int, |
| 913 | + region: Optional[Region] = None, |
| 914 | + password: Optional[str] = None, |
| 915 | + ) -> Mailbox: |
| 916 | + """ |
| 917 | + Update the mailbox within your hosting plan. |
| 918 | + :param online_id: The Online hosting ID. |
| 919 | + :param mailbox_id: The ID of the mailbox to update. |
| 920 | + :param region: Region to target. If none is passed will use default region from the config. |
| 921 | + :param password: New password for the mailbox. |
| 922 | + :return: :class:`Mailbox <Mailbox>` |
| 923 | +
|
| 924 | + Usage: |
| 925 | + :: |
| 926 | +
|
| 927 | + result = await api.update_mailbox( |
| 928 | + online_id=1, |
| 929 | + mailbox_id=1, |
| 930 | + ) |
| 931 | + """ |
| 932 | + |
| 933 | + param_region = validate_path_param( |
| 934 | + "region", region or self.client.default_region |
| 935 | + ) |
| 936 | + param_online_id = validate_path_param("online_id", online_id) |
| 937 | + param_mailbox_id = validate_path_param("mailbox_id", mailbox_id) |
| 938 | + |
| 939 | + res = self._request( |
| 940 | + "PATCH", |
| 941 | + f"/webhosting/v1alpha1/regions/{param_region}/classic-hostings/{param_online_id}/mailboxes/{param_mailbox_id}", |
| 942 | + body=marshal_ClassicMailApiUpdateMailboxRequest( |
| 943 | + ClassicMailApiUpdateMailboxRequest( |
| 944 | + online_id=online_id, |
| 945 | + mailbox_id=mailbox_id, |
| 946 | + region=region, |
| 947 | + password=password, |
| 948 | + ), |
| 949 | + self.client, |
| 950 | + ), |
| 951 | + ) |
| 952 | + |
| 953 | + self._throw_on_error(res) |
| 954 | + return unmarshal_Mailbox(res.json()) |
0 commit comments