public bool DeleteTeam() { // Use the previously created team (from the sample above) WebApiTeamRef team; TeamProjectReference project = ClientSampleHelpers.FindAnyProject(this.Context); if (!this.Context.TryGetValue <WebApiTeamRef>("$newTeam", out team) || !this.Context.TryGetValue <TeamProjectReference>("$projectOfNewTeam", out project)) { throw new Exception("Run the create team sample above first."); } // Get a client VssConnection connection = Context.Connection; TeamHttpClient teamClient = connection.GetClient <TeamHttpClient>(); try { teamClient.DeleteTeamAsync(project.Id.ToString(), team.Id.ToString()).SyncResult(); Console.WriteLine("'{0}' team deleted from project {1}", team.Name, project.Name); return(true); } catch (Exception ex) { Console.WriteLine("Unable to delete team: " + ex); return(false); } }
public void PrepairProjectForCreation(Project project) { ProjectHttpClient projClient; TeamProjectReference onlineProject; Uri tfsUri = new Uri(project.ProjectAreaPath); VssBasicCredential credentials = new VssBasicCredential(project.UserName, project.Password); VssConnection connection = new VssConnection(tfsUri, credentials); _teamClient = connection.GetClientAsync <TeamHttpClient>().Result; projClient = connection.GetClientAsync <ProjectHttpClient>().Result; _workItemTrackingClient = connection.GetClient <WorkItemTrackingHttpClient>(); IPagedList <TeamProjectReference> projects = projClient.GetProjects().Result; onlineProject = projects.FirstOrDefault(pro => pro.Name.ToUpperInvariant().Equals(project.ProjectName.ToUpperInvariant(), StringComparison.InvariantCulture)); if (onlineProject != null) { project.CreationDate = DateTime.Now; OnlineTfsTeamProjectName = project.ProjectName; OnlineTfsProjectId = onlineProject.Id.ToString(); project.ProjectType = Projects.Enums.ProjectType.Online.ToString(); project.Password = project.AuthType == 1 ? encryption.DecryptString(project.Password, DecryptionKey) : project.Password; ConnectToOnLineTfsAndCreateQuries(project.ProjectName); } else { throw new UserFriendlyException($"Project Path: '{project.ProjectAreaPath}' Was Not Found!"); } }
public WebApiTeam CreateTeam() { // Find a project to create the team in TeamProjectReference project = ClientSampleHelpers.FindAnyProject(this.Context); string teamName = "Sample team " + Guid.NewGuid(); string teamDescription = "Short description of my new team"; // Get a client VssConnection connection = Context.Connection; TeamHttpClient teamClient = connection.GetClient <TeamHttpClient>(); // Construct team parameters object WebApiTeam newTeamCreateParameters = new WebApiTeam() { Name = teamName, Description = teamDescription }; WebApiTeam newTeam = teamClient.CreateTeamAsync(newTeamCreateParameters, project.Id.ToString()).Result; Console.WriteLine("Team created: '{0}' (ID: {1})", newTeam.Name, newTeam.Id); // Save the team for use later in the rename/delete samples this.Context.SetValue <WebApiTeamRef>("$newTeam", newTeam); this.Context.SetValue <TeamProjectReference>("$projectOfNewTeam", project); return(newTeam); }
/// <summary> /// Gets all teams for the given <paramref name="projectId"/>. /// </summary> /// <param name="client">The <see cref="TeamHttpClient"/> to use.</param> /// <param name="projectId">The project identifier.</param> /// <param name="pageSize">Page size to use while retrieving the projects.</param> /// <param name="userState">The user state object.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns></returns> /// <exception cref="System.ArgumentNullException"> /// </exception> public static async Task <IList <WebApiTeam> > GetAllTeams(this TeamHttpClient client, string projectId, int pageSize = 10, object userState = null, CancellationToken cancellationToken = default(CancellationToken)) { if (client == null) { throw new ArgumentNullException(nameof(client)); } if (projectId == null) { throw new ArgumentNullException(nameof(projectId)); } var result = new List <WebApiTeam>(); int currentPage = 0; var teamsForCurrentPage = (await client.GetTeamsAsync(projectId, pageSize, currentPage, userState, cancellationToken).ConfigureAwait(false)).ToList(); while (teamsForCurrentPage.Count > 0) { cancellationToken.ThrowIfCancellationRequested(); result.AddRange(teamsForCurrentPage); // check whether the recently returned item(s) were less than the max page size if (teamsForCurrentPage.Count < pageSize) { break; // if so, break the loop as we've read all instances } // otherwise continue cancellationToken.ThrowIfCancellationRequested(); teamsForCurrentPage = (await client.GetTeamsAsync(projectId, pageSize, currentPage, userState, cancellationToken).ConfigureAwait(false)).ToList(); } cancellationToken.ThrowIfCancellationRequested(); return(result); }
public void DeleteTeam(string project, string team) { VssConnection connection = new VssConnection(_uri, _credentials); TeamHttpClient teamHttpClient = connection.GetClient <TeamHttpClient>(); teamHttpClient.DeleteTeamAsync(project, team).SyncResult(); }
/// <summary> /// получение списка команд в проекте /// </summary> /// <param name="projectId">иден. проекта</param> /// <returns></returns> public List <WebApiTeam> GetTeamsResult(string projectId) { using (TeamHttpClient teamHttpClient = VssConnection.GetConnection().GetClient <TeamHttpClient>()) { return(teamHttpClient.GetTeamsAsync(projectId, null, 100).GetAwaiter().GetResult()); } }
public static bool FindAnyTeam(ClientSampleContext context, Guid?projectId, out WebApiTeamRef team) { if (!projectId.HasValue) { TeamProjectReference project; if (FindAnyProject(context, out project)) { projectId = project.Id; } } // Check if we already have a team that has been cached for this project if (!context.TryGetValue <WebApiTeamRef>("$" + projectId + "Team", out team)) { TeamHttpClient teamClient = context.Connection.GetClient <TeamHttpClient>(); using (new ClientSampleHttpLoggerOutputSuppression()) { team = teamClient.GetTeamsAsync(projectId.ToString(), top: 1).Result.FirstOrDefault(); } if (team != null) { context.SetValue <WebApiTeamRef>("$" + projectId + "Team", team); } else { // create a team? throw new Exception("No team available for running this sample."); } } return(team != null); }
public static IEnumerable <WebApiTeam> GetTeams(string _project, VssBasicCredential _credentials, Uri _uri) { using (var teamHttpClient = new TeamHttpClient(_uri, _credentials)) { return(teamHttpClient.GetTeamsAsync(_project).Result); } }
/// <summary> /// получение информации по команде /// </summary> /// <param name="tfsIdentity">авторизация в TFS</param> /// <returns></returns> public WebApiTeam GetTeamById(TfsIdentity tfsIdentity) { using (TeamHttpClient teamHttpClient = VssConnection.GetConnection().GetClient <TeamHttpClient>()) { return(teamHttpClient.GetTeamAsync(tfsIdentity.ProjectId.ToString(), tfsIdentity.TeamId.ToString()).GetAwaiter().GetResult()); } }
public WebApiTeam RenameTeam() { // Use the previously created team (from the sample above) WebApiTeamRef team; TeamProjectReference project = ClientSampleHelpers.FindAnyProject(this.Context); if (!this.Context.TryGetValue <WebApiTeamRef>("$newTeam", out team) || !this.Context.TryGetValue <TeamProjectReference>("$projectOfNewTeam", out project)) { throw new Exception("Run the create team sample above first."); } //Get a client VssConnection connection = Context.Connection; TeamHttpClient teamClient = connection.GetClient <TeamHttpClient>(); WebApiTeam teamUpdateParameters = new WebApiTeam() { Name = team.Name + " (renamed)" }; WebApiTeam updatedTeam = teamClient.UpdateTeamAsync(teamUpdateParameters, project.Id.ToString(), team.Id.ToString()).Result; Console.WriteLine("Team renamed from '{0}' to '{1}'", team.Name, updatedTeam.Name); return(updatedTeam); }
/// <summary> /// получение членов команды /// </summary> /// <param name="tfsIdentity">авторизация в TFS</param> /// <returns></returns> public IEnumerable <IdentityRef> GetTeamMembers(TfsIdentity tfsIdentity) { using (TeamHttpClient teamHttpClient = VssConnection.GetConnection().GetClient <TeamHttpClient>()) { return(teamHttpClient.GetTeamMembers(tfsIdentity.ProjectId.ToString(), tfsIdentity.TeamId.ToString()).ConfigureAwait(false).GetAwaiter().GetResult()); } }
public IEnumerable <IdentityRef> GetTeamMembers() { VssConnection connection = new VssConnection(_uri, _credentials); TeamHttpClient teamHttpClient = connection.GetClient <TeamHttpClient>(); IEnumerable <IdentityRef> results = teamHttpClient.GetTeamMembersAsync(_configuration.Project, _configuration.Team).Result; return(results); }
public void DeleteTeam(string project, string team) { // create team object using (TeamHttpClient teamHttpClient = new TeamHttpClient(_uri, _credentials)) { teamHttpClient.DeleteTeamAsync(project, team).SyncResult(); } }
public IEnumerable <WebApiTeam> GetTeams() { VssConnection connection = new VssConnection(_uri, _credentials); TeamHttpClient teamHttpClient = connection.GetClient <TeamHttpClient>(); IEnumerable <WebApiTeam> results = teamHttpClient.GetTeamsAsync(_configuration.Project).Result; return(results); }
public WebApiTeam UpdateTeam(string project, string team, WebApiTeam teamData) { VssConnection connection = new VssConnection(_uri, _credentials); TeamHttpClient teamHttpClient = connection.GetClient <TeamHttpClient>(); WebApiTeam result = teamHttpClient.UpdateTeamAsync(teamData, project, team).Result; return(result); }
/// <summary> /// Gets all team members for the given <paramref name="projectId" /> and <paramref name="teamId"/>. /// </summary> /// <param name="client">The <see cref="TeamHttpClient" /> to use.</param> /// <param name="connection">The connection for the <paramref name="client"/> that will be used to retrieve the identities for the team members.</param> /// <param name="projectId">The project identifier.</param> /// <param name="teamId">The team identifier whose members to retrieve.</param> /// <param name="pageSize">Page size to use while retrieving the projects.</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.ArgumentException">$The '{nameof(connection)}' parameter must be for the given '{nameof(client)}'</exception> public static async Task <IReadOnlyCollection <Identity> > GetAllTeamMembers(this TeamHttpClient client, VssConnection connection, string projectId, string teamId, int pageSize = 10, object userState = null, CancellationToken cancellationToken = default(CancellationToken)) { if (client == null) { throw new ArgumentNullException(nameof(client)); } if (connection == null) { throw new ArgumentNullException(nameof(connection)); } if (projectId == null) { throw new ArgumentNullException(nameof(projectId)); } if (teamId == null) { throw new ArgumentNullException(nameof(teamId)); } if (Equals(client.BaseAddress, connection.Uri)) { throw new ArgumentException($"The '{nameof(connection)}' parameter must be for the base uri of the VSTS / TFS system", nameof(connection)); } var result = new List <Identity>(); var identityReferences = new List <IdentityRef>(); int currentPage = 0; var teamMembersForCurrentPage = (await client.GetTeamMembersAsync(projectId, teamId, pageSize, currentPage, userState, cancellationToken).ConfigureAwait(false)).ToList(); while (teamMembersForCurrentPage.Count > 0) { cancellationToken.ThrowIfCancellationRequested(); identityReferences.AddRange(teamMembersForCurrentPage); // check whether the recently returned item(s) were less than the max page size if (teamMembersForCurrentPage.Count < pageSize) { break; // if so, break the loop as we've read all instances } // otherwise continue cancellationToken.ThrowIfCancellationRequested(); teamMembersForCurrentPage = (await client.GetTeamMembersAsync(projectId, teamId, pageSize, currentPage, userState, cancellationToken).ConfigureAwait(false)).ToList(); } cancellationToken.ThrowIfCancellationRequested(); if (identityReferences.Count > 0) { using (var identityHttpClient = await connection.GetClientAsync <IdentityHttpClient>(cancellationToken).ConfigureAwait(false)) { result.AddRange(await identityHttpClient.ReadIdentitiesAsync(identityReferences.Select(identityReference => new Guid(identityReference.Id)).ToList(), cancellationToken: cancellationToken).ConfigureAwait(false)); } } cancellationToken.ThrowIfCancellationRequested(); return(result); }
public void DeleteTeam() { string teamName = "My new team"; VssConnection connection = new VssConnection(_uri, _credentials); TeamHttpClient teamHttpClient = connection.GetClient <TeamHttpClient>(); teamHttpClient.DeleteTeamAsync(_configuration.Project, teamName).SyncResult(); }
public WebApiTeam UpdateTeam(string project, string team, WebApiTeam teamData) { // create team object using (TeamHttpClient teamHttpClient = new TeamHttpClient(_uri, _credentials)) { WebApiTeam result = teamHttpClient.UpdateTeamAsync(teamData, project, team).Result; return(result); } }
public WebApiTeam GetTeam(string project, string team) { // create team object using (TeamHttpClient teamHttpClient = new TeamHttpClient(_uri, _credentials)) { WebApiTeam result = teamHttpClient.GetTeamAsync(project, team).Result; return(result); } }
public IEnumerable <IdentityRef> GetTeamMembers(string project, string team) { // create team object using (TeamHttpClient teamHttpClient = new TeamHttpClient(_uri, _credentials)) { IEnumerable <IdentityRef> results = teamHttpClient.GetTeamMembersAsync(project, team).Result; return(results); } }
public IEnumerable <WebApiTeam> GetTeams(string project) { // create team object using (TeamHttpClient teamHttpClient = new TeamHttpClient(_uri, _credentials)) { IEnumerable <WebApiTeam> results = teamHttpClient.GetTeamsAsync(project).Result; return(results); } }
public WebApiTeam GetTeam() { string teamName = "My new team"; VssConnection connection = new VssConnection(_uri, _credentials); TeamHttpClient teamHttpClient = connection.GetClient <TeamHttpClient>(); WebApiTeam result = teamHttpClient.GetTeamAsync(_configuration.Project, teamName).Result; return(result); }
static void InitClients(VssConnection Connection) { WitClient = Connection.GetClient <WorkItemTrackingHttpClient>(); BuildClient = Connection.GetClient <BuildHttpClient>(); ProjectClient = Connection.GetClient <ProjectHttpClient>(); TeamClient = Connection.GetClient <TeamHttpClient>(); GitClient = Connection.GetClient <GitHttpClient>(); TfvsClient = Connection.GetClient <TfvcHttpClient>(); TestManagementClient = Connection.GetClient <TestManagementHttpClient>(); }
public void DeleteTeam() { string project = _configuration.Project; string team = "My new team"; // create team object using (TeamHttpClient teamHttpClient = new TeamHttpClient(_uri, _credentials)) { teamHttpClient.DeleteTeamAsync(project, team).SyncResult(); } }
public IEnumerable <IdentityRef> GetTeamMembers() { string project = _configuration.Project; string team = _configuration.Team; // create team object using (TeamHttpClient teamHttpClient = new TeamHttpClient(_uri, _credentials)) { IEnumerable <IdentityRef> results = teamHttpClient.GetTeamMembersAsync(project, team).Result; return(results); } }
public void ShowAllTeamSubscriptions() { VssConnection connection = Context.Connection; // // Step 1: construct query to find all subscriptions belonging to teams in the project // TeamProjectReference project = ClientSampleHelpers.FindAnyProject(this.Context); // Get all teams in the project TeamHttpClient teamClient = connection.GetClient <TeamHttpClient>(); IEnumerable <WebApiTeam> teams = teamClient.GetTeamsAsync(project.Id.ToString()).Result; // Construct a set of query conditions (one for each team) IEnumerable <SubscriptionQueryCondition> conditions = teams.Select <WebApiTeam, SubscriptionQueryCondition>(team => { return(new SubscriptionQueryCondition() { SubscriberId = team.Id }); } ); // Construct the query, making sure to return basic details for subscriptions the caller doesn't have read access to SubscriptionQuery query = new SubscriptionQuery() { Conditions = conditions, QueryFlags = SubscriptionQueryFlags.AlwaysReturnBasicInformation }; // // Part 2: query and show the results // NotificationHttpClient notificationClient = connection.GetClient <NotificationHttpClient>(); IEnumerable <NotificationSubscription> subscriptions = notificationClient.QuerySubscriptionsAsync(query).Result; var subscriptionsBySubscriber = subscriptions.GroupBy <NotificationSubscription, Guid>(sub => { return(Guid.Parse(sub.Subscriber.Id)); }); foreach (var team in teams) { // Find the corresponding team for this group var group = subscriptionsBySubscriber.First(t => t.Key == team.Id); // Show the details for each subscription owned by this team foreach (NotificationSubscription subscription in group) { LogSubscription(subscription); } } }
public WebApiTeam GetTeam() { string project = _configuration.Project; string team = "My new team"; // create team object using (TeamHttpClient teamHttpClient = new TeamHttpClient(_uri, _credentials)) { WebApiTeam result = teamHttpClient.GetTeamAsync(project, team).Result; return(result); } }
/// <summary> /// Gets all teams for the given <paramref name="project"/>. /// </summary> /// <param name="client">The <see cref="TeamHttpClient"/> to use.</param> /// <param name="project">The project.</param> /// <param name="pageSize">Page size to use while retrieving the projects.</param> /// <param name="userState">The user state object.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns></returns> /// <exception cref="System.ArgumentNullException"> /// </exception> public static Task <IList <WebApiTeam> > GetAllTeams(this TeamHttpClient client, TeamProject project, int pageSize = 10, object userState = null, CancellationToken cancellationToken = default(CancellationToken)) { if (client == null) { throw new ArgumentNullException(nameof(client)); } if (project == null) { throw new ArgumentNullException(nameof(project)); } return(client.GetAllTeams(project.Id, pageSize, userState, cancellationToken)); }
/// <summary> /// Gets all teams for the given <paramref name="projectId"/>. /// </summary> /// <param name="client">The <see cref="TeamHttpClient"/> to use.</param> /// <param name="projectId">The project identifier.</param> /// <param name="pageSize">Page size to use while retrieving the projects.</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.ArgumentException"></exception> public static Task <IList <WebApiTeam> > GetAllTeams(this TeamHttpClient client, Guid projectId, int pageSize = 10, object userState = null, CancellationToken cancellationToken = default(CancellationToken)) { if (client == null) { throw new ArgumentNullException(nameof(client)); } if (Equals(Guid.Empty, projectId)) { throw new ArgumentOutOfRangeException(nameof(projectId)); } return(client.GetAllTeams(projectId.ToString(), pageSize, userState, cancellationToken)); }
public WebApiTeam CreateTeam() { WebApiTeam teamData = new WebApiTeam() { Name = "My new team" }; VssConnection connection = new VssConnection(_uri, _credentials); TeamHttpClient teamHttpClient = connection.GetClient <TeamHttpClient>(); WebApiTeam result = teamHttpClient.CreateTeamAsync(teamData, _configuration.Project).Result; return(result); }