2018-08-16 12:36:27 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
import sys
|
|
|
|
import base
|
2021-04-15 11:27:58 +02:00
|
|
|
import v2_swagger_client
|
|
|
|
from v2_swagger_client.rest import ApiException
|
|
|
|
|
|
|
|
class Label(base.Base, object):
|
|
|
|
def __init__(self):
|
|
|
|
super(Label,self).__init__(api_type = "label")
|
2018-08-16 12:36:27 +02:00
|
|
|
|
2020-12-16 11:06:41 +01:00
|
|
|
def create_label(self, name=None, desc="", color="", scope="g",
|
|
|
|
project_id=0, expect_status_code = 201, **kwargs):
|
2018-11-30 06:32:20 +01:00
|
|
|
if name is None:
|
|
|
|
name = base._random_name("label")
|
2021-04-15 11:27:58 +02:00
|
|
|
label = v2_swagger_client.Label(name=name,
|
2020-12-16 11:06:41 +01:00
|
|
|
description=desc, color=color,
|
2018-08-16 12:36:27 +02:00
|
|
|
scope=scope, project_id=project_id)
|
|
|
|
client = self._get_client(**kwargs)
|
2020-12-16 11:06:41 +01:00
|
|
|
|
|
|
|
try:
|
2021-04-15 11:27:58 +02:00
|
|
|
_, status_code, header = client.create_label_with_http_info(label)
|
2020-12-16 11:06:41 +01:00
|
|
|
except ApiException as e:
|
|
|
|
base._assert_status_code(expect_status_code, e.status)
|
|
|
|
else:
|
|
|
|
base._assert_status_code(expect_status_code, status_code)
|
|
|
|
base._assert_status_code(201, status_code)
|
|
|
|
return base._get_id_from_header(header), name
|
|
|
|
|
2018-11-01 11:26:04 +01:00
|
|
|
def delete_label(self, label_id, **kwargs):
|
|
|
|
client = self._get_client(**kwargs)
|
2021-04-15 11:27:58 +02:00
|
|
|
return client.delete_label_with_http_info(int(label_id))
|