text: #!/usr/bin/python
  # Copyright (c) 2020, 2021 Oracle and/or its affiliates.
  # This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license.
  # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
  # Apache License v2.0
  # See LICENSE.TXT for details.
  # GENERATED FILE - DO NOT EDIT - MANUAL CHANGES WILL BE OVERWRITTEN
  
  
  from __future__ import absolute_import, division, print_function
  
  __metaclass__ = type
  
  ANSIBLE_METADATA = {
      "metadata_version": "1.1",
      "status": ["preview"],
      "supported_by": "community",
  }
  
  DOCUMENTATION = """
  ---
  module: oci_data_catalog_catalog_facts
  short_description: Fetches details about one or multiple Catalog resources in Oracle Cloud Infrastructure
  description:
      - Fetches details about one or multiple Catalog resources in Oracle Cloud Infrastructure
      - Returns a list of all the data catalogs in the specified compartment.
      - If I(catalog_id) is specified, the details of a single Catalog will be returned.
  version_added: "2.9.0"
  author: Oracle (@oracle)
  options:
      catalog_id:
          description:
              - Unique catalog identifier.
              - Required to get a specific catalog.
          type: str
          aliases: ["id"]
      compartment_id:
          description:
              - The OCID of the compartment where you want to list resources.
              - Required to list multiple catalogs.
          type: str
      display_name:
          description:
              - A filter to return only resources that match the entire display name given. The match is not case sensitive.
          type: str
          aliases: ["name"]
      lifecycle_state:
          description:
              - A filter to return only resources that match the specified lifecycle state. The value is case insensitive.
          type: str
          choices:
              - "CREATING"
              - "ACTIVE"
              - "INACTIVE"
              - "UPDATING"
              - "DELETING"
              - "DELETED"
              - "FAILED"
              - "MOVING"
      sort_order:
          description:
              - The sort order to use, either 'asc' or 'desc'.
          type: str
          choices:
              - "ASC"
              - "DESC"
      sort_by:
          description:
              - The field to sort by. Only one sort order may be provided. Default order for TIMECREATED is descending. Default order for DISPLAYNAME is
                ascending. If no value is specified TIMECREATED is default.
          type: str
          choices:
              - "TIMECREATED"
              - "DISPLAYNAME"
  extends_documentation_fragment: [ oracle.oci.oracle ]
  """
  
  EXAMPLES = """
  - name: List catalogs
    oci_data_catalog_catalog_facts:
      compartment_id: "ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx"
  
  - name: Get a specific catalog
    oci_data_catalog_catalog_facts:
      catalog_id: "ocid1.catalog.oc1..xxxxxxEXAMPLExxxxxx"
  
  """
  
  RETURN = """
  catalogs:
      description:
          - List of Catalog resources
      returned: on success
      type: complex
      contains:
          id:
              description:
                  - OCID of the data catalog instance.
              returned: on success
              type: str
              sample: "ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx"
          display_name:
              description:
                  - Data catalog identifier, which can be renamed.
              returned: on success
              type: str
              sample: display_name_example
          compartment_id:
              description:
                  - Compartment identifier.
              returned: on success
              type: str
              sample: "ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx"
          time_created:
              description:
                  - The time the data catalog was created. An L(RFC3339,https://tools.ietf.org/html/rfc3339) formatted datetime string.
              returned: on success
              type: str
              sample: "2013-10-20T19:20:30+01:00"
          time_updated:
              description:
                  - The time the data catalog was updated. An L(RFC3339,https://tools.ietf.org/html/rfc3339) formatted datetime string.
              returned: on success
              type: str
              sample: "2013-10-20T19:20:30+01:00"
          service_api_url:
              description:
                  - The REST front endpoint URL to the data catalog instance.
              returned: on success
              type: str
              sample: service_api_url_example
          service_console_url:
              description:
                  - The console front endpoint URL to the data catalog instance.
              returned: on success
              type: str
              sample: service_console_url_example
          number_of_objects:
              description:
                  - The number of data objects added to the data catalog.
                    Please see the data catalog documentation for further information on how this is calculated.
              returned: on success
              type: int
              sample: 56
          lifecycle_state:
              description:
                  - The current state of the data catalog resource.
              returned: on success
              type: str
              sample: CREATING
          lifecycle_details:
              description:
                  - An message describing the current state in more detail.
                    For example, it can be used to provide actionable information for a resource in 'Failed' state.
              returned: on success
              type: str
              sample: lifecycle_details_example
          freeform_tags:
              description:
                  - "Simple key-value pair that is applied without any predefined name, type, or scope. Exists for cross-compatibility only.
                    Example: `{\\"bar-key\\": \\"value\\"}`"
              returned: on success
              type: dict
              sample: {'Department': 'Finance'}
          defined_tags:
              description:
                  - "Usage of predefined tag keys. These predefined keys are scoped to namespaces.
                    Example: `{\\"foo-namespace\\": {\\"bar-key\\": \\"value\\"}}`"
              returned: on success
              type: dict
              sample: {'Operations': {'CostCenter': 'US'}}
          attached_catalog_private_endpoints:
              description:
                  - The list of private reverse connection endpoints attached to the catalog
              returned: on success
              type: list
              sample: []
      sample: [{
          "id": "ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx",
          "display_name": "display_name_example",
          "compartment_id": "ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx",
          "time_created": "2013-10-20T19:20:30+01:00",
          "time_updated": "2013-10-20T19:20:30+01:00",
          "service_api_url": "service_api_url_example",
          "service_console_url": "service_console_url_example",
          "number_of_objects": 56,
          "lifecycle_state": "CREATING",
          "lifecycle_details": "lifecycle_details_example",
          "freeform_tags": {'Department': 'Finance'},
          "defined_tags": {'Operations': {'CostCenter': 'US'}},
          "attached_catalog_private_endpoints": []
      }]
  """
  
  from ansible.module_utils.basic import AnsibleModule
  from ansible_collections.oracle.oci.plugins.module_utils import oci_common_utils
  from ansible_collections.oracle.oci.plugins.module_utils.oci_resource_utils import (
      OCIResourceFactsHelperBase,
      get_custom_class,
  )
  
  try:
      from oci.data_catalog import DataCatalogClient
  
      HAS_OCI_PY_SDK = True
  except ImportError:
      HAS_OCI_PY_SDK = False
  
  
  class DataCatalogCatalogFactsHelperGen(OCIResourceFactsHelperBase):
      """Supported operations: get, list"""
  
      def get_required_params_for_get(self):
          return [
              "catalog_id",
          ]
  
      def get_required_params_for_list(self):
          return [
              "compartment_id",
          ]
  
      def get_resource(self):
          return oci_common_utils.call_with_backoff(
              self.client.get_catalog, catalog_id=self.module.params.get("catalog_id"),
          )
  
      def list_resources(self):
          optional_list_method_params = [
              "display_name",
              "lifecycle_state",
              "sort_order",
              "sort_by",
          ]
          optional_kwargs = dict(
              (param, self.module.params[param])
              for param in optional_list_method_params
              if self.module.params.get(param) is not None
          )
          return oci_common_utils.list_all_resources(
              self.client.list_catalogs,
              compartment_id=self.module.params.get("compartment_id"),
              **optional_kwargs
          )
  
  
  DataCatalogCatalogFactsHelperCustom = get_custom_class(
      "DataCatalogCatalogFactsHelperCustom"
  )
  
  
  class ResourceFactsHelper(
      DataCatalogCatalogFactsHelperCustom, DataCatalogCatalogFactsHelperGen
  ):
      pass
  
  
  def main():
      module_args = oci_common_utils.get_common_arg_spec()
      module_args.update(
          dict(
              catalog_id=dict(aliases=["id"], type="str"),
              compartment_id=dict(type="str"),
              display_name=dict(aliases=["name"], type="str"),
              lifecycle_state=dict(
                  type="str",
                  choices=[
                      "CREATING",
                      "ACTIVE",
                      "INACTIVE",
                      "UPDATING",
                      "DELETING",
                      "DELETED",
                      "FAILED",
                      "MOVING",
                  ],
              ),
              sort_order=dict(type="str", choices=["ASC", "DESC"]),
              sort_by=dict(type="str", choices=["TIMECREATED", "DISPLAYNAME"]),
          )
      )
  
      module = AnsibleModule(argument_spec=module_args)
  
      if not HAS_OCI_PY_SDK:
          module.fail_json(msg="oci python sdk required for this module.")
  
      resource_facts_helper = ResourceFactsHelper(
          module=module,
          resource_type="catalog",
          service_client_class=DataCatalogClient,
          namespace="data_catalog",
      )
  
      result = []
  
      if resource_facts_helper.is_get():
          result = [resource_facts_helper.get()]
      elif resource_facts_helper.is_list():
          result = resource_facts_helper.list()
      else:
          resource_facts_helper.fail()
  
      module.exit_json(catalogs=result)
  
  
  if __name__ == "__main__":
      main()
  