/// <summary> /// Get a list of all Team Projects within the current Project Collection. /// </summary> /// <param name="projectState">The state of the Team Project(s) to query</param> /// <param name="count">The maximum number of Team Projects to return</param> /// <param name="skip">The number of Team Projects to skip</param> /// <returns>The list of Team Projects that match the criteria</returns> public async Task <IEnumerable <Project> > GetProjects( ProjectState projectState = ProjectState.All, int count = 0, int skip = 0) { var request = new TfsRestRequest("/_apis/projects"); if (projectState != ProjectState.All) { request.AddParameter("statefilter", projectState.ToString()); } if (count > 0) { request.AddParameter("top", count); } if (skip > 0) { request.AddParameter("$skip", skip); } Sequence <Project> projects = await Executor.Execute <Sequence <Project> >(request); return((projects != null) ? projects.Value : new List <Project>()); }
/// <summary> /// Get a list of all Team Projects within the current Project Collection. /// </summary> /// <param name="projectState">The state of the Team Project(s) to query</param> /// <param name="count">The maximum number of Team Projects to return</param> /// <param name="skip">The number of Team Projects to skip</param> /// <returns>The list of Team Projects that match the criteria</returns> public async Task<IEnumerable<Project>> GetProjects( ProjectState projectState = ProjectState.All, int count = 0, int skip = 0) { var request = new TfsRestRequest("/_apis/projects"); if (projectState != ProjectState.All) { request.AddParameter("statefilter", projectState.ToString()); } if (count > 0) { request.AddParameter("top", count); } if (skip > 0) { request.AddParameter("$skip", skip); } Sequence<Project> projects = await Executor.Execute<Sequence<Project>>(request); return (projects != null) ? projects.Value : new List<Project>(); }
/// <summary> /// Get the item in the repository at the given path. /// </summary> /// <param name="repositoryId">The ID of the repository to query</param> /// <param name="path">Path of the item to query</param> /// <param name="filters">Filters to provide additional query information</param> /// <param name="includeMetadata">To include item metadata or not</param> /// <returns>A list of commits in the Git repository</returns> public async Task<IEnumerable<Item>> GetItem(Guid repositoryId, string path, ItemFilters filters = null, bool includeMetadata = false) { Assert.NotNull(repositoryId, "repositoryId"); Assert.NotNull(path, "path"); var request = new TfsRestRequest("/_apis/git/repositories/{RepositoryId}/items"); request.AddUrlSegment("RepositoryId", repositoryId.ToString()); // This header instructs VSO to return metadata rather than the item contents request.AddHeader("Accept", "application/json"); filters = filters ?? new ItemFilters(); request.AddParameter("scopePath", path); request.AddOptionalParameter("recursionLevel", filters.RecursionLevel, () => { return filters.RecursionLevel != RecursionLevel.None; }); if (includeMetadata) { request.AddParameter("includeContentMetadata", "true"); } Sequence<Item> list = await Executor.Execute<Sequence<Item>>(request); return list.Value; }
/// <summary> /// Get a push in a Git repository. /// </summary> /// <param name="repositoryId">The ID of the repository to query</param> /// <param name="id">The ID of the push</param> /// <param name="includeRefUpdates">Whether to include information about references that were updated</param> /// <returns>A list of pushes in the Git repository</returns> public async Task<PushDetails> GetPush(Guid repositoryId, int id, bool includeRefUpdates = false) { var request = new TfsRestRequest("/_apis/git/repositories/{RepositoryId}/pushes/{PushId}"); request.AddUrlSegment("RepositoryId", repositoryId.ToString()); request.AddUrlSegment("PushId", id.ToString()); if (includeRefUpdates) { request.AddParameter("includeRefUpdates", "true"); } return await Executor.Execute<PushDetails>(request); }
/// <summary> /// Get the Team Project by ID. /// /// Optionally queries the "capabilities" for the team project, /// including source control type (TFVC or Git) and process /// template. /// </summary> /// <param name="id">The ID of the Team Project.</param> /// <param name="includeCapabilities">true to include project capabilities</param> /// <returns>The Team Project, or <code>null</code> if none matched</returns> public async Task<Project> GetProject(Guid id, bool includeCapabilities = false) { Assert.NotNull(id, "id"); var request = new TfsRestRequest("/_apis/projects/{ProjectId}"); request.AddUrlSegment("ProjectId", id.ToString()); if (includeCapabilities) { request.AddParameter("includecapabilities", "true"); } return await Executor.Execute<Project>(request); }
/// <summary> /// Get the Team Project by name. /// /// Optionally queries the "capabilities" for the team project, /// including source control type (TFVC or Git) and process /// template. /// </summary> /// <param name="name">The name of the Team Project.</param> /// <param name="includeCapabilities">true to include project capabilities</param> /// <returns>The Team Project, or <code>null</code> if none matched</returns> public async Task <Project> GetProject(string name, bool includeCapabilities = false) { Assert.NotNull(name, "name"); var request = new TfsRestRequest("/_apis/projects/{Name}"); request.AddUrlSegment("Name", name); if (includeCapabilities) { request.AddParameter("includecapabilities", "true"); } return(await Executor.Execute <Project>(request)); }
/// <summary> /// Get the Team Project by ID. /// /// Optionally queries the "capabilities" for the team project, /// including source control type (TFVC or Git) and process /// template. /// </summary> /// <param name="id">The ID of the Team Project.</param> /// <param name="includeCapabilities">true to include project capabilities</param> /// <returns>The Team Project, or <code>null</code> if none matched</returns> public async Task <Project> GetProject(Guid id, bool includeCapabilities = false) { Assert.NotNull(id, "id"); var request = new TfsRestRequest("/_apis/projects/{ProjectId}"); request.AddUrlSegment("ProjectId", id.ToString()); if (includeCapabilities) { request.AddParameter("includecapabilities", "true"); } return(await Executor.Execute <Project>(request)); }
/// <summary> /// Gets the list of messages that have been written to the Team Room. /// /// You can filter by the PostedTime field for up to 30 days. If there is /// no filter then messages from the last 24 hours will be returned. /// </summary> /// <param name="roomId">The ID of the Team Room to query messages for</param> /// <param name="filter">OData PostedTime filter to apply to the message list</param> /// <returns>The list of messages</returns> public async Task <IEnumerable <TeamRoomMessage> > GetMessages(int roomId, string filter = null) { var request = new TfsRestRequest("/_apis/chat/rooms/{RoomId}/messages", HttpMethod.Get); request.AddUrlSegment("RoomId", roomId.ToString()); if (filter != null) { request.AddParameter("$filter", filter); } Sequence <TeamRoomMessage> messages = await Executor.Execute <Sequence <TeamRoomMessage> >(request); return((messages != null) ? messages.Value : new List <TeamRoomMessage>()); }
/// <summary> /// Get the Team Project by name. /// /// Optionally queries the "capabilities" for the team project, /// including source control type (TFVC or Git) and process /// template. /// </summary> /// <param name="name">The name of the Team Project.</param> /// <param name="includeCapabilities">true to include project capabilities</param> /// <returns>The Team Project, or <code>null</code> if none matched</returns> public async Task<Project> GetProject(string name, bool includeCapabilities = false) { Assert.NotNull(name, "name"); var request = new TfsRestRequest("/_apis/projects/{Name}"); request.AddUrlSegment("Name", name); if (includeCapabilities) { request.AddParameter("includecapabilities", "true"); } return await Executor.Execute<Project>(request); }
/// <summary> /// Gets the list of messages that have been written to the Team Room. /// /// You can filter by the PostedTime field for up to 30 days. If there is /// no filter then messages from the last 24 hours will be returned. /// </summary> /// <param name="roomId">The ID of the Team Room to query messages for</param> /// <param name="filter">OData PostedTime filter to apply to the message list</param> /// <returns>The list of messages</returns> public async Task<IEnumerable<TeamRoomMessage>> GetMessages(int roomId, string filter = null) { var request = new TfsRestRequest("/_apis/chat/rooms/{RoomId}/messages", HttpMethod.Get); request.AddUrlSegment("RoomId", roomId.ToString()); if (filter != null) { request.AddParameter("$filter", filter); } Sequence<TeamRoomMessage> messages = await Executor.Execute<Sequence<TeamRoomMessage>>(request); return (messages != null) ? messages.Value : new List<TeamRoomMessage>(); }