11package org .azd .utils ;
22
3+ import org .azd .common .types .BaseAbstractMethod ;
34import org .azd .connection .Connection ;
45import org .azd .enums .ApiExceptionTypes ;
56import org .azd .enums .CustomHeader ;
1112import java .net .http .HttpRequest ;
1213import java .net .http .HttpResponse ;
1314import java .util .Map ;
15+ import java .util .Optional ;
1416import java .util .OptionalLong ;
1517import java .util .concurrent .CompletableFuture ;
1618
@@ -26,7 +28,7 @@ public abstract class RestClient {
2628 * can be checked after every request, but we don't want to have to modify all the existing API methods
2729 * to return the data.
2830 *
29- * We need this to bw able to check if we are near any API rate limits - as creating 20+ releases in
31+ * We need this to be able to check if we are near any API rate limits - as creating 20+ releases in
3032 * a short time can cause one to go over the limit and even have requests fail.
3133 */
3234 static HttpHeaders headersFromLastRequest = null ;
@@ -42,6 +44,16 @@ static OptionalLong retryAfterInterval() {
4244 return OptionalLong .empty ();
4345 }
4446
47+ /**
48+ * Metadata class to retrieve the response headers. This separates the implementation and
49+ * retrieval from the RestClient adapter class.
50+ */
51+ public static final class Metadata {
52+ public static String getResponseHeader (String value ) {
53+ return RestClient .headersFromLastRequest .firstValue (value ).orElse ("" );
54+ }
55+ }
56+
4557 /**
4658 * Request the Azure DevOps REST API and builds the request url dynamically based on resource id and endpoints passed
4759 *
0 commit comments