コード例 #1
0
        public async Task <GitlabResponse <GitlabIssueBoard> > SetUpIssueDiscussionBoardForGitlabProject(GitlabProject gitlabProject)
        {
            // lag en ny gitlab frontend client som er autentisert
            GitlabFrontendClient authorizedGitlabFrontendClient;

            try {
                authorizedGitlabFrontendClient = await GitlabFrontendClient.CreateAuthorizedGitlabFrontendClientForGitlabProject(_gitlabConfiguration, gitlabProject);
            } catch (Exception e) {
                return(GitlabResponse <GitlabIssueBoard> .Error($"Failed to authorize gitlab frontent client: ${e.Message}"));
            }

            // slett alle tidligere issue boards
            var deletionResponse = await _DeleteAllIssueBoardsForGitlabProject(gitlabProject, authorizedGitlabFrontendClient);

            if (!deletionResponse.Success)
            {
                return(GitlabResponse <GitlabIssueBoard> .Error($"Failed to delete gitlab issue boards: {deletionResponse.Message}"));
            }

            // slett alle gamle labels for prosjektet
            deletionResponse = await _DeleteAllLabelsForGitlabProject(gitlabProject);

            if (!deletionResponse.Success)
            {
                return(GitlabResponse <GitlabIssueBoard> .Error($"Failed to delete gitlab project labels: {deletionResponse.Message}"));
            }

            // lag et nytt issue board for diskusjon med riktige lister og labels
            return(await _CreateNewDiscussionIssueBoardWithCorrectIssueListsAndLabelsForProject(gitlabProject, authorizedGitlabFrontendClient));
        }
コード例 #2
0
        private async Task <GitlabResponse <GitlabIssueBoard> > _CreateNewDiscussionIssueBoardWithCorrectIssueListsAndLabelsForProject(GitlabProject gitlabProject, GitlabFrontendClient authorizedGitlabFrontendClient)
        {
            // opprett nytt issue board med riktig navn
            var newIssueBoardResponse = await _CreateNewDiscussionIssueBoardWithCorrectNameForProject(gitlabProject, authorizedGitlabFrontendClient);

            if (!newIssueBoardResponse.Success)
            {
                return(GitlabResponse <GitlabIssueBoard> .Error(newIssueBoardResponse.Message));
            }

            // slett alle issue listene på issue boardet
            var newIssueBoard = newIssueBoardResponse.Resource;
            var issueListsDeletionResponse = await _DeleteAllIssueListsInIssueBoardForGitlabProject(gitlabProject, newIssueBoard);

            if (!issueListsDeletionResponse.Success)
            {
                return(GitlabResponse <GitlabIssueBoard> .Error(issueListsDeletionResponse.Message));
            }

            // opprett nye issue lister for labels i open-data namespacet
            var issueListCreationResponse = await _CreateNewIssueListsForAllOpenDataLabelsOnIssueBoardInGitlabProject(gitlabProject, newIssueBoard);

            if (!issueListCreationResponse.Success)
            {
                return(GitlabResponse <GitlabIssueBoard> .Error(issueListCreationResponse.Message));
            }

            // alt vellykket, returner riktig issue board
            return(GitlabResponse <GitlabIssueBoard> .Successful(newIssueBoard));
        }
コード例 #3
0
        private async Task <GitlabResponse> _DeleteAllIssueBoardsForGitlabProject(GitlabProject gitlabProject, GitlabFrontendClient authorizedGitlabFrontendClient)
        {
            // hent først ned en liste over alle eksisterende gitlab issue boards.
            var issueBoardsEndpoint = $"projects/{gitlabProject.id}/boards";
            var gitlabIssueBoards   = await _GetGitlabObject <List <GitlabIssueBoard> >(issueBoardsEndpoint);

            if (!gitlabIssueBoards.Success)
            {
                return(GitlabResponse.Error($"Failed to get gitlab issue boards: {gitlabIssueBoards.Message}"));
            }

            // disse skal slettes
            var deletionResults = await Task.WhenAll(gitlabIssueBoards.Resource
                                                     .Select(async board => await authorizedGitlabFrontendClient.DeleteGitlabIssueBoardForProject(gitlabProject, board)));

            if (deletionResults.All(r => r.Success))
            {
                return(GitlabResponse.Successful());
            }
            else
            {
                return(GitlabResponse.Error($"Failed to delete gitlab issue boards: {_AggregateErrorMessages(deletionResults)}"));
            }
        }
コード例 #4
0
        private Task <GitlabResponse <GitlabIssueBoard> > _CreateNewDiscussionIssueBoardWithCorrectNameForProject(GitlabProject gitlabProject, GitlabFrontendClient authorizedGitlabFrontendClient)
        {
            // Opprett først et nytt issue board med riktig navn
            var newIssueBoardName = _gitlabProjectsConfiguration["IssueDiscussionBoardName"];

            return(authorizedGitlabFrontendClient.CreateGitlabIssueBoardWithNameForProject(gitlabProject, newIssueBoardName));
        }