New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide examples for API #3

Closed
jussisallinen opened this Issue Sep 12, 2018 · 1 comment

Comments

Projects
None yet
2 participants
@jussisallinen

jussisallinen commented Sep 12, 2018

I'm having following issue and would love to have better documentation with examples, ie. how to update ProbeGroup with new contact details:

# sdc-amon /pub/admin/probegroups/47c9613f-669e-e72a-9829-f1b9204fa8d1 -X PUT -d '{
    "user": "930896af-bf8c-48d4-885c-6573a94b1853",
    "contacts": ["email", "pagerdutyemail", "mymattermost"]
}'
HTTP/1.1 500 Internal Server Error
Content-Type: application/json
Content-Length: 1280
Date: Tue, 11 Sep 2018 04:46:18 GMT
Server: Amon Master/1.0.0
Request-Id: 9f23e7b0-b57d-11e8-9080-956875c4c1df
Response-Time: 3
Connection: keep-alive

{
  "message": "Object function ProbeGroup(app, raw) {\n    assert.object(app, 'app');\n    assert.object(raw, 'raw');\n    assert.string(raw.user, 'raw.user');\n    assert.string(raw.uuid, 'raw.uuid');\n    assert.string(raw.objectclass, 'raw.objectclass');\n    if (raw.objectclass !== ProbeGroup.objectclass) {\n        assert.equal(raw.objectclass, ProbeGroup.objectclass,\n            format('invalid probe group data: objectclass \"%s\" !== \"%s\"',\n            raw.objectclass, ProbeGroup.objectclass));\n    }\n\n    this.user = raw.user;\n    this.uuid = raw.uuid;\n    this.dn = ProbeGroup.dn(this.user, this.uuid);\n    if (raw.dn) {\n        assert.equal(raw.dn, this.dn,\n            format('invalid probe group data: given \"dn\" (%s) does not '\n                + 'match built dn (%s)', raw.dn, this.dn));\n    }\n\n    var rawCopy = objCopy(raw);\n    delete rawCopy.dn;\n    delete rawCopy.controls;\n    this.raw = ProbeGroup.validate(app, rawCopy);\n\n    var self = this;\n    this.__defineGetter__('name', function () {\n        return self.raw.name;\n    });\n    this.__defineGetter__('contacts', function () {\n        return self.raw.contact;\n    });\n    this.disabled = boolFromString(this.raw.disabled, false, 'raw.disabled');\n} has no method 'update'"
}


amon-master log:

