Skip to content

Commit 9d0cccd

Browse files
committed
Added support for deployments api. Routes coding done by @neekipatel. Fixes octokit#198
1 parent a14fb95 commit 9d0cccd

File tree

2 files changed

+320
-0
lines changed

2 files changed

+320
-0
lines changed

api/v3.0.0/repos.js

Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2998,4 +2998,186 @@ var repos = module.exports = {
29982998
});
29992999
};
30003000

3001+
/** section: github
3002+
* repos#getDeployments(msg, callback) -> null
3003+
* - msg (Object): Object that contains the parameters and their values to be sent to the server.
3004+
* - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
3005+
*
3006+
* ##### Params on the `msg` object:
3007+
*
3008+
* - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'.
3009+
* - sha (String): Optional. The short or long sha that was recorded at creation time. Default: none.
3010+
* - ref (String): Optional. The name of the ref. This can be a branch, tag, or sha. Default: none.
3011+
* - task (String): Optional. The name of the task for the deployment. e.g. deploy or deploy:migrations. Default: none.
3012+
* - environment (String): Optional. The name of the environment that was deployed to. e.g. staging or production. Default: none.
3013+
* - user (String): Required.
3014+
* - repo (String): Required.
3015+
* - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `.
3016+
* - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `.
3017+
**/
3018+
this.getDeployments = function(msg, block, callback) {
3019+
var self = this;
3020+
this.client.httpSend(msg, block, function(err, res) {
3021+
if (err)
3022+
return self.sendError(err, null, msg, callback);
3023+
3024+
var ret;
3025+
try {
3026+
ret = res.data && JSON.parse(res.data);
3027+
}
3028+
catch (ex) {
3029+
if (callback)
3030+
callback(new error.InternalServerError(ex.message), res);
3031+
return;
3032+
}
3033+
3034+
if (!ret)
3035+
ret = {};
3036+
if (!ret.meta)
3037+
ret.meta = {};
3038+
["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) {
3039+
if (res.headers[header])
3040+
ret.meta[header] = res.headers[header];
3041+
});
3042+
3043+
if (callback)
3044+
callback(null, ret);
3045+
});
3046+
};
3047+
3048+
/** section: github
3049+
* repos#createDeployment(msg, callback) -> null
3050+
* - msg (Object): Object that contains the parameters and their values to be sent to the server.
3051+
* - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
3052+
*
3053+
* ##### Params on the `msg` object:
3054+
*
3055+
* - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'.
3056+
* - ref (String): Required. The ref to deploy. This can be a branch, tag, or sha.
3057+
* - task (String): Required. The named task to execute. e.g. deploy or deploy:migrations. Default: deploy
3058+
* - auto_merge (Boolean): Optional. Optional parameter to merge the default branch into the requested ref if it is behind the default branch. Default: true
3059+
* - required_contexts (Array): Optional. Optional array of status contexts verified against commit status checks. If this parameter is omitted from the parameters then all unique contexts will be verified before a deployment is created. To bypass checking entirely pass an empty array. Defaults to all unique contexts.
3060+
* - payload (String): Optional. Optional JSON payload with extra information about the deployment. Default: ''
3061+
* - environment (String): Optional. The name of the environment that was deployed to. e.g. staging or production. Default: none.
3062+
* - description (String): Optional. Optional short description. Default: ''
3063+
* - user (String): Required.
3064+
* - repo (String): Required.
3065+
**/
3066+
this.createDeployment = function(msg, block, callback) {
3067+
var self = this;
3068+
this.client.httpSend(msg, block, function(err, res) {
3069+
if (err)
3070+
return self.sendError(err, null, msg, callback);
3071+
3072+
var ret;
3073+
try {
3074+
ret = res.data && JSON.parse(res.data);
3075+
}
3076+
catch (ex) {
3077+
if (callback)
3078+
callback(new error.InternalServerError(ex.message), res);
3079+
return;
3080+
}
3081+
3082+
if (!ret)
3083+
ret = {};
3084+
if (!ret.meta)
3085+
ret.meta = {};
3086+
["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) {
3087+
if (res.headers[header])
3088+
ret.meta[header] = res.headers[header];
3089+
});
3090+
3091+
if (callback)
3092+
callback(null, ret);
3093+
});
3094+
};
3095+
3096+
/** section: github
3097+
* repos#getDeploymentStatuses(msg, callback) -> null
3098+
* - msg (Object): Object that contains the parameters and their values to be sent to the server.
3099+
* - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
3100+
*
3101+
* ##### Params on the `msg` object:
3102+
*
3103+
* - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'.
3104+
* - user (String): Required.
3105+
* - repo (String): Required.
3106+
* - id (String): Required.
3107+
**/
3108+
this.getDeploymentStatuses = function(msg, block, callback) {
3109+
var self = this;
3110+
this.client.httpSend(msg, block, function(err, res) {
3111+
if (err)
3112+
return self.sendError(err, null, msg, callback);
3113+
3114+
var ret;
3115+
try {
3116+
ret = res.data && JSON.parse(res.data);
3117+
}
3118+
catch (ex) {
3119+
if (callback)
3120+
callback(new error.InternalServerError(ex.message), res);
3121+
return;
3122+
}
3123+
3124+
if (!ret)
3125+
ret = {};
3126+
if (!ret.meta)
3127+
ret.meta = {};
3128+
["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) {
3129+
if (res.headers[header])
3130+
ret.meta[header] = res.headers[header];
3131+
});
3132+
3133+
if (callback)
3134+
callback(null, ret);
3135+
});
3136+
};
3137+
3138+
/** section: github
3139+
* repos#createDeploymentStatus(msg, callback) -> null
3140+
* - msg (Object): Object that contains the parameters and their values to be sent to the server.
3141+
* - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
3142+
*
3143+
* ##### Params on the `msg` object:
3144+
*
3145+
* - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'.
3146+
* - state (String): Optional. The state of the status. Can be one of pending, success, error, or failure.
3147+
* - target_url (String): Optional. The target URL to associate with this status. This URL should contain output to keep the user updated while the task is running or serve as historical information for what happened in the deployment. Default: ''
3148+
* - description (String): Optional. A short description of the status. Default: ''
3149+
* - user (String): Required.
3150+
* - repo (String): Required.
3151+
* - id (String): Required.
3152+
**/
3153+
this.createDeploymentStatus = function(msg, block, callback) {
3154+
var self = this;
3155+
this.client.httpSend(msg, block, function(err, res) {
3156+
if (err)
3157+
return self.sendError(err, null, msg, callback);
3158+
3159+
var ret;
3160+
try {
3161+
ret = res.data && JSON.parse(res.data);
3162+
}
3163+
catch (ex) {
3164+
if (callback)
3165+
callback(new error.InternalServerError(ex.message), res);
3166+
return;
3167+
}
3168+
3169+
if (!ret)
3170+
ret = {};
3171+
if (!ret.meta)
3172+
ret.meta = {};
3173+
["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) {
3174+
if (res.headers[header])
3175+
ret.meta[header] = res.headers[header];
3176+
});
3177+
3178+
if (callback)
3179+
callback(null, ret);
3180+
});
3181+
};
3182+
30013183
}).call(repos.repos);

