community.general icon indicating copy to clipboard operation
community.general copied to clipboard

slack: add file upload functionality

Open Powma opened this issue 11 months ago • 12 comments

SUMMARY

Add file upload functionality to upload the files with the new API SLACK.

Continuation of #9431.

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME
  • Slack
ADDITIONAL INFORMATION

This enhancement allows you to upload files with the new version of the Slack API https://api.slack.com/methods/files.completeUploadExternal https://api.slack.com/methods/files.getUploadURLExternal

Example usage:

    - name: Upload a file to Slack
      community.general.slack:
        token: thetoken/generatedby/slack
        channel: 'kuma'
        upload_file:
          path: "/tmp/test.py"
          title: "main.py"
         snippet_type: "python"

Powma avatar Dec 30 '24 09:12 Powma

The test ansible-test sanity --test compile --python 2.7 [explain] failed with 1 error:

plugins/modules/slack.py:479:49: SyntaxError: headers = {"Authorization": f"Bearer {token}"}

The test ansible-test sanity --test import --python 2.7 [explain] failed with 1 error:

plugins/modules/slack.py:479:49: traceback: SyntaxError: invalid syntax

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

plugins/modules/slack.py:151:161: E501: line too long (177 > 160 characters)
plugins/modules/slack.py:477:1: E302: expected 2 blank lines, found 1
plugins/modules/slack.py:657:15: E121: continuation line under-indented for hanging indent

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

plugins/modules/slack.py:151:161: E501: line too long (177 > 160 characters)
plugins/modules/slack.py:477:1: E302: expected 2 blank lines, found 1
plugins/modules/slack.py:657:15: E121: continuation line under-indented for hanging indent

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

plugins/modules/slack.py:151:161: E501: line too long (177 > 160 characters)
plugins/modules/slack.py:477:1: E302: expected 2 blank lines, found 1
plugins/modules/slack.py:657:15: E121: continuation line under-indented for hanging indent

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

plugins/modules/slack.py:151:161: E501: line too long (177 > 160 characters)
plugins/modules/slack.py:477:1: E302: expected 2 blank lines, found 1
plugins/modules/slack.py:657:15: E121: continuation line under-indented for hanging indent

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

plugins/modules/slack.py:0:0: parameter-type-not-in-doc: Argument 'thread_ts' in argument_spec found in upload_file defines type as 'str' but documentation doesn't define type
plugins/modules/slack.py:0:0: undocumented-parameter: Argument 'thread_ts' found in upload_file is listed in the argument_spec, but not documented in the module documentation

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

plugins/modules/slack.py:0:0: parameter-type-not-in-doc: Argument 'thread_ts' in argument_spec found in upload_file defines type as 'str' but documentation doesn't define type
plugins/modules/slack.py:0:0: undocumented-parameter: Argument 'thread_ts' found in upload_file is listed in the argument_spec, but not documented in the module documentation

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

plugins/modules/slack.py:0:0: parameter-type-not-in-doc: Argument 'thread_ts' in argument_spec found in upload_file defines type as 'str' but documentation doesn't define type
plugins/modules/slack.py:0:0: undocumented-parameter: Argument 'thread_ts' found in upload_file is listed in the argument_spec, but not documented in the module documentation

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

plugins/modules/slack.py:0:0: parameter-type-not-in-doc: Argument 'thread_ts' in argument_spec found in upload_file defines type as 'str' but documentation doesn't define type
plugins/modules/slack.py:0:0: undocumented-parameter: Argument 'thread_ts' found in upload_file is listed in the argument_spec, but not documented in the module documentation

click here for bot help

ansibullbot avatar Dec 30 '24 09:12 ansibullbot

cc @ramondelafuente click here for bot help

ansibullbot avatar Dec 30 '24 09:12 ansibullbot

The test ansible-test sanity --test compile --python 2.7 [explain] failed with 1 error:

