{"id":13709738,"url":"https://github.com/chanyipiaomiao/devops-api","last_synced_at":"2026-02-05T03:30:25.183Z","repository":{"id":43642963,"uuid":"123130558","full_name":"chanyipiaomiao/devops-api","owner":"chanyipiaomiao","description":"Golang + Beego 编写 提供开发/运维常用操作的HTTP API接口:  手机归属地查询、IP地址查询、工作日节假日判断、微信报警、钉钉报警、2步验证、密码存储、发送邮件、生成随机密码等功能","archived":false,"fork":false,"pushed_at":"2019-04-02T01:58:12.000Z","size":480,"stargazers_count":311,"open_issues_count":0,"forks_count":102,"subscribers_count":29,"default_branch":"master","last_synced_at":"2025-08-14T12:28:26.915Z","etag":null,"topics":["alert","api","beego","devops","devops-api","dingding","dingding-alert","dingtalk","go","golang","google-authenticator","holiday","holiday-api","md5","password","password-store","sendmail","two-factor-authentication","weixin","weixin-alert"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chanyipiaomiao.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-02-27T13:08:29.000Z","updated_at":"2025-05-21T04:08:01.000Z","dependencies_parsed_at":"2022-09-24T23:31:34.875Z","dependency_job_id":null,"html_url":"https://github.com/chanyipiaomiao/devops-api","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/chanyipiaomiao/devops-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chanyipiaomiao%2Fdevops-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chanyipiaomiao%2Fdevops-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chanyipiaomiao%2Fdevops-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chanyipiaomiao%2Fdevops-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chanyipiaomiao","download_url":"https://codeload.github.com/chanyipiaomiao/devops-api/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chanyipiaomiao%2Fdevops-api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29109299,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-05T03:27:05.906Z","status":"ssl_error","status_checked_at":"2026-02-05T03:26:43.416Z","response_time":65,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["alert","api","beego","devops","devops-api","dingding","dingding-alert","dingtalk","go","golang","google-authenticator","holiday","holiday-api","md5","password","password-store","sendmail","two-factor-authentication","weixin","weixin-alert"],"created_at":"2024-08-02T23:00:44.935Z","updated_at":"2026-02-05T03:30:25.168Z","avatar_url":"https://github.com/chanyipiaomiao.png","language":"Go","readme":"# devops-api\n\nGolang + Beego编写, 提供一些开发/运维常见操作的HTTP API接口，提供开发/运维常用操作的HTTP API接口: 手机归属地查询、IP地址查询、工作日节假日判断、微信报警、钉钉报警、2步验证、密码存储、发送邮件、生成随机密码等功能\n\n# 主要功能\n\n- 手机归属地查询\n- IP地址查询\n- 工作日节假日判断\n- 微信报警\n- 钉钉报警\n- 2步验证(Google Authenticator验证)\n- 密码存储\n- 发送邮件\n- 生成随机密码\n- 获取字符串的MD5值\n- 生成验证密码\n\n更多功能,正在思考中...\n\n# 目录\n- [安装使用](#安装使用)\n- [依赖](#依赖)\n- [功能列表](#功能列表)\n    - [手机归属地查询](#手机归属地查询)\n    - [IP地址查询](#ip地址查询)\n\t- [工作日节假日判断](#工作日节假日判断)\n\t\t- [设置节假日和工作日](#设置节假日和工作日)\n\t\t- [判断给定的日期是节假日/工作日/周末](#判断给定的日期是节假日工作日周末)\n\t- [微信报警](#微信报警)\n\t\t- [发送微信消息](#发送微信消息)\n\t- [钉钉报警](#钉钉报警)\n\t\t- [发送钉钉消息](#发送钉钉消息)\n\t- [2步验证](#2步验证)\n\t\t- [启用2步验证](#启用2步验证)\n\t\t- [验证6位数字](#验证google-authenticator或是其他的类似的app生成的6位数字)\n\t\t- [禁用2步验证](#禁用2步验证)\n\t- [密码存储](#密码存储)\n\t\t- [存储](#存储)\n\t\t- [查询](#查询)\n\t\t- [删除](#删除)\n\t- [发送邮件](#发送邮件)\n\t\t- [api接口](#发送邮件api接口)\n\t\t- [Curl 示例](#curl-示例)\n\t\t- [Python 文本邮件/html邮件 示例](#python-文本邮件html邮件-示例)\n\t\t- [Python 发送带附件邮件 示例](#python-发送带附件邮件-示例)\n\t\t- [Go 文本邮件/html邮件 示例](#go-文本邮件html邮件-示例)\n\t\t- [Go 发送带附件的邮件 示例](#go-发送带附件的邮件-示例)\n\t- [生成随机密码](#生成随机密码)\n\t\t- [api接口](#生成随机密码api接口)\n\t\t- [Curl 示例](#curl-示例)\n\t\t- [别名使用](#别名使用)\n\t\t- [Python示例](#python示例)\n\t\t- [Go示例](#go示例)\n\t- [获取字符串的MD5值](#获取字符串的md5值)\n\t\t- [api接口](#获取字符串的md5值api接口)\n\t- [生成验证密码](#生成验证密码)\n\t\t- [生成验证密码](#生成验证密码)\n\t\t\t- [api接口](#生成验证密码api接口)\n\t\t- [验证上面的密码是否正确](#验证上面的密码是否正确)\n\t\t\t- [api接口](#验证密码api接口)\n\t- [获取程序自身版本信息](#获取程序自身版本信息)\n\t\t- [api接口](#获取程序自身版本信息api接口)\n\n\n# 安装使用\n\n## 安装\n\n直接[**下载**](https://github.com/chanyipiaomiao/devops-api/releases)二级制文件即可\n\n## 使用\n\n配置文件说明:\n\n- app.conf          主配置文件\n- dev.conf          开发时的配置文件\n- prod.conf         线上生产运行时的配置文件\n- authpassword.conf 验证密码配置文件\n- db.conf           数据库配置文件\n- email.conf        邮箱用户名和密码配置\n- log.conf          日志相关配置\n- security.conf     安全相关的配置\n- twostep.conf      2步验证相关\n- weixin.conf       微信报警相关\n- phone.conf        手机归属地查询配置\n\n主配置文件 app.conf 通过include的方式加载其他的配置文件\n\n\n**注意: 如果配置文件security.conf中, security-\u003eenableToken 的值是 false, 可以跳过 步骤2 和 步骤3, 默认为true, 如果是false 可以不用在请求头里面添加 DEVOPS-API-TOKEN 头**\n\n\n1. 自定义配置(**该步骤可选**)\n\n\t- 配置监听端口\n\t- 配置上传目录,确保有权限写入\n\t- 配置日志目录,默认情况当前目录下,确保有权限写入\n\t- 配置日志最大存放天数\n\t- 配置邮箱地址、端口、用户名、密码\n\t- 配置是否启用token验证\n\t- 配置jwt token签名字符串,请自行生成修改\n\t- 配置微信报警的配置, corpID、warningAppAgentID、warningAppSecret,可参考文档[设置微信报警流程](/doc/weixin.md)\n\t- 配置钉钉机器人的URL(**可选**)\n\n2. 首先初始化, 会生成root token，该root token 管理其他的token(**该步骤可选**)\n\n```sh\n./devops-api init\n```\n\n```sh\n注意: 忘记root token, 可以使用以下重新生成\n\n./devops-api init --refresh-root-token\n```\n\n3. 使用root token 生成普通的token，用于验证请求(**该步骤可选**)\n\n```sh\n./devops-api token --create=名称 --root-token=上边的root token\n\n注意：忘记token，重新生成即可\n```\n\n4. 启动服务\n\n```sh\n./devops-api server --mode=prod\n\n--mode 指定程序运行模式, prod: 生产模式 dev: 开发模式, 默认是开发模式\n\n也可以在配置文件app.conf中修改 runmode=prod 也可以设置为生产模式\n```\n\n```sh\n使用生成token就能愉快的访问API了\n\n注意: token必须放到请求头里面,名称必须是: DEVOPS-API-TOKEN\n```\n\n5. 获取帮助\n\n```sh\n./devops-api --help\n```\n\n6. 备份数据库文件\n\n```sh\n./devops-api backup --filepath=备份文件路径\n```\n\n[返回到目录](#目录)\n\n# 开发依赖\n\n```go\ngo get github.com/astaxie/beego\ngo get github.com/robfig/cron\ngo get gopkg.in/alecthomas/kingpin.v2\ngo get github.com/satori/go.uuid\ngo get github.com/sec51/twofactor\ngo get github.com/tidwall/gjson\ngo get github.com/chanyipiaomiao/hltool\ngo get github.com/chanyipiaomiao/weixin-kit\ngo get github.com/chanyipiaomiao/cal\ngo get github.com/chanyipiaomiao/ip2region/binding/golang\ngo get github.com/chanyipiaomiao/phonedata\n```\n\n[返回到目录](#目录)\n\n# API\n\n## 手机归属地查询\n\n本功能使用了 [xluohome](https://github.com/xluohome/phonedata) 项目提供的手机归属地数据库\n\n首先进入到script目录，执行 get_phone_dat.sh 来下载数据文件，可以定期执行脚本获取最新的.\n\n```sh\n/api/v1/queryphone?phone=手机号\n\nphone 要查询的手机号\n```\n\n返回:\n\n```sh\n{\n    \"data\": {\n        \"AreaZone\": \"021\",\n        \"CardType\": \"中国移动\",\n        \"City\": \"上海\",\n        \"PhoneNum\": \"xxxxxxxxxx\",\n        \"Province\": \"上海\",\n        \"ZipCode\": \"200000\"\n    },\n    \"entryType\": \"Query Phone Location\",\n    \"errmsg\": \"\",\n    \"requestId\": \"0860edaa-db7f-46ee-ac89-d41eeb2ed80d\",\n    \"statuscode\": 0\n}\n```\n\n## IP地址查询\n\n本功能使用了 [狮子的魂](https://gitee.com/lionsoul/ip2region) 项目提供的IP地址数据库.\n\n首先进入到script目录, 执行 gen_ip_region.sh 脚本, 来下载IP地址数据库, 可以定期执行脚本获取最新的.\n\n\n```sh\nGET /api/v1/queryip?ip=xxx.xxx.xxx.xxx\n\nip  要查询的IP地址\n```\n\n返回: \n\n```sh\n{\n    \"data\": {\n        \"ip\": \"xxx.xxx.xxx.xxx\",\n        \"ipInfo\": {\n            \"CityId\": 995,\n            \"Country\": \"中国\",\n            \"Region\": \"0\",\n            \"Province\": \"上海\",\n            \"City\": \"上海市\",\n            \"ISP\": \"电信\"\n        }\n    },\n    \"entryType\": \"Query IP\",\n    \"errmsg\": \"\",\n    \"requestId\": \"6aae483e-5c72-4cb7-bbb7-50089e2da4d3\",\n    \"statuscode\": 0\n}\n```\n\n[返回到目录](#目录)\n\n## 工作日节假日判断\n\n#### 设置节假日和工作日\n\n```sh\nPOST /api/v1/holiworkday\n\n设置头部: Content-Type: application/json\n\n内容: 参考下面的模板\n```\n节假日和工作日模板json, 每年都要根据国内的放假安排提前做一下设置,毕竟国内放假安排不是固定的,日期不足2位必须补0\n\nworkday 是指放假安排中的调整上班的日期\n\n```sh\n{\n    \"year\": \"2018\",\n    \"holiday\": [\n        {\n            \"name\": \"yuandan\",\n            \"zh_name\": \"元旦\",\n            \"start_time\": \"2018-01-01\",\n            \"end_time\": \"2018-01-01\"\n        },\n        {\n            \"name\": \"chunjie\",\n            \"zh_name\": \"春节\",\n            \"start_time\": \"2018-02-15\",\n            \"end_time\": \"2018-02-21\"\n        },\n        {\n            \"name\": \"qingming\",\n            \"zh_name\": \"清明节\",\n            \"start_time\": \"2018-04-05\",\n            \"end_time\": \"2018-04-07\"\n        },\n        {\n            \"name\": \"laodong\",\n            \"zh_name\": \"劳动节\",\n            \"start_time\": \"2018-04-29\",\n            \"end_time\": \"2018-05-01\"\n        },\n        {\n            \"name\": \"duanwu\",\n            \"zh_name\": \"端午节\",\n            \"start_time\": \"2018-06-16\",\n            \"end_time\": \"2018-06-18\"\n        },\n        {\n            \"name\": \"zhongqiu\",\n            \"zh_name\": \"中秋节\",\n            \"start_time\": \"2018-09-22\",\n            \"end_time\": \"2018-09-24\"\n        },\n        {\n            \"name\": \"guoqing\",\n            \"zh_name\": \"国庆节\",\n            \"start_time\": \"2018-10-01\",\n            \"end_time\": \"2018-10-07\"\n        }\n    ],\n    \"workday\": [\n        \"2018-02-11\",\n        \"2018-02-24\",\n        \"2018-04-08\",\n        \"2018-04-28\",\n        \"2018-09-29\",\n        \"2018-09-30\"\n    ]\n}\n```\n\n[返回到目录](#目录)\n\n#### 判断给定的日期是节假日工作日周末\n\n```sh\nGET /api/v1/holiworkday?date=2018-08-25\n\ndate: 判断的日期, 日期格式不足2位必须补0\n```\n\n返回:\n```sh\n{\n    \"data\": {\n        \"date\": \"2018-08-25\",\n        \"dateType\": \"weekend\"\n    },\n    \"entryType\": \"Get Holiday/Workday\",\n    \"errmsg\": \"\",\n    \"requestId\": \"562444c2-1a48-4c69-9ed1-d2553dea3cba\",\n    \"statuscode\": 0\n}\n\ndateType: 有3种 workday: 工作日  holiday: 节假日  weekend: 周末\n```\n\n[返回到目录](#目录)\n\n## 微信报警\n\n点击查看设置[微信报警流程](/doc/weixin.md)\n\n还需要在 conf/app.conf 中配置已下3个参数\n- corpID \t\t\t\t公司或者组织的ID\n- warningAppAgentID\t\t报警应用的ID\n- warningAppSecret    \t报警应用的密钥\n\n这3个参数可以在企业微信后台管理页面可以看到，详情可以查看上面的文档。\n\n\n#### 发送微信消息\n\n```sh\nPOST /api/v1/sendmsg/weixin\n\nmsgType: text \t\t消息类型,目前只支持文本消息\ntoTag:   标签ID \t\t在企业微信后台可以查看到\ntoUser： 用户ID \t\t在企业微信后台可以查看到\ntoParty: 部门ID \t\t在企业微信后台可以查看到\nmsg：    要发送的消息\n```\n\n[返回到目录](#目录)\n\n## 钉钉报警\n\n需要在conf/app.conf 配置钉钉机器人的URL，或者是在POST中传递url参数指定钉钉机器人地址\n\n#### 发送钉钉消息\n\n```sh\nPOST /api/v1/sendmsg/dingding\n\nmsgType： text|markdown\nmsg:      要发送的消息\ntitle:    发送markdown消息时需要指定此参数，指定标题\nurl:      可以指定钉钉机器人的URL，这样就不用在conf/app.conf 配置钉钉机器人的URL\n```\n\n注意: 在发送markdown消息时，markdown的语法可以查看[官方文档](https://open-doc.dingtalk.com/docs/doc.htm?spm=a219a.7629140.0.0.xuaZtG\u0026treeId=257\u0026articleId=105735\u0026docType=1#s2)\n\n[返回到目录](#目录)\n\n## 2步验证\n\n2步验证,可以方便的集成到系统中,只需要调用3个API即可.\n\n### 2步验证api接口\n\n#### 启用2步验证\n\n```sh\nGET /api/v1/twostepauth/enable?username=用户名\u0026issuer=发行者\n\nusername email或者是用户名\nissuer 可以是比如 公司的域名/公司的代号等\n```\n返回结果:\n\n```sh\n{\n    \"data\": {\n        \"key\": \"xxxxxxxxxxxx\",\n        \"qrImage\": \"/static/download/qr/xxxx.png\"\n    },\n    \"entryType\": \"TwoStepAuth\",\n    \"errmsg\": \"\",\n    \"requestId\": \"e55fc2ea-4465-4a4f-aba7-f73272900b03\",\n    \"statuscode\": 0\n}\n\nqrImage \t2步验证 二维码图片路径\nkey     \t没办法扫描二维码时可以手动添加\nstatuscode  \t返回0,代表成功,其他失败 \n```\n\n[返回到目录](#目录)\n\n#### 验证Google Authenticator或是其他的类似的APP生成的6位数字\n\n```sh\nPOST /api/v1/twostepauth/auth\n\nusername: 用户名\nissuer:   发行者\ntoken:    6位数字的验证码\n```\n返回结果:\n\n```sh\n{\n    \"data\": {\n        \"auth\": false,\n        \"issuer\": \"xxxxx\",\n        \"username\": \"xxxxxxx\"\n    },\n    \"entryType\": \"TwoStepAuth\",\n    \"errmsg\": \"Tokens mismatch.\",\n    \"requestId\": \"5529567b-1c5a-4e04-aaa0-5a86ac19ca94\",\n    \"statuscode\": 1\n}\n\nauth: 验证成功true, 不成功false\n```\n\n[返回到目录](#目录)\n\n#### 禁用2步验证\n\n```sh\nGET /api/v1/twostepauth/disable?username=用户名\n```\n\n返回结果:\n\n```sh\n{\n    \"data\": {\n        \"disable\": \"yes\",\n        \"username\": \"xxxxx\"\n    },\n    \"entryType\": \"TwoStepAuth\",\n    \"errmsg\": \"\",\n    \"requestId\": \"4451ef02-f245-466a-8bb4-172238f47c50\",\n    \"statuscode\": 0\n}\n\ndisable: yes 禁用成功,删除二维码图片,从数据库中删除该用户\n```\n\n[返回到目录](#目录)\n\n\n## 密码存储\n\n### 密码存储API\n\n#### 存储\n\n```sh\nPOST /api/v1/storepass\n\n设置头部: Content-Type: application/json\n\n请求体内容格式:\n{\n  \"uniqueId\": \"10.10.1.2\",\n  \"password\": [\n    {\"name\": \"root\", \"password\": \"444\"},\n    {\"name\": \"user1\", \"password\": \"333\"}\n  ]\n}\nuniqueId 唯一标识\n\n注意字段名称必须是以上格式\n\n```\n返回结果:\n```sh\n{\n    \"data\": {\n        \"update\": \"ok\"\n    },\n    \"entryType\": \"Store Password\",\n    \"errmsg\": \"\",\n    \"requestId\": \"2494ad20-ca52-4d3e-8e8e-6dd0d6289f4a\",\n    \"statuscode\": 0\n}\n```\n\n[返回到目录](#目录)\n\n#### 查询\n```sh\nGET /api/v1/storepass/10.10.1.2,1.1.1.1\n\n多个标识逗号分开\n```\n\n返回结果:\n```sh\n{\n    \"data\": {\n        \"password\": {\n            \"1.1.1.1\": {},\n            \"10.10.1.2\": {\n                \"root\": \"444\",\n                \"user1\": \"333\"\n            }\n        }\n    },\n    \"entryType\": \"Store Password\",\n    \"errmsg\": \"\",\n    \"requestId\": \"d5f61efe-8c22-4e4e-9d97-c343eb1e7f58\",\n    \"statuscode\": 0\n}\n\n1.1.1.1 在数据库中不存在则返回的是空\n```\n[返回到目录](#目录)\n\n#### 删除\n\n```sh\nDELETE /api/v1/storepass/10.10.1.2,1.1.1.1\n\n如果请求的标识在数据库中不存从则返回空\n```\n\n返回结果:\n```sh\n{\n    \"data\": {\n        \"delete\": \"ok\",\n        \"id\": \"10.10.1.2,1.1.1.1\"\n    },\n    \"entryType\": \"Store Password\",\n    \"errmsg\": \"\",\n    \"requestId\": \"29ed3301-319f-45b6-8cbd-934becc7c5cb\",\n    \"statuscode\": 0\n}\n```\n\n[返回到目录](#目录)\n\n\n## 发送邮件 \n\n#### 发送邮件api接口\n\n```sh\nPOST /api/v1/sendmsg/mail\n```\n\n- DEVOPS-API-TOKEN 指定API-TOKEN\n- subject 主题\n- content 内容\n- type text/plain|text/html\n- to 收件人多个用逗号分开\n- cc 抄送人多个用逗号分开\n- attach 指定附件的路径\n- isattach 是否有附件 true|false\n\n[返回到目录](#目录)\n\n### Curl 示例\n\n```sh\ncurl -X POST \\\n  http://127.0.0.1:8080/api/v1/sendmsg/mail \\\n  -H 'DEVOPS-API-TOKEN: 生成Token' \\\n  -H 'content-type: multipart/form-data' \\\n  -F subject=haha \\\n  -F 'content=测试一下哈' \\\n  -F type=text/plain \\\n  -F to=xxxx@qq.com,xxx@163.com \\\n  -F cc=xxxx@qq.com,xxx@163.com \\\n  -F 'attach=@C:\\Users\\41176\\Desktop\\1111.txt' \\\n  -F isattach=true\n```\n[返回到目录](#目录)\n\n### Python 文本邮件/html邮件 示例\n\n记得安装 requests\n\n```python\npip install requests\n```\n\n```python\nimport requests\n\nurl = \"http://127.0.0.1:8080/api/v1/sendmsg/mail\"\ntoken = \"生成的Token\"\nheaders = {'DEVOPS-API-TOKEN': token}\npayload = {\n    \"subject\": u\"测试邮件\",\n    \"content\": u\"测试邮件内容\",  # u\"\u003ch1\u003e测试邮件内容\u003c/h1\u003e\",\n    \"type\":    \"text/plain\",    # \"text/html\"\n    \"to\":      \"xxxx@qq.com,xxx@163.com\",\n    \"cc\":      \"xxxx@qq.com,xxx@163.com\",\n}\nresponse = requests.post(url, data=payload, headers=headers)\nprint(response.json())\n```\n[返回到目录](#目录)\n\n### Python 发送带附件邮件 示例\n\n```python\nimport requests\n\nurl = \"http://127.0.0.1:8080/api/v1/sendmsg/mail\"\ntoken = \"生成的Token\"\npayload = {\n    \"subject\": u\"测试邮件\",\n    \"content\": u\"测试邮件内容\",\n    \"type\":    \"text/plain\",\n    \"to\":      \"xxxx@qq.com\",\n    \"cc\":      \"xxxx@163.com\",\n    \"isattach\": \"true\"\n}\nheaders = {'DEVOPS-API-TOKEN': token}\nfiles = {'attach': open('文件的路径', 'rb')} # 键名必须是 attach\nresponse = requests.post(url, data=payload, headers=headers, files=files)\nprint(response.json())\n```\n\n[返回到目录](#目录)\n\n### Go 文本邮件/html邮件 示例\n\n记得安装 grequests\n\n```go\ngo get github.com/levigross/grequests\n```\n\n```go\npackage main\n\nimport (\n\t\"log\"\n\n\t\"github.com/levigross/grequests\"\n)\n\nfunc main() {\n\turl := \"http://127.0.0.1:8080/api/v1/sendmsg/mail\"\n\ttoken := \"生成的Token\"\n\to := \u0026grequests.RequestOptions{\n\t\tHeaders: map[string]string{\n\t\t\t\"DEVOPS-API-TOKEN\": token,\n\t\t},\n\t\tData: map[string]string{\n\t\t\t\"subject\": \"测试邮件\",\n\t\t\t\"content\": \"测试邮件内容\", // \u003ch1\u003e测试邮件内容\u003c/h1\u003e\n\t\t\t\"type\":    \"text/plain\", // text/html\n            \"to\":      \"xxxx@qq.com,xxx@163.com\",\n            \"cc\":      \"xxxx@qq.com,xxx@163.com\",\n\t\t},\n\t}\n\tresp, err := grequests.Post(url, o)\n\tif err != nil {\n\t\tlog.Fatalln(\"Unable to make request: \", err)\n\t}\n\tlog.Println(resp.String())\n}\n\n```\n\n[返回到目录](#目录)\n\n### Go 发送带附件的邮件 示例\n\n```go\npackage main\n\nimport (\n\t\"log\"\n\t\"os\"\n\n\t\"github.com/levigross/grequests\"\n)\n\nfunc main() {\n\turl := \"http://127.0.0.1:8080/api/v1/sendmsg/mail\"\n\ttoken := \"生成的token\"\n\n\tfd, err := os.Open(\"文件路径\")\n\tif err != nil {\n\t\tlog.Fatalln(\"open file error: \", err)\n\t}\n\n\to := \u0026grequests.RequestOptions{\n\t\tHeaders: map[string]string{\n\t\t\t\"DEVOPS-API-TOKEN\": token,\n\t\t},\n\t\tData: map[string]string{\n\t\t\t\"subject\":  \"测试邮件\",\n\t\t\t\"content\":  \"测试邮件内容\", \n\t\t\t\"type\":     \"text/plain\", \n\t\t\t\"to\":       \"xxx@qq.com\",\n\t\t\t\"cc\":       \"xxxx@163.com\",\n\t\t\t\"isattach\": \"true\",\n\t\t},\n\t\tFiles: []grequests.FileUpload{\n\t\t\tgrequests.FileUpload{\n\t\t\t\tFileName:     \"上传之后生成的文件名\",\n\t\t\t\tFileContents: fd,\n\t\t\t\tFieldName:    \"attach\", // FieldName 必须是 attach\n\t\t\t},\n\t\t},\n\t}\n\tresp, err := grequests.Post(url, o)\n\tif err != nil {\n\t\tlog.Fatalln(\"Unable to make request: \", err)\n\t}\n\tlog.Println(resp.String())\n}\n\n```\n\n[返回到目录](#目录)\n\n## 生成随机密码\n\n#### 生成随机密码api接口\n\n```sh\nGET /api/v1/password/generation\n```\n\n生成随机密码 默认32位, 可以添加如下参数\n\n- length 指定长度\n- name  指定多个名称，为多个名称生成密码\n- specialChar 是否添加特殊字符(!@#%$*.=)到密码里面 specialChar=yes 添加，其他不添加\n\n[返回到目录](#目录)\n\n### Curl 示例\n\n```sh\ncurl http://127.0.0.1:8080/api/v1/password/generation?length=64 \\\n  -H 'DEVOPS-API-TOKEN: 生成的Token'\n```\n\n[返回到目录](#目录)\n\n### 别名使用\n\n#### 首先设置一下环境变量\n\n```sh\nexport DEVOPS_API_TOKEN=生成的Token\n```\n\nLinux\n\n```sh\nalias genpwd=\"curl -H \\\"DEVOPS-API-TOKEN: ${DEVOPS_API_TOKEN}\\\" http://127.0.0.1:8080/api/v1/password/generation?length=64;echo\"\nalias genpwdspecial=\"curl -H \\\"DEVOPS-API-TOKEN: ${DEVOPS_API_TOKEN}\\\" http://127.0.0.1:8080/api/v1/password/generation?length=64\u0026specialChar=yes;echo\"\n```\nMac 可能需要把?=\u0026转义一下\n\n```sh\nalias genpwd=\"curl -H \\\"DEVOPS-API-TOKEN: ${DEVOPS_API_TOKEN}\\\" http://127.0.0.1:8080/api/v1/password/generation\\?length\\=64;echo\"\nalias genpwdspecial=\"curl -H \\\"DEVOPS-API-TOKEN: ${DEVOPS_API_TOKEN}\\\" http://127.0.0.1:8080/api/v1/password/generation\\?length\\=64\\\u0026specialChar\\=yes;echo\"\n```\n\n[返回到目录](#目录)\n\n### Python示例\n\n```python\nimport requests\nimport pprint\n\nurl = \"http://127.0.0.1:8080/api/v1/password/generation\"\ntoken = \"生成的Token\"\npayload = {\n    \"length\": 64,                   # 指定密码长度\n    \"name\": \"user1,user2,user3\",    # 可以为多个名称生成密码\n    \"specialChar\": \"yes\"            # 密码中是否带有特殊字符\n}\nheaders = {'DEVOPS-API-TOKEN': token}\nresponse = requests.get(url, params=payload, headers=headers)\npprint.pprint(response.json())\n```\n\n[返回到目录](#目录)\n\n### Go示例\n\n```go\npackage main\n\nimport (\n\t\"log\"\n\n\t\"github.com/levigross/grequests\"\n)\n\nfunc main() {\n\turl := \"http://127.0.0.1:8080/api/v1/password/generation\"\n\ttoken := \"生成的Token\"\n\n\to := \u0026grequests.RequestOptions{\n\t\tHeaders: map[string]string{\n\t\t\t\"DEVOPS-API-TOKEN\": token,\n\t\t},\n\t\tParams: map[string]string{\n\t\t\t\"length\":      \"64\",                // 指定密码长度\n\t\t\t\"name\":        \"user1,user2,user3\", // 可以为多个名称生成密码\n\t\t\t\"specialChar\": \"yes\",               // 密码中是否带有特殊字符\n\t\t},\n\t}\n\tresp, err := grequests.Get(url, o)\n\tif err != nil {\n\t\tlog.Fatalln(\"Unable to make request: \", err)\n\t}\n\tlog.Println(resp.String())\n}\n\n```\n\n[返回到目录](#目录)\n\n\n## 获取字符串的MD5值\n\n### 获取字符串的MD5值api接口\n\n```sh\nGET /api/v1/md5?rawstr=123456\n```\n\n可以写一个shell脚本命令行传入字符串，返回MD5值\n\n[返回到目录](#目录)\n\n\n## 生成验证密码\n\n### 生成验证密码\n\n#### 生成验证密码api接口\n\n```sh\nGET /api/v1/password/manualGenAuthPassword\n```\n\n手动生成验证密码，该功能是 生成一个32位的密码，然后通过钉钉或者邮件通知，别人可以拿这个密码到本程序验证是否正确，这个密码也会定时的清除，不会一直生效 执行成功返回 {\"manualGenAuthPassword\": true}\n\n### 验证上面的密码是否正确\n\n#### 验证密码api接口\n\n```sh\nPOST /api/v1/password/authPassword\n```\n\n验证密码是否正确，就上一个API生成的密码, 参数: password 执行成功返回 {\"auth\", true}\n\n[返回到目录](#目录)\n\n## 获取程序自身版本信息\n\n#### 获取程序自身版本信息api接口\n\n```sh\nGET /api/v1/version  \n```\n\n[返回到目录](#目录)\n","funding_links":[],"categories":["Repositories"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchanyipiaomiao%2Fdevops-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchanyipiaomiao%2Fdevops-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchanyipiaomiao%2Fdevops-api/lists"}