18
18
# See the License for the specific language governing permissions and
19
19
# limitations under the License.
20
20
21
- from pyatlan .model .typedef import TypeDefResponse
22
- from pyatlan .utils import API , BASE_URI , HTTPMethod , HTTPStatus
23
21
from pyatlan .client .atlan import AtlanClient
24
- from pyatlan .model .enums import AtlanTypeCategory
25
- from pyatlan .model .typedef import TypeDef , ClassificationDef , CustomMetadataDef
26
22
from pyatlan .exceptions import InvalidRequestException
23
+ from pyatlan .model .enums import AtlanTypeCategory
24
+ from pyatlan .model .typedef import (
25
+ ClassificationDef ,
26
+ CustomMetadataDef ,
27
+ TypeDef ,
28
+ TypeDefResponse ,
29
+ )
30
+ from pyatlan .utils import API , BASE_URI , HTTPMethod , HTTPStatus
27
31
28
32
29
33
class TypeDefClient :
@@ -55,9 +59,7 @@ def get_all_typedefs(self) -> TypeDefResponse:
55
59
return TypeDefResponse (** raw_json )
56
60
57
61
def get_typedefs (self , type : AtlanTypeCategory ) -> TypeDefResponse :
58
- query_params = {
59
- "type" : type .value
60
- }
62
+ query_params = {"type" : type .value }
61
63
raw_json = self .client .call_api (
62
64
TypeDefClient .GET_ALL_TYPE_DEFS .format_path_with_params (),
63
65
query_params ,
@@ -74,7 +76,7 @@ def create_typedef(self, typedef: TypeDef) -> TypeDefResponse:
74
76
struct_defs = [],
75
77
entity_defs = [],
76
78
relationship_defs = [],
77
- businessMetadataDefs = []
79
+ businessMetadataDefs = [],
78
80
)
79
81
elif isinstance (typedef , CustomMetadataDef ):
80
82
# Set up the request payload...
@@ -84,22 +86,25 @@ def create_typedef(self, typedef: TypeDef) -> TypeDefResponse:
84
86
struct_defs = [],
85
87
entity_defs = [],
86
88
relationship_defs = [],
87
- businessMetadataDefs = [typedef ]
89
+ businessMetadataDefs = [typedef ],
88
90
)
89
91
else :
90
92
raise InvalidRequestException (
91
- "Unable to create new type definitions of category: " + typedef .category .value ,
92
- param = "category"
93
+ "Unable to create new type definitions of category: "
94
+ + typedef .category .value ,
95
+ param = "category" ,
93
96
)
94
97
# Throw an invalid request exception
95
98
raw_json = self .client .call_api (
96
- TypeDefClient .CREATE_TYPE_DEFS ,
97
- request_obj = payload
99
+ TypeDefClient .CREATE_TYPE_DEFS , request_obj = payload
98
100
)
99
101
return TypeDefResponse (** raw_json )
100
102
101
103
def purge_typedef (self , internal_name : str ) -> None :
102
- self .client .call_api (TypeDefClient .DELETE_TYPE_DEF_BY_NAME .format_path_with_params (internal_name ))
104
+ self .client .call_api (
105
+ TypeDefClient .DELETE_TYPE_DEF_BY_NAME .format_path_with_params (internal_name )
106
+ )
107
+
103
108
104
109
if __name__ == "__main__" :
105
110
client = TypeDefClient (AtlanClient ())
0 commit comments