plugins/modules/slack.py:496:35: SyntaxError: full_url = f"{url}?{query}"

The test ansible-test sanity --test import --python 2.7 [explain] failed with 1 error:

plugins/modules/slack.py:496:35: traceback: SyntaxError: invalid syntax

The test ansible-test sanity --test pep8 [explain] failed with 2 errors:

plugins/modules/slack.py:483:1: E302: expected 2 blank lines, found 1
plugins/modules/slack.py:663:17: E123: closing bracket does not match indentation of opening bracket's line

The test ansible-test sanity --test pep8 [explain] failed with 2 errors:

plugins/modules/slack.py:483:1: E302: expected 2 blank lines, found 1
plugins/modules/slack.py:663:17: E123: closing bracket does not match indentation of opening bracket's line

The test ansible-test sanity --test pep8 [explain] failed with 2 errors:

plugins/modules/slack.py:483:1: E302: expected 2 blank lines, found 1
plugins/modules/slack.py:663:17: E123: closing bracket does not match indentation of opening bracket's line

The test ansible-test sanity --test pep8 [explain] failed with 2 errors:

plugins/modules/slack.py:483:1: E302: expected 2 blank lines, found 1
plugins/modules/slack.py:663:17: E123: closing bracket does not match indentation of opening bracket's line

click here for bot help

ansibullbot avatar Dec 30 '24 13:12 ansibullbot

The test ansible-test sanity --test compile --python 2.7 [explain] failed with 1 error:

