using System; using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Net.Http; using System.Threading; using System.Threading.Tasks; using GitHub.Services.Common; using GitHub.Services.Common.Diagnostics; using GitHub.Services.WebApi; namespace GitHub.Build.WebApi { public abstract class BuildHttpClientCompatBase: VssHttpClientBase { public BuildHttpClientCompatBase(Uri baseUrl, VssCredentials credentials) : base(baseUrl, credentials) { } public BuildHttpClientCompatBase(Uri baseUrl, VssCredentials credentials, VssHttpRequestSettings settings) : base(baseUrl, credentials, settings) { } public BuildHttpClientCompatBase(Uri baseUrl, VssCredentials credentials, params DelegatingHandler[] handlers) : base(baseUrl, credentials, handlers) { } public BuildHttpClientCompatBase(Uri baseUrl, VssCredentials credentials, VssHttpRequestSettings settings, params DelegatingHandler[] handlers) : base(baseUrl, credentials, settings, handlers) { } public BuildHttpClientCompatBase(Uri baseUrl, HttpMessageHandler pipeline, bool disposeHandler) : base(baseUrl, pipeline, disposeHandler) { } [Obsolete] public virtual Task> GetBuildsAsync( string project, IEnumerable definitions = null, IEnumerable queues = null, string buildNumber = null, DateTime? minFinishTime = null, DateTime? maxFinishTime = null, string requestedFor = null, BuildReason? reasonFilter = null, BuildStatus? statusFilter = null, BuildResult? resultFilter = null, IEnumerable tagFilters = null, IEnumerable properties = null, int? top = null, string continuationToken = null, int? maxBuildsPerDefinition = null, QueryDeletedOption? deletedFilter = null, BuildQueryOrder? queryOrder = null, string branchName = null, IEnumerable buildIds = null, object userState = null, CancellationToken cancellationToken = default(CancellationToken)) { HttpMethod httpMethod = new HttpMethod("GET"); Guid locationId = new Guid("0cd358e1-9217-4d94-8269-1c1ee6f93dcf"); object routeValues = new { project = project }; List> queryParams = new List>(); if (definitions != null && definitions.Any()) { queryParams.Add("definitions", string.Join(",", definitions)); } if (queues != null && queues.Any()) { queryParams.Add("queues", string.Join(",", queues)); } if (!string.IsNullOrEmpty(buildNumber)) { queryParams.Add("buildNumber", buildNumber); } if (minFinishTime != null) { AddDateTimeToQueryParams(queryParams, "minFinishTime", minFinishTime.Value); } if (maxFinishTime != null) { AddDateTimeToQueryParams(queryParams, "maxFinishTime", maxFinishTime.Value); } if (!string.IsNullOrEmpty(requestedFor)) { queryParams.Add("requestedFor", requestedFor); } if (reasonFilter != null) { queryParams.Add("reasonFilter", reasonFilter.Value.ToString()); } if (statusFilter != null) { queryParams.Add("statusFilter", statusFilter.Value.ToString()); } if (resultFilter != null) { queryParams.Add("resultFilter", resultFilter.Value.ToString()); } if (tagFilters != null && tagFilters.Any()) { queryParams.Add("tagFilters", string.Join(",", tagFilters)); } if (properties != null && properties.Any()) { queryParams.Add("properties", string.Join(",", properties)); } if (top != null) { queryParams.Add("$top", top.Value.ToString(CultureInfo.InvariantCulture)); } if (!string.IsNullOrEmpty(continuationToken)) { queryParams.Add("continuationToken", continuationToken); } if (maxBuildsPerDefinition != null) { queryParams.Add("maxBuildsPerDefinition", maxBuildsPerDefinition.Value.ToString(CultureInfo.InvariantCulture)); } if (deletedFilter != null) { queryParams.Add("deletedFilter", deletedFilter.Value.ToString()); } if (queryOrder != null) { queryParams.Add("queryOrder", queryOrder.Value.ToString()); } if (!string.IsNullOrEmpty(branchName)) { queryParams.Add("branchName", branchName); } if (buildIds != null && buildIds.Any()) { queryParams.Add("buildIds", string.Join(",", buildIds)); } return SendAsync>( httpMethod, locationId, routeValues: routeValues, version: s_BuildsApiVersion, queryParameters: queryParams, userState: userState, cancellationToken: cancellationToken); } /// /// [Preview API] Queues a build /// /// /// Project ID /// /// /// /// /// The cancellation token to cancel operation. public virtual Task QueueBuildAsync( Build build, Guid project, bool? ignoreWarnings = null, string checkInTicket = null, object userState = null, CancellationToken cancellationToken = default(CancellationToken)) { HttpMethod httpMethod = new HttpMethod("POST"); Guid locationId = new Guid("0cd358e1-9217-4d94-8269-1c1ee6f93dcf"); object routeValues = new { project = project }; HttpContent content = new ObjectContent(build, new VssJsonMediaTypeFormatter(true)); List> queryParams = new List>(); if (ignoreWarnings != null) { queryParams.Add("ignoreWarnings", ignoreWarnings.Value.ToString()); } if (!string.IsNullOrEmpty(checkInTicket)) { queryParams.Add("checkInTicket", checkInTicket); } return SendAsync( httpMethod, locationId, routeValues: routeValues, version: new ApiResourceVersion("5.0-preview.4"), queryParameters: queryParams, userState: userState, cancellationToken: cancellationToken, content: content); } /// /// [Preview API] Queues a build /// /// /// /// /// /// /// The cancellation token to cancel operation. public virtual Task QueueBuildAsync( Build build, bool? ignoreWarnings = null, string checkInTicket = null, object userState = null, CancellationToken cancellationToken = default(CancellationToken)) { HttpMethod httpMethod = new HttpMethod("POST"); Guid locationId = new Guid("0cd358e1-9217-4d94-8269-1c1ee6f93dcf"); HttpContent content = new ObjectContent(build, new VssJsonMediaTypeFormatter(true)); List> queryParams = new List>(); if (ignoreWarnings != null) { queryParams.Add("ignoreWarnings", ignoreWarnings.Value.ToString()); } if (!string.IsNullOrEmpty(checkInTicket)) { queryParams.Add("checkInTicket", checkInTicket); } return SendAsync( httpMethod, locationId, version: new ApiResourceVersion("5.0-preview.4"), queryParameters: queryParams, userState: userState, cancellationToken: cancellationToken, content: content); } /// /// [Preview API] Queues a build /// /// /// Project ID or project name /// /// /// /// /// The cancellation token to cancel operation. public virtual Task QueueBuildAsync( Build build, string project, bool? ignoreWarnings = null, string checkInTicket = null, object userState = null, CancellationToken cancellationToken = default(CancellationToken)) { HttpMethod httpMethod = new HttpMethod("POST"); Guid locationId = new Guid("0cd358e1-9217-4d94-8269-1c1ee6f93dcf"); object routeValues = new { project = project }; HttpContent content = new ObjectContent(build, new VssJsonMediaTypeFormatter(true)); List> queryParams = new List>(); if (ignoreWarnings != null) { queryParams.Add("ignoreWarnings", ignoreWarnings.Value.ToString()); } if (!string.IsNullOrEmpty(checkInTicket)) { queryParams.Add("checkInTicket", checkInTicket); } return SendAsync( httpMethod, locationId, routeValues: routeValues, version: new ApiResourceVersion("5.0-preview.4"), queryParameters: queryParams, userState: userState, cancellationToken: cancellationToken, content: content); } /// /// [Preview API] Gets builds /// /// Project ID /// A comma-delimited list of definition ids /// A comma-delimited list of queue ids /// /// /// /// /// /// /// /// A comma-delimited list of tags /// A comma-delimited list of properties to include in the results /// The maximum number of builds to retrieve /// /// /// /// /// /// /// /// The cancellation token to cancel operation. public virtual Task> GetBuildsAsync( Guid project, IEnumerable definitions = null, IEnumerable queues = null, string buildNumber = null, DateTime? minFinishTime = null, DateTime? maxFinishTime = null, string requestedFor = null, BuildReason? reasonFilter = null, BuildStatus? statusFilter = null, BuildResult? resultFilter = null, IEnumerable tagFilters = null, IEnumerable properties = null, int? top = null, string continuationToken = null, int? maxBuildsPerDefinition = null, QueryDeletedOption? deletedFilter = null, BuildQueryOrder? queryOrder = null, string branchName = null, IEnumerable buildIds = null, object userState = null, CancellationToken cancellationToken = default(CancellationToken)) { HttpMethod httpMethod = new HttpMethod("GET"); Guid locationId = new Guid("0cd358e1-9217-4d94-8269-1c1ee6f93dcf"); object routeValues = new { project = project }; List> queryParams = new List>(); if (definitions != null && definitions.Any()) { queryParams.Add("definitions", string.Join(",", definitions)); } if (queues != null && queues.Any()) { queryParams.Add("queues", string.Join(",", queues)); } if (!string.IsNullOrEmpty(buildNumber)) { queryParams.Add("buildNumber", buildNumber); } if (minFinishTime != null) { AddDateTimeToQueryParams(queryParams, "minFinishTime", minFinishTime.Value); } if (maxFinishTime != null) { AddDateTimeToQueryParams(queryParams, "maxFinishTime", maxFinishTime.Value); } if (!string.IsNullOrEmpty(requestedFor)) { queryParams.Add("requestedFor", requestedFor); } if (reasonFilter != null) { queryParams.Add("reasonFilter", reasonFilter.Value.ToString()); } if (statusFilter != null) { queryParams.Add("statusFilter", statusFilter.Value.ToString()); } if (resultFilter != null) { queryParams.Add("resultFilter", resultFilter.Value.ToString()); } if (tagFilters != null && tagFilters.Any()) { queryParams.Add("tagFilters", string.Join(",", tagFilters)); } if (properties != null && properties.Any()) { queryParams.Add("properties", string.Join(",", properties)); } if (top != null) { queryParams.Add("$top", top.Value.ToString(CultureInfo.InvariantCulture)); } if (!string.IsNullOrEmpty(continuationToken)) { queryParams.Add("continuationToken", continuationToken); } if (maxBuildsPerDefinition != null) { queryParams.Add("maxBuildsPerDefinition", maxBuildsPerDefinition.Value.ToString(CultureInfo.InvariantCulture)); } if (deletedFilter != null) { queryParams.Add("deletedFilter", deletedFilter.Value.ToString()); } if (queryOrder != null) { queryParams.Add("queryOrder", queryOrder.Value.ToString()); } if (!string.IsNullOrEmpty(branchName)) { queryParams.Add("branchName", branchName); } if (buildIds != null && buildIds.Any()) { queryParams.Add("buildIds", string.Join(",", buildIds)); } return SendAsync>( httpMethod, locationId, routeValues: routeValues, version: s_BuildsApiVersion, queryParameters: queryParams, userState: userState, cancellationToken: cancellationToken); } /// /// [Preview API] Gets builds /// /// A comma-delimited list of definition ids /// A comma-delimited list of queue ids /// /// /// /// /// /// /// /// A comma-delimited list of tags /// A comma-delimited list of properties to include in the results /// The maximum number of builds to retrieve /// /// /// /// /// /// /// /// The cancellation token to cancel operation. public virtual Task> GetBuildsAsync( IEnumerable definitions = null, IEnumerable queues = null, string buildNumber = null, DateTime? minFinishTime = null, DateTime? maxFinishTime = null, string requestedFor = null, BuildReason? reasonFilter = null, BuildStatus? statusFilter = null, BuildResult? resultFilter = null, IEnumerable tagFilters = null, IEnumerable properties = null, int? top = null, string continuationToken = null, int? maxBuildsPerDefinition = null, QueryDeletedOption? deletedFilter = null, BuildQueryOrder? queryOrder = null, string branchName = null, IEnumerable buildIds = null, object userState = null, CancellationToken cancellationToken = default(CancellationToken)) { HttpMethod httpMethod = new HttpMethod("GET"); Guid locationId = new Guid("0cd358e1-9217-4d94-8269-1c1ee6f93dcf"); List> queryParams = new List>(); if (definitions != null && definitions.Any()) { queryParams.Add("definitions", string.Join(",", definitions)); } if (queues != null && queues.Any()) { queryParams.Add("queues", string.Join(",", queues)); } if (!string.IsNullOrEmpty(buildNumber)) { queryParams.Add("buildNumber", buildNumber); } if (minFinishTime != null) { AddDateTimeToQueryParams(queryParams, "minFinishTime", minFinishTime.Value); } if (maxFinishTime != null) { AddDateTimeToQueryParams(queryParams, "maxFinishTime", maxFinishTime.Value); } if (!string.IsNullOrEmpty(requestedFor)) { queryParams.Add("requestedFor", requestedFor); } if (reasonFilter != null) { queryParams.Add("reasonFilter", reasonFilter.Value.ToString()); } if (statusFilter != null) { queryParams.Add("statusFilter", statusFilter.Value.ToString()); } if (resultFilter != null) { queryParams.Add("resultFilter", resultFilter.Value.ToString()); } if (tagFilters != null && tagFilters.Any()) { queryParams.Add("tagFilters", string.Join(",", tagFilters)); } if (properties != null && properties.Any()) { queryParams.Add("properties", string.Join(",", properties)); } if (top != null) { queryParams.Add("$top", top.Value.ToString(CultureInfo.InvariantCulture)); } if (!string.IsNullOrEmpty(continuationToken)) { queryParams.Add("continuationToken", continuationToken); } if (maxBuildsPerDefinition != null) { queryParams.Add("maxBuildsPerDefinition", maxBuildsPerDefinition.Value.ToString(CultureInfo.InvariantCulture)); } if (deletedFilter != null) { queryParams.Add("deletedFilter", deletedFilter.Value.ToString()); } if (queryOrder != null) { queryParams.Add("queryOrder", queryOrder.Value.ToString()); } if (!string.IsNullOrEmpty(branchName)) { queryParams.Add("branchName", branchName); } if (buildIds != null && buildIds.Any()) { queryParams.Add("buildIds", string.Join(",", buildIds)); } return SendAsync>( httpMethod, locationId, version: s_BuildsApiVersion, queryParameters: queryParams, userState: userState, cancellationToken: cancellationToken); } /// /// [Preview API] Gets a definition, optionally at a specific revision /// /// Project ID or project name /// /// /// /// /// The cancellation token to cancel operation. public virtual Task GetDefinitionAsync( string project, int definitionId, int? revision = null, IEnumerable propertyFilters = null, object userState = null, CancellationToken cancellationToken = default(CancellationToken)) { HttpMethod httpMethod = new HttpMethod("GET"); Guid locationId = new Guid("dbeaf647-6167-421a-bda9-c9327b25e2e6"); object routeValues = new { project = project, definitionId = definitionId }; List> queryParams = new List>(); if (revision != null) { queryParams.Add("revision", revision.Value.ToString(CultureInfo.InvariantCulture)); } if (propertyFilters != null && propertyFilters.Any()) { queryParams.Add("propertyFilters", string.Join(",", propertyFilters)); } return SendAsync( httpMethod, locationId, routeValues: routeValues, version: s_DefinitionsApiVersion, queryParameters: queryParams, userState: userState, cancellationToken: cancellationToken); } /// /// [Preview API] Gets a definition, optionally at a specific revision /// /// Project ID /// /// /// /// /// The cancellation token to cancel operation. public virtual Task GetDefinitionAsync( Guid project, int definitionId, int? revision = null, IEnumerable propertyFilters = null, object userState = null, CancellationToken cancellationToken = default(CancellationToken)) { HttpMethod httpMethod = new HttpMethod("GET"); Guid locationId = new Guid("dbeaf647-6167-421a-bda9-c9327b25e2e6"); object routeValues = new { project = project, definitionId = definitionId }; List> queryParams = new List>(); if (revision != null) { queryParams.Add("revision", revision.Value.ToString(CultureInfo.InvariantCulture)); } if (propertyFilters != null && propertyFilters.Any()) { queryParams.Add("propertyFilters", string.Join(",", propertyFilters)); } return SendAsync( httpMethod, locationId, routeValues: routeValues, version: s_DefinitionsApiVersion, queryParameters: queryParams, userState: userState, cancellationToken: cancellationToken); } /// /// [Preview API] Gets a definition, optionally at a specific revision /// /// /// /// /// /// The cancellation token to cancel operation. [Obsolete("Use GetDefinitionAsync(string, int) instead.")] public virtual Task GetDefinitionAsync( int definitionId, int? revision = null, IEnumerable propertyFilters = null, object userState = null, CancellationToken cancellationToken = default(CancellationToken)) { HttpMethod httpMethod = new HttpMethod("GET"); Guid locationId = new Guid("dbeaf647-6167-421a-bda9-c9327b25e2e6"); object routeValues = new { definitionId = definitionId }; List> queryParams = new List>(); if (revision != null) { queryParams.Add("revision", revision.Value.ToString(CultureInfo.InvariantCulture)); } if (propertyFilters != null && propertyFilters.Any()) { queryParams.Add("propertyFilters", string.Join(",", propertyFilters)); } return SendAsync( httpMethod, locationId, routeValues: routeValues, version: s_DefinitionsApiVersion, queryParameters: queryParams, userState: userState, cancellationToken: cancellationToken); } /// /// [Preview API] Gets definitions, optionally filtered by name /// /// Project ID or project name /// /// /// /// /// /// /// /// /// /// /// /// /// The cancellation token to cancel operation. public virtual Task> GetDefinitionsAsync( string project, string name = null, string repositoryId = null, string repositoryType = null, DefinitionQueryOrder? queryOrder = null, int? top = null, string continuationToken = null, DateTime? minMetricsTime = null, IEnumerable definitionIds = null, string path = null, DateTime? builtAfter = null, DateTime? notBuiltAfter = null, object userState = null, CancellationToken cancellationToken = default(CancellationToken)) { HttpMethod httpMethod = new HttpMethod("GET"); Guid locationId = new Guid("dbeaf647-6167-421a-bda9-c9327b25e2e6"); object routeValues = new { project = project }; List> queryParams = new List>(); if (!string.IsNullOrEmpty(name)) { queryParams.Add("name", name); } if (!string.IsNullOrEmpty(repositoryId)) { queryParams.Add("repositoryId", repositoryId); } if (!string.IsNullOrEmpty(repositoryType)) { queryParams.Add("repositoryType", repositoryType); } if (queryOrder != null) { queryParams.Add("queryOrder", queryOrder.Value.ToString()); } if (top != null) { queryParams.Add("$top", top.Value.ToString(CultureInfo.InvariantCulture)); } if (!string.IsNullOrEmpty(continuationToken)) { queryParams.Add("continuationToken", continuationToken); } if (minMetricsTime != null) { AddDateTimeToQueryParams(queryParams, "minMetricsTime", minMetricsTime.Value); } if (definitionIds != null && definitionIds.Any()) { queryParams.Add("definitionIds", string.Join(",", definitionIds)); } if (!string.IsNullOrEmpty(path)) { queryParams.Add("path", path); } if (builtAfter != null) { AddDateTimeToQueryParams(queryParams, "builtAfter", builtAfter.Value); } if (notBuiltAfter != null) { AddDateTimeToQueryParams(queryParams, "notBuiltAfter", notBuiltAfter.Value); } return SendAsync>( httpMethod, locationId, routeValues: routeValues, version: s_DefinitionsApiVersion, queryParameters: queryParams, userState: userState, cancellationToken: cancellationToken); } /// /// [Preview API] Gets definitions, optionally filtered by name /// /// Project ID /// /// /// /// /// /// /// /// /// /// /// /// /// The cancellation token to cancel operation. public virtual Task> GetDefinitionsAsync( Guid project, string name = null, string repositoryId = null, string repositoryType = null, DefinitionQueryOrder? queryOrder = null, int? top = null, string continuationToken = null, DateTime? minMetricsTime = null, IEnumerable definitionIds = null, string path = null, DateTime? builtAfter = null, DateTime? notBuiltAfter = null, object userState = null, CancellationToken cancellationToken = default(CancellationToken)) { HttpMethod httpMethod = new HttpMethod("GET"); Guid locationId = new Guid("dbeaf647-6167-421a-bda9-c9327b25e2e6"); object routeValues = new { project = project }; List> queryParams = new List>(); if (!string.IsNullOrEmpty(name)) { queryParams.Add("name", name); } if (!string.IsNullOrEmpty(repositoryId)) { queryParams.Add("repositoryId", repositoryId); } if (!string.IsNullOrEmpty(repositoryType)) { queryParams.Add("repositoryType", repositoryType); } if (queryOrder != null) { queryParams.Add("queryOrder", queryOrder.Value.ToString()); } if (top != null) { queryParams.Add("$top", top.Value.ToString(CultureInfo.InvariantCulture)); } if (!string.IsNullOrEmpty(continuationToken)) { queryParams.Add("continuationToken", continuationToken); } if (minMetricsTime != null) { AddDateTimeToQueryParams(queryParams, "minMetricsTime", minMetricsTime.Value); } if (definitionIds != null && definitionIds.Any()) { queryParams.Add("definitionIds", string.Join(",", definitionIds)); } if (!string.IsNullOrEmpty(path)) { queryParams.Add("path", path); } if (builtAfter != null) { AddDateTimeToQueryParams(queryParams, "builtAfter", builtAfter.Value); } if (notBuiltAfter != null) { AddDateTimeToQueryParams(queryParams, "notBuiltAfter", notBuiltAfter.Value); } return SendAsync>( httpMethod, locationId, routeValues: routeValues, version: s_DefinitionsApiVersion, queryParameters: queryParams, userState: userState, cancellationToken: cancellationToken); } /// /// [Preview API] Gets definitions, optionally filtered by name /// /// /// /// /// /// /// /// /// /// /// /// /// /// The cancellation token to cancel operation. [Obsolete("Use GetDefinitionsAsync(string) instead.")] public virtual Task> GetDefinitionsAsync( string name = null, string repositoryId = null, string repositoryType = null, DefinitionQueryOrder? queryOrder = null, int? top = null, string continuationToken = null, DateTime? minMetricsTime = null, IEnumerable definitionIds = null, string path = null, DateTime? builtAfter = null, DateTime? notBuiltAfter = null, object userState = null, CancellationToken cancellationToken = default(CancellationToken)) { HttpMethod httpMethod = new HttpMethod("GET"); Guid locationId = new Guid("dbeaf647-6167-421a-bda9-c9327b25e2e6"); List> queryParams = new List>(); if (!string.IsNullOrEmpty(name)) { queryParams.Add("name", name); } if (!string.IsNullOrEmpty(repositoryId)) { queryParams.Add("repositoryId", repositoryId); } if (!string.IsNullOrEmpty(repositoryType)) { queryParams.Add("repositoryType", repositoryType); } if (queryOrder != null) { queryParams.Add("queryOrder", queryOrder.Value.ToString()); } if (top != null) { queryParams.Add("$top", top.Value.ToString(CultureInfo.InvariantCulture)); } if (!string.IsNullOrEmpty(continuationToken)) { queryParams.Add("continuationToken", continuationToken); } if (minMetricsTime != null) { AddDateTimeToQueryParams(queryParams, "minMetricsTime", minMetricsTime.Value); } if (definitionIds != null && definitionIds.Any()) { queryParams.Add("definitionIds", string.Join(",", definitionIds)); } if (!string.IsNullOrEmpty(path)) { queryParams.Add("path", path); } if (builtAfter != null) { AddDateTimeToQueryParams(queryParams, "builtAfter", builtAfter.Value); } if (notBuiltAfter != null) { AddDateTimeToQueryParams(queryParams, "notBuiltAfter", notBuiltAfter.Value); } return SendAsync>( httpMethod, locationId, version: s_DefinitionsApiVersion, queryParameters: queryParams, userState: userState, cancellationToken: cancellationToken); } /// /// [Preview API] Gets definitions, optionally filtered by name /// /// Project ID or project name /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// The cancellation token to cancel operation. protected virtual Task> GetDefinitionsAsync( string project, string name = null, string repositoryId = null, string repositoryType = null, DefinitionQueryOrder? queryOrder = null, int? top = null, string continuationToken = null, DateTime? minMetricsTime = null, IEnumerable definitionIds = null, string path = null, DateTime? builtAfter = null, DateTime? notBuiltAfter = null, bool? includeAllProperties = null, bool? includeLatestBuilds = null, object userState = null, CancellationToken cancellationToken = default(CancellationToken)) { HttpMethod httpMethod = new HttpMethod("GET"); Guid locationId = new Guid("dbeaf647-6167-421a-bda9-c9327b25e2e6"); object routeValues = new { project = project }; List> queryParams = new List>(); if (!string.IsNullOrEmpty(name)) { queryParams.Add("name", name); } if (!string.IsNullOrEmpty(repositoryId)) { queryParams.Add("repositoryId", repositoryId); } if (!string.IsNullOrEmpty(repositoryType)) { queryParams.Add("repositoryType", repositoryType); } if (queryOrder != null) { queryParams.Add("queryOrder", queryOrder.Value.ToString()); } if (top != null) { queryParams.Add("$top", top.Value.ToString(CultureInfo.InvariantCulture)); } if (!string.IsNullOrEmpty(continuationToken)) { queryParams.Add("continuationToken", continuationToken); } if (minMetricsTime != null) { AddDateTimeToQueryParams(queryParams, "minMetricsTime", minMetricsTime.Value); } if (definitionIds != null && definitionIds.Any()) { queryParams.Add("definitionIds", string.Join(",", definitionIds)); } if (!string.IsNullOrEmpty(path)) { queryParams.Add("path", path); } if (builtAfter != null) { AddDateTimeToQueryParams(queryParams, "builtAfter", builtAfter.Value); } if (notBuiltAfter != null) { AddDateTimeToQueryParams(queryParams, "notBuiltAfter", notBuiltAfter.Value); } if (includeAllProperties != null) { queryParams.Add("includeAllProperties", includeAllProperties.Value.ToString()); } if (includeLatestBuilds != null) { queryParams.Add("includeLatestBuilds", includeLatestBuilds.Value.ToString()); } return SendAsync>( httpMethod, locationId, routeValues: routeValues, version: s_DefinitionsApiVersion, queryParameters: queryParams, userState: userState, cancellationToken: cancellationToken); } /// /// [Preview API] Gets definitions, optionally filtered by name /// /// Project ID /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// The cancellation token to cancel operation. protected virtual Task> GetDefinitionsAsync( Guid project, string name = null, string repositoryId = null, string repositoryType = null, DefinitionQueryOrder? queryOrder = null, int? top = null, string continuationToken = null, DateTime? minMetricsTime = null, IEnumerable definitionIds = null, string path = null, DateTime? builtAfter = null, DateTime? notBuiltAfter = null, bool? includeAllProperties = null, bool? includeLatestBuilds = null, object userState = null, CancellationToken cancellationToken = default(CancellationToken)) { HttpMethod httpMethod = new HttpMethod("GET"); Guid locationId = new Guid("dbeaf647-6167-421a-bda9-c9327b25e2e6"); object routeValues = new { project = project }; List> queryParams = new List>(); if (!string.IsNullOrEmpty(name)) { queryParams.Add("name", name); } if (!string.IsNullOrEmpty(repositoryId)) { queryParams.Add("repositoryId", repositoryId); } if (!string.IsNullOrEmpty(repositoryType)) { queryParams.Add("repositoryType", repositoryType); } if (queryOrder != null) { queryParams.Add("queryOrder", queryOrder.Value.ToString()); } if (top != null) { queryParams.Add("$top", top.Value.ToString(CultureInfo.InvariantCulture)); } if (!string.IsNullOrEmpty(continuationToken)) { queryParams.Add("continuationToken", continuationToken); } if (minMetricsTime != null) { AddDateTimeToQueryParams(queryParams, "minMetricsTime", minMetricsTime.Value); } if (definitionIds != null && definitionIds.Any()) { queryParams.Add("definitionIds", string.Join(",", definitionIds)); } if (!string.IsNullOrEmpty(path)) { queryParams.Add("path", path); } if (builtAfter != null) { AddDateTimeToQueryParams(queryParams, "builtAfter", builtAfter.Value); } if (notBuiltAfter != null) { AddDateTimeToQueryParams(queryParams, "notBuiltAfter", notBuiltAfter.Value); } if (includeAllProperties != null) { queryParams.Add("includeAllProperties", includeAllProperties.Value.ToString()); } if (includeLatestBuilds != null) { queryParams.Add("includeLatestBuilds", includeLatestBuilds.Value.ToString()); } return SendAsync>( httpMethod, locationId, routeValues: routeValues, version: s_DefinitionsApiVersion, queryParameters: queryParams, userState: userState, cancellationToken: cancellationToken); } /// /// [Preview API] Gets definitions, optionally filtered by name /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// The cancellation token to cancel operation. [Obsolete("Use GetDefinitionsAsync(string) instead.")] protected virtual Task> GetDefinitionsAsync( string name = null, string repositoryId = null, string repositoryType = null, DefinitionQueryOrder? queryOrder = null, int? top = null, string continuationToken = null, DateTime? minMetricsTime = null, IEnumerable definitionIds = null, string path = null, DateTime? builtAfter = null, DateTime? notBuiltAfter = null, bool? includeAllProperties = null, bool? includeLatestBuilds = null, object userState = null, CancellationToken cancellationToken = default(CancellationToken)) { HttpMethod httpMethod = new HttpMethod("GET"); Guid locationId = new Guid("dbeaf647-6167-421a-bda9-c9327b25e2e6"); List> queryParams = new List>(); if (!string.IsNullOrEmpty(name)) { queryParams.Add("name", name); } if (!string.IsNullOrEmpty(repositoryId)) { queryParams.Add("repositoryId", repositoryId); } if (!string.IsNullOrEmpty(repositoryType)) { queryParams.Add("repositoryType", repositoryType); } if (queryOrder != null) { queryParams.Add("queryOrder", queryOrder.Value.ToString()); } if (top != null) { queryParams.Add("$top", top.Value.ToString(CultureInfo.InvariantCulture)); } if (!string.IsNullOrEmpty(continuationToken)) { queryParams.Add("continuationToken", continuationToken); } if (minMetricsTime != null) { AddDateTimeToQueryParams(queryParams, "minMetricsTime", minMetricsTime.Value); } if (definitionIds != null && definitionIds.Any()) { queryParams.Add("definitionIds", string.Join(",", definitionIds)); } if (!string.IsNullOrEmpty(path)) { queryParams.Add("path", path); } if (builtAfter != null) { AddDateTimeToQueryParams(queryParams, "builtAfter", builtAfter.Value); } if (notBuiltAfter != null) { AddDateTimeToQueryParams(queryParams, "notBuiltAfter", notBuiltAfter.Value); } if (includeAllProperties != null) { queryParams.Add("includeAllProperties", includeAllProperties.Value.ToString()); } if (includeLatestBuilds != null) { queryParams.Add("includeLatestBuilds", includeLatestBuilds.Value.ToString()); } return SendAsync>( httpMethod, locationId, version: s_DefinitionsApiVersion, queryParameters: queryParams, userState: userState, cancellationToken: cancellationToken); } /// /// [Preview API] Gets a list of definitions. /// /// Project ID or project name /// If specified, filters to definitions whose names match this pattern. /// A repository ID. If specified, filters to definitions that use this repository. /// If specified, filters to definitions that have a repository of this type. /// Indicates the order in which definitions should be returned. /// The maximum number of definitions to return. /// A continuation token, returned by a previous call to this method, that can be used to return the next set of definitions. /// If specified, indicates the date from which metrics should be included. /// A comma-delimited list that specifies the IDs of definitions to retrieve. /// If specified, filters to definitions under this folder. /// If specified, filters to definitions that have builds after this date. /// If specified, filters to definitions that do not have builds after this date. /// Indicates whether the full definitions should be returned. By default, shallow representations of the definitions are returned. /// Indicates whether to return the latest and latest completed builds for this definition. /// If specified, filters to definitions that use the specified task. /// /// The cancellation token to cancel operation. protected virtual Task> GetDefinitionsAsync( string project, string name = null, string repositoryId = null, string repositoryType = null, DefinitionQueryOrder? queryOrder = null, int? top = null, string continuationToken = null, DateTime? minMetricsTime = null, IEnumerable definitionIds = null, string path = null, DateTime? builtAfter = null, DateTime? notBuiltAfter = null, bool? includeAllProperties = null, bool? includeLatestBuilds = null, Guid? taskIdFilter = null, object userState = null, CancellationToken cancellationToken = default(CancellationToken)) { HttpMethod httpMethod = new HttpMethod("GET"); Guid locationId = new Guid("dbeaf647-6167-421a-bda9-c9327b25e2e6"); object routeValues = new { project = project }; List> queryParams = new List>(); if (!string.IsNullOrEmpty(name)) { queryParams.Add("name", name); } if (!string.IsNullOrEmpty(repositoryId)) { queryParams.Add("repositoryId", repositoryId); } if (!string.IsNullOrEmpty(repositoryType)) { queryParams.Add("repositoryType", repositoryType); } if (queryOrder != null) { queryParams.Add("queryOrder", queryOrder.Value.ToString()); } if (top != null) { queryParams.Add("$top", top.Value.ToString(CultureInfo.InvariantCulture)); } if (!string.IsNullOrEmpty(continuationToken)) { queryParams.Add("continuationToken", continuationToken); } if (minMetricsTime != null) { AddDateTimeToQueryParams(queryParams, "minMetricsTime", minMetricsTime.Value); } if (definitionIds != null && definitionIds.Any()) { queryParams.Add("definitionIds", string.Join(",", definitionIds)); } if (!string.IsNullOrEmpty(path)) { queryParams.Add("path", path); } if (builtAfter != null) { AddDateTimeToQueryParams(queryParams, "builtAfter", builtAfter.Value); } if (notBuiltAfter != null) { AddDateTimeToQueryParams(queryParams, "notBuiltAfter", notBuiltAfter.Value); } if (includeAllProperties != null) { queryParams.Add("includeAllProperties", includeAllProperties.Value.ToString()); } if (includeLatestBuilds != null) { queryParams.Add("includeLatestBuilds", includeLatestBuilds.Value.ToString()); } if (taskIdFilter != null) { queryParams.Add("taskIdFilter", taskIdFilter.Value.ToString()); } return SendAsync>( httpMethod, locationId, routeValues: routeValues, version: new ApiResourceVersion("5.0-preview.6"), queryParameters: queryParams, userState: userState, cancellationToken: cancellationToken); } /// /// [Preview API] Gets a list of definitions. /// /// Project ID /// If specified, filters to definitions whose names match this pattern. /// A repository ID. If specified, filters to definitions that use this repository. /// If specified, filters to definitions that have a repository of this type. /// Indicates the order in which definitions should be returned. /// The maximum number of definitions to return. /// A continuation token, returned by a previous call to this method, that can be used to return the next set of definitions. /// If specified, indicates the date from which metrics should be included. /// A comma-delimited list that specifies the IDs of definitions to retrieve. /// If specified, filters to definitions under this folder. /// If specified, filters to definitions that have builds after this date. /// If specified, filters to definitions that do not have builds after this date. /// Indicates whether the full definitions should be returned. By default, shallow representations of the definitions are returned. /// Indicates whether to return the latest and latest completed builds for this definition. /// If specified, filters to definitions that use the specified task. /// /// The cancellation token to cancel operation. protected virtual Task> GetDefinitionsAsync( Guid project, string name = null, string repositoryId = null, string repositoryType = null, DefinitionQueryOrder? queryOrder = null, int? top = null, string continuationToken = null, DateTime? minMetricsTime = null, IEnumerable definitionIds = null, string path = null, DateTime? builtAfter = null, DateTime? notBuiltAfter = null, bool? includeAllProperties = null, bool? includeLatestBuilds = null, Guid? taskIdFilter = null, object userState = null, CancellationToken cancellationToken = default(CancellationToken)) { HttpMethod httpMethod = new HttpMethod("GET"); Guid locationId = new Guid("dbeaf647-6167-421a-bda9-c9327b25e2e6"); object routeValues = new { project = project }; List> queryParams = new List>(); if (!string.IsNullOrEmpty(name)) { queryParams.Add("name", name); } if (!string.IsNullOrEmpty(repositoryId)) { queryParams.Add("repositoryId", repositoryId); } if (!string.IsNullOrEmpty(repositoryType)) { queryParams.Add("repositoryType", repositoryType); } if (queryOrder != null) { queryParams.Add("queryOrder", queryOrder.Value.ToString()); } if (top != null) { queryParams.Add("$top", top.Value.ToString(CultureInfo.InvariantCulture)); } if (!string.IsNullOrEmpty(continuationToken)) { queryParams.Add("continuationToken", continuationToken); } if (minMetricsTime != null) { AddDateTimeToQueryParams(queryParams, "minMetricsTime", minMetricsTime.Value); } if (definitionIds != null && definitionIds.Any()) { queryParams.Add("definitionIds", string.Join(",", definitionIds)); } if (!string.IsNullOrEmpty(path)) { queryParams.Add("path", path); } if (builtAfter != null) { AddDateTimeToQueryParams(queryParams, "builtAfter", builtAfter.Value); } if (notBuiltAfter != null) { AddDateTimeToQueryParams(queryParams, "notBuiltAfter", notBuiltAfter.Value); } if (includeAllProperties != null) { queryParams.Add("includeAllProperties", includeAllProperties.Value.ToString()); } if (includeLatestBuilds != null) { queryParams.Add("includeLatestBuilds", includeLatestBuilds.Value.ToString()); } if (taskIdFilter != null) { queryParams.Add("taskIdFilter", taskIdFilter.Value.ToString()); } return SendAsync>( httpMethod, locationId, routeValues: routeValues, version: new ApiResourceVersion("5.0-preview.6"), queryParameters: queryParams, userState: userState, cancellationToken: cancellationToken); } /// /// [Preview API] Gets a list of definitions. /// /// If specified, filters to definitions whose names match this pattern. /// A repository ID. If specified, filters to definitions that use this repository. /// If specified, filters to definitions that have a repository of this type. /// Indicates the order in which definitions should be returned. /// The maximum number of definitions to return. /// A continuation token, returned by a previous call to this method, that can be used to return the next set of definitions. /// If specified, indicates the date from which metrics should be included. /// A comma-delimited list that specifies the IDs of definitions to retrieve. /// If specified, filters to definitions under this folder. /// If specified, filters to definitions that have builds after this date. /// If specified, filters to definitions that do not have builds after this date. /// Indicates whether the full definitions should be returned. By default, shallow representations of the definitions are returned. /// Indicates whether to return the latest and latest completed builds for this definition. /// If specified, filters to definitions that use the specified task. /// /// The cancellation token to cancel operation. protected virtual Task> GetDefinitionsAsync( string name = null, string repositoryId = null, string repositoryType = null, DefinitionQueryOrder? queryOrder = null, int? top = null, string continuationToken = null, DateTime? minMetricsTime = null, IEnumerable definitionIds = null, string path = null, DateTime? builtAfter = null, DateTime? notBuiltAfter = null, bool? includeAllProperties = null, bool? includeLatestBuilds = null, Guid? taskIdFilter = null, object userState = null, CancellationToken cancellationToken = default(CancellationToken)) { HttpMethod httpMethod = new HttpMethod("GET"); Guid locationId = new Guid("dbeaf647-6167-421a-bda9-c9327b25e2e6"); List> queryParams = new List>(); if (!string.IsNullOrEmpty(name)) { queryParams.Add("name", name); } if (!string.IsNullOrEmpty(repositoryId)) { queryParams.Add("repositoryId", repositoryId); } if (!string.IsNullOrEmpty(repositoryType)) { queryParams.Add("repositoryType", repositoryType); } if (queryOrder != null) { queryParams.Add("queryOrder", queryOrder.Value.ToString()); } if (top != null) { queryParams.Add("$top", top.Value.ToString(CultureInfo.InvariantCulture)); } if (!string.IsNullOrEmpty(continuationToken)) { queryParams.Add("continuationToken", continuationToken); } if (minMetricsTime != null) { AddDateTimeToQueryParams(queryParams, "minMetricsTime", minMetricsTime.Value); } if (definitionIds != null && definitionIds.Any()) { queryParams.Add("definitionIds", string.Join(",", definitionIds)); } if (!string.IsNullOrEmpty(path)) { queryParams.Add("path", path); } if (builtAfter != null) { AddDateTimeToQueryParams(queryParams, "builtAfter", builtAfter.Value); } if (notBuiltAfter != null) { AddDateTimeToQueryParams(queryParams, "notBuiltAfter", notBuiltAfter.Value); } if (includeAllProperties != null) { queryParams.Add("includeAllProperties", includeAllProperties.Value.ToString()); } if (includeLatestBuilds != null) { queryParams.Add("includeLatestBuilds", includeLatestBuilds.Value.ToString()); } if (taskIdFilter != null) { queryParams.Add("taskIdFilter", taskIdFilter.Value.ToString()); } return SendAsync>( httpMethod, locationId, version: new ApiResourceVersion("5.0-preview.6"), queryParameters: queryParams, userState: userState, cancellationToken: cancellationToken); } /// /// [Preview API] Gets definitions, optionally filtered by name /// /// Project ID or project name /// /// /// /// /// /// /// /// /// /// The cancellation token to cancel operation. public virtual Task> GetDefinitionsAsync2( string project, string name = null, string repositoryId = null, string repositoryType = null, DefinitionQueryOrder? queryOrder = null, int? top = null, string continuationToken = null, DateTime? minMetricsTimeInUtc = null, IEnumerable definitionIds = null, string path = null, DateTime? builtAfter = null, DateTime? notBuiltAfter = null, object userState = null, CancellationToken cancellationToken = default(CancellationToken)) { HttpMethod httpMethod = new HttpMethod("GET"); Guid locationId = new Guid("dbeaf647-6167-421a-bda9-c9327b25e2e6"); object routeValues = new { project = project }; List> queryParams = GetDefinitionsQueryParams( name, repositoryId, repositoryType, queryOrder, top, continuationToken, minMetricsTimeInUtc, definitionIds, path, builtAfter, notBuiltAfter, false); return SendAsync>( httpMethod, locationId, routeValues: routeValues, version: s_DefinitionsApiVersion, queryParameters: queryParams, userState: userState, cancellationToken: cancellationToken, processResponse: GetPagedList ); } /// /// [Preview API] Gets definitions, optionally filtered by name /// /// Project ID /// /// /// /// /// /// /// /// /// /// /// The cancellation token to cancel operation. public virtual Task> GetDefinitionsAsync2( Guid project, string name = null, string repositoryId = null, string repositoryType = null, DefinitionQueryOrder? queryOrder = null, int? top = null, string continuationToken = null, DateTime? minMetricsTimeInUtc = null, IEnumerable definitionIds = null, String path = null, DateTime? builtAfter = null, DateTime? notBuiltAfter = null, object userState = null, CancellationToken cancellationToken = default(CancellationToken)) { HttpMethod httpMethod = new HttpMethod("GET"); Guid locationId = new Guid("dbeaf647-6167-421a-bda9-c9327b25e2e6"); object routeValues = new { project = project }; List> queryParams = GetDefinitionsQueryParams( name, repositoryId, repositoryType, queryOrder, top, continuationToken, minMetricsTimeInUtc, definitionIds, path, builtAfter, notBuiltAfter, false); return SendAsync>( httpMethod, locationId, routeValues: routeValues, version: s_DefinitionsApiVersion, queryParameters: queryParams, userState: userState, cancellationToken: cancellationToken, processResponse: GetPagedList ); } /// /// [Preview API] Gets definitions, optionally filtered by name /// /// /// /// /// /// /// /// /// /// /// /// The cancellation token to cancel operation. [Obsolete("Use GetDefinitionsAsync2(string) instead.")] public virtual Task> GetDefinitionsAsync2( string name = null, string repositoryId = null, string repositoryType = null, DefinitionQueryOrder? queryOrder = null, int? top = null, string continuationToken = null, DateTime? minMetricsTimeInUtc = null, IEnumerable definitionIds = null, String path = null, DateTime? builtAfter = null, DateTime? notBuiltAfter = null, object userState = null, CancellationToken cancellationToken = default(CancellationToken)) { HttpMethod httpMethod = new HttpMethod("GET"); Guid locationId = new Guid("dbeaf647-6167-421a-bda9-c9327b25e2e6"); List> queryParams = GetDefinitionsQueryParams( name, repositoryId, repositoryType, queryOrder, top, continuationToken, minMetricsTimeInUtc, definitionIds, path, builtAfter, notBuiltAfter, false); return SendAsync>( httpMethod, locationId, version: s_DefinitionsApiVersion, queryParameters: queryParams, userState: userState, cancellationToken: cancellationToken, processResponse: GetPagedList ); } /// /// [Preview API] Gets definitions, optionally filtered by name /// /// Project ID or project name /// /// /// /// /// /// /// /// /// /// The cancellation token to cancel operation. public virtual Task> GetFullDefinitionsAsync( string project, string name = null, string repositoryId = null, string repositoryType = null, DefinitionQueryOrder? queryOrder = null, int? top = null, string continuationToken = null, DateTime? minMetricsTimeInUtc = null, IEnumerable definitionIds = null, string path = null, DateTime? builtAfter = null, DateTime? notBuiltAfter = null, object userState = null, CancellationToken cancellationToken = default(CancellationToken)) { HttpMethod httpMethod = new HttpMethod("GET"); Guid locationId = new Guid("dbeaf647-6167-421a-bda9-c9327b25e2e6"); object routeValues = new { project = project }; List> queryParams = GetDefinitionsQueryParams( name, repositoryId, repositoryType, queryOrder, top, continuationToken, minMetricsTimeInUtc, definitionIds, path, builtAfter, notBuiltAfter, true); return SendAsync>( httpMethod, locationId, routeValues: routeValues, version: s_DefinitionsApiVersion, queryParameters: queryParams, userState: userState, cancellationToken: cancellationToken ); } /// /// [Preview API] Gets definitions, optionally filtered by name /// /// Project ID /// /// /// /// /// /// /// /// /// /// /// The cancellation token to cancel operation. public virtual Task> GetFullDefinitionsAsync( Guid project, string name = null, string repositoryId = null, string repositoryType = null, DefinitionQueryOrder? queryOrder = null, int? top = null, string continuationToken = null, DateTime? minMetricsTimeInUtc = null, IEnumerable definitionIds = null, String path = null, DateTime? builtAfter = null, DateTime? notBuiltAfter = null, object userState = null, CancellationToken cancellationToken = default(CancellationToken)) { HttpMethod httpMethod = new HttpMethod("GET"); Guid locationId = new Guid("dbeaf647-6167-421a-bda9-c9327b25e2e6"); object routeValues = new { project = project }; List> queryParams = GetDefinitionsQueryParams( name, repositoryId, repositoryType, queryOrder, top, continuationToken, minMetricsTimeInUtc, definitionIds, path, builtAfter, notBuiltAfter, true); return SendAsync>( httpMethod, locationId, routeValues: routeValues, version: s_DefinitionsApiVersion, queryParameters: queryParams, userState: userState, cancellationToken: cancellationToken ); } /// /// [Preview API] Gets definitions, optionally filtered by name /// /// /// /// /// /// /// /// /// /// /// /// The cancellation token to cancel operation. [Obsolete("Use GetFullDefinitionsAsync(string) instead.")] public virtual Task> GetFullDefinitionsAsync( string name = null, string repositoryId = null, string repositoryType = null, DefinitionQueryOrder? queryOrder = null, int? top = null, string continuationToken = null, DateTime? minMetricsTimeInUtc = null, IEnumerable definitionIds = null, String path = null, DateTime? builtAfter = null, DateTime? notBuiltAfter = null, object userState = null, CancellationToken cancellationToken = default(CancellationToken)) { HttpMethod httpMethod = new HttpMethod("GET"); Guid locationId = new Guid("dbeaf647-6167-421a-bda9-c9327b25e2e6"); List> queryParams = GetDefinitionsQueryParams( name, repositoryId, repositoryType, queryOrder, top, continuationToken, minMetricsTimeInUtc, definitionIds, path, builtAfter, notBuiltAfter, true); return SendAsync>( httpMethod, locationId, version: s_DefinitionsApiVersion, queryParameters: queryParams, userState: userState, cancellationToken: cancellationToken ); } /// /// [Preview API] Gets definitions, optionally filtered by name /// /// Project ID or project name /// /// /// /// /// /// /// /// /// /// The cancellation token to cancel operation. public virtual Task> GetFullDefinitionsAsync2( string project, string name = null, string repositoryId = null, string repositoryType = null, DefinitionQueryOrder? queryOrder = null, int? top = null, string continuationToken = null, DateTime? minMetricsTimeInUtc = null, IEnumerable definitionIds = null, string path = null, DateTime? builtAfter = null, DateTime? notBuiltAfter = null, object userState = null, CancellationToken cancellationToken = default(CancellationToken)) { HttpMethod httpMethod = new HttpMethod("GET"); Guid locationId = new Guid("dbeaf647-6167-421a-bda9-c9327b25e2e6"); object routeValues = new { project = project }; List> queryParams = GetDefinitionsQueryParams( name, repositoryId, repositoryType, queryOrder, top, continuationToken, minMetricsTimeInUtc, definitionIds, path, builtAfter, notBuiltAfter, true); return SendAsync>( httpMethod, locationId, routeValues: routeValues, version: s_DefinitionsApiVersion, queryParameters: queryParams, userState: userState, cancellationToken: cancellationToken, processResponse: GetPagedList ); } /// /// [Preview API] Gets definitions, optionally filtered by name /// /// Project ID /// /// /// /// /// /// /// /// /// /// /// The cancellation token to cancel operation. public virtual Task> GetFullDefinitionsAsync2( Guid project, string name = null, string repositoryId = null, string repositoryType = null, DefinitionQueryOrder? queryOrder = null, int? top = null, string continuationToken = null, DateTime? minMetricsTimeInUtc = null, IEnumerable definitionIds = null, String path = null, DateTime? builtAfter = null, DateTime? notBuiltAfter = null, object userState = null, CancellationToken cancellationToken = default(CancellationToken)) { HttpMethod httpMethod = new HttpMethod("GET"); Guid locationId = new Guid("dbeaf647-6167-421a-bda9-c9327b25e2e6"); object routeValues = new { project = project }; List> queryParams = GetDefinitionsQueryParams( name, repositoryId, repositoryType, queryOrder, top, continuationToken, minMetricsTimeInUtc, definitionIds, path, builtAfter, notBuiltAfter, true); return SendAsync>( httpMethod, locationId, routeValues: routeValues, version: s_DefinitionsApiVersion, queryParameters: queryParams, userState: userState, cancellationToken: cancellationToken, processResponse: GetPagedList ); } /// /// [Preview API] Gets definitions, optionally filtered by name /// /// /// /// /// /// /// /// /// /// /// /// The cancellation token to cancel operation. [Obsolete("Use GetFullDefinitionsAsync2(string) instead.")] public virtual Task> GetFullDefinitionsAsync2( string name = null, string repositoryId = null, string repositoryType = null, DefinitionQueryOrder? queryOrder = null, int? top = null, string continuationToken = null, DateTime? minMetricsTimeInUtc = null, IEnumerable definitionIds = null, String path = null, DateTime? builtAfter = null, DateTime? notBuiltAfter = null, object userState = null, CancellationToken cancellationToken = default(CancellationToken)) { HttpMethod httpMethod = new HttpMethod("GET"); Guid locationId = new Guid("dbeaf647-6167-421a-bda9-c9327b25e2e6"); List> queryParams = GetDefinitionsQueryParams( name, repositoryId, repositoryType, queryOrder, top, continuationToken, minMetricsTimeInUtc, definitionIds, path, builtAfter, notBuiltAfter, true); return SendAsync>( httpMethod, locationId, version: s_DefinitionsApiVersion, queryParameters: queryParams, userState: userState, cancellationToken: cancellationToken, processResponse: GetPagedList ); } /// /// [Preview API] Updates a build. /// /// The build. /// The ID of the build. /// /// /// The cancellation token to cancel operation. [Obsolete("Use UpdateBuildAsync(Build, bool, object, CancellationToken) instead.")] public virtual Task UpdateBuildAsync( Build build, int buildId, object userState = null, CancellationToken cancellationToken = default(CancellationToken)) { HttpMethod httpMethod = new HttpMethod("PATCH"); Guid locationId = new Guid("0cd358e1-9217-4d94-8269-1c1ee6f93dcf"); object routeValues = new { buildId = buildId }; HttpContent content = new ObjectContent(build, new VssJsonMediaTypeFormatter(true)); return SendAsync( httpMethod, locationId, routeValues: routeValues, version: new ApiResourceVersion(5.0, 4), userState: userState, cancellationToken: cancellationToken, content: content); } /// /// [Preview API] Updates a build. /// /// The build. /// Project ID or project name /// The ID of the build. /// /// /// The cancellation token to cancel operation. [Obsolete("Use UpdateBuildAsync(Build, bool, object, CancellationToken) instead.")] public virtual Task UpdateBuildAsync( Build build, string project, int buildId, object userState = null, CancellationToken cancellationToken = default(CancellationToken)) { HttpMethod httpMethod = new HttpMethod("PATCH"); Guid locationId = new Guid("0cd358e1-9217-4d94-8269-1c1ee6f93dcf"); object routeValues = new { project = project, buildId = buildId }; HttpContent content = new ObjectContent(build, new VssJsonMediaTypeFormatter(true)); return SendAsync( httpMethod, locationId, routeValues: routeValues, version: new ApiResourceVersion(5.0, 4), userState: userState, cancellationToken: cancellationToken, content: content); } /// /// [Preview API] Updates a build. /// /// The build. /// Project ID /// The ID of the build. /// /// /// The cancellation token to cancel operation. [Obsolete("Use UpdateBuildAsync(Build, bool, object, CancellationToken) instead.")] public virtual Task UpdateBuildAsync( Build build, Guid project, int buildId, object userState = null, CancellationToken cancellationToken = default(CancellationToken)) { HttpMethod httpMethod = new HttpMethod("PATCH"); Guid locationId = new Guid("0cd358e1-9217-4d94-8269-1c1ee6f93dcf"); object routeValues = new { project = project, buildId = buildId }; HttpContent content = new ObjectContent(build, new VssJsonMediaTypeFormatter(true)); return SendAsync( httpMethod, locationId, routeValues: routeValues, version: new ApiResourceVersion(5.0, 4), userState: userState, cancellationToken: cancellationToken, content: content); } /// /// [Preview API] Gets a list of branches for the given source code repository. /// /// Project ID or project name /// The name of the source provider. /// If specified, the ID of the service endpoint to query. Can only be omitted for providers that do not use service endpoints, e.g. TFVC or TFGit. /// If specified, the vendor-specific identifier or the name of the repository to get branches. Can only be omitted for providers that do not support multiple repositories. /// /// The cancellation token to cancel operation. public virtual Task> ListBranchesAsync( string project, string providerName, Guid? serviceEndpointId = null, string repository = null, object userState = null, CancellationToken cancellationToken = default) { HttpMethod httpMethod = new HttpMethod("GET"); Guid locationId = new Guid("e05d4403-9b81-4244-8763-20fde28d1976"); object routeValues = new { project = project, providerName = providerName }; List> queryParams = new List>(); if (serviceEndpointId != null) { queryParams.Add("serviceEndpointId", serviceEndpointId.Value.ToString()); } if (repository != null) { queryParams.Add("repository", repository); } return SendAsync>( httpMethod, locationId, routeValues: routeValues, version: new ApiResourceVersion(5.1, 1), queryParameters: queryParams, userState: userState, cancellationToken: cancellationToken); } /// /// [Preview API] Gets a list of branches for the given source code repository. /// /// Project ID /// The name of the source provider. /// If specified, the ID of the service endpoint to query. Can only be omitted for providers that do not use service endpoints, e.g. TFVC or TFGit. /// If specified, the vendor-specific identifier or the name of the repository to get branches. Can only be omitted for providers that do not support multiple repositories. /// /// The cancellation token to cancel operation. public virtual Task> ListBranchesAsync( Guid project, string providerName, Guid? serviceEndpointId = null, string repository = null, object userState = null, CancellationToken cancellationToken = default) { HttpMethod httpMethod = new HttpMethod("GET"); Guid locationId = new Guid("e05d4403-9b81-4244-8763-20fde28d1976"); object routeValues = new { project = project, providerName = providerName }; List> queryParams = new List>(); if (serviceEndpointId != null) { queryParams.Add("serviceEndpointId", serviceEndpointId.Value.ToString()); } if (repository != null) { queryParams.Add("repository", repository); } return SendAsync>( httpMethod, locationId, routeValues: routeValues, version: new ApiResourceVersion(5.1, 1), queryParameters: queryParams, userState: userState, cancellationToken: cancellationToken); } private protected List> GetDefinitionsQueryParams( string name = null, string repositoryId = null, string repositoryType = null, DefinitionQueryOrder? queryOrder = null, int? top = null, string continuationToken = null, DateTime? minMetricsTimeInUtc = null, IEnumerable definitionIds = null, String path = null, DateTime? builtAfter = null, DateTime? notBuiltAfter = null, bool? includeAllProperties = null, bool? includeLatestBuilds = null, Guid? taskIdFilter = null, int? processType = null, string yamlFilename = null) { List> queryParams = new List>(); // in case the server doesn't support 3.x yet queryParams.Add("type", DefinitionType.Build.ToString()); if (!string.IsNullOrEmpty(name)) { queryParams.Add("name", name); } if (!string.IsNullOrEmpty(repositoryId)) { queryParams.Add("repositoryId", repositoryId); } if (!string.IsNullOrEmpty(repositoryType)) { queryParams.Add("repositoryType", repositoryType); } if (queryOrder != null) { queryParams.Add("queryOrder", queryOrder.Value.ToString()); } if (top != null) { queryParams.Add("$top", top.Value.ToString(CultureInfo.InvariantCulture)); } if (!string.IsNullOrEmpty(continuationToken)) { queryParams.Add("continuationToken", continuationToken); } if (minMetricsTimeInUtc != null) { AddDateTimeToQueryParams(queryParams, "minMetricsTimeInUtc", minMetricsTimeInUtc.Value); } if (definitionIds != null && definitionIds.Any()) { queryParams.Add("definitionIds", string.Join(",", definitionIds)); } if (!string.IsNullOrEmpty(path)) { queryParams.Add("path", path); } if (builtAfter != null) { AddDateTimeToQueryParams(queryParams, "builtAfter", builtAfter.Value); } if (notBuiltAfter != null) { AddDateTimeToQueryParams(queryParams, "notBuiltAfter", notBuiltAfter.Value); } if (includeAllProperties ?? false) { queryParams.Add("includeAllProperties", includeAllProperties.Value.ToString()); } if (includeLatestBuilds ?? false) { queryParams.Add("includeLatestBuilds", includeLatestBuilds.Value.ToString()); } if (taskIdFilter.HasValue) { queryParams.Add("taskIdFilter", taskIdFilter.Value.ToString()); } if (processType.HasValue) { queryParams.Add("processType", processType.Value.ToString(CultureInfo.InvariantCulture)); } if (!string.IsNullOrEmpty(yamlFilename)) { queryParams.Add("yamlFilename", yamlFilename); } return queryParams; } private protected async Task> GetPagedList(HttpResponseMessage responseMessage, CancellationToken cancellationToken) { var continuationToken = GetContinuationToken(responseMessage); var list = await ReadContentAsAsync>(responseMessage, cancellationToken).ConfigureAwait(false); return new PagedList(list, continuationToken); } private protected Task SendAsync( HttpMethod method, Guid locationId, Object routeValues = null, ApiResourceVersion version = null, HttpContent content = null, IEnumerable> queryParameters = null, Object userState = null, CancellationToken cancellationToken = default(CancellationToken), Func> processResponse = null) { return SendAsync(method, null, locationId, routeValues, version, content, queryParameters, userState, cancellationToken, processResponse); } private protected async Task SendAsync( HttpMethod method, IEnumerable> additionalHeaders, Guid locationId, Object routeValues = null, ApiResourceVersion version = null, HttpContent content = null, IEnumerable> queryParameters = null, Object userState = null, CancellationToken cancellationToken = default(CancellationToken), Func> processResponse = null) { using (VssTraceActivity.GetOrCreate().EnterCorrelationScope()) using (HttpRequestMessage requestMessage = await CreateRequestMessageAsync(method, additionalHeaders, locationId, routeValues, version, content, queryParameters, userState, cancellationToken).ConfigureAwait(false)) { return await SendAsync(requestMessage, userState, cancellationToken, processResponse).ConfigureAwait(false); } } private protected async Task SendAsync( HttpRequestMessage message, Object userState = null, CancellationToken cancellationToken = default(CancellationToken), Func> processResponse = null) { if (processResponse == null) { processResponse = ReadContentAsAsync; } //ConfigureAwait(false) enables the continuation to be run outside //any captured SyncronizationContext (such as ASP.NET's) which keeps things //from deadlocking... using (HttpResponseMessage response = await this.SendAsync(message, userState, cancellationToken).ConfigureAwait(false)) { return await processResponse(response, cancellationToken).ConfigureAwait(false); } } private protected string GetContinuationToken(HttpResponseMessage responseMessage) { string continuationToken = null; IEnumerable headerValues = null; if (responseMessage.Headers.TryGetValues("x-ms-continuationtoken", out headerValues)) { continuationToken = headerValues.FirstOrDefault(); } return continuationToken; } protected static readonly ApiResourceVersion s_BuildsApiVersion = new ApiResourceVersion("4.1-preview.3"); protected static readonly ApiResourceVersion s_DefinitionsApiVersion = new ApiResourceVersion("4.1-preview.6"); } }