Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: cleanup backend endpoints #14418

Merged
merged 14 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

49 changes: 0 additions & 49 deletions backend/src/Designer/Controllers/LanguagesController.cs

This file was deleted.

23 changes: 0 additions & 23 deletions backend/src/Designer/Controllers/ProcessModelingController.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Net.Mime;
using System.Text.Json;
Expand All @@ -14,7 +13,6 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using NuGet.Versioning;

namespace Altinn.Studio.Designer.Controllers
{
Expand Down Expand Up @@ -102,27 +100,6 @@ await _mediator.Publish(new ProcessDataTypesChangedEvent
return Accepted();
}

[HttpGet("templates/{appVersion}")]
public IEnumerable<string> GetTemplates(string org, string repo, SemanticVersion appVersion)
{
Guard.AssertArgumentNotNull(appVersion, nameof(appVersion));
return _processModelingService.GetProcessDefinitionTemplates(appVersion);
}

[HttpPut("templates/{appVersion}/{templateName}")]
public async Task<FileStreamResult> SaveProcessDefinitionFromTemplate(string org, string repo,
SemanticVersion appVersion, string templateName, CancellationToken cancellationToken)
{
Guard.AssertArgumentNotNull(appVersion, nameof(appVersion));
string developer = AuthenticationHelper.GetDeveloperUserName(HttpContext);
var editingContext = AltinnRepoEditingContext.FromOrgRepoDeveloper(org, repo, developer);
await _processModelingService.SaveProcessDefinitionFromTemplateAsync(editingContext, templateName,
appVersion, cancellationToken);

Stream processDefinitionStream = _processModelingService.GetProcessDefinitionStream(editingContext);
return new FileStreamResult(processDefinitionStream, MediaTypeNames.Text.Plain);
}

[HttpPost("data-type/{dataTypeId}")]
public async Task<ActionResult> AddDataTypeToApplicationMetadata(string org, string repo, [FromRoute] string dataTypeId, [FromQuery] string taskId, CancellationToken cancellationToken)
{
Expand Down
142 changes: 0 additions & 142 deletions backend/src/Designer/Controllers/RepositoryController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -343,32 +343,6 @@ public async Task<ActionResult> Push(string org, string repository)
return pushSuccess ? Ok() : StatusCode(StatusCodes.Status500InternalServerError);
}

/// <summary>
/// Fetches the repository log
/// </summary>
/// <param name="org">Unique identifier of the organisation responsible for the app.</param>
/// <param name="repository">The repo name</param>
/// <returns>List of commits</returns>
[HttpGet]
[Route("repo/{org}/{repository:regex(^(?!datamodels$)[[a-z]][[a-z0-9-]]{{1,28}}[[a-z0-9]]$)}/log")]
public List<Commit> Log(string org, string repository)
{
return _sourceControl.Log(org, repository);
}

/// <summary>
/// Fetches the initial commit
/// </summary>
/// <param name="org">Unique identifier of the organisation responsible for the app.</param>
/// <param name="repository">The repo name</param>
/// <returns>The initial commit</returns>
[HttpGet]
[Route("repo/{org}/{repository:regex(^(?!datamodels$)[[a-z]][[a-z0-9-]]{{1,28}}[[a-z0-9]]$)}/initial-commit")]
public Commit GetInitialCommit(string org, string repository)
{
return _sourceControl.GetInitialCommit(org, repository);
}

/// <summary>
/// Gets the latest commit from current user
/// </summary>
Expand All @@ -382,82 +356,6 @@ public Commit GetLatestCommitFromCurrentUser(string org, string repository)
return _sourceControl.GetLatestCommitForCurrentUser(org, repository);
}

/// <summary>
/// List all branches for a repository
/// </summary>
/// <param name="org">Unique identifier of the organisation responsible for the app.</param>
/// <param name="repository">The repository</param>
/// <returns>List of repos</returns>
[HttpGet]
[Route("repo/{org}/{repository:regex(^(?!datamodels$)[[a-z]][[a-z0-9-]]{{1,28}}[[a-z0-9]]$)}/branches")]
public async Task<List<Branch>> Branches(string org, string repository)
=> await _giteaApi.GetBranches(org, repository);

/// <summary>
/// Returns information about a given branch
/// </summary>
/// <param name="org">Unique identifier of the organisation responsible for the app.</param>
/// <param name="repository">The name of repository</param>
/// <param name="branch">Name of branch</param>
/// <returns>The branch info</returns>
[HttpGet]
[Route("repo/{org}/{repository:regex(^(?!datamodels$)[[a-z]][[a-z0-9-]]{{1,28}}[[a-z0-9]]$)}/branches/branch")]
public async Task<Branch> Branch(string org, string repository, [FromQuery] string branch)
=> await _giteaApi.GetBranch(org, repository, branch);

/// <summary>
/// Discards all local changes for the logged in user and the local repository is updated with latest remote commit (origin/master)
/// </summary>
/// <param name="org">Unique identifier of the organisation responsible for the app.</param>
/// <param name="repository">The name of repository</param>
/// <returns>Http response message as ok if reset operation is successful</returns>
[HttpGet]
[Route("repo/{org}/{repository:regex(^(?!datamodels$)[[a-z]][[a-z0-9-]]{{1,28}}[[a-z0-9]]$)}/discard")]
public ActionResult DiscardLocalChanges(string org, string repository)
{
try
{
if (string.IsNullOrEmpty(org) || string.IsNullOrEmpty(repository))
{
return ValidationProblem("One or all of the input parameters are null");
}

_sourceControl.ResetCommit(org, repository);
return Ok();
}
catch (Exception)
{
return StatusCode(StatusCodes.Status500InternalServerError);
}
}

/// <summary>
/// Discards local changes to a specific file and the files is updated with latest remote commit (origin/master)
/// </summary>
/// <param name="org">Unique identifier of the organisation responsible for the app.</param>
/// <param name="repository">The name of repository</param>
/// <param name="fileName">the name of the file</param>
/// <returns>Http response message as ok if checkout operation is successful</returns>
[HttpGet]
[Route("repo/{org}/{repository:regex(^(?!datamodels$)[[a-z]][[a-z0-9-]]{{1,28}}[[a-z0-9]]$)}/discard/{fileName}")]
public ActionResult DiscardLocalChangesForSpecificFile(string org, string repository, string fileName)
{
try
{
if (string.IsNullOrEmpty(org) || string.IsNullOrEmpty(repository) || string.IsNullOrEmpty(fileName))
{
return ValidationProblem("One or all of the input parameters are null");
}

_sourceControl.CheckoutLatestCommitForSpecificFile(org, repository, fileName);
return Ok();
}
catch (Exception)
{
return StatusCode(StatusCodes.Status500InternalServerError);
}
}

/// <summary>
/// Stages a specific file changed in working repository.
/// </summary>
Expand Down Expand Up @@ -485,46 +383,6 @@ public ActionResult StageChange(string org, string repository, string fileName)
}
}

/// <summary>
/// Clones the remote repository
/// </summary>
/// <param name="org">Unique identifier of the organisation responsible for the app.</param>
/// <param name="repository">The name of repository</param>
/// <returns>The result of the cloning</returns>
[HttpGet]
[Route("repo/{org}/{repository:regex(^(?!datamodels$)[[a-z]][[a-z0-9-]]{{1,28}}[[a-z0-9]]$)}/clone")]
public Task<string> CloneRemoteRepository(string org, string repository)
{
return _sourceControl.CloneRemoteRepository(org, repository);
}

/// <summary>
/// Halts the merge operation and keeps local changes
/// </summary>
/// <param name="org">Unique identifier of the organisation responsible for the app.</param>
/// <param name="repository">The name of the repository</param>
/// <returns>Http response message as ok if abort merge operation is successful</returns>
[HttpGet]
[Route("repo/{org}/{repository:regex(^(?!datamodels$)[[a-z]][[a-z0-9-]]{{1,28}}[[a-z0-9]]$)}/abort-merge")]
public ActionResult AbortMerge(string org, string repository)
{
try
{
if (string.IsNullOrEmpty(org) || string.IsNullOrEmpty(repository))
{
return ValidationProblem("One or all of the input parameters are null");
}

_sourceControl.AbortMerge(org, repository);

return Ok();
}
catch (Exception)
{
return StatusCode(StatusCodes.Status500InternalServerError);
}
}

/// <summary>
/// Gets the repository content
/// </summary>
Expand Down
Loading
Loading