api/v3.0.0/routes.json

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2936,6 +2936,144 @@
29362936
"$user": null,
29372937
"$repo": null
29382938
}
2939+
},
2940+
2941+
"get-deployments": {
2942+
"url": "/repos/:user/:repo/deployments",
2943+
"method": "GET",
2944+
"params": {
2945+
"sha": {
2946+
"type": "String",
2947+
"required": false,
2948+
"validation": "",
2949+
"invalidmsg": "",
2950+
"description": "The short or long sha that was recorded at creation time. Default: none."
2951+
},
2952+
"ref": {
2953+
"type": "String",
2954+
"required": false,
2955+
"validation": "",
2956+
"invalidmsg": "",
2957+
"description": "The name of the ref. This can be a branch, tag, or sha. Default: none."
2958+
},
2959+
"task": {
2960+
"type": "String",
2961+
"required": false,
2962+
"validation": "",
2963+
"invalidmsg": "",
2964+
"description": "The name of the task for the deployment. e.g. deploy or deploy:migrations. Default: none."
2965+
},
2966+
"environment": {
2967+
"type": "String",
2968+
"required": false,
2969+
"validation": "",
2970+
"invalidmsg": "",
2971+
"description": "The name of the environment that was deployed to. e.g. staging or production. Default: none."
2972+
},
2973+
"$user": null,
2974+
"$repo": null,
2975+
"$page": null,
2976+
"$per_page": null
2977+
}
2978+
},
2979+
2980+
"create-deployment": {
2981+
"url": "/repos/:user/:repo/deployments",
2982+
"method": "POST",
2983+
"params": {
2984+
"ref": {
2985+
"type": "String",
2986+
"required": true,
2987+
"validation": "",
2988+
"invalidmsg": "",
2989+
"description": "The ref to deploy. This can be a branch, tag, or sha."
2990+
},
2991+
"task": {
2992+
"type": "String",
2993+
"required": true,
2994+
"validation": "",
2995+
"invalidmsg": "",
2996+
"description": "The named task to execute. e.g. deploy or deploy:migrations. Default: deploy"
2997+
},
2998+
"auto_merge": {
2999+
"type": "Boolean",
3000+
"required": false,
3001+
"validation": "",
3002+
"invalidmsg": "",
3003+
"description": "Optional parameter to merge the default branch into the requested ref if it is behind the default branch. Default: true"
3004+
},
3005+
"required_contexts": {
3006+
"type": "Array",
3007+
"required": false,
3008+
"validation": "",
3009+
"invalidmsg": "",
3010+
"description": "Optional array of status contexts verified against commit status checks. If this parameter is omitted from the parameters then all unique contexts will be verified before a deployment is created. To bypass checking entirely pass an empty array. Defaults to all unique contexts."
3011+
},
3012+
"payload": {
3013+
"type": "String",
3014+
"required": false,
3015+
"validation": "",
3016+
"invalidmsg": "",
3017+
"description": "Optional JSON payload with extra information about the deployment. Default: ''"
3018+
},
3019+
"environment": {
3020+
"type": "String",
3021+
"required": false,
3022+
"validation": "",
3023+
"invalidmsg": "",
3024+
"description": "The name of the environment that was deployed to. e.g. staging or production. Default: none."
3025+
},
3026+
"description": {
3027+
"type": "String",
3028+
"required": false,
3029+
"validation": "",
3030+
"invalidmsg": "",
3031+
"description": "Optional short description. Default: ''"
3032+
},
3033+
"$user": null,
3034+
"$repo": null
3035+
}
3036+
},
3037+
3038+
"get-deployment-statuses": {
3039+
"url": "/repos/:user/:repo/deployments/:id/statuses",
3040+
"method": "GET",
3041+
"params": {
3042+
"$user": null,
3043+
"$repo": null,
3044+
"$id": null
3045+
}
3046+
},
3047+
3048+
"create-deployment-status": {
3049+
"url": "/repos/:user/:repo/deployments/:id/statuses",
3050+
"method": "POST",
3051+
"params": {
3052+
"state": {
3053+
"type": "String",
3054+
"required": false,
3055+
"validation": "",
3056+
"invalidmsg": "",
3057+
"description": "The state of the status. Can be one of pending, success, error, or failure."
3058+
},
3059+
"target_url": {
3060+
"type": "String",
3061+
"required": false,
3062+
"validation": "",
3063+
"invalidmsg": "",
3064+
"description": "The target URL to associate with this status. This URL should contain output to keep the user updated while the task is running or serve as historical information for what happened in the deployment. Default: ''"
3065+
},
3066+
"description": {
3067+
"type": "String",
3068+
"required": false,
3069+
"validation": "",
3070+
"invalidmsg": "",
3071+
"description": "A short description of the status. Default: ''"
3072+
},
3073+
"$user": null,
3074+
"$repo": null,
3075+
"$id": null
3076+
}
29393077
}
29403078
},
29413079

0 commit comments

Comments
 (0)