public async Task <IActionResult> UpdateCourseAsync([FromBody] WebHookModel model)
        {
            if (model == null)
            {
                throw new NotSupportedException($"Invalid web hook model");
            }

            var generatedDataMessage = new List <string>();

            // Generate course data for all courses and versions.
            // Ideally, we would want to regenerate only the item that changes (+ possibly children), but that
            // is not worth the effort right now + there is very limited possibility of identifying in which items certain item is included as modular content.
            // Or there could be more personalized web hooks coming in..
            var projectCourses = await CourseService.GetAllPackagesWithinProjectAsync(model.Message.ProjectId);

            // go through all courses within a project :-(
            foreach (var projectCourse in projectCourses)
            {
                var result = await CourseGenerateService.GeneratePackageDataAsync(projectCourse.CourseId, false, CourseFileTypeEnum.Prod);

                generatedDataMessage.Add($"Data for course '{result.Course.CourseName}' and version '{projectCourse.CourseVersionVersion.FirstOrDefault()?.Codename}' have been generated.");
            }

            return(new ObjectResult(generatedDataMessage));
        }
        public async Task PostWebhook([FromBody] WebHookModel value)
        {
//            var key = value.Issue.Key;
//            var issue = await _jiraService.GetIssue(key);
            var simpleIssue = MapToSimpleIssue(value.Issue);
            await _storageService.SendIssueToStorage(simpleIssue);
        }
Exemple #3
0
        /// <summary>
        /// Updates the given <see cref="WebHookModel"/>.
        /// Please note that you should always use HTTPS when adding Webhooks in order to ensure security.
        /// Also, there is no way to validate that the request originate from Bizzebee, so it is important that you always validate these event with an API call.
        /// For example, if you receive a Webhook event regarding an order status update, validate this and retrieve the actual data of that order using a GET to /api/v2/orders/{order-id}
        /// All Webhook events will retry up to 10 times or until they get a 20x response. If they don't get a 20x response they will retry again after 30 min.
        /// </summary>
        /// <param name="webhookId">Id of the object being updated.</param>
        /// <param name="webhook">The <see cref="WebHookModel"/> to update.</param>
        /// <returns>The updated <see cref="WebHookModel"/>.</returns>
        public virtual async Task <WebHookModel> PatchAsync(int webhookId, WebHookModel webhook)
        {
            var req     = PrepareRequest($"web-hooks/{webhookId}");
            var body    = webhook.ToDictionary();
            var content = new JsonContent(body);

            return(await ExecuteRequestAsync <WebHookModel>(req, HttpMethod.Patch, content, "data"));
        }
Exemple #4
0
        /// <summary>
        /// Creates a new <see cref="WebHookModel"/> on the store.
        /// Please note that you should always use HTTPS when adding Webhooks in order to ensure security.
        /// Also, there is no way to validate that the request originate from Bizzebee, so it is important that you always validate these event with an API call.
        /// For example, if you receive a Webhook event regarding an order status update, validate this and retrieve the actual data of that order using a GET to /api/v2/orders/{order-id}
        /// All Webhook events will retry up to 10 times or until they get a 20x response. If they don't get a 20x response they will retry again after 30 min.
        /// </summary>
        /// <param name="webhook">A new <see cref="WebHookModel"/>. Id should be set to null.</param>
        /// <returns>The new <see cref="WebHookModel"/>.</returns>
        public virtual async Task <WebHookModel> CreateAsync(WebHookModel webhook)
        {
            var req     = PrepareRequest("web-hooks");
            var body    = webhook.ToDictionary();
            var content = new JsonContent(body);

            return(await ExecuteRequestAsync <WebHookModel>(req, HttpMethod.Post, content, "data"));
        }
 public async Task CreateWebhook([FromBody] WebHookModel model)
 {
     var url      = model.BugTrackerUrl;
     var login    = model.Login;
     var password = model.Password;
     var settings = MapToSettings(model);
     await _jiraConfiguration.CreateWebhook(url, password, login, settings);
 }
 //TODO вынести отсюда
 private WebHookSettings MapToSettings(WebHookModel model)
 {
     return(new WebHookSettings()
     {
         Url = model.WebHookUrl,
         Name = model.WebHookName,
         JqlFilter = model.JqlFilter,
         ExcludeIssueDetails = model.ExcludeIssueDetails,
         Events = model.Events.Select(GetWebhookEventByType).ToArray()
     });
 }
Exemple #7
0
        public async Task <IActionResult> Post([FromBody] WebHookModel model)
        {
            var unityCloudBuildEvent = GetUnityCloudBuildEventHeaderValue();

            if (unityCloudBuildEvent == null)
            {
                return(BadRequest());
            }

            if (unityCloudBuildEvent != "ProjectBuildSuccess")
            {
                return(Ok());
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                await _slackClient.PostStartedAsync(
                    model.ProjectName,
                    model.BuildTargetName,
                    model.BuildNumber,
                    model.StartedBy);

                await _buildService.HandleAsync(model, _environment.WebRootPath);

                await _slackClient.PostSuccessAsync(
                    model.ProjectName,
                    model.BuildTargetName,
                    model.BuildNumber,
                    model.StartedBy);
            }
            catch (Exception e)
            {
                _logger.LogError(e.ToString());

                await _slackClient.PostFailureAsync(
                    model.ProjectName,
                    model.BuildTargetName,
                    model.BuildNumber,
                    model.StartedBy);

                throw;
            }

            return(Ok());
        }
        public async Task <IActionResult> HubAsync(WebHookModel webHook)
        {
            await _dockerClient.Images.PullImageAsync(new ImagesPullParameters()
            {
                All    = true,
                Parent = "promact/oauth-server",
                Tag    = "dev"
            }, null);

            var runningContainer = await _dockerClient.Containers.ListContainersAsync(new ContainersListParameters()
            {
                All = true
            });

            await _dockerClient.Containers.RestartContainerAsync(runningContainer.First(x => x.Names.Contains("oauth")).ID, new ConatinerRestartParameters(), CancellationToken.None);

            return(Ok());
        }
Exemple #9
0
        public async Task HandleAsync(WebHookModel model, string wwwroot)
        {
            var buildStatusUrl   = $"{_options.CloudUrl}{model.Links.Api_Self.Href}";
            var buildStatusModel = await _buildStatusService.GetBuildStatusModelAsync(buildStatusUrl, _options.ApiKey);

            var downloadUrl = $"{buildStatusModel.Links.Download_Primary.Href}";

            using (var stream = await _downloadService.DownloadAsStreamAsync(downloadUrl))
            {
                var zipDirectory = GetZipDirectory(wwwroot);

                if (!Directory.Exists(zipDirectory))
                {
                    Directory.CreateDirectory(zipDirectory);
                }

                var path = Path.Combine(zipDirectory, $"{buildStatusModel.Build}.zip");

                SaveZipFile(stream, path);
                UnzipFileToWwwRoot(path, wwwroot);
            }
        }
Exemple #10
0
 public async Task CreateWebhook(WebHookModel settings)
 {
     var url     = API.TrelloConfiguration.CreateWebhook(_trelloConfigurationBaseUrl);
     var content = new StringContent(JsonConvert.SerializeObject(settings), Encoding.UTF8, "application/json");
     await _httpClient.PostAsync(url, content);
 }