plugins/modules/slack.py:538:18: SyntaxError: **(

The test ansible-test sanity --test import --python 2.7 [explain] failed with 1 error:

plugins/modules/slack.py:538:18: traceback: SyntaxError: invalid syntax

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

plugins/modules/slack.py:483:1: E302: expected 2 blank lines, found 1

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

plugins/modules/slack.py:483:1: E302: expected 2 blank lines, found 1

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

plugins/modules/slack.py:483:1: E302: expected 2 blank lines, found 1

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

plugins/modules/slack.py:483:1: E302: expected 2 blank lines, found 1

click here for bot help

ansibullbot avatar Dec 30 '24 18:12 ansibullbot

ping @Powma

Are you still working on this?

russoz avatar Feb 23 '25 21:02 russoz

needs_info

felixfontein avatar Mar 23 '25 13:03 felixfontein

Sorry, I’ll take a look at it next week. I know there’s an IRC channel if I need help.

Powma avatar Mar 23 '25 20:03 Powma

The test ansible-test sanity --test compile --python 2.7 [explain] failed with 1 error:

plugins/modules/slack.py:618:11: SyntaxError: try:

The test ansible-test sanity --test compile --python 3.10 [explain] failed with 1 error:

plugins/modules/slack.py:618:9: SyntaxError: try:

The test ansible-test sanity --test compile --python 3.11 [explain] failed with 1 error:

plugins/modules/slack.py:618:9: SyntaxError: try:

The test ansible-test sanity --test compile --python 3.12 [explain] failed with 1 error:

plugins/modules/slack.py:618:9: SyntaxError: try:

The test ansible-test sanity --test compile --python 3.6 [explain] failed with 1 error:

plugins/modules/slack.py:618:11: SyntaxError: try:

The test ansible-test sanity --test compile --python 3.7 [explain] failed with 1 error:

plugins/modules/slack.py:618:11: SyntaxError: try:

The test ansible-test sanity --test compile --python 3.8 [explain] failed with 1 error:

plugins/modules/slack.py:618:9: SyntaxError: try:

The test ansible-test sanity --test compile --python 3.9 [explain] failed with 1 error:

plugins/modules/slack.py:618:9: SyntaxError: try:

The test ansible-test sanity --test import --python 2.7 [explain] failed with 1 error:

plugins/modules/slack.py:618:11: traceback: SyntaxError: invalid syntax

The test ansible-test sanity --test import --python 3.10 [explain] failed with 1 error:

plugins/modules/slack.py:618:9: traceback: SyntaxError: invalid syntax

The test ansible-test sanity --test import --python 3.11 [explain] failed with 1 error:

plugins/modules/slack.py:618:9: traceback: SyntaxError: invalid syntax

The test ansible-test sanity --test import --python 3.12 [explain] failed with 1 error:

plugins/modules/slack.py:618:9: traceback: SyntaxError: invalid syntax

The test ansible-test sanity --test import --python 3.6 [explain] failed with 1 error:

plugins/modules/slack.py:618:11: traceback: SyntaxError: invalid syntax

The test ansible-test sanity --test import --python 3.7 [explain] failed with 1 error:

plugins/modules/slack.py:618:11: traceback: SyntaxError: invalid syntax

The test ansible-test sanity --test import --python 3.8 [explain] failed with 1 error:

plugins/modules/slack.py:618:9: traceback: SyntaxError: invalid syntax

The test ansible-test sanity --test import --python 3.9 [explain] failed with 1 error:

plugins/modules/slack.py:618:9: traceback: SyntaxError: invalid syntax

The test ansible-test sanity --test pep8 [explain] failed with 7 errors:

plugins/modules/slack.py:618:9: E122: continuation line missing indentation or outdented
plugins/modules/slack.py:619:28: E251: unexpected spaces around keyword / parameter equals
plugins/modules/slack.py:619:30: E251: unexpected spaces around keyword / parameter equals
plugins/modules/slack.py:620:9: E122: continuation line missing indentation or outdented
plugins/modules/slack.py:621:29: E251: unexpected spaces around keyword / parameter equals
plugins/modules/slack.py:621:31: E251: unexpected spaces around keyword / parameter equals
plugins/modules/slack.py:623:13: E123: closing bracket does not match indentation of opening bracket's line

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

plugins/modules/slack.py:618:9: python-syntax-error: invalid syntax (<unknown>, line 618)

The test ansible-test sanity --test compile --python 3.10 [explain] failed with 1 error:

plugins/modules/slack.py:618:9: SyntaxError: try:

The test ansible-test sanity --test compile --python 3.11 [explain] failed with 1 error:

plugins/modules/slack.py:618:9: SyntaxError: try:

The test ansible-test sanity --test compile --python 3.12 [explain] failed with 1 error:

plugins/modules/slack.py:618:9: SyntaxError: try:

The test ansible-test sanity --test compile --python 3.7 [explain] failed with 1 error:

plugins/modules/slack.py:618:11: SyntaxError: try:

The test ansible-test sanity --test compile --python 3.8 [explain] failed with 1 error:

plugins/modules/slack.py:618:9: SyntaxError: try:

The test ansible-test sanity --test compile --python 3.9 [explain] failed with 1 error:

plugins/modules/slack.py:618:9: SyntaxError: try:

The test ansible-test sanity --test import --python 3.10 [explain] failed with 1 error:

plugins/modules/slack.py:618:9: traceback: SyntaxError: invalid syntax

The test ansible-test sanity --test import --python 3.11 [explain] failed with 1 error:

plugins/modules/slack.py:618:9: traceback: SyntaxError: invalid syntax

The test ansible-test sanity --test import --python 3.12 [explain] failed with 1 error:

plugins/modules/slack.py:618:9: traceback: SyntaxError: invalid syntax

The test ansible-test sanity --test import --python 3.7 [explain] failed with 1 error:

plugins/modules/slack.py:618:11: traceback: SyntaxError: invalid syntax

The test ansible-test sanity --test import --python 3.8 [explain] failed with 1 error:

plugins/modules/slack.py:618:9: traceback: SyntaxError: invalid syntax

The test ansible-test sanity --test import --python 3.9 [explain] failed with 1 error:

plugins/modules/slack.py:618:9: traceback: SyntaxError: invalid syntax

The test ansible-test sanity --test pep8 [explain] failed with 7 errors:

plugins/modules/slack.py:618:9: E122: continuation line missing indentation or outdented
plugins/modules/slack.py:619:28: E251: unexpected spaces around keyword / parameter equals
plugins/modules/slack.py:619:30: E251: unexpected spaces around keyword / parameter equals
plugins/modules/slack.py:620:9: E122: continuation line missing indentation or outdented
plugins/modules/slack.py:621:29: E251: unexpected spaces around keyword / parameter equals
plugins/modules/slack.py:621:31: E251: unexpected spaces around keyword / parameter equals
plugins/modules/slack.py:623:13: E123: closing bracket does not match indentation of opening bracket's line

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

plugins/modules/slack.py:618:9: python-syntax-error: invalid syntax (<unknown>, line 618)

The test ansible-test sanity --test compile --python 3.10 [explain] failed with 1 error:

plugins/modules/slack.py:618:9: SyntaxError: try:

The test ansible-test sanity --test compile --python 3.11 [explain] failed with 1 error:

plugins/modules/slack.py:618:9: SyntaxError: try:

The test ansible-test sanity --test compile --python 3.12 [explain] failed with 1 error:

plugins/modules/slack.py:618:9: SyntaxError: try:

The test ansible-test sanity --test compile --python 3.13 [explain] failed with 1 error:

plugins/modules/slack.py:618:9: SyntaxError: try:

The test ansible-test sanity --test compile --python 3.8 [explain] failed with 1 error:

plugins/modules/slack.py:618:9: SyntaxError: try:

The test ansible-test sanity --test compile --python 3.9 [explain] failed with 1 error:

plugins/modules/slack.py:618:9: SyntaxError: try:

The test ansible-test sanity --test import --python 3.10 [explain] failed with 1 error:

plugins/modules/slack.py:618:9: traceback: SyntaxError: invalid syntax

The test ansible-test sanity --test import --python 3.11 [explain] failed with 1 error:

plugins/modules/slack.py:618:9: traceback: SyntaxError: invalid syntax

The test ansible-test sanity --test import --python 3.12 [explain] failed with 1 error:

plugins/modules/slack.py:618:9: traceback: SyntaxError: invalid syntax

The test ansible-test sanity --test import --python 3.13 [explain] failed with 1 error:

plugins/modules/slack.py:618:9: traceback: SyntaxError: invalid syntax

The test ansible-test sanity --test import --python 3.8 [explain] failed with 1 error:

plugins/modules/slack.py:618:9: traceback: SyntaxError: invalid syntax

The test ansible-test sanity --test import --python 3.9 [explain] failed with 1 error:

plugins/modules/slack.py:618:9: traceback: SyntaxError: invalid syntax

The test ansible-test sanity --test pep8 [explain] failed with 7 errors:

plugins/modules/slack.py:618:9: E122: continuation line missing indentation or outdented
plugins/modules/slack.py:619:28: E251: unexpected spaces around keyword / parameter equals
plugins/modules/slack.py:619:30: E251: unexpected spaces around keyword / parameter equals
plugins/modules/slack.py:620:9: E122: continuation line missing indentation or outdented
plugins/modules/slack.py:621:29: E251: unexpected spaces around keyword / parameter equals
plugins/modules/slack.py:621:31: E251: unexpected spaces around keyword / parameter equals
plugins/modules/slack.py:623:13: E123: closing bracket does not match indentation of opening bracket's line

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

plugins/modules/slack.py:618:9: python-syntax-error: invalid syntax (<unknown>, line 618)

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

plugins/modules/slack.py:618:9: syntax-error: Parsing failed: 'invalid syntax (ansible_collections.community.general.plugins.modules.slack, line 618)'

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

Command "ansible-doc -t module community.general.slack" returned exit status 1.
>>> Standard Error
ERROR! module community.general.slack missing documentation (or could not parse documentation): community.general.slack did not contain a DOCUMENTATION attribute (/root/ansible_collections/community/general/plugins/modules/slack.py). Unable to parse documentation in python file '/root/ansible_collections/community/general/plugins/modules/slack.py': invalid syntax (<unknown>, line 618). invalid syntax (<unknown>, line 618)

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

plugins/modules/slack.py:0:0: python-syntax-error: Python SyntaxError while parsing module

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

Command "ansible-doc -t module community.general.slack" returned exit status 1.
>>> Standard Error
ERROR! module community.general.slack missing documentation (or could not parse documentation): community.general.slack did not contain a DOCUMENTATION attribute (/root/ansible_collections/community/general/plugins/modules/slack.py). Unable to parse documentation in python file '/root/ansible_collections/community/general/plugins/modules/slack.py': invalid syntax (<unknown>, line 618). invalid syntax (<unknown>, line 618)

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

plugins/modules/slack.py:0:0: python-syntax-error: Python SyntaxError while parsing module

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

plugins/modules/slack.py:618:9: syntax-error: Parsing failed: 'invalid syntax (<unknown>, line 618)'

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

plugins/modules/slack.py:618:9: syntax-error: Parsing failed: 'invalid syntax (ansible_collections.community.general.plugins.modules.slack, line 618)'

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

plugins/modules/slack.py:618:9: syntax-error: Parsing failed: 'invalid syntax (ansible_collections.community.general.plugins.modules.slack, line 618)'

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

Command "ansible-doc -t module community.general.slack" returned exit status 1.
>>> Standard Error
ERROR! module community.general.slack missing documentation (or could not parse documentation): community.general.slack did not contain a DOCUMENTATION attribute (/root/ansible_collections/community/general/plugins/modules/slack.py). Unable to parse documentation in python file '/root/ansible_collections/community/general/plugins/modules/slack.py': invalid syntax (<unknown>, line 618). invalid syntax (<unknown>, line 618)

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

plugins/modules/slack.py:0:0: python-syntax-error: Python SyntaxError while parsing module

The test extra-docs failed with 2 errors:

plugins/modules/slack.py:0:0: Did not return correct DOCUMENTATION
plugins/modules/slack.py:0:0: Missing documentation or could not parse documentation: community.general.slack did not contain a DOCUMENTATION attribute (/tmp/antsibull-docs-8xllr_zr/ansible_collections/community/general/plugins/modules/slack.py). Unable to parse documentation in python file '/tmp/antsibull-docs-8xllr_zr/ansible_collections/community/general/plugins/modules/slack.py': invalid syntax (<unknown>, line 618). invalid syntax (<unknown>, line 618)

The test ansible-test sanity --test compile --python 3.10 [explain] failed with 1 error:

plugins/modules/slack.py:618:9: SyntaxError: try:

The test ansible-test sanity --test compile --python 3.11 [explain] failed with 1 error:

plugins/modules/slack.py:618:9: SyntaxError: try:

The test ansible-test sanity --test compile --python 3.12 [explain] failed with 1 error:

plugins/modules/slack.py:618:9: SyntaxError: try:

The test ansible-test sanity --test compile --python 3.13 [explain] failed with 1 error:

plugins/modules/slack.py:618:9: SyntaxError: try:

The test ansible-test sanity --test compile --python 3.8 [explain] failed with 1 error:

plugins/modules/slack.py:618:9: SyntaxError: try:

The test ansible-test sanity --test compile --python 3.9 [explain] failed with 1 error:

plugins/modules/slack.py:618:9: SyntaxError: try:

The test ansible-test sanity --test import --python 3.10 [explain] failed with 1 error:

plugins/modules/slack.py:618:9: traceback: SyntaxError: invalid syntax

The test ansible-test sanity --test import --python 3.11 [explain] failed with 1 error:

plugins/modules/slack.py:618:9: traceback: SyntaxError: invalid syntax

The test ansible-test sanity --test import --python 3.12 [explain] failed with 1 error:

plugins/modules/slack.py:618:9: traceback: SyntaxError: invalid syntax

The test ansible-test sanity --test import --python 3.13 [explain] failed with 1 error:

plugins/modules/slack.py:618:9: traceback: SyntaxError: invalid syntax

The test ansible-test sanity --test import --python 3.8 [explain] failed with 1 error:

plugins/modules/slack.py:618:9: traceback: SyntaxError: invalid syntax

The test ansible-test sanity --test import --python 3.9 [explain] failed with 1 error:

plugins/modules/slack.py:618:9: traceback: SyntaxError: invalid syntax

The test ansible-test sanity --test pep8 [explain] failed with 7 errors:

plugins/modules/slack.py:618:9: E122: continuation line missing indentation or outdented
plugins/modules/slack.py:619:28: E251: unexpected spaces around keyword / parameter equals
plugins/modules/slack.py:619:30: E251: unexpected spaces around keyword / parameter equals
plugins/modules/slack.py:620:9: E122: continuation line missing indentation or outdented
plugins/modules/slack.py:621:29: E251: unexpected spaces around keyword / parameter equals
plugins/modules/slack.py:621:31: E251: unexpected spaces around keyword / parameter equals
plugins/modules/slack.py:623:13: E123: closing bracket does not match indentation of opening bracket's line

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

plugins/modules/slack.py:618:9: python-syntax-error: invalid syntax (<unknown>, line 618)

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

Command "ansible-doc -t module community.general.slack" returned exit status 1.
>>> Standard Error
ERROR! module community.general.slack missing documentation (or could not parse documentation): community.general.slack did not contain a DOCUMENTATION attribute (/root/ansible_collections/community/general/plugins/modules/slack.py). Unable to parse documentation in python file '/root/ansible_collections/community/general/plugins/modules/slack.py': invalid syntax (<unknown>, line 618). invalid syntax (<unknown>, line 618)

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

plugins/modules/slack.py:0:0: python-syntax-error: Python SyntaxError while parsing module

click here for bot help

ansibullbot avatar Mar 27 '25 13:03 ansibullbot

The test ansible-test sanity --test pep8 [explain] failed with 2 errors:

plugins/modules/slack.py:616:15: E111: indentation is not a multiple of 4
plugins/modules/slack.py:626:11: E111: indentation is not a multiple of 4

The test ansible-test sanity --test pep8 [explain] failed with 2 errors:

plugins/modules/slack.py:616:15: E111: indentation is not a multiple of 4
plugins/modules/slack.py:626:11: E111: indentation is not a multiple of 4

The test ansible-test sanity --test pep8 [explain] failed with 2 errors:

plugins/modules/slack.py:616:15: E111: indentation is not a multiple of 4
plugins/modules/slack.py:626:11: E111: indentation is not a multiple of 4

The test ansible-test sanity --test pep8 [explain] failed with 2 errors:

plugins/modules/slack.py:616:15: E111: indentation is not a multiple of 4
plugins/modules/slack.py:626:11: E111: indentation is not a multiple of 4

click here for bot help

ansibullbot avatar Mar 27 '25 13:03 ansibullbot

Hi @Powma

You are probably busy, but the PR is very close to being good to go, and we're having a release of the collection next week. Do you think you will have time to give it some TLC before that? No pressure, just trying to work on the logistics, there will be other releases in the future. :-)

russoz avatar Apr 18 '25 08:04 russoz

needs_info

felixfontein avatar May 24 '25 13:05 felixfontein

@Powma This pullrequest is waiting for your response. Please respond or the pullrequest will be closed.

click here for bot help

ansibullbot avatar Jun 24 '25 18:06 ansibullbot

@Powma You have not responded to information requests in this pullrequest so we will assume it no longer affects you. If you are still interested in this, please create a new pullrequest with the requested information.

click here for bot help

ansibullbot avatar Jul 26 '25 18:07 ansibullbot