Skip to content

[4.0][webservice][com_installer] add filtering of data#32769

Closed
alikon wants to merge 7 commits intojoomla:4.0-devfrom
alikon:patch-81
Closed

[4.0][webservice][com_installer] add filtering of data#32769
alikon wants to merge 7 commits intojoomla:4.0-devfrom
alikon:patch-81

Conversation

@alikon
Copy link
Copy Markdown
Contributor

@alikon alikon commented Mar 21, 2021

Summary of Changes

add filtering of data

Testing Instructions

  • GET {{base_path}}/api/index.php/v1/installer/manage?core=true/false
  • GET {{base_path}}/api/index.php/v1/installer/manage?status=0/1
  • GET {{base_path}}/api/index.php/v1/installer/manage?type=component/plugin/module/template

Actual result BEFORE applying this Pull Request

N/A

Expected result AFTER applying this Pull Request

{
    "links": {
        "self": "https://demo4.loc/api/index.php/v1/installer/manage?core=0"
    },
    "data": [
        {
            "type": "manage",
            "id": "224",
            "attributes": {
                "name": "Action Log - Akeeba Backup",
                "type": "plugin",
                "folder": "actionlog",
                "client_id": "0",
                "status": "0",
                "version": "8.0.1",
                "id": "224"
            }
        },
        {
            "type": "manage",
            "id": "220",
            "attributes": {
                "name": "Akeeba Backup",
                "type": "component",
                "folder": "",
                "client_id": "1",
                "status": "1",
                "version": "8.0.1",
                "id": "220"
            }
        },
        {
            "type": "manage",
            "id": "225",
            "attributes": {
                "name": "Akeeba Backup package",
                "type": "package",
                "folder": "",
                "client_id": "0",
                "status": "1",
                "version": "8.0.1",
                "id": "225"
            }
        },
        {
            "type": "manage",
            "id": "221",
            "attributes": {
                "name": "Console - Akeeba Backup",
                "type": "plugin",
                "folder": "console",
                "client_id": "0",
                "status": "1",
                "version": "8.0.1",
                "id": "221"
            }
        },
        {
            "type": "manage",
            "id": "226",
            "attributes": {
                "name": "file_fef",
                "type": "file",
                "folder": "",
                "client_id": "0",
                "status": "1",
                "version": "2.0.1",
                "id": "226"
            }
        },
        {
            "type": "manage",
            "id": "219",
            "attributes": {
                "name": "file_fof40",
                "type": "file",
                "folder": "",
                "client_id": "0",
                "status": "1",
                "version": "4.0.2",
                "id": "219"
            }
        },
        {
            "type": "manage",
            "id": "218",
            "attributes": {
                "name": "Joomla! Patch Tester",
                "type": "component",
                "folder": "",
                "client_id": "1",
                "status": "1",
                "version": "4.0.1",
                "id": "218"
            }
        },
        {
            "type": "manage",
            "id": "222",
            "attributes": {
                "name": "Quick Icon - Akeeba Backup Notification",
                "type": "plugin",
                "folder": "quickicon",
                "client_id": "0",
                "status": "1",
                "version": "8.0.1",
                "id": "222"
            }
        },
        {
            "type": "manage",
            "id": "217",
            "attributes": {
                "name": "Sample Data - Testing",
                "type": "plugin",
                "folder": "sampledata",
                "client_id": "0",
                "status": "0",
                "version": "4.0.0",
                "id": "217"
            }
        },
        {
            "type": "manage",
            "id": "223",
            "attributes": {
                "name": "System - Backup on update",
                "type": "plugin",
                "folder": "system",
                "client_id": "0",
                "status": "0",
                "version": "8.0.1",
                "id": "223"
            }
        }
    ],
    "meta": {
        "total-pages": 1
    }
}

Documentation Changes Required

@rdeutz rdeutz added this to the Joomla 4.0.1 milestone Mar 22, 2021
Co-authored-by: Richard Fath <richard67@users.noreply.github.com>
@Quy
Copy link
Copy Markdown
Contributor

Quy commented Mar 25, 2021

For core, should all entries be displayed if true/false is not entered?

@alikon
Copy link
Copy Markdown
Contributor Author

alikon commented Mar 25, 2021

when core is omitted it works like before ie all items are returned

@Quy
Copy link
Copy Markdown
Contributor

Quy commented Mar 25, 2021

core=0 returns entries. Should it?

@alikon
Copy link
Copy Markdown
Contributor Author

alikon commented Mar 27, 2021

no
better a 400

{
    "errors": [
        {
            "title": "Invalid field: core",
            "code": 400
        }
    ]
}

@Quy
Copy link
Copy Markdown
Contributor

Quy commented Mar 28, 2021

It is not a consistent to show an error vs. the following.

In this example, a 2 is added at the end.

{
    "links": {
        "self": "http://localhost/joomla-cms-4.0-dev/api/index.php/v1/installer/manage?type=component2"
    },
    "data": [],
    "meta": {
        "total-pages": 0
    }
}

@alikon
Copy link
Copy Markdown
Contributor Author

alikon commented Mar 29, 2021

these are different things
it has been requested to manage core like boolean hence the check (invalid field)
but for type it's a string so 0 found it's a correct response

@anibalsanchez
Copy link
Copy Markdown
Contributor

I think that the GET verb is wrong in the REST API controller Installer.

/installer is not a data entity. It is a controller/helper itself that provides the behaviour, actions.

It looks odd calling an action with a GET. /installer/manage is a method, so for clarity, it is better if it is called with a POST (even if it doesn't persist a change).

So, if everything that Installer does is managing, then the method manage must return different types of data based on a control parameter. If we follow the Joomla practice, it should have a task parameter to return data or persist changes.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/32769.

@alikon
Copy link
Copy Markdown
Contributor Author

alikon commented Apr 24, 2021

beyond the scope of this pr

@anibalsanchez
Copy link
Copy Markdown
Contributor

anibalsanchez commented Apr 24, 2021

Thinking twice about the API for extensions, it is not right to publish the "Installer" /installer. It is not the right semantic.

Check the documentation https://docs.joomla.org/J4.x:Joomla_Core_APIs. The entry points are always entities.

It is better to manage the extensions as /api/index.php/v1/extensions/...

For instance, to install an extension you should do a POST /api/index.php/v1/extensions/install.

@wilsonge
Copy link
Copy Markdown
Contributor

@anibalsanchez i agree with you - however Nicola is also correct that his pr is just adding filters to an existing endpoint - so can you create a separate issue to track your comment - and I'll try and work on it

@alikon
Copy link
Copy Markdown
Contributor Author

alikon commented May 9, 2021

merged in #33339

@alikon alikon closed this May 9, 2021
@alikon alikon deleted the patch-81 branch May 9, 2021 07:39
@wilsonge wilsonge removed this from the Joomla 4.0.1 milestone Aug 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants