diff --git a/gcloud/apigw/views/copy_template_across_project.py b/gcloud/apigw/views/copy_template_across_project.py index 684c14b69..730358da5 100644 --- a/gcloud/apigw/views/copy_template_across_project.py +++ b/gcloud/apigw/views/copy_template_across_project.py @@ -31,6 +31,8 @@ from gcloud.iam_auth.view_interceptors.apigw import CopyTemplateInterceptor from gcloud.apigw.validators.copy_template_across_project import CopyTemplateAcrossProjectValidator +TEMPLATE_COPY_MAX_NUMBER = 10 + @login_exempt @csrf_exempt @@ -55,6 +57,12 @@ def copy_template_across_project(request, project_id): try: export_data = TaskTemplate.objects.export_templates(template_ids, is_full=False, project_id=request.project.id) + if len(export_data["template"]) > TEMPLATE_COPY_MAX_NUMBER: + return { + "result": False, + "message": "only {} templates can be copied once.".format(TEMPLATE_COPY_MAX_NUMBER), + "code": err_code.INVALID_OPERATION.code, + } import_result = TaskTemplate.objects.import_templates( template_data=export_data, override=False,