Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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
82 changes: 82 additions & 0 deletions src/Controller/Studio/Config/AddController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?php
declare(strict_types=1);

/**
* This source file is available under the terms of the
* Pimcore Open Core License (POCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) Pimcore GmbH (https://www.pimcore.com)
* @license Pimcore Open Core License (POCL)
*/

namespace Pimcore\Bundle\DataHubBundle\Controller\Studio\Config;

use OpenApi\Attributes\Post;
use Pimcore\Bundle\DataHubBundle\OpenApi\Config\Prefix;
use Pimcore\Bundle\DataHubBundle\OpenApi\Config\Tags;
use Pimcore\Bundle\DataHubBundle\Schema\AddConfiguration;
use Pimcore\Bundle\DataHubBundle\Service\Studio\ConfigurationServiceInterface;
use Pimcore\Bundle\StudioBackendBundle\Controller\AbstractApiController;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Parameter\Query\StringParameter;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\CreatedResponse;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\DefaultResponses;
use Pimcore\Bundle\StudioBackendBundle\Util\Constant\HttpResponseCodes;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Attribute\MapQueryString;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Serializer\SerializerInterface;

/**
* @internal
*/
final class AddController extends AbstractApiController
{
private const string ROUTE = '/config/add';

public function __construct(
SerializerInterface $serializer,
private readonly ConfigurationServiceInterface $configurationService
) {
parent::__construct($serializer);
}

/**
* @throws \Exception
*/
#[Route(
path: self::ROUTE,
name: 'pimcore_studio_api_data_hub_config_add',
methods: ['POST']
)]
#[Post(
path: Prefix::BUNDLE . self::ROUTE,
operationId: 'bundle_data_hub_config_add',
description: 'bundle_data_hub_config_add_description',
summary: 'bundle_data_hub_config_add_summary',
tags: [Tags::DataHub->value]
)]
#[StringParameter('name', 'assets', 'The name of the configuration')]
#[StringParameter('type', 'graphql', 'Type of the adapter')]
#[StringParameter('path', '', 'Configuration path', false)]
#[CreatedResponse(
description: 'bundle_data_hub_config_add_success_response'
)]
#[DefaultResponses([
HttpResponseCodes::UNAUTHORIZED,
HttpResponseCodes::NOT_FOUND,
])]
public function addConfiguration(
#[MapQueryString] AddConfiguration $addConfiguration
): Response {
$this->configurationService->addConfiguration(
$addConfiguration->getName(),
$addConfiguration->getType(),
$addConfiguration->getPath() ?? ''
);

return new Response();
}
}

1 change: 0 additions & 1 deletion src/Controller/Studio/Config/CollectionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ public function __construct(
description: 'bundle_copilot_actions_success_response',
content: new CollectionJson(new GenericCollection(Configuration::class)),
)]
#[IsGranted(PermissionConstants::PLUGIN_DATA_HUB_CONFIG)]
#[DefaultResponses([
HttpResponseCodes::UNAUTHORIZED,
HttpResponseCodes::NOT_FOUND,
Expand Down
81 changes: 81 additions & 0 deletions src/Controller/Studio/Config/DeleteController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?php
declare(strict_types=1);

/**
* This source file is available under the terms of the
* Pimcore Open Core License (POCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) Pimcore GmbH (https://www.pimcore.com)
* @license Pimcore Open Core License (POCL)
*/

namespace Pimcore\Bundle\DataHubBundle\Controller\Studio\Config;

use OpenApi\Attributes\Delete;
use OpenApi\Attributes\Schema;
use Pimcore\Bundle\DataHubBundle\OpenApi\Config\Prefix;
use Pimcore\Bundle\DataHubBundle\OpenApi\Config\Tags;
use Pimcore\Bundle\DataHubBundle\Service\Studio\ConfigurationServiceInterface;
use Pimcore\Bundle\DataHubBundle\Utils\Constants\PermissionConstants;
use Pimcore\Bundle\StudioBackendBundle\Controller\AbstractApiController;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Parameter\Path\IdParameter;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\DefaultResponses;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\SuccessResponse;
use Pimcore\Bundle\StudioBackendBundle\Util\Constant\HttpResponseCodes;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;
use Symfony\Component\Serializer\SerializerInterface;

