..
.. SPDX-License-Identifier: Apache-2.0
..

:github_url: https://github.com/IBM-Blockchain/ansible-collection/edit/main/plugins/modules/channel_member.py


channel_member -- Manage a member for a Hyperledger Fabric channel
==================================================================

.. contents::
   :local:
   :depth: 1


Synopsis
--------

Add, update, and remove members for a Hyperledger Fabric channel by using the IBM Blockchain Platform.

This module works with the IBM Blockchain Platform managed service running in IBM Cloud, or the IBM Blockchain Platform software running in a Red Hat OpenShift or Kubernetes cluster.






Parameters
----------

  api_endpoint (required)
    The URL for the IBM Blockchain Platform console.

    | **Type**: str

  api_authtype (required)
    ``ibmcloud`` - Authenticate to the IBM Blockchain Platform console using IBM Cloud authentication. You must provide a valid API key using *api_key*.

    ``basic`` - Authenticate to the IBM Blockchain Platform console using basic authentication. You must provide both a valid API key using *api_key* and API secret using *api_secret*.

    | **Type**: str

  api_key (required)
    The API key for the IBM Blockchain Platform console.

    | **Type**: str

  api_secret
    The API secret for the IBM Blockchain Platform console.

    Only required when *api_authtype* is ``basic``.

    | **Type**: str

  api_timeout
    The timeout, in seconds, to use when interacting with the IBM Blockchain Platform console.

    | **Type**: int
    | **Default value**: ``60``

  api_token_endpoint
    The IBM Cloud IAM token endpoint to use when using IBM Cloud authentication.

    Only required when *api_authtype* is ``ibmcloud``, and you are using IBM internal staging servers for testing.

    | **Type**: str
    | **Default value**: ``https://iam.cloud.ibm.com/identity/token``

  state
    ``absent`` - An organization matching the specified name will be removed from the channel.

    ``present`` - Asserts that an organization matching the specified name and configuration exists in the channel. If no organization matches the specified name, the organization will be added to the channel. If an organization matches the specified name but the configuration does not match, then the organization in the channel will be updated.

    | **Type**: str
    | **Default value**: ``present``

  path (required)
    Path to current the channel configuration file.

    This file can be fetched by using the :ref:`channel_config <channel_config_module>` module.

    This file will be updated in place. You will need to keep a copy of the original file for computing the configuration update.

    | **Type**: str

  organization (required)
    The organization to add, update, or remove from the channel.

    You can pass a string, which is the display name of an organization registered with the IBM Blockchain Platform console.

    You can also pass a dictionary, which must match the result format of one of the :ref:`organization_info <organization_info_module>` or :ref:`organization[] <organization[]_module>` modules.

    | **Type**: raw

  anchor_peers
    The anchor peers for this organization in this channel.

    You can pass strings, which are the names of peers that are registered with the IBM Blockchain Platform console.

    You can also pass a dict, which must match the result format of one of the :ref:`peer_info <peer_info_module>` or :ref:`peer <peer_module>` modules.

    | **Type**: list
    | **Elements**: raw

  policies
    The set of policies for the channel member. The keys are the policy names, and the values are the policies.

    You can pass strings, which are paths to JSON files containing policies in the Hyperledger Fabric format (common.Policy).

    You can also pass a dict, which must correspond to a parsed policy in the Hyperledger Fabric format (common.Policy).

    Default policies are provided for the Admins, Writers, Readers, and Endorsement policies. You only need to provide policies if you want to override these default policies, or add additional policies.

    | **Type**: dict








Examples
--------

.. code-block:: yaml+jinja

    
    - name: Add the organization to the channel
      ibm.blockchain_platform.channel_member:
        state: present
        api_endpoint: https://ibp-console.example.org:32000
        api_authtype: basic
        api_key: xxxxxxxx
        api_secret: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        organization: Org2
        path: channel_config.bin

    - name: Update the organization in the channel with anchor peers
      ibm.blockchain_platform.channel_member:
        state: present
        api_endpoint: https://ibp-console.example.org:32000
        api_authtype: basic
        api_key: xxxxxxxx
        api_secret: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        organization: Org2
        path: channel_config.bin
        anchor_peers:
          - Org2 Peer

    - name: Remove the organization from the channel
      ibm.blockchain_platform.channel_member:
        state: absent
        api_endpoint: https://ibp-console.example.org:32000
        api_authtype: basic
        api_key: xxxxxxxx
        api_secret: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        organization: Org2
        path: channel_config.bin