{"name":"amon-master","hostname":"d71146b3-b398-4497-b5ae-aaac71cc4a24","pid":79856,"req_id":"e6ef5430-b5e6-11e8-9080-956875c4c1df","level":50,"err":{"message":"Object function ProbeGroup(app, raw) {\n    assert.object(app, 'app');\n    assert.object(raw, 'raw');\n    assert.string(raw.user, 'raw.user');\n    assert.string(raw.uuid, 'raw.uuid');\n    assert.string(raw.objectclass, 'raw.objectclass');\n    if (raw.objectclass !== ProbeGroup.objectclass) {\n        assert.equal(raw.objectclass, ProbeGroup.objectclass,\n            format('invalid probe group data: objectclass \"%s\" !== \"%s\"',\n            raw.objectclass, ProbeGroup.objectclass));\n    }\n\n    this.user = raw.user;\n    this.uuid = raw.uuid;\n    this.dn = ProbeGroup.dn(this.user, this.uuid);\n    if (raw.dn) {\n        assert.equal(raw.dn, this.dn,\n            format('invalid probe group data: given \"dn\" (%s) does not '\n                + 'match built dn (%s)', raw.dn, this.dn));\n    }\n\n    var rawCopy = objCopy(raw);\n    delete rawCopy.dn;\n    delete rawCopy.controls;\n    this.raw = ProbeGroup.validate(app, rawCopy);\n\n    var self = this;\n    this.__defineGetter__('name', function () {\n        return self.raw.name;\n    });\n    this.__defineGetter__('contacts', function () {\n        return self.raw.contact;\n    });\n    this.disabled = boolFromString(this.raw.disabled, false, 'raw.disabled');\n} has no method 'update'","name":"TypeError","stack":"TypeError: Object function ProbeGroup(app, raw) {\n    assert.object(app, 'app');\n    assert.object(raw, 'raw');\n    assert.string(raw.user, 'raw.user');\n    assert.string(raw.uuid, 'raw.uuid');\n    assert.string(raw.objectclass, 'raw.objectclass');\n    if (raw.objectclass !== ProbeGroup.objectclass) {\n        assert.equal(raw.objectclass, ProbeGroup.objectclass,\n            format('invalid probe group data: objectclass \"%s\" !== \"%s\"',\n            raw.objectclass, ProbeGroup.objectclass));\n    }\n\n    this.user = raw.user;\n    this.uuid = raw.uuid;\n    this.dn = ProbeGroup.dn(this.user, this.uuid);\n    if (raw.dn) {\n        assert.equal(raw.dn, this.dn,\n            format('invalid probe group data: given \"dn\" (%s) does not '\n                + 'match built dn (%s)', raw.dn, this.dn));\n    }\n\n    var rawCopy = objCopy(raw);\n    delete rawCopy.dn;\n    delete rawCopy.controls;\n    this.raw = ProbeGroup.validate(app, rawCopy);\n\n    var self = this;\n    this.__defineGetter__('name', function () {\n        return self.raw.name;\n    });\n    this.__defineGetter__('contacts', function () {\n        return self.raw.contact;\n    });\n    this.disabled = boolFromString(this.raw.disabled, false, 'raw.disabled');\n} has no method 'update'\n    at modelPut (/opt/smartdc/amon/lib/ufdsmodel.js:183:11)\n    at Object.requestPut (/opt/smartdc/amon/lib/ufdsmodel.js:390:5)\n    at Server.apiPutProbeGroup (/opt/smartdc/amon/lib/probegroups.js:267:22)\n    at next (/opt/smartdc/amon/node_modules/restify/lib/server.js:707:42)\n    at /opt/smartdc/amon/node_modules/once/once.js:17:15\n    at /opt/smartdc/amon/lib/app.js:407:21\n    at App.userFromId (/opt/smartdc/amon/lib/app.js:824:9)\n    at Server.setup (/opt/smartdc/amon/lib/app.js:398:18)\n    at next (/opt/smartdc/amon/node_modules/restify/lib/server.js:707:42)\n    at /opt/smartdc/amon/node_modules/once/once.js:17:15"},"msg":"Object function ProbeGroup(app, raw) {\n    assert.object(app, 'app');\n    assert.object(raw, 'raw');\n    assert.string(raw.user, 'raw.user');\n    assert.string(raw.uuid, 'raw.uuid');\n    assert.string(raw.objectclass, 'raw.objectclass');\n    if (raw.objectclass !== ProbeGroup.objectclass) {\n        assert.equal(raw.objectclass, ProbeGroup.objectclass,\n            format('invalid probe group data: objectclass \"%s\" !== \"%s\"',\n            raw.objectclass, ProbeGroup.objectclass));\n    }\n\n    this.user = raw.user;\n    this.uuid = raw.uuid;\n    this.dn = ProbeGroup.dn(this.user, this.uuid);\n    if (raw.dn) {\n        assert.equal(raw.dn, this.dn,\n            format('invalid probe group data: given \"dn\" (%s) does not '\n                + 'match built dn (%s)', raw.dn, this.dn));\n    }\n\n    var rawCopy = objCopy(raw);\n    delete rawCopy.dn;\n    delete rawCopy.controls;\n    this.raw = ProbeGroup.validate(app, rawCopy);\n\n    var self = this;\n    this.__defineGetter__('name', function () {\n        return self.raw.name;\n    });\n    this.__defineGetter__('contacts', function () {\n        return self.raw.contact;\n    });\n    this.disabled = boolFromString(this.raw.disabled, false, 'raw.disabled');\n} has no method 'update'","time":"2018-09-11T17:19:55.637Z","v":0}
@davepacheco

This comment has been minimized.

Member

davepacheco commented Sep 20, 2018

I don't think you're using it wrong. This appears to be bug MON-355.

I'm closing this because we don't generally track issues with Amon on this repo (not because it's not a problem).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment