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

Add support for adding custom query parameters to URL #46390

Merged
merged 1 commit into from
Oct 26, 2018

Conversation

remyleone
Copy link
Contributor

@remyleone remyleone commented Oct 2, 2018

SUMMARY

It is currently not possible to specify query parameters to Scaleway URL. For instance, it is not currently possible to specify how many results you want per page. It makes it difficult to test pagination for Scaleway compute without hitting the default number of machines per pages (50).

By adding arbitrary queries parameters to each ansible modules we will be able to have a greater flexibility in our API calls.

Will be very useful to test #46117

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME
  • scaleway
ANSIBLE VERSION
ansible 2.8.0.dev0 (scaleway_query_filters 2c9caa04d2) last updated 2018/10/02 12:53:33 (GMT +200)
  config file = None
  configured module search path = [u'/Users/sieben/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/sieben/workspace/ansible/lib/ansible
  executable location = /Users/sieben/workspace/ansible/bin/ansible
  python version = 2.7.15 (default, Jun 17 2018, 12:46:58) [GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.2)]

@ansibot
Copy link
Contributor

ansibot commented Oct 2, 2018

@ansibot ansibot added WIP This issue/PR is a work in progress. Nevertheless it was shared for getting input from peers. affects_2.8 This issue/PR affects Ansible v2.8 cloud feature This issue/PR relates to a feature request. inventory Inventory category needs_triage Needs a first human triage before being processed. owner_pr This PR is made by the module's maintainer. scaleway support:community This issue/PR relates to code supported by the Ansible community. labels Oct 2, 2018
@ansibot
Copy link
Contributor

ansibot commented Oct 2, 2018

The test ansible-test sanity --test pylint [explain] failed with 3 errors:

lib/ansible/module_utils/scaleway.py:34:17: undefined-variable Undefined variable 'ALLOWED_DEVICE_QUERY_PARAMETERS'
lib/ansible/module_utils/scaleway.py:36:77: undefined-variable Undefined variable 'ALLOWED_DEVICE_QUERY_PARAMETERS'
lib/ansible/module_utils/scaleway.py:45:71: undefined-variable Undefined variable 'urlencode'

click here for bot help

@ansibot ansibot added the ci_verified Changes made in this PR are causing tests to fail. label Oct 2, 2018
@webknjaz webknjaz removed the needs_triage Needs a first human triage before being processed. label Oct 2, 2018
@ansibot ansibot added the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Oct 10, 2018
@ansibot
Copy link
Contributor

ansibot commented Oct 12, 2018

The test ansible-test sanity --test ansible-doc --python 2.6 [explain] failed with the error:

Output on stderr from ansible-doc is considered an error.

Command "ansible-doc -t module scaleway_compute scaleway_image_facts scaleway_ip scaleway_ip_facts scaleway_organization_facts scaleway_security_group scaleway_security_group_facts scaleway_security_group_rule scaleway_server_facts scaleway_snapshot_facts scaleway_sshkey scaleway_user_data scaleway_volume scaleway_volume_facts" returned exit status 0.
>>> Standard Error
[WARNING]: While constructing a mapping from /root/ansible/lib/ansible/modules
/cloud/scaleway/scaleway_security_group_facts.py, line 13, column 5, found a
duplicate dict key (choices). Using last defined value only.

The test ansible-test sanity --test ansible-doc --python 2.7 [explain] failed with the error:

Output on stderr from ansible-doc is considered an error.

Command "ansible-doc -t module scaleway_compute scaleway_image_facts scaleway_ip scaleway_ip_facts scaleway_organization_facts scaleway_security_group scaleway_security_group_facts scaleway_security_group_rule scaleway_server_facts scaleway_snapshot_facts scaleway_sshkey scaleway_user_data scaleway_volume scaleway_volume_facts" returned exit status 0.
>>> Standard Error
[WARNING]: While constructing a mapping from /root/ansible/lib/ansible/modules
/cloud/scaleway/scaleway_security_group_facts.py, line 13, column 5, found a
duplicate dict key (choices). Using last defined value only.

The test ansible-test sanity --test ansible-doc --python 3.5 [explain] failed with the error:

Output on stderr from ansible-doc is considered an error.

Command "ansible-doc -t module scaleway_compute scaleway_image_facts scaleway_ip scaleway_ip_facts scaleway_organization_facts scaleway_security_group scaleway_security_group_facts scaleway_security_group_rule scaleway_server_facts scaleway_snapshot_facts scaleway_sshkey scaleway_user_data scaleway_volume scaleway_volume_facts" returned exit status 0.
>>> Standard Error
[WARNING]: While constructing a mapping from /root/ansible/lib/ansible/modules
/cloud/scaleway/scaleway_security_group_facts.py, line 13, column 5, found a
duplicate dict key (choices). Using last defined value only.

The test ansible-test sanity --test ansible-doc --python 3.7 [explain] failed with the error:

Output on stderr from ansible-doc is considered an error.

Command "ansible-doc -t module scaleway_compute scaleway_image_facts scaleway_ip scaleway_ip_facts scaleway_organization_facts scaleway_security_group scaleway_security_group_facts scaleway_security_group_rule scaleway_server_facts scaleway_snapshot_facts scaleway_sshkey scaleway_user_data scaleway_volume scaleway_volume_facts" returned exit status 0.
>>> Standard Error
[WARNING]: While constructing a mapping from /root/ansible/lib/ansible/modules
/cloud/scaleway/scaleway_security_group_facts.py, line 13, column 5, found a
duplicate dict key (choices). Using last defined value only.

The test ansible-test sanity --test ansible-doc --python 3.6 [explain] failed with the error:

Output on stderr from ansible-doc is considered an error.

Command "ansible-doc -t module scaleway_compute scaleway_image_facts scaleway_ip scaleway_ip_facts scaleway_organization_facts scaleway_security_group scaleway_security_group_facts scaleway_security_group_rule scaleway_server_facts scaleway_snapshot_facts scaleway_sshkey scaleway_user_data scaleway_volume scaleway_volume_facts" returned exit status 0.
>>> Standard Error
[WARNING]: While constructing a mapping from /root/ansible/lib/ansible/modules
/cloud/scaleway/scaleway_security_group_facts.py, line 13, column 5, found a
duplicate dict key (choices). Using last defined value only.

The test ansible-test sanity --test validate-modules [explain] failed with 14 errors:

lib/ansible/modules/cloud/scaleway/scaleway_compute.py:0:0: E322 "query_parameters" is listed in the argument_spec, but not documented in the module
lib/ansible/modules/cloud/scaleway/scaleway_image_facts.py:0:0: E322 "query_parameters" is listed in the argument_spec, but not documented in the module
lib/ansible/modules/cloud/scaleway/scaleway_ip.py:0:0: E322 "query_parameters" is listed in the argument_spec, but not documented in the module
lib/ansible/modules/cloud/scaleway/scaleway_ip_facts.py:0:0: E322 "query_parameters" is listed in the argument_spec, but not documented in the module
lib/ansible/modules/cloud/scaleway/scaleway_organization_facts.py:0:0: E322 "query_parameters" is listed in the argument_spec, but not documented in the module
lib/ansible/modules/cloud/scaleway/scaleway_security_group.py:0:0: E322 "query_parameters" is listed in the argument_spec, but not documented in the module
lib/ansible/modules/cloud/scaleway/scaleway_security_group_facts.py:0:0: E322 "query_parameters" is listed in the argument_spec, but not documented in the module
lib/ansible/modules/cloud/scaleway/scaleway_security_group_rule.py:0:0: E322 "query_parameters" is listed in the argument_spec, but not documented in the module
lib/ansible/modules/cloud/scaleway/scaleway_server_facts.py:0:0: E322 "query_parameters" is listed in the argument_spec, but not documented in the module
lib/ansible/modules/cloud/scaleway/scaleway_snapshot_facts.py:0:0: E322 "query_parameters" is listed in the argument_spec, but not documented in the module
lib/ansible/modules/cloud/scaleway/scaleway_sshkey.py:0:0: E322 "query_parameters" is listed in the argument_spec, but not documented in the module
lib/ansible/modules/cloud/scaleway/scaleway_user_data.py:0:0: E322 "query_parameters" is listed in the argument_spec, but not documented in the module
lib/ansible/modules/cloud/scaleway/scaleway_volume.py:0:0: E322 "query_parameters" is listed in the argument_spec, but not documented in the module
lib/ansible/modules/cloud/scaleway/scaleway_volume_facts.py:0:0: E322 "query_parameters" is listed in the argument_spec, but not documented in the module

The test ansible-test sanity --test yamllint [explain] failed with 1 error:

lib/ansible/modules/cloud/scaleway/scaleway_security_group_facts.py:31:5: key-duplicates DOCUMENTATION: duplication of key "choices" in mapping

click here for bot help

@ansibot
Copy link
Contributor

ansibot commented Oct 12, 2018

@ansibot ansibot added module This issue/PR relates to a module. needs_maintainer Ansibot is unable to identify maintainers for this PR. (Check `author` in docs or BOTMETA.yml) support:core This issue/PR relates to code supported by the Ansible Engineering Team. test This PR relates to tests. and removed ci_verified Changes made in this PR are causing tests to fail. owner_pr This PR is made by the module's maintainer. stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. labels Oct 12, 2018
@remyleone remyleone force-pushed the scaleway_query_filters branch 2 times, most recently from f151022 to 286f1ca Compare October 15, 2018 11:57
@remyleone remyleone changed the title WIP: Add support for adding custom query parameters to URL Add support for adding custom query parameters to URL Oct 15, 2018
@remyleone
Copy link
Contributor Author

@Spredzy @pilou- could I get a review?

@ansibot
Copy link
Contributor

ansibot commented Oct 15, 2018

The test ansible-test sanity --test validate-modules [explain] failed with 14 errors:

lib/ansible/modules/cloud/scaleway/scaleway_compute.py:0:0: E322 "query_parameters" is listed in the argument_spec, but not documented in the module
lib/ansible/modules/cloud/scaleway/scaleway_image_facts.py:0:0: E322 "query_parameters" is listed in the argument_spec, but not documented in the module
lib/ansible/modules/cloud/scaleway/scaleway_ip.py:0:0: E322 "query_parameters" is listed in the argument_spec, but not documented in the module
lib/ansible/modules/cloud/scaleway/scaleway_ip_facts.py:0:0: E322 "query_parameters" is listed in the argument_spec, but not documented in the module
lib/ansible/modules/cloud/scaleway/scaleway_organization_facts.py:0:0: E322 "query_parameters" is listed in the argument_spec, but not documented in the module
lib/ansible/modules/cloud/scaleway/scaleway_security_group.py:0:0: E322 "query_parameters" is listed in the argument_spec, but not documented in the module
lib/ansible/modules/cloud/scaleway/scaleway_security_group_facts.py:0:0: E322 "query_parameters" is listed in the argument_spec, but not documented in the module
lib/ansible/modules/cloud/scaleway/scaleway_security_group_rule.py:0:0: E322 "query_parameters" is listed in the argument_spec, but not documented in the module
lib/ansible/modules/cloud/scaleway/scaleway_server_facts.py:0:0: E322 "query_parameters" is listed in the argument_spec, but not documented in the module
lib/ansible/modules/cloud/scaleway/scaleway_snapshot_facts.py:0:0: E322 "query_parameters" is listed in the argument_spec, but not documented in the module
lib/ansible/modules/cloud/scaleway/scaleway_sshkey.py:0:0: E322 "query_parameters" is listed in the argument_spec, but not documented in the module
lib/ansible/modules/cloud/scaleway/scaleway_user_data.py:0:0: E322 "query_parameters" is listed in the argument_spec, but not documented in the module
lib/ansible/modules/cloud/scaleway/scaleway_volume.py:0:0: E322 "query_parameters" is listed in the argument_spec, but not documented in the module
lib/ansible/modules/cloud/scaleway/scaleway_volume_facts.py:0:0: E322 "query_parameters" is listed in the argument_spec, but not documented in the module

click here for bot help

@ansibot ansibot removed the WIP This issue/PR is a work in progress. Nevertheless it was shared for getting input from peers. label Oct 15, 2018
@ansibot ansibot added the core_review In order to be merged, this PR must follow the core review workflow. label Oct 15, 2018
@remyleone
Copy link
Contributor Author

@gundalow Could you review and merge?

@remyleone
Copy link
Contributor Author

@pilou- Could you review?

@mscherer
Copy link
Contributor

So, I am a bit concerned about the level of code duplication between module_utils/scaleway.py and the online.py one, especially since we start to change one to add more flexibility that could end being useful to the others. And also concerned about cut and paste with DO module_utils.

@mscherer
Copy link
Contributor

shipit

1 similar comment
@remyleone
Copy link
Contributor Author

shipit

@ansibot ansibot added shipit This PR is ready to be merged by Core and removed core_review In order to be merged, this PR must follow the core review workflow. labels Oct 19, 2018
@pilou-
Copy link
Contributor

pilou- commented Oct 19, 2018

I have a negative opinion on this PR:

  • pagination settings must not be module parameters instead use something like max_results
  • if a user really would to do that, he could use uri module

@remyleone
Copy link
Contributor Author

@pilou- This PR is not about pagination. This PR is about adding the possibility to add query_parameters to the URL from the module. This can be used to offer the possibility to the user to add optional filters to speed up queries for instance if they want to and if the module does not support it natively.

@pilou-
Copy link
Contributor

pilou- commented Oct 19, 2018

Users still can use URI module :) I am not convinced by the given examples. And what about the idempotence ? Should not this feature be used only for facts modules ?

@remyleone
Copy link
Contributor Author

I don't understand what idempotence have to do with this PR. I also don't understand why it should also only be used for facts? Could you give examples?

@remyleone
Copy link
Contributor Author

@halberom How do you handle the case where you have several time the same key in a url query string? Espically with urlencode?

@halberom
Copy link
Contributor

@sieben, not sure what you mean. I made my comment because it looked like you had typos on the doc of the param. It states type: list but has default: {}. If it should be a list (of dicts), then your default is wrong (and possibly your examples and code).

@ansibot ansibot added core_review In order to be merged, this PR must follow the core review workflow. needs_ci This PR requires CI testing to be performed. Please close and re-open this PR to trigger CI. stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. and removed shipit This PR is ready to be merged by Core labels Oct 26, 2018
@remyleone
Copy link
Contributor Author

@gundalow Could this be merged?

@ansibot ansibot removed needs_ci This PR requires CI testing to be performed. Please close and re-open this PR to trigger CI. stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. labels Oct 26, 2018
@gundalow gundalow merged commit 3386058 into ansible:devel Oct 26, 2018
@gundalow
Copy link
Contributor

Merged into devel for release in Ansible 2.8.

Thanks for the PR and reviews!

Tomorrow9 pushed a commit to Tomorrow9/ansible that referenced this pull request Dec 4, 2018
@ansible ansible locked and limited conversation to collaborators Jul 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.8 This issue/PR affects Ansible v2.8 cloud core_review In order to be merged, this PR must follow the core review workflow. feature This issue/PR relates to a feature request. inventory Inventory category module This issue/PR relates to a module. needs_maintainer Ansibot is unable to identify maintainers for this PR. (Check `author` in docs or BOTMETA.yml) scaleway support:community This issue/PR relates to code supported by the Ansible community. support:core This issue/PR relates to code supported by the Ansible Engineering Team. test This PR relates to tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants