Skip to content

Commit

Permalink
feat(versioning): add versioning to apis
Browse files Browse the repository at this point in the history
Refs: CPLP-1936
  • Loading branch information
Phil91 committed Dec 11, 2023
1 parent f73c0f7 commit 218706e
Show file tree
Hide file tree
Showing 60 changed files with 405 additions and 141 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.RegularExpressions;
using UnsupportedMediaTypeException = Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling.UnsupportedMediaTypeException;

namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.BusinessLogic;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

using Asp.Versioning;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.BusinessLogic;
Expand All @@ -28,13 +29,14 @@
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums;
using System.Net;

namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Controllers;
namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Controllers.V1;

/// <summary>
/// Creates a new instance of <see cref="CompanyDataController"/>
/// </summary>
[ApiController]
[Route("api/administration/companydata")]
[ApiVersion("1.0")]
[Route("api/v{version:apiVersion}/administration/companydata")]
[Produces("application/json")]
[Consumes("application/json")]
public class CompanyDataController : ControllerBase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

using Asp.Versioning;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.BusinessLogic;
Expand All @@ -29,13 +30,14 @@
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums;
using Org.Eclipse.TractusX.Portal.Backend.SdFactory.Library.Models;

namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Controllers;
namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Controllers.V1;

/// <summary>
/// Controller providing actions for displaying, filtering and updating connectors for companies.
/// </summary>
[Route("api/administration/[controller]")]
[ApiController]
[ApiVersion("1.0")]
[Route("api/v{version:apiVersion}/administration/[controller]")]
[Produces("application/json")]
public class ConnectorsController : ControllerBase
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

using Asp.Versioning;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.BusinessLogic;
Expand All @@ -27,13 +28,14 @@
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models;
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums;

namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Controllers;
namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Controllers.V1;

/// <summary>
/// Controller providing actions for displaying, filtering and updating connectors for documents.
/// </summary>
[Route("api/administration/[controller]")]
[ApiController]
[ApiVersion("1.0")]
[Route("api/v{version:apiVersion}/administration/[controller]")]
[Consumes("application/json")]
public class DocumentsController : ControllerBase
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

using Asp.Versioning;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.BusinessLogic;
Expand All @@ -27,13 +28,14 @@
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums;
using Org.Eclipse.TractusX.Portal.Backend.Provisioning.Library.Enums;

namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Controllers;
namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Controllers.V1;

