22# If you have any remark or suggestion do not hesitate to open an issue.
33
44from typing import Any , Dict
5+ from dateutil import parser
56
67from scaleway_core .profile import ProfileDefaults
7- from dateutil import parser
88from .types import (
9- ListProjectsResponse ,
109 Project ,
10+ ListProjectsResponse ,
1111 CreateProjectRequest ,
1212 UpdateProjectRequest ,
1313)
1414
1515
1616def unmarshal_Project (data : Any ) -> Project :
17- if type (data ) is not dict :
17+ if not isinstance (data , dict ) :
1818 raise TypeError (
19- f "Unmarshalling the type 'Project' failed as data isn't a dictionary."
19+ "Unmarshalling the type 'Project' failed as data isn't a dictionary."
2020 )
2121
2222 args : Dict [str , Any ] = {}
2323
24- field = data .get ("created_at" , None )
25- args ["created_at" ] = parser .isoparse (field ) if type (field ) is str else field
26-
27- field = data .get ("description" , None )
28- args ["description" ] = field
29-
3024 field = data .get ("id" , None )
31- args ["id" ] = field
25+ if field is not None :
26+ args ["id" ] = field
3227
3328 field = data .get ("name" , None )
34- args ["name" ] = field
29+ if field is not None :
30+ args ["name" ] = field
3531
3632 field = data .get ("organization_id" , None )
37- args ["organization_id" ] = field
33+ if field is not None :
34+ args ["organization_id" ] = field
35+
36+ field = data .get ("description" , None )
37+ if field is not None :
38+ args ["description" ] = field
39+
40+ field = data .get ("created_at" , None )
41+ if field is not None :
42+ args ["created_at" ] = parser .isoparse (field ) if isinstance (field , str ) else field
3843
3944 field = data .get ("updated_at" , None )
40- args ["updated_at" ] = parser .isoparse (field ) if type (field ) is str else field
45+ if field is not None :
46+ args ["updated_at" ] = parser .isoparse (field ) if isinstance (field , str ) else field
4147
4248 return Project (** args )
4349
4450
4551def unmarshal_ListProjectsResponse (data : Any ) -> ListProjectsResponse :
46- if type (data ) is not dict :
52+ if not isinstance (data , dict ) :
4753 raise TypeError (
48- f "Unmarshalling the type 'ListProjectsResponse' failed as data isn't a dictionary."
54+ "Unmarshalling the type 'ListProjectsResponse' failed as data isn't a dictionary."
4955 )
5056
5157 args : Dict [str , Any ] = {}
5258
53- field = data .get ("projects" , None )
54- args ["projects" ] = (
55- [unmarshal_Project (v ) for v in field ] if field is not None else None
56- )
57-
5859 field = data .get ("total_count" , None )
59- args ["total_count" ] = field
60+ if field is not None :
61+ args ["total_count" ] = field
62+
63+ field = data .get ("projects" , None )
64+ if field is not None :
65+ args ["projects" ] = (
66+ [unmarshal_Project (v ) for v in field ] if field is not None else None
67+ )
6068
6169 return ListProjectsResponse (** args )
6270
@@ -67,9 +75,6 @@ def marshal_CreateProjectRequest(
6775) -> Dict [str , Any ]:
6876 output : Dict [str , Any ] = {}
6977
70- if request .description is not None :
71- output ["description" ] = request .description
72-
7378 if request .name is not None :
7479 output ["name" ] = request .name
7580
@@ -78,6 +83,9 @@ def marshal_CreateProjectRequest(
7883 request .organization_id or defaults .default_organization_id
7984 )
8085
86+ if request .description is not None :
87+ output ["description" ] = request .description
88+
8189 return output
8290
8391
@@ -87,10 +95,10 @@ def marshal_UpdateProjectRequest(
8795) -> Dict [str , Any ]:
8896 output : Dict [str , Any ] = {}
8997
90- if request .description is not None :
91- output ["description" ] = request .description
92-
9398 if request .name is not None :
9499 output ["name" ] = request .name
95100
101+ if request .description is not None :
102+ output ["description" ] = request .description
103+
96104 return output
0 commit comments