-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial implementation of ApiSource (CFM-115)
- Loading branch information
Benn Oshrin
committed
Dec 31, 2023
1 parent
c54ccfc
commit f88d8a6
Showing
35 changed files
with
1,964 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| # ApiSource plugin for CakePHP | ||
|
|
||
| ## Installation | ||
|
|
||
| You can install this plugin into your CakePHP application using [composer](https://getcomposer.org). | ||
|
|
||
| The recommended way to install composer packages is: | ||
|
|
||
| ``` | ||
| composer require your-name-here/api-source | ||
| ``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| { | ||
| "name": "your-name-here/api-connector", | ||
| "description": "ApiConnector plugin for CakePHP", | ||
| "type": "cakephp-plugin", | ||
| "license": "MIT", | ||
| "require": { | ||
| "php": ">=7.2", | ||
| "cakephp/cakephp": "4.4.*" | ||
| }, | ||
| "require-dev": { | ||
| "phpunit/phpunit": "^8.5 || ^9.3" | ||
| }, | ||
| "autoload": { | ||
| "psr-4": { | ||
| "ApiConnector\\": "src/" | ||
| } | ||
| }, | ||
| "autoload-dev": { | ||
| "psr-4": { | ||
| "ApiConnector\\Test\\": "tests/", | ||
| "Cake\\Test\\": "vendor/cakephp/cakephp/tests/" | ||
| } | ||
| } | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| <?php | ||
| /** | ||
| * ApiSource plugin specific routes. | ||
| * | ||
| * Portions licensed to the University Corporation for Advanced Internet | ||
| * Development, Inc. ("UCAID") under one or more contributor license agreements. | ||
| * See the NOTICE file distributed with this work for additional information | ||
| * regarding copyright ownership. | ||
| * | ||
| * UCAID licenses this file to you under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with the | ||
| * License. You may obtain a copy of the License at: | ||
| * | ||
| * http://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. | ||
| * | ||
| * @link https://www.internet2.edu/comanage COmanage Project | ||
| * @package registry-plugins | ||
| * @since COmanage Registry v5.0.0 | ||
| * @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) | ||
| */ | ||
|
|
||
| use Cake\Http\Middleware\BodyParserMiddleware; | ||
| use Cake\Http\Middleware\CsrfProtectionMiddleware; | ||
| use Cake\Routing\Route\DashedRoute; | ||
| use Cake\Routing\RouteBuilder; | ||
| use Cake\Routing\Router; | ||
|
|
||
| // In general, we're probably trying to set up API routes if we're doing | ||
| // something within a plugin, but not necessarily. API routes are a subset | ||
| // of Cake routes, so either can be specified here. | ||
|
|
||
| // ApiSource API routes | ||
| // We place these under /v2 since the Registry v4 plugin essentially implemented v1 | ||
|
|
||
| $routes->scope('/api/apisource', function (RouteBuilder $builder) { | ||
| // Register scoped middleware for in scopes. | ||
| // Do not enable CSRF for the REST API, it will break standard (non-AJAX) clients | ||
| // $builder->registerMiddleware('csrf', new CsrfProtectionMiddleware(['httponly' => true])); | ||
| // BodyParserMiddleware will automatically parse JSON bodies, but we only | ||
| // want that for API transactions, so we only apply it to the /api scope. | ||
| $builder->registerMiddleware('bodyparser', new BodyParserMiddleware()); | ||
| /* | ||
| * Apply a middleware to the current route scope. | ||
| * Requires middleware to be registered through `Application::routes()` with `registerMiddleware()` | ||
| */ | ||
| // Do not enable CSRF for the REST API, it will break standard (non-AJAX) clients | ||
| // $builder->applyMiddleware('csrf'); | ||
| $builder->setExtensions(['json']); | ||
| $builder->applyMiddleware('bodyparser'); | ||
|
|
||
| $builder->delete( | ||
| '/{id}/v2/sorPeople/{sorlabel}/{sorid}', | ||
| ['plugin' => 'ApiConnector', 'controller' => 'ApiV2', 'action' => 'delete'] | ||
| ) | ||
| ->setPass(['id', 'sorlabel', 'sorid']) | ||
| ->setPatterns(['id' => '[0-9]+']); | ||
|
|
||
| $builder->get( | ||
| '/{id}/v2/sorPeople/{sorlabel}/{sorid}', | ||
| ['plugin' => 'ApiConnector', 'controller' => 'ApiV2', 'action' => 'get'] | ||
| ) | ||
| ->setPass(['id', 'sorlabel', 'sorid']) | ||
| ->setPatterns(['id' => '[0-9]+']); | ||
|
|
||
| $builder->put( | ||
| '/{id}/v2/sorPeople/{sorlabel}/{sorid}', | ||
| ['plugin' => 'ApiConnector', 'controller' => 'ApiV2', 'action' => 'upsert'] | ||
| ) | ||
| ->setPass(['id', 'sorlabel', 'sorid']) | ||
| ->setPatterns(['id' => '[0-9]+']); | ||
| }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <phpunit | ||
| colors="true" | ||
| processIsolation="false" | ||
| stopOnFailure="false" | ||
| bootstrap="tests/bootstrap.php" | ||
| > | ||
| <php> | ||
| <ini name="memory_limit" value="-1"/> | ||
| <ini name="apc.enable_cli" value="1"/> | ||
| </php> | ||
|
|
||
| <!-- Add any additional test suites you want to run here --> | ||
| <testsuites> | ||
| <testsuite name="ApiSource"> | ||
| <directory>tests/TestCase/</directory> | ||
| </testsuite> | ||
| </testsuites> | ||
|
|
||
| <!-- Setup fixture extension --> | ||
| <extensions> | ||
| <extension class="Cake\TestSuite\Fixture\PHPUnitExtension" /> | ||
| </extensions> | ||
|
|
||
| <filter> | ||
| <whitelist> | ||
| <directory suffix=".php">src/</directory> | ||
| </whitelist> | ||
| </filter> | ||
| </phpunit> |
32 changes: 32 additions & 0 deletions
32
app/availableplugins/ApiConnector/resources/locales/en_US/api_connector.po
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| # COmanage Registry Localizations (api_connector domain) | ||
| # | ||
| # Portions licensed to the University Corporation for Advanced Internet | ||
| # Development, Inc. ("UCAID") under one or more contributor license agreements. | ||
| # See the NOTICE file distributed with this work for additional information | ||
| # regarding copyright ownership. | ||
| # | ||
| # UCAID licenses this file to you under the Apache License, Version 2.0 | ||
| # (the "License"); you may not use this file except in compliance with the | ||
| # License. You may obtain a copy of the License at: | ||
| # | ||
| # http://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. | ||
| # | ||
| # @link https://www.internet2.edu/comanage COmanage Project | ||
| # @package registry | ||
| # @since COmanage Registry v5.0.0 | ||
| # @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) | ||
|
|
||
| msgid "controller.ApiSources" | ||
| #msgstr "{0,plural,=1{API Source} other{API Sources}}" | ||
|
|
||
| msgid "field.ApiSources.push_mode" | ||
| msgstr "Push Mode" | ||
|
|
||
| msgid "information.endpoint.push" | ||
| msgstr "The API endpoint for using this plugin in Push Mode is {0}" |
Oops, something went wrong.