text: #!/usr/bin/python
  # Copyright (c) 2020, 2022 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_vulnerability_scanning_host_scan_recipe_facts
  short_description: Fetches details about one or multiple HostScanRecipe resources in Oracle Cloud Infrastructure
  description:
      - Fetches details about one or multiple HostScanRecipe resources in Oracle Cloud Infrastructure
      - Retrieves a list of HostScanRecipeSummary objects in a compartment. A recipe determines the types of security issues that you want scanned, and how often
        to scan.
      - If I(host_scan_recipe_id) is specified, the details of a single HostScanRecipe will be returned.
  version_added: "2.9.0"
  author: Oracle (@oracle)
  options:
      host_scan_recipe_id:
          description:
              - unique HostScanRecipe identifier
              - Required to get a specific host_scan_recipe.
          type: str
          aliases: ["id"]
      compartment_id:
          description:
              - The ID of the compartment in which to list resources.
              - Required to list multiple host_scan_recipes.
          type: str
      lifecycle_state:
          description:
              - A filter to return only resources whose lifecycleState matches the given lifecycleState.
          type: str
          choices:
              - "CREATING"
              - "UPDATING"
              - "ACTIVE"
              - "DELETING"
              - "DELETED"
              - "FAILED"
      display_name:
          description:
              - A filter to return only resources that match the entire display name given.
          type: str
          aliases: ["name"]
      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: Get a specific host_scan_recipe
    oci_vulnerability_scanning_host_scan_recipe_facts:
      # required
      host_scan_recipe_id: "ocid1.hostscanrecipe.oc1..xxxxxxEXAMPLExxxxxx"
  
  - name: List host_scan_recipes
    oci_vulnerability_scanning_host_scan_recipe_facts:
      # required
      compartment_id: "ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx"
  
      # optional
      lifecycle_state: CREATING
      display_name: display_name_example
      sort_order: ASC
      sort_by: timeCreated
  
  """
  
  RETURN = """
  host_scan_recipes:
      description:
          - List of HostScanRecipe resources
      returned: on success
      type: complex
      contains:
          id:
              description:
                  - Unique identifier of the config that is immutable on creation
              returned: on success
              type: str
              sample: "ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx"
          display_name:
              description:
                  - Recipe identifier, which can be renamed
              returned: on success
              type: str
              sample: display_name_example
          compartment_id:
              description:
                  - Compartment ID of the scan recipe
              returned: on success
              type: str
              sample: "ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx"
          lifecycle_state:
              description:
                  - The current state of the config.
              returned: on success
              type: str
              sample: CREATING
          time_created:
              description:
                  - Date and time the recipe was created, format as described in L(RFC 3339,https://tools.ietf.org/rfc/rfc3339)
              returned: on success
              type: str
              sample: "2013-10-20T19:20:30+01:00"
          time_updated:
              description:
                  - Date and time the recipe was last updated, format as described in L(RFC 3339,https://tools.ietf.org/rfc/rfc3339)
              returned: on success
              type: str
              sample: "2013-10-20T19:20:30+01:00"
          port_settings:
              description:
                  - ""
                  - Returned for get operation
              returned: on success
              type: complex
              contains:
                  scan_level:
                      description:
                          - The scan level
                      returned: on success
                      type: str
                      sample: NONE
          agent_settings:
              description:
                  - ""
                  - Returned for get operation
              returned: on success
              type: complex
              contains:
                  scan_level:
                      description:
                          - The scan level
                      returned: on success
                      type: str
                      sample: NONE
                  agent_configuration:
                      description:
                          - ""
                      returned: on success
                      type: complex
                      contains:
                          vendor:
                              description:
                                  - Vendor to use for the host scan agent.
                              returned: on success
                              type: str
                              sample: OCI
                          cis_benchmark_settings:
                              description:
                                  - ""
                              returned: on success
                              type: complex
                              contains:
                                  scan_level:
                                      description:
                                          - The level of strictness to apply for CIS Benchmarks. Use 'NONE' to disable CIS Benchmark checks entirely.
                                      returned: on success
                                      type: str
                                      sample: NONE
                          endpoint_protection_settings:
                              description:
                                  - ""
                              returned: on success
                              type: complex
                              contains:
                                  scan_level:
                                      description:
                                          - The scan level. Use 'NONE' to disable Endpoint Protection checks entirely.
                                      returned: on success
                                      type: str
                                      sample: NONE
          schedule:
              description:
                  - ""
                  - Returned for get operation
              returned: on success
              type: complex
              contains:
                  type:
                      description:
                          - How often the scan occurs
                      returned: on success
                      type: str
                      sample: DAILY
                  day_of_week:
                      description:
                          - Day of week the scheduled scan occurs (not applicable for DAILY type)
                      returned: on success
                      type: str
                      sample: SUNDAY
          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:
                  - "Defined tags for this resource. Each key is predefined and scoped to a namespace.
                    Example: `{\\"foo-namespace\\": {\\"bar-key\\": \\"value\\"}}`"
              returned: on success
              type: dict
              sample: {'Operations': {'CostCenter': 'US'}}
          system_tags:
              description:
                  - "Usage of system tag keys. These predefined keys are scoped to namespaces.
                    Example: `{\\"orcl-cloud\\": {\\"free-tier-retained\\": \\"true\\"}}`"
              returned: on success
              type: dict
              sample: {}
      sample: [{
          "id": "ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx",
          "display_name": "display_name_example",
          "compartment_id": "ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx",
          "lifecycle_state": "CREATING",
          "time_created": "2013-10-20T19:20:30+01:00",
          "time_updated": "2013-10-20T19:20:30+01:00",
          "port_settings": {
              "scan_level": "NONE"
          },
          "agent_settings": {
              "scan_level": "NONE",
              "agent_configuration": {
                  "vendor": "OCI",
                  "cis_benchmark_settings": {
                      "scan_level": "NONE"
                  },
                  "endpoint_protection_settings": {
                      "scan_level": "NONE"
                  }
              }
          },
          "schedule": {
              "type": "DAILY",
              "day_of_week": "SUNDAY"
          },
          "freeform_tags": {'Department': 'Finance'},
          "defined_tags": {'Operations': {'CostCenter': 'US'}},
          "system_tags": {}
      }]
  """
  
  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.vulnerability_scanning import VulnerabilityScanningClient
  
      HAS_OCI_PY_SDK = True
  except ImportError:
      HAS_OCI_PY_SDK = False
  
  
  class HostScanRecipeFactsHelperGen(OCIResourceFactsHelperBase):
      """Supported operations: get, list"""
  
      def get_required_params_for_get(self):
          return [
              "host_scan_recipe_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_host_scan_recipe,
              host_scan_recipe_id=self.module.params.get("host_scan_recipe_id"),
          )
  
      def list_resources(self):
          optional_list_method_params = [
              "lifecycle_state",
              "display_name",
              "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_host_scan_recipes,
              compartment_id=self.module.params.get("compartment_id"),
              **optional_kwargs
          )
  
  
  HostScanRecipeFactsHelperCustom = get_custom_class("HostScanRecipeFactsHelperCustom")
  
  
  class ResourceFactsHelper(
      HostScanRecipeFactsHelperCustom, HostScanRecipeFactsHelperGen
  ):
      pass
  
  
  def main():
      module_args = oci_common_utils.get_common_arg_spec()
      module_args.update(
          dict(
              host_scan_recipe_id=dict(aliases=["id"], type="str"),
              compartment_id=dict(type="str"),
              lifecycle_state=dict(
                  type="str",
                  choices=[
                      "CREATING",
                      "UPDATING",
                      "ACTIVE",
                      "DELETING",
                      "DELETED",
                      "FAILED",
                  ],
              ),
              display_name=dict(aliases=["name"], type="str"),
              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="host_scan_recipe",
          service_client_class=VulnerabilityScanningClient,
          namespace="vulnerability_scanning",
      )
  
      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(host_scan_recipes=result)
  
  
  if __name__ == "__main__":
      main()
  