Skip to content

Commit

Permalink
fix: 修改接口名称 TencentBlueKing#7626
Browse files Browse the repository at this point in the history
  • Loading branch information
guohelu committed Dec 13, 2024
1 parent faa50e3 commit 0bd5bd3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
11 changes: 5 additions & 6 deletions gcloud/contrib/template_market/clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,22 @@ def __init__(self):
def _get_url(self, endpoint):
return f"{self.base_url}{endpoint}"

def get_template_detail(self, market_record_id):
def get_shared_detail(self, market_record_id):
url = self._get_url(f"/sre_scene/flow_template_scene/{market_record_id}/")
cookies = {"bk_ticket": "5IT20mfD9mI_uTitTrUuDKTp9GIif7ZaBivi9E6k5qw"}
response = requests.get(url, cookies=cookies)
response = requests.get(url)
return response.json()

def get_market_template_list(self):
def get_shared_list(self):
url = self._get_url("/sre_scene/flow_template_scene/?is_all=true")
response = requests.get(url)
return response.json()

def create_market_template_record(self, data):
def create_shared_record(self, data):
url = self._get_url("/sre_scene/flow_template_scene/")
response = requests.post(url, json=data)
return response.json()

def patch_market_template_record(self, data, market_record_id):
def patch_shared_record(self, data, market_record_id):
url = self._get_url(f"/sre_scene/flow_template_scene/{market_record_id}/")
response = requests.patch(url, json=data)
return response.json()
8 changes: 4 additions & 4 deletions gcloud/contrib/template_market/viewsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def _build_template_data(self, serializer, **kwargs):
return data

def list(self, request, *args, **kwargs):
response_data = self.market_client.get_market_template_list()
response_data = self.market_client.get_shared_list()

if not response_data["result"]:
logging.exception("Failed to obtain the market template list")
Expand All @@ -97,7 +97,7 @@ def create(self, request, *args, **kwargs):
serializer.is_valid(raise_exception=True)

data = self._build_template_data(serializer)
response_data = self.market_client.create_market_template_record(data)
response_data = self.market_client.create_shared_record(data)
if not response_data.get("result"):
return Response(
{
Expand All @@ -119,10 +119,10 @@ def partial_update(self, request, *args, **kwargs):
market_record_id = kwargs["pk"]
serializer = self.serializer_class(data=request.data, partial=True)
serializer.is_valid(raise_exception=True)
existing_records = self.market_client.get_template_detail(market_record_id)
existing_records = self.market_client.get_shared_detail(market_record_id)
existing_template_ids = set([template["id"] for template in json.loads(existing_records["data"]["templates"])])
data = self._build_template_data(serializer, market_record_id=market_record_id)
response_data = self.market_client.patch_market_template_record(data, market_record_id)
response_data = self.market_client.patch_shared_record(data, market_record_id)
if not response_data.get("result"):
return Response(
{
Expand Down

0 comments on commit 0bd5bd3

Please sign in to comment.