File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -48,4 +48,32 @@ export class ClientApiBase {
4848 serializationData . responseIsCollection ) ;
4949 return deserializedResult ;
5050 }
51+
52+ public extractRateLimitHeaders ( headers : any , target : any ) : void {
53+ if ( ! headers || ! target ) {
54+ return ;
55+ }
56+
57+ const rateLimit : VsoBaseInterfaces . RateLimit = { } ;
58+
59+ if ( headers [ 'x-ratelimit-resource' ] ) {
60+ rateLimit . resource = headers [ 'x-ratelimit-resource' ] ;
61+ }
62+ if ( headers [ 'x-ratelimit-delay' ] ) {
63+ rateLimit . delay = parseFloat ( headers [ 'x-ratelimit-delay' ] ) ;
64+ }
65+ if ( headers [ 'x-ratelimit-limit' ] ) {
66+ rateLimit . limit = parseInt ( headers [ 'x-ratelimit-limit' ] , 10 ) ;
67+ }
68+ if ( headers [ 'x-ratelimit-remaining' ] ) {
69+ rateLimit . remaining = parseInt ( headers [ 'x-ratelimit-remaining' ] , 10 ) ;
70+ }
71+ if ( headers [ 'x-ratelimit-reset' ] ) {
72+ rateLimit . reset = parseInt ( headers [ 'x-ratelimit-reset' ] , 10 ) ;
73+ }
74+ if ( headers [ 'retry-after' ] ) {
75+ rateLimit . retryAfter = parseInt ( headers [ 'retry-after' ] , 10 ) ;
76+ }
77+ target . rateLimit = rateLimit ;
78+ }
5179}
Original file line number Diff line number Diff line change @@ -120,3 +120,30 @@ export interface ICertConfiguration {
120120 keyFile ?: string ;
121121 passphrase ?: string ;
122122}
123+
124+ export interface RateLimit {
125+ /**
126+ * Service and type of threshold reached. For display purposes only.
127+ */
128+ resource ?: string ;
129+ /**
130+ * Request delay in seconds (tarpit state). Supports up to 3 decimal places.
131+ */
132+ delay ?: number ;
133+ /**
134+ * Total TSTUs allowed before delays are imposed.
135+ */
136+ limit ?: number ;
137+ /**
138+ * TSTUs remaining before delays start. 0 if already delayed or blocked.
139+ */
140+ remaining ?: number ;
141+ /**
142+ * Unix epoch time (seconds) when usage resets to 0 TSTUs.
143+ */
144+ reset ?: number ;
145+ /**
146+ * Seconds to wait before retrying (HTTP 429 block state).
147+ */
148+ retryAfter ?: number ;
149+ }
Original file line number Diff line number Diff line change 11{
22 "name" : " azure-devops-node-api" ,
33 "description" : " Node client for Azure DevOps and TFS REST APIs" ,
4- "version" : " 15.1.1 " ,
4+ "version" : " 15.1.2 " ,
55 "main" : " ./WebApi.js" ,
66 "types" : " ./WebApi.d.ts" ,
77 "scripts" : {
You can’t perform that action at this time.
0 commit comments