Module: Utility

Defined in:
lib/utility/common.rb,
lib/utility/cron.rb,
lib/utility/errors.rb,
lib/utility/logger.rb,
lib/utility/constants.rb,
lib/utility/es_client.rb,
lib/utility/environment.rb,
lib/utility/exception_tracking.rb,
lib/utility/middleware/basic_auth.rb,
lib/utility/extension_mapping_util.rb,
lib/utility/middleware/bearer_auth.rb,
lib/utility/elasticsearch/index/mappings.rb,
lib/utility/middleware/restrict_hostnames.rb,
lib/utility/elasticsearch/index/text_analysis_settings.rb

Overview

frozen_string_literal: true

Defined Under Namespace

Modules: Cron, Elasticsearch, Environment, Middleware Classes: AuthorizationError, ClientError, Common, ConnectorNotAvailableError, Constants, DocumentError, Error, EsClient, EvictionError, EvictionWithNoProgressError, ExceptionTracking, ExplicitlyCausedError, ExtensionMappingUtil, HealthCheckFailedError, InvalidFilterConfigError, InvalidIndexingConfigurationError, InvalidTokenError, JobCannotBeUpdatedError, JobClaimingError, JobDocumentLimitError, JobInterruptedError, JobSyncNotPossibleYetError, Logger, MaxErrorsExceededError, MaxErrorsInWindowExceededError, MaxSuccessiveErrorsExceededError, MonitoringError, PlatinumLicenseRequiredError, PublishingFailedError, SecretInvalidError, SuspendedJobError, ThrottlingError, TokenRefreshFailedError, TransientServerError, TransientSubextractorError, UnrecoverableServerError

Constant Summary collapse

CRON_REGEXP =

taken from regex101.com/r/cU7zG2/1 previous regexp allowed days of the week as [0-6], but it’s not correct because the Kibana scheduler is using [1-7] for days of the week, aligned with the Quartz scheduler: see www.quartz-scheduler.org/documentation/2.4.0-SNAPSHOT/tutorials/tutorial-lesson-06.html But just replacing with [1-7] would also be incorrect, since according to the Cron spec, the days of the week are 1-6 for Monday-Saturday, and 0 or 7 for Sunday, 7 being a non-standard but still widely used. So, we need to allow for 0-7.

/^\s*($|#|\w+\s*=|(\?|\*|(?:[0-5]?\d)(?:(?:-|\/|,)(?:[0-5]?\d))?(?:,(?:[0-5]?\d)(?:(?:-|\/|,)(?:[0-5]?\d))?)*)\s+(\?|\*|(?:[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::Errors::Unauthorized]
INTERNAL_SERVER_ERROR =
Utility::Error.new(500, 'INTERNAL_SERVER_ERROR', 'Internal server error')
INVALID_API_KEY =
Utility::Error.new(401, 'INVALID_API_KEY', 'Invalid API key')
UNSUPPORTED_AUTH_SCHEME =
Utility::Error.new(401, 'UNSUPPORTED_AUTH_SCHEME', 'Unsupported authorization scheme')
INVALID_ACCESS_TOKEN =
Utility::Error.new(401, 'INVALID_ACCESS_TOKEN', 'Invalid/expired access token, please refresh the token')
TOKEN_REFRESH_ERROR =
Utility::Error.new(401, 'TOKEN_REFRESH_ERROR', 'Failed to refresh token, please re-authenticate the application')