{"id":20282601,"url":"https://github.com/veops/cmdb-sdk-golang","last_synced_at":"2025-09-22T16:30:36.826Z","repository":{"id":189936944,"uuid":"681034465","full_name":"veops/cmdb-sdk-golang","owner":"veops","description":null,"archived":false,"fork":false,"pushed_at":"2023-10-30T06:10:09.000Z","size":34,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-11-14T14:10:27.730Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/veops.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,"governance":null}},"created_at":"2023-08-21T06:00:59.000Z","updated_at":"2024-07-18T05:42:50.000Z","dependencies_parsed_at":"2023-08-22T15:17:18.259Z","dependency_job_id":"9d36378f-daae-49c1-8cdd-62d3074689b1","html_url":"https://github.com/veops/cmdb-sdk-golang","commit_stats":null,"previous_names":["veops/cmdb-sdk-golang"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/veops%2Fcmdb-sdk-golang","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/veops%2Fcmdb-sdk-golang/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/veops%2Fcmdb-sdk-golang/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/veops%2Fcmdb-sdk-golang/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/veops","download_url":"https://codeload.github.com/veops/cmdb-sdk-golang/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":233861664,"owners_count":18741995,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-11-14T14:10:30.263Z","updated_at":"2025-09-22T16:30:31.427Z","avatar_url":"https://github.com/veops.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cmdb-sdk-golang\ngolang sdk of cmdb operations\n\n## install\n```shell\ngo get \"github.com/veops/cmdb-sdk-golang\"\n```\n\n## Operation of CI\n```golang\n// create a helper firstly\n// urlPrefix is used to combine http request eg. the final query url with urlPrefix https://demo.veops.cn/api/v0.1 is https://demo.veops.cn/api/v0.1/ci/s\n// key and secret is obtained from ACL\n//\n// doc https://github.com/veops/cmdb/blob/master/docs/cmdb_api.md#%E5%9B%9Bapi%E9%89%B4%E6%9D%83%E6%96%B9%E6%B3%95\nhelper := cmdb_sdk.NewHelper(\"urlprefix\", \"your key\", \"your secret\")\n\n// suppose you have created a ci type called mycitype\n// with three attributes server_name, ip and custom_attr\n// you can add a ci instance as following\n//\n// doc https://github.com/veops/cmdb/blob/master/docs/cmdb_api.md#2-%E6%96%B0%E5%A2%9Eci%E6%8E%A5%E5%8F%A3\nattrs := map[string]any{\n  \"server_name\": \"test-1\",\n  \"ip\":          \"192.168.0.1\",\n  \"custom_attr\": 123,\n}\naddCIRes, err := helper.AddCI(\"mycitype\", cmdb_sdk.NoAttrPolicyDefault, cmdb_sdk.ExistPolicyDefault, attrs)\n\n// you are able to get the ci instance created above by query now\n//\n// doc https://github.com/veops/cmdb/blob/master/docs/cmdb_api.md#1-ci%E6%9F%A5%E8%AF%A2%E6%8E%A5%E5%8F%A3\ngetCIRes, err := helper.GetCI(\"_type:mycitype\", \"\", \"\", \"\", 0, 0, cmdb_sdk.RetKeyDefault)\n\n// now let's update some attribute of a ci instance\n// reminder that you can get ci_id from the return result of AddCI or instance info of GetCI\n//\n// doc https://github.com/veops/cmdb/blob/master/docs/cmdb_api.md#3-%E4%BF%AE%E6%94%B9ci%E6%8E%A5%E5%8F%A3\nupdates := map[string]any{\n  \"ip\":          \"127.0.0.1\",\n  \"custom_attr\": 321,\n}\nupdateCIRes, err := helper.UpdateCI(666, \"mycitype\", cmdb_sdk.NoAttrPolicyDefault, updates)\n\n// finally, delete this ci if you want\n//\n// doc https://github.com/veops/cmdb/blob/master/docs/cmdb_api.md#4-%E5%88%A0%E9%99%A4ci%E6%8E%A5%E5%8F%A3\ndeleteCIRes, err := helper.DeleteCI(666)\n```\n\n## Operation of CI Relation\n```golang\n// create a helper firstly\nhelper := cmdb_sdk.NewHelper(\"urlprefix\", \"your key\", \"your secret\")\n\n// assuming you now have create a relation between two ci types\n// and two ci instances with ci_id=666 and 777 sperately of these types\n// you can add a relation to these instances\n//\n// doc https://github.com/veops/cmdb/blob/master/docs/cmdb_api.md#2-%E5%A2%9E%E5%8A%A0ci%E5%85%B3%E7%B3%BB%E6%8E%A5%E5%8F%A3\nAddCIRRes, err := helper.AddRelation(666, 777)\n\n// you will get a cr_id after the creation which can be used to delete the relation\n//\n// doc https://github.com/veops/cmdb/blob/master/docs/cmdb_api.md#3-%E5%88%A0%E9%99%A4ci%E5%85%B3%E7%B3%BB%E6%8E%A5%E5%8F%A3\ndeleteCIRRes, err := helper.DeleteRelation(666777, 0, 0)\n// in the case that you don't keep the ci_id, you can delete relation by two ci_id\ndeleteCIRRes, err := helper.DeleteRelation(0, 666, 777)\n\n// except for root_id,reverse and level, relation query is much similar to ci query\n//\n// doc https://github.com/veops/cmdb/blob/master/docs/cmdb_api.md#1-ci%E5%85%B3%E7%B3%BB%E6%9F%A5%E8%AF%A2%E6%8E%A5%E5%8F%A3\ngetCIRRes, err := helper.GetRelation(666, 0, \"1\", \"\", \"\", \"\", \"\", 0, 0, cmdb_sdk.RetKeyDefault)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fveops%2Fcmdb-sdk-golang","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fveops%2Fcmdb-sdk-golang","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fveops%2Fcmdb-sdk-golang/lists"}