class Form(BaseComponentForm): msg_type = forms.CharField(label='msg type', required=True) receiver__username = ListField(label='recipients', required=True) sender = forms.CharField(label='mail sender', required=False) cc__username = ListField(label='CC', required=False) title = forms.CharField(label='subject', required=True) content = forms.CharField(label='content', required=True) body_format = forms.CharField(label='email format', required=False) attachments = TypeCheckField(label='attachments', promise_type=list, required=False) date = forms.CharField(label='notification sending time', required=False) remark = forms.CharField(label='notification tail text', required=False) wx_qy_agentid = forms.CharField(label='enterprise wechat agentid', required=False) wx_qy_corpsecret = forms.CharField(label='enterprise wechat corpsecret', required=False) is_content_base64 = DefaultBooleanField( label='content is encoded by base64 or not', default=False, required=False) def clean(self): data = self.cleaned_data if data['msg_type'] == "voice": data['auto_read_message'] = data['content'] if data['msg_type'] == "weixin": data['data'] = { 'heading': data['title'], 'message': data['content'], 'date': data['date'], 'remark': data['remark'], 'is_message_base64': data['is_content_base64'] } return data
class Form(BaseComponentForm): sender = forms.CharField(label='sender', required=False) receiver = ListField(label='email recipients', required=False) receiver__username = ListField(label='email recipients', required=False) cc = ListField(label='CC', required=False) cc__username = ListField(label='CC', required=False) title = forms.CharField(label='email subject', required=True) content = forms.CharField(label='email content', required=True) is_content_base64 = DefaultBooleanField( label='content is encoded by base64 or not', default=False, required=False) body_format = forms.CharField(label='email format', required=False) def clean(self): data = self.cleaned_data if not (data['receiver'] or data['receiver__username']): raise forms.ValidationError( 'Receiver [receiver, receiver__username] shall not be empty at the same time' ) if data['receiver']: data['receiver__username'] = None if data['cc']: data['cc__username'] = None if data['is_content_base64']: try: data['content'] = base64.b64decode(data['content']) except Exception: pass return data
class Form(BaseComponentForm): receiver = ListField(label='wechat receiver', required=False) receiver__username = ListField(label='wechat receiver', required=False) data = TypeCheckField(label='message data', promise_type=dict, required=True) def clean(self): data = self.cleaned_data if not (data['receiver'] or data['receiver__username']): raise forms.ValidationError( 'WeChat receiver [receiver, receiver__username] shall not be empty at the same time' ) if data['receiver']: data['receiver__username'] = None return { 'receiver': data['receiver'], 'receiver__username': data['receiver__username'], 'data': SendWeixin.DataForm(data['data']).get_cleaned_data_or_error(), }
class Form(BaseComponentForm): app_id = forms.IntegerField(label='business ID', required=True) app_name = forms.CharField(label='business name', required=False) maintainers = ListField(label='OPS', required=False) product_pm = ListField(label='PM', required=False) developer = ListField(label='developer', required=False) tester = ListField(label='test staff', required=False) operator = ListField(label='operator', required=False) life_cycle = forms.CharField(label='life cycle', required=False) def clean(self): cleaned_data = self.cleaned_data data = self.data to_cc_key_map = { 'app_id': 'ApplicationID', 'app_name': 'ApplicationName', 'maintainers': 'Maintainers', 'product_pm': 'ProductPm', 'developer': 'Developer', 'tester': 'Tester', 'operator': 'Operator', 'life_cycle': 'LifeCycle', } params = {} for bk_key, cc_key in to_cc_key_map.iteritems(): if data.get(bk_key) is not None: if bk_key in [ 'maintainers', 'product_pm', 'developer', 'tester', 'operator' ]: params[cc_key] = ','.join(cleaned_data[bk_key]) else: params[cc_key] = cleaned_data[bk_key] return params
class Form(BaseComponentForm): target_app_code = ListField(label='target app code', required=False) fields = ListField(label='fields', required=False) def clean(self): return { 'target_app_code': ';'.join(self.cleaned_data['target_app_code']), 'fields': ';'.join(self.cleaned_data['fields']) }
class Form(BaseComponentForm): app_id = forms.CharField(label='business ID', required=True) set_id = ListField(label='set ID', required=False) set_envi_type = ListField(label='set environment type', required=False) set_service_status = ListField(label='set service status', required=False) def clean(self): data = self.cleaned_data return { 'ApplicationID': data['app_id'], 'SetID': ','.join(data['set_id']), 'SetEnviType': ','.join(data['set_envi_type']), 'SetServiceStatus': ','.join(data['set_service_status']), }
class Form(BaseComponentForm): sdk_app_id = forms.CharField(label='tencent cloud sdkappid', required=True) app_key = forms.CharField(label='tencent cloud appkey', required=True) sign = forms.CharField(label='sms signature', required=False) tpl_id = forms.IntegerField(label='template id', required=True) params = TypeCheckField(label='template params', promise_type=list, required=False) nation_code = forms.CharField(label='nation code', required=False) phone_numbers = ListField(label='phone numbers', required=True) extend = forms.CharField(label='extend', required=False) ext = forms.CharField(label='ext', required=False) def clean(self): data = self.cleaned_data nation_code = data['nation_code'] or configs.default_nation_code new_data = { 'tel': [{ 'nationcode': nation_code, 'mobile': phone_number } for phone_number in data['phone_numbers']], 'sign': data['sign'], 'tpl_id': data['tpl_id'], 'params': data['params'], 'extend': data['extend'], 'ext': data['ext'], } return new_data
class Form(BaseComponentForm): sdk_app_id = forms.CharField(label=u'腾讯云sdkappid', required=True) app_key = forms.CharField(label=u'腾讯云appkey', required=True) sms_type = forms.IntegerField(label=u'短信类型', required=False) nation_code = forms.CharField(label=u'国家码', required=False) phone_numbers = ListField(label=u'不带国家码的手机号', required=True) content = forms.CharField(label=u'消息内容', required=True) extend = forms.CharField(label=u'通道扩展码', required=False) ext = forms.CharField(label=u'服务端原样返回的参数', required=False) def clean(self): data = self.cleaned_data nation_code = data['nation_code'] or configs.default_nation_code new_data = { 'tel': [{ 'nationcode': nation_code, 'mobile': phone_number } for phone_number in data['phone_numbers']], 'type': data['sms_type'] or 0, 'msg': data['content'], 'extend': data['extend'], 'ext': data['ext'], } return new_data
class Form(BaseComponentForm): app_id = forms.CharField(label='business ID', required=True) set_names = ListField(label='set name', required=True) chn_name = forms.CharField(label='chinese name', required=False) group_flag = forms.CharField(label='group flag', required=False) env_type = forms.IntegerField(label='environment type', required=False) service_status = forms.IntegerField(label='service status', required=False) capacity = forms.IntegerField(label='capacity', required=False) des = forms.CharField(label='description', required=False) def clean(self): data = self.cleaned_data property_data = { 'ChnName': data.get('chn_name'), 'GroupFlag': data.get('group_flag'), 'EnviType': data.get('env_type'), 'ServiceStatus': data.get('service_status'), 'Capacity': data.get('capacity'), 'Description': data.get('des') } property_data = {key: val for key, val in property_data.iteritems() if val or val == 0} return { 'ApplicationID': data['app_id'], 'SetName': ','.join(data['set_names']).encode('utf-8'), 'properties': json.dumps(property_data) }
class Form(BaseComponentForm): sdk_app_id = forms.CharField(label=u'腾讯云sdkappid', required=True) app_key = forms.CharField(label=u'腾讯云appkey', required=True) sign = forms.CharField(label=u'短信签名', required=False) tpl_id = forms.IntegerField(label=u'短信模版ID', required=True) params = TypeCheckField(label=u'模版参数', promise_type=list, required=False) nation_code = forms.CharField(label=u'国家码', required=False) phone_numbers = ListField(label=u'不带国家码的手机号', required=True) extend = forms.CharField(label=u'通道扩展码', required=False) ext = forms.CharField(label=u'服务端原样返回的参数', required=False) def clean(self): data = self.cleaned_data nation_code = data['nation_code'] or configs.default_nation_code new_data = { 'tel': [ {'nationcode': nation_code, 'mobile': phone_number} for phone_number in data['phone_numbers'] ], 'sign': data['sign'], 'tpl_id': data['tpl_id'], 'params': data['params'], 'extend': data['extend'], 'ext': data['ext'], } return new_data
class Form(BaseComponentForm): appid = forms.CharField(label='wechat appid', required=True) secret = forms.CharField(label='wechat app secret', required=True) touser = ListField(label='touser', required=True) template_id = forms.CharField(label='template ID', required=True) data = TypeCheckField(label='message data', promise_type=dict, required=False)
class Form(BaseComponentForm): ips = ListField(label=u'主机内网IP', required=True) def clean(self): data = self.cleaned_data return { 'Ips': ','.join(data['ips']), }
class Form(BaseComponentForm): bk_host_id = ListField(label='host ids', required=True) data = TypeCheckField(label='data', promise_type=dict, required=False) def clean(self): data = self.cleaned_data data['data'].update(bk_host_id=','.join(map(str, data['bk_host_id']))) return data['data']
class Form(BaseComponentForm): user_role = ListField(label='user role', required=True) def clean(self): data = self.cleaned_data return { 'roleList': ','.join(data['user_role']), }
class Form(BaseComponentForm): receiver = ListField(label='wechat receiver', required=True) content = forms.CharField(label=u'message content', required=True) def clean(self): return { 'touser': self.cleaned_data['receiver'], 'content': self.cleaned_data['content'], }
class Form(BaseComponentForm): ips = ListField(label='ip address', required=True) hostname = ListField(label='hostname', required=False) app_name = forms.CharField(label='business name', required=False) set_name = forms.CharField(label='set name', required=False) module_name = forms.CharField(label='module name', required=False) os_type = forms.CharField(label='OS type', required=False) def clean(self): data = self.cleaned_data return { 'ip': ','.join(data['ips']), 'hostname': ','.join(data['hostname']), 'appName': data['app_name'], 'setName': data['set_name'], 'moduleName': data['module_name'], 'osType': data['os_type'], }
class Form(BaseComponentForm): application_ids = ListField(label='business IDs', required=True) type = forms.IntegerField(label='type', required=True) def clean(self): data = self.cleaned_data return { 'ApplicationIDs': ','.join(data['application_ids']), 'Type': data['type'], }
class Form(BaseComponentForm): app_id = forms.CharField(label='business ID', required=True) module_ids = ListField(label='module IDs', required=True) def clean(self): data = self.cleaned_data return { 'ApplicationID': data['app_id'], 'ModuleID': ','.join(data['module_ids']), }
class Form(BaseComponentForm): bk_supplier_account = forms.CharField(label='bk supplier account', required=False) bk_host_id = ListField(label='host ids', required=True) def clean(self): data = self.get_cleaned_data_when_exist() data.setdefault('bk_supplier_account', configs.DEFAULT_BK_SUPPLIER_ACCOUNT) data['bk_host_id'] = ','.join(data['bk_host_id']) return data
class Form(BaseComponentForm): app_id = forms.IntegerField(label='business ID', required=True) plat_id = forms.IntegerField(label='subnet ID', required=True) ip_list = ListField(label='ip list', required=True) def clean(self): data = self.cleaned_data return { 'appId': data['app_id'], 'platId': data['plat_id'], 'ipList': ','.join(data['ip_list']), }
class Form(BaseComponentForm): app_id = forms.IntegerField(label='business ID', required=True) ip = forms.CharField(label='intranet IP', required=True) plat_id = forms.IntegerField(label='subnet ID', required=True) dst_module_id = ListField(label='target module ID', required=True) def clean(self): data = self.cleaned_data return { 'ApplicationID': data['app_id'], 'ip': data['ip'], 'platId': data['plat_id'], 'dstModuleID': ','.join(data['dst_module_id']), }
class Form(BaseComponentForm): receiver = ListField(label='wechat receiver', required=True) data = TypeCheckField(label='message data', promise_type=dict, required=True) def clean(self): data = self.cleaned_data return { 'touser': data['receiver'], 'data': SendMpWeixin.DataForm( data['data']).get_cleaned_data_or_error(), }
class Form(BaseComponentForm): receiver = ListField(label='SMS receiver', required=False) receiver__username = ListField(label='SMS receiver', required=False) content = forms.CharField(label='message content', required=True) is_content_base64 = DefaultBooleanField( label='content is encoded by base64 or not', default=False, required=False) def decode_content(self, content, is_content_base64): if is_content_base64: try: content = base64.b64decode(content) except Exception: pass return content def clean(self): data = self.cleaned_data if data['receiver']: data['receiver__username'] = None data['content'] = self.decode_content(data['content'], data['is_content_base64']) return data
class Form(BaseComponentForm): app_name = forms.CharField(label='business name', required=True) maintainers = ListField(label='OPS', required=True) product_pm = ListField(label='PM', required=False) developer = ListField(label='developer', required=False) tester = ListField(label='test staff', required=False) operator = ListField(label='operator', required=False) company_name = forms.CharField(label='company name', required=True) level = forms.IntegerField(label='business topology level', required=True) life_cycle = forms.CharField(label='life cycle', required=True) def clean(self): data = self.cleaned_data return { 'ApplicationName': data['app_name'], 'Maintainers': ','.join(data['maintainers']), 'ProductPm': ','.join(data['product_pm']), 'Developer': ','.join(data['developer']), 'Tester': ','.join(data['tester']), 'Operator': ','.join(data['operator']), 'CompanyName': data['company_name'], 'Level': data['level'], 'LifeCycle': data['life_cycle'], }
class Form(BaseComponentForm): bk_light_app_name = forms.CharField(label='bk light app name', required=True) app_url = forms.CharField(label='app url', required=True) developer = ListField(label='developer', required=True) app_tag = forms.CharField(label='app tag', required=False) introduction = forms.CharField(label='introduction', required=False) width = forms.IntegerField(label='width', required=False) height = forms.IntegerField(label='height', required=False) def clean(self): param_keys = [ 'bk_light_app_name', 'app_url', 'developer', 'app_tag', 'introduction', 'width', 'height' ] params = self.get_cleaned_data_when_exist(param_keys) params['developer'] = ';'.join(params['developer']) return params
class Form(BaseComponentForm): auto_read_message = forms.CharField(label='auto voice reading info', required=True) user_list_information = TypeCheckField(label='user list', promise_type=list, required=False) receiver__username = ListField(label='BlueKing user list', required=False) def clean(self): data = self.cleaned_data user_list_information = [ SendVoiceMsg.UserListInfoForm(user_info).get_cleaned_data_or_error() for user_info in data['user_list_information'] if user_info ] if not (data.get('receiver__username') or user_list_information): raise forms.ValidationError( 'The parameters [user_list_information and receiver__username] shall not be empty at the same time') data['user_list_information'] = user_list_information if user_list_information: data['receiver__username'] = None return data
class Form(BaseComponentForm): app_id = forms.IntegerField(label='business ID', required=True) set_id = forms.IntegerField(label='set ID', required=True) module_name = ListField(label='module name', required=False) operator = forms.CharField(label='operator', required=False) bak_operator = forms.CharField(label='backup operator', required=False) module_type = forms.IntegerField(label='module type', required=False) properties = TypeCheckField(label='module properties', promise_type=dict, required=False) def clean(self): data = self.cleaned_data return { 'ApplicationID': data['app_id'], 'SetID': data['set_id'], 'ModuleName': ','.join(data['module_name']), 'Operator': data['operator'], 'BakOperator': data['bak_operator'], 'ModuleType': data['module_type'], 'properties': json.dumps(data['properties']), }
class Form(BaseComponentForm): auto_read_message = forms.CharField(label=u'自动语音读字信息', required=True) user_list_information = TypeCheckField(label=u'用户列表', promise_type=list, required=False) receiver__username = ListField(label=u'蓝鲸用户列表', required=False) def clean(self): data = self.cleaned_data user_list_information = [ NocNotice.UserListInfoForm( user_info).get_cleaned_data_or_error() for user_info in data['user_list_information'] if user_info ] if not (data.get('receiver__username') or user_list_information): raise forms.ValidationError( u'参数[user_list_information、receiver__username]不能同时为空') data['user_list_information'] = user_list_information if user_list_information: data['receiver__username'] = None return data
class Form(BaseComponentForm): sdk_app_id = forms.CharField(label='tencent cloud sdkappid', required=True) app_key = forms.CharField(label='tencent cloud appkey', required=True) sms_type = forms.IntegerField(label='sms type', required=False) nation_code = forms.CharField(label='nation code', required=False) phone_numbers = ListField(label='phone numbers', required=True) content = forms.CharField(label='content', required=True) extend = forms.CharField(label='extend', required=False) ext = forms.CharField(label='ext', required=False) def clean(self): data = self.cleaned_data nation_code = data['nation_code'] or configs.default_nation_code new_data = { 'tel': [ {'nationcode': nation_code, 'mobile': phone_number} for phone_number in data['phone_numbers'] ], 'type': data['sms_type'] or 0, 'msg': data['content'], 'extend': data['extend'], 'ext': data['ext'], } return new_data
class Form(BaseComponentForm): bk_username_list = ListField(label='username list', required=True) bk_token = forms.CharField(label='login token', required=False)