11#
22# This file is part of the Ingram Micro CloudBlue Connect Python OpenAPI Client.
33#
4- # Copyright (c) 2021 Ingram Micro. All Rights Reserved.
4+ # Copyright (c) 2022 Ingram Micro. All Rights Reserved.
55#
66from connect .client .exceptions import ClientError
77from connect .client .utils import resolve_attribute
@@ -17,12 +17,70 @@ def create(self, payload=None, **kwargs):
1717 :return: The newly created resource.
1818 :rtype: dict
1919 """
20+ if payload is not None and not isinstance (payload , dict ):
21+ raise TypeError ('`payload` must be a dict.' )
22+
23+ return self ._client .create (
24+ self ._path ,
25+ payload = payload ,
26+ ** kwargs ,
27+ )
28+
29+ def bulk_create (self , payload , ** kwargs ):
30+ """
31+ Create new resources within this collection. This operation may not be supported
32+ by the API.
33+
34+ :param payload: JSON payload of the list of resources to create.
35+ :type payload: list
36+ :return: The newly created resources.
37+ :rtype: list
38+ """
39+ if not isinstance (payload , (list , tuple )):
40+ raise TypeError ('`payload` must be a list or tuple.' )
41+
2042 return self ._client .create (
2143 self ._path ,
2244 payload = payload ,
2345 ** kwargs ,
2446 )
2547
48+ def bulk_update (self , payload , ** kwargs ):
49+ """
50+ Update a list of resources in this collection. This operation may not be supported
51+ by the API.
52+
53+ :param payload: JSON payload of the list of resources to update.
54+ :type payload: list
55+ :return: A list of the updated resources.
56+ :rtype: list
57+ """
58+ if not isinstance (payload , (list , tuple )):
59+ raise TypeError ('`payload` must be a list or tuple.' )
60+
61+ return self ._client .update (
62+ self ._path ,
63+ payload = payload ,
64+ ** kwargs ,
65+ )
66+
67+ def bulk_delete (self , payload , ** kwargs ):
68+ """
69+ Delete a list of resources from this collection. This operation may not be supported
70+ by the API.
71+
72+ :param payload: JSON payload of the list of resources to delete.
73+ :type payload: list
74+ """
75+ if not isinstance (payload , (list , tuple )):
76+ raise TypeError ('`payload` must be a list or tuple.' )
77+
78+ self ._client .delete (
79+ self ._path ,
80+ payload = payload ,
81+ ** kwargs ,
82+ )
83+
2684
2785class AsyncCollectionMixin :
2886 async def create (self , payload = None , ** kwargs ):
@@ -34,12 +92,70 @@ async def create(self, payload=None, **kwargs):
3492 :return: The newly created resource.
3593 :rtype: dict
3694 """
95+ if payload is not None and not isinstance (payload , dict ):
96+ raise TypeError ('`payload` must be a dict.' )
97+
3798 return await self ._client .create (
3899 self ._path ,
39100 payload = payload ,
40101 ** kwargs ,
41102 )
42103
104+ async def bulk_create (self , payload , ** kwargs ):
105+ """
106+ Create new resources within this collection. This operation may not be supported
107+ by the API.
108+
109+ :param payload: JSON payload of the list of resources to create.
110+ :type payload: list
111+ :return: The newly created resources.
112+ :rtype: list
113+ """
114+ if not isinstance (payload , (list , tuple )):
115+ raise TypeError ('`payload` must be a list or tuple.' )
116+
117+ return await self ._client .create (
118+ self ._path ,
119+ payload = payload ,
120+ ** kwargs ,
121+ )
122+
123+ async def bulk_update (self , payload , ** kwargs ):
124+ """
125+ Update a list of resources in this collection. This operation may not be supported
126+ by the API.
127+
128+ :param payload: JSON payload of the list of resources to update.
129+ :type payload: list
130+ :return: A list of the updated resources.
131+ :rtype: list
132+ """
133+ if not isinstance (payload , (list , tuple )):
134+ raise TypeError ('`payload` must be a list or tuple.' )
135+
136+ return await self ._client .update (
137+ self ._path ,
138+ payload = payload ,
139+ ** kwargs ,
140+ )
141+
142+ async def bulk_delete (self , payload , ** kwargs ):
143+ """
144+ Delete a list of resources from this collection. This operation may not be supported
145+ by the API.
146+
147+ :param payload: JSON payload of the list of resources to delete.
148+ :type payload: list
149+ """
150+ if not isinstance (payload , (list , tuple )):
151+ raise TypeError ('`payload` must be a list or tuple.' )
152+
153+ return await self ._client .delete (
154+ self ._path ,
155+ payload = payload ,
156+ ** kwargs ,
157+ )
158+
43159
44160class ResourceMixin :
45161 def exists (self ):
0 commit comments