/**
* @internal
*/
final class DeleteController extends AbstractApiController
{
private const string ROUTE = '/config/delete/{name}';

public function __construct(
SerializerInterface $serializer,
private readonly ConfigurationServiceInterface $configurationService
) {
parent::__construct($serializer);
}

/**
* @throws \Exception
*/
#[Route(
path: self::ROUTE,
name: 'pimcore_studio_api_data_hub_config_delete',
methods: ['DELETE']
)]
#[Delete(
path: Prefix::BUNDLE . self::ROUTE,
operationId: 'bundle_data_hub_config_delete',
description: 'bundle_data_hub_config_delete_description',
summary: 'bundle_data_hub_config_delete_summary',
tags: [Tags::DataHub->value]
)]
#[IdParameter(
type: 'configuration',
schema: new Schema(type: 'string'),
name: 'name',
)]
#[SuccessResponse(
description: 'bundle_data_hub_config_delete_success_response',
)]
#[IsGranted(PermissionConstants::PLUGIN_DATA_HUB_CONFIG)]
#[DefaultResponses([
HttpResponseCodes::UNAUTHORIZED,
HttpResponseCodes::NOT_FOUND,
])]
public function deleteConfiguration(string $name): Response
{
$this->configurationService->deleteConfiguration($name);

return new Response();
}
}

81 changes: 81 additions & 0 deletions src/Controller/Studio/Config/GetController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?php
declare(strict_types=1);

/**
* This source file is available under the terms of the
* Pimcore Open Core License (POCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) Pimcore GmbH (https://www.pimcore.com)
* @license Pimcore Open Core License (POCL)
*/

namespace Pimcore\Bundle\DataHubBundle\Controller\Studio\Config;

use OpenApi\Attributes\Get;
use OpenApi\Attributes\Schema;
use Pimcore\Bundle\DataHubBundle\OpenApi\Config\Prefix;
use Pimcore\Bundle\DataHubBundle\OpenApi\Config\Tags;
use Pimcore\Bundle\DataHubBundle\Service\Studio\ConfigurationServiceInterface;
use Pimcore\Bundle\DataHubBundle\Utils\Constants\PermissionConstants;
use Pimcore\Bundle\StudioBackendBundle\Controller\AbstractApiController;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Parameter\Path\IdParameter;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\DefaultResponses;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\SuccessResponse;
use Pimcore\Bundle\StudioBackendBundle\Util\Constant\HttpResponseCodes;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;
use Symfony\Component\Serializer\SerializerInterface;

/**
* @internal
*/
final class GetController extends AbstractApiController
{
private const string ROUTE = '/config/{name}';

public function __construct(
SerializerInterface $serializer,
private readonly ConfigurationServiceInterface $configurationService
) {
parent::__construct($serializer);
}

/**
* @throws \Exception
*/
#[Route(
path: self::ROUTE,
name: 'pimcore_studio_api_data_hub_config_get',
methods: ['GET']
)]
#[Get(
path: Prefix::BUNDLE . self::ROUTE,
operationId: 'bundle_data_hub_config_get',
description: 'bundle_data_hub_config_get_description',
summary: 'bundle_data_hub_config_get_summary',
tags: [Tags::DataHub->value]
)]
#[IdParameter(
type: 'configuration',
schema: new Schema(type: 'string'),
name: 'name',
)]
#[SuccessResponse(
description: 'bundle_data_hub_config_get_success_response',
)]
#[IsGranted(PermissionConstants::PLUGIN_DATA_HUB_CONFIG)]
#[DefaultResponses([
HttpResponseCodes::UNAUTHORIZED,
HttpResponseCodes::NOT_FOUND,
])]
public function getConfiguration(string $name): JsonResponse
{
return $this->jsonResponse(
$this->configurationService->getConfiguration($name)
);
}
}

40 changes: 40 additions & 0 deletions src/Hydrator/ConfigurationDetailHydrator.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php
declare(strict_types=1);

/**
* This source file is available under the terms of the
* Pimcore Open Core License (POCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) Pimcore GmbH (https://www.pimcore.com)
* @license Pimcore Open Core License (POCL)
*/

namespace Pimcore\Bundle\DataHubBundle\Hydrator;

use Pimcore\Bundle\DataHubBundle\Configuration;
use Pimcore\Bundle\DataHubBundle\Schema\ConfigurationDetail;

/**
* @internal
*/
final readonly class ConfigurationDetailHydrator implements ConfigurationDetailHydratorInterface
{
public function hydrate(
Configuration $configuration,
array $supportedQueryDataTypes,
array $supportedMutationDataTypes
): ConfigurationDetail
{
return new ConfigurationDetail(
$configuration->getName(),
$configuration->getConfiguration(),
$configuration->getPermissionsConfig(),
$supportedQueryDataTypes,
$supportedMutationDataTypes,
$configuration->getModificationDate()
);
}
}

30 changes: 30 additions & 0 deletions src/Hydrator/ConfigurationDetailHydratorInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
declare(strict_types=1);

/**
* This source file is available under the terms of the
* Pimcore Open Core License (POCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) Pimcore GmbH (https://www.pimcore.com)
* @license Pimcore Open Core License (POCL)
*/

namespace Pimcore\Bundle\DataHubBundle\Hydrator;

use Pimcore\Bundle\DataHubBundle\Configuration;
use Pimcore\Bundle\DataHubBundle\Schema\ConfigurationDetail;

/**
* @internal
*/
interface ConfigurationDetailHydratorInterface
{
public function hydrate(
Configuration $configuration,
array $supportedQueryDataTypes,
array $supportedMutationDataTypes
): ConfigurationDetail;
}

5 changes: 4 additions & 1 deletion src/Resources/config/studio_backend.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,7 @@ services:
class: Pimcore\Bundle\DataHubBundle\Service\Studio\ConfigurationService

Pimcore\Bundle\DataHubBundle\Hydrator\ConfigurationHydratorInterface:
class: Pimcore\Bundle\DataHubBundle\Hydrator\ConfigurationHydrator
class: Pimcore\Bundle\DataHubBundle\Hydrator\ConfigurationHydrator

Pimcore\Bundle\DataHubBundle\Hydrator\ConfigurationDetailHydratorInterface:
class: Pimcore\Bundle\DataHubBundle\Hydrator\ConfigurationDetailHydrator
17 changes: 16 additions & 1 deletion src/Resources/translations/studio_api_docs.en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,19 @@ bundle_tag_data_hub_description: Operations related to Data Hub Bundle
pimcore_studio_api_data_hub_config_collection: Data Hub Config Collection
bundle_data_hub_config_collection: Data Hub Config Collection
bundle_data_hub_config_collection_description: Data Hub Config Collection
bundle_data_hub_config_collection_summary: Data Hub Config Collection
bundle_data_hub_config_collection_summary: Data Hub Config Collection
pimcore_studio_api_data_hub_config_delete: Delete Data Hub Configuration
bundle_data_hub_config_delete: Delete Data Hub Configuration
bundle_data_hub_config_delete_description: Delete a Data Hub configuration by name
bundle_data_hub_config_delete_summary: Delete Data Hub Configuration
bundle_data_hub_config_delete_success_response: Data Hub configuration successfully deleted
pimcore_studio_api_data_hub_config_add: Add Data Hub Configuration
bundle_data_hub_config_add: Add Data Hub Configuration
bundle_data_hub_config_add_description: Create a new Data Hub configuration
bundle_data_hub_config_add_summary: Add Data Hub Configuration
bundle_data_hub_config_add_success_response: Data Hub configuration successfully created
pimcore_studio_api_data_hub_config_get: Get Data Hub Configuration
bundle_data_hub_config_get: Get Data Hub Configuration
bundle_data_hub_config_get_description: Get a Data Hub configuration by name
bundle_data_hub_config_get_summary: Get Data Hub Configuration
bundle_data_hub_config_get_success_response: Data Hub configuration details
Loading
Loading