/// <summary>
/// Controller providing actions for displaying, filtering and updating identityProviders for companies.
/// </summary>
[Route("api/administration/identityprovider")]
[ApiController]
[ApiVersion("1.0")]
[Route("api/v{version:apiVersion}/administration/identityprovider")]
public class IdentityProviderController : ControllerBase
{
private readonly IIdentityProviderBusinessLogic _businessLogic;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
/********************************************************************************
* Copyright (c) 2021, 2023 BMW Group AG
* Copyright (c) 2021, 2023 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

using Asp.Versioning;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.BusinessLogic;
using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Models;
using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling.Library;
using Org.Eclipse.TractusX.Portal.Backend.Framework.Models;

namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Controllers.V1;

/// <summary>
/// Controller providing actions execute invitation
/// </summary>
[ApiController]
[ApiVersion("1.0", Deprecated = true)]
[ApiVersion("1.1", Deprecated = true)]
[Route("api/v{version:apiVersion}/administration/invitation")]
[Produces("application/json")]
[Consumes("application/json")]
public class InvitationController : ControllerBase
{
private readonly IInvitationBusinessLogic _logic;

/// <summary>
/// Creates a new instance of <see cref="InvitationController"/>
/// </summary>
/// <param name="logic">The invitation business logic</param>
public InvitationController(IInvitationBusinessLogic logic)
{
_logic = logic;
}

/// <summary>
/// Executes the invitation
/// </summary>
/// <param name="invitationData"></param>
/// <returns></returns>
/// <remarks>
/// Example: POST: api/administration/invitation
/// </remarks>
/// <response code="200">Successfully executed the invitation.</response>
/// <response code="400">Missing mandatory input values (e.g. email, organization name, etc.)</response>
/// <response code="500">Internal Server Error.</response>
/// <response code="502">Bad Gateway Service Error.</response>
/// <response code="409">user is not associated with company.</response>
[MapToApiVersion("1.0")]
[HttpPost]
[Authorize(Roles = "invite_new_partner")]
[Authorize(Policy = PolicyTypes.CompanyUser)]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status400BadRequest)]
[ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status500InternalServerError)]
[ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status502BadGateway)]
[ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status409Conflict)]
public Task ExecuteInvitation([FromBody] CompanyInvitationData invitationData) =>
_logic.ExecuteInvitation(invitationData);

/// <summary>
/// Executes the invitation
/// </summary>
/// <param name="invitationData"></param>
/// <returns></returns>
/// <remarks>
/// Example: POST: api/administration/invitation
/// </remarks>
/// <response code="200">Successfully executed the invitation.</response>
/// <response code="400">Missing mandatory input values (e.g. email, organization name, etc.)</response>
/// <response code="500">Internal Server Error.</response>
/// <response code="502">Bad Gateway Service Error.</response>
/// <response code="409">user is not associated with company.</response>
[MapToApiVersion("1.1")]
[HttpPost]
[Authorize(Roles = "invite_new_partner")]
[Authorize(Policy = PolicyTypes.CompanyUser)]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status400BadRequest)]
[ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status500InternalServerError)]
[ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status502BadGateway)]
[ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status409Conflict)]
public Task ExecuteInvitationV11([FromBody] CompanyInvitationData invitationData) =>
_logic.ExecuteInvitation(invitationData);
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

using Asp.Versioning;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.BusinessLogic;
Expand All @@ -25,10 +26,11 @@
using Org.Eclipse.TractusX.Portal.Backend.Framework.Models;
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums;

namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Controllers;
namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Controllers.V1;

[ApiController]
[Route("api/administration/registration/[controller]")]
[ApiVersion("1.0")]
[Route("api/v{version:apiVersion}/administration/registration/[controller]")]
[Produces("application/json")]
[Consumes("application/json")]
public class NetworkController : ControllerBase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,21 @@
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

using Asp.Versioning;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.BusinessLogic;
using Org.Eclipse.TractusX.Portal.Backend.Framework.PublicInfos;
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums;

namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Controllers;
namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Controllers.V1;

/// <summary>
/// Creates a new instance of <see cref="PartnerNetworkController"/>
/// </summary>
[ApiController]
[Route("api/administration/[controller]")]
[ApiVersion("1.0")]
[Route("api/v{version:apiVersion}/administration/[controller]")]
[Produces("application/json")]
[Consumes("application/json")]
public class PartnerNetworkController : ControllerBase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

using Asp.Versioning;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.BusinessLogic;
Expand All @@ -29,10 +30,11 @@
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums;
using Org.Eclipse.TractusX.Portal.Backend.SdFactory.Library.Models;

namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Controllers;
namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Controllers.V1;

[ApiController]
[Route("api/administration/registration")]
[ApiVersion("1.0")]
[Route("api/v{version:apiVersion}/administration/registration")]
[Produces("application/json")]
[Consumes("application/json")]
public class RegistrationController : ControllerBase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,19 @@
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

using Asp.Versioning;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.BusinessLogic;
using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling.Library;
using Org.Eclipse.TractusX.Portal.Backend.Framework.Models;
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models;

namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Controllers;
namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Controllers.V1;

[ApiController]
[Route("api/administration/[controller]")]
[ApiVersion("1.0")]
[Route("api/v{version:apiVersion}/administration/[controller]")]
[Produces("application/json")]
[Consumes("application/json")]
public class RegistrationStatusController : ControllerBase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

using Asp.Versioning;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.BusinessLogic;
Expand All @@ -27,10 +28,11 @@
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models;
using Org.Eclipse.TractusX.Portal.Backend.Provisioning.Library.Models;

namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Controllers;
namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Controllers.V1;

[ApiController]
[Route("api/administration/serviceaccount")]
[ApiVersion("1.0")]
[Route("api/v{version:apiVersion}/administration/serviceaccount")]
[Produces("application/json")]
[Consumes("application/json")]
public class ServiceAccountController : ControllerBase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,20 @@
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

using Asp.Versioning;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.BusinessLogic;
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models;

namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Controllers;
namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Controllers.V1;

/// <summary>
/// Controller providing actions for displaying, filtering and updating static data for app.
/// </summary>
[ApiController]
[Route("api/administration/staticdata")]
[ApiVersion("1.0")]
[Route("api/v{version:apiVersion}/administration/staticdata")]
[Produces("application/json")]
[Consumes("application/json")]
public class StaticDataController : ControllerBase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

using Asp.Versioning;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.BusinessLogic;
Expand All @@ -27,13 +28,14 @@
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models;
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums;

namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Controllers;
namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Controllers.V1;

/// <summary>
/// Creates a new instance of <see cref="SubscriptionConfigurationController"/>
/// </summary>
[ApiController]
[Route("api/administration/[controller]")]
[ApiVersion("1.0")]
[Route("api/v{version:apiVersion}/administration/[controller]")]
[Produces("application/json")]
[Consumes("application/json")]
public class SubscriptionConfigurationController : ControllerBase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

using Asp.Versioning;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.BusinessLogic;
Expand All @@ -27,10 +28,11 @@
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models;
using Org.Eclipse.TractusX.Portal.Backend.Provisioning.Library.Models;

namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Controllers;
namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Controllers.V1;

[ApiController]
[Route("api/administration/user")]
[ApiVersion("1.0")]
[Route("api/v{version:apiVersion}/administration/user")]
[Produces("application/json")]
[Consumes("application/json")]
public class UserController : ControllerBase
Expand Down
Loading

0 comments on commit 218706e

Please sign in to comment.