55
66from __future__ import annotations
77
8- import json
9- from typing import Any
10-
8+ from gitlab import types
119from gitlab .base import RESTObject
1210from gitlab .mixins import CRUDMixin , ObjectDeleteMixin , SaveMixin
1311from gitlab .types import RequiredOptional
@@ -28,53 +26,4 @@ class ProjectFeatureFlagManager(CRUDMixin[ProjectFeatureFlag]):
2826 )
2927 _update_attrs = RequiredOptional (optional = ("description" , "active" , "strategies" ))
3028 _list_filters = ("scope" ,)
31-
32- def create (
33- self , data : dict [str , Any ] | None = None , ** kwargs : Any
34- ) -> ProjectFeatureFlag :
35- """Create a new object.
36-
37- Args:
38- data: Parameters to send to the server to create the
39- resource
40- **kwargs: Extra options to send to the server (e.g. sudo)
41-
42- Returns:
43- A new instance of the managed object class build with
44- the data sent by the server
45- """
46- # Handle strategies being passed as a JSON string (e.g. from CLI)
47- if "strategies" in kwargs and isinstance (kwargs ["strategies" ], str ):
48- kwargs ["strategies" ] = json .loads (kwargs ["strategies" ])
49- if data and "strategies" in data and isinstance (data ["strategies" ], str ):
50- data ["strategies" ] = json .loads (data ["strategies" ])
51-
52- return super ().create (data , ** kwargs )
53-
54- def update (
55- self ,
56- id : str | int | None = None ,
57- new_data : dict [str , Any ] | None = None ,
58- ** kwargs : Any ,
59- ) -> dict [str , Any ]:
60- """Update an object on the server.
61-
62- Args:
63- id: ID of the object to update (can be None if not required)
64- new_data: the update data for the object
65- **kwargs: Extra options to send to the server (e.g. sudo)
66-
67- Returns:
68- The new object data (*not* a RESTObject)
69- """
70- # Handle strategies being passed as a JSON string (e.g. from CLI)
71- if "strategies" in kwargs and isinstance (kwargs ["strategies" ], str ):
72- kwargs ["strategies" ] = json .loads (kwargs ["strategies" ])
73- if (
74- new_data
75- and "strategies" in new_data
76- and isinstance (new_data ["strategies" ], str )
77- ):
78- new_data ["strategies" ] = json .loads (new_data ["strategies" ])
79-
80- return super ().update (id , new_data , ** kwargs )
29+ _types = {"strategies" : types .JsonAttribute }
0 commit comments