/// <summary> /// Gets the team project collection references for the given <paramref name="projectCollectionHttpClient" />. /// </summary> /// <param name="projectCollectionHttpClient">The project collection HTTP client.</param> /// <param name="count">The amount of project collection references to retrieve at most.</param> /// <param name="skip">How many project collection references to skip.</param> /// <param name="userState">The user state object to pass along to the underlying method.</param> /// <returns></returns> /// <exception cref="System.ArgumentNullException">projectCollectionHttpClient</exception> public static IObservable <TeamProjectCollectionReference> GetTeamProjectCollectionReferences( this ProjectCollectionHttpClient projectCollectionHttpClient, int?count = null, int?skip = null, object userState = null) { if (projectCollectionHttpClient == null) { throw new ArgumentNullException(nameof(projectCollectionHttpClient)); } return(Observable.FromAsync(token => projectCollectionHttpClient.GetProjectCollections(count, skip, userState)) .SelectMany(projectCollectionReferences => projectCollectionReferences)); }
/// <summary> /// List all available collections on the server /// </summary> /// <param name="connection">Connection to use</param> private static void ListCollections(VssConnection connection) { ProjectCollectionHttpClient projectCollectionClient = connection.GetClient <ProjectCollectionHttpClient>(); IEnumerable <TeamProjectCollectionReference> projectCollections = projectCollectionClient.GetProjectCollections().Result; // get all collections Console.WriteLine($"Found {projectCollections.Count()} collections"); foreach (var collection in projectCollections) { Console.WriteLine($"\t{collection.Name}"); } Console.WriteLine(); }
public IEnumerable <TeamProjectCollectionReference> ListProjectCollections() { VssConnection connection = Context.Connection; ProjectCollectionHttpClient projectCollectionClient = connection.GetClient <ProjectCollectionHttpClient>(); IEnumerable <TeamProjectCollectionReference> projectCollections = projectCollectionClient.GetProjectCollections().Result; foreach (var collection in projectCollections) { Console.WriteLine(collection.Name); } return(projectCollections); }
private Task GetCollectionAsync(ProjectCollectionHttpClient projectCollectionHttpClient) { return(Task.Factory.StartNew(() => { foreach (var projectCollectionReference in projectCollectionHttpClient.GetProjectCollections(10, 0).Result) { // retrieve a reference to the actual project collection based on its (reference) .Id var projectCollection = projectCollectionHttpClient.GetProjectCollection(projectCollectionReference.Id.ToString()).Result; // the 'web' Url is the one for the PC itself, the API endpoint one is different, see below var webUrlForProjectCollection = projectCollection.Links.Links["web"] as ReferenceLink; } })); }
/// <summary> /// Gets all project collections. /// </summary> /// <param name="client">The <see cref="ProjectCollectionHttpClient"/> to use.</param> /// <param name="pageSize">Page size to use while retrieving Project Collections.</param> /// <param name="userState">The user state object.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns></returns> /// <exception cref="System.ArgumentNullException"></exception> /// <exception cref="System.ArgumentOutOfRangeException"></exception> public static async Task <IList <TeamProjectCollection> > GetAllProjectCollections(this ProjectCollectionHttpClient client, int pageSize = 10, object userState = null, CancellationToken cancellationToken = default(CancellationToken)) { if (client == null) { throw new ArgumentNullException(nameof(client)); } if (pageSize <= 0) { throw new ArgumentOutOfRangeException(nameof(pageSize)); } var result = new List <TeamProjectCollection>(); int currentPage = 0; var currentProjectCollectionReferences = (await client.GetProjectCollections(pageSize, currentPage, userState).ConfigureAwait(false)).ToList(); while (currentProjectCollectionReferences.Count > 0) { foreach (var projectCollectionReference in currentProjectCollectionReferences) { cancellationToken.ThrowIfCancellationRequested(); result.Add(await client.GetProjectCollection(projectCollectionReference.Id, userState).ConfigureAwait(false)); } // check whether the recently returned item(s) were less than the max page size if (currentProjectCollectionReferences.Count < pageSize) { break; // if so, break the loop as we've read all instances } // otherwise continue cancellationToken.ThrowIfCancellationRequested(); currentProjectCollectionReferences = (await client.GetProjectCollections(pageSize, currentPage++, userState).ConfigureAwait(false)).ToList(); } cancellationToken.ThrowIfCancellationRequested(); return(result); }
public override IEnumerable <PSObject> GetItems(Segment segment) { segment.GetProvider().WriteDebug("DriveItems.Projects.ProjectCollections.GetItems(Segment)"); ProjectCollectionHttpClient httpClient = this.GetHttpClient(segment) as ProjectCollectionHttpClient; return(this.Wrap( segment, (int?top, int?skip) => { return httpClient .GetProjectCollections( top: top, skip: skip, userState: null) .Result .Select(x => this.ConvertToChildDriveItem(segment, x)) .ToArray(); })); }
public IEnumerable <TeamProjectCollectionReference> GetProjectCollections() { // Create instance of VssConnection using passed credentials VssConnection connection = new VssConnection(_uri, _credentials); ProjectCollectionHttpClient projectCollectionHttpClient = connection.GetClient <ProjectCollectionHttpClient>(); IEnumerable <TeamProjectCollectionReference> teamProjectCollectionReference = projectCollectionHttpClient.GetProjectCollections(null).Result; return(teamProjectCollectionReference); }
public IEnumerable <TeamProjectCollectionReference> GetProjectCollections() { using (ProjectCollectionHttpClient projectCollectionHttpClient = new ProjectCollectionHttpClient(_uri, _credentials)) { IEnumerable <TeamProjectCollectionReference> teamProjectCollectionReference = projectCollectionHttpClient.GetProjectCollections(null).Result; return(teamProjectCollectionReference); } }