create or replace PACKAGE               ORDS_INTERNAL AUTHID definer
AS
  /**
  * This internal package is invoked with definers rights, so it can
  * can execute various privileged actions including altering a user
  * to connect via a proxy user.
  * Therefore access to this package needs to be carefully protected.
  * It MUST NEVER BE accessible from outside it's owning schema.
  */
  /**
  * Enable/disable the specified schema for ORDS access.
  * @param p_enabled If true ORDS access is enabled, if false it is disabled.
  * @param p_schema The name of the schema to enable/disable.
  */
  PROCEDURE enable_schema(
      p_enabled                  BOOLEAN,
      p_schema                   VARCHAR2,
      p_url_mapping_type         VARCHAR2,
      p_url_mapping_pattern      VARCHAR2,
      p_auto_rest_auth           BOOLEAN);
  /**
  * Delete autorest ords metadata for the specified schema.
  * @param p_schema The name of the schema's auto rest delete.
  */
  PROCEDURE delete_schema(
      p_schema              VARCHAR2);
  /**
  * Enable/disable the specified schema object for ORDS access.
  * @param p_enabled If true ORDS access is enabled, if false it is disabled.
  * @param p_schema The name of the schema to enable/disable.
  */
  PROCEDURE enable_object(
      p_enabled             BOOLEAN,
      p_schema              VARCHAR2,
      p_object              VARCHAR2,
      p_object_type         VARCHAR2,
      p_object_alias        VARCHAR2,
      p_type_path           BOOLEAN,
      p_auto_rest_auth      BOOLEAN);

  /**
  * Configure how the sepcified schema is mapped to request URLs
  * @param p_schema The name of the schema to map.
  * @param p_url_mapping_type The URL Mapping type, 'BASE_PATH' or 'BASE_URL'.
  * @param p_url_mapping_pattern The URL Mapping pattern.
  */
  PROCEDURE set_url_mapping(
      p_schema              VARCHAR2,
      p_url_mapping_type    VARCHAR2,
      p_url_mapping_pattern VARCHAR2);

  FUNCTION installed_version RETURN VARCHAR2;

  PROCEDURE AUTOREST_SCHEMA_SYNCHRONISE(
      P_EVENT VARCHAR2,
      P_OWNER VARCHAR2,
      P_OBJECT VARCHAR2,
      P_TYPE VARCHAR2);
      
  PROCEDURE CLEAN_OLD_SESSIONS;
  
-- Deprecated

  /**
   * @deprecated Use procedure with p_user argument
   */
  PROCEDURE enable_schema(
      p_enabled                  BOOLEAN,
      p_schema                   VARCHAR2,
      p_url_mapping_type         VARCHAR2,
      p_url_mapping_pattern      VARCHAR2,
      p_auto_rest_auth           BOOLEAN,
      p_user                     VARCHAR2);

  /**
   * @deprecated Use procedure with p_user argument
   */
  PROCEDURE delete_schema(
      p_schema              VARCHAR2,
      p_user                VARCHAR2);

  /**
   * @deprecated Use procedure with p_user argument
   */
  PROCEDURE enable_object(
      p_enabled             BOOLEAN,
      p_schema              VARCHAR2,
      p_object              VARCHAR2,
      p_object_type         VARCHAR2,
      p_object_alias        VARCHAR2,
      p_type_path           BOOLEAN,
      p_auto_rest_auth      BOOLEAN,
      p_user                VARCHAR2);

  /**
   * @deprecated Use procedure with p_user argument
   */
  PROCEDURE set_url_mapping(
      p_schema              VARCHAR2,
      p_url_mapping_type    VARCHAR2,
      p_url_mapping_pattern VARCHAR2,
      p_user                VARCHAR2);
      
END ords